Esempio n. 1
0
        public static void VisualizeTaggables(string id)
        {
            var curated_feeds = GetCuratedFeeds(id);

            var taggable_source_types = GenUtils.EnumToList <TaggableSourceType>();

            var taggables_template_uri = BlobStorage.MakeAzureBlobUri("admin", "taggables.tmpl", false);
            var html = HttpUtils.FetchUrl(taggables_template_uri).DataAsString();

            html = html.Replace("__TITLE__", "taggables for " + id);

            var sb_links = new StringBuilder();
            var sb_json  = new StringBuilder();

            foreach (var type in taggable_source_types)
            {
                sb_links.Append("<h1>" + type + "</h1>\n");

                var taggables = GetTaggables(id, type);

                var curated = from unique in taggables
                              where curated_feeds.Exists(feed => feed["feedurl"] == unique.ical_url)
                              select unique;

                var uncurated = taggables.Except(curated);

                var inactive = from unique in uncurated
                               where unique.has_future_events == false
                               select unique;

                //if (type == TaggableSourceType.facebook.ToString())
                //	uncurated = uncurated.Except(inactive);

                foreach (var taggable in taggables)
                {
                    var is_curated = curated_feeds.Exists(feed => feed["feedurl"] == taggable.ical_url);
                    if (is_curated == false)
                    {
                        sb_json.Append(RenderTaggableJson(taggable, curated_feeds, type));
                    }
                }

                sb_links.Append("<p><b>Curated</b></p>");

                foreach (var taggable in curated)
                {
                    sb_links.Append(RenderTaggableLink(taggable, curated_feeds, type));
                }

                sb_links.Append("<p><b>Uncurated (calendar has future events)</b></p>");

                foreach (var taggable in uncurated)
                {
                    sb_links.Append(RenderTaggableLink(taggable, curated_feeds, type));
                }

                if (type == TaggableSourceType.facebook.ToString() && inactive.Count() > 0)
                {
                    sb_links.Append("<p><b>Uncurated (calendar has only past events)</b></p>");
                    foreach (var taggable in inactive)
                    {
                        sb_links.Append(RenderTaggableLink(taggable, curated_feeds, type));
                    }
                }
            }

            html = html.Replace("__BODY__", sb_links.ToString());
            bs.PutBlob(id, "taggable_sources.html", html.ToString(), "text/html");

            var json = "[" + sb_json.ToString().TrimEnd(',').TrimEnd(',', '\n') + "]";

            json = GenUtils.PrettifyJson(json);
            bs.PutBlob(id, "taggable_sources.json", json, "application/json");
        }