コード例 #1
0
ファイル: EventStore.cs プロジェクト: mikesavior/elmcity
        // recover the UTC datetime that was in the original ZonedEvent,
        // used by CalendarRenderer.RenderJson
        public static ZonelessEvent UniversalFromLocalAndTzinfo(ZonelessEvent evt, TimeZoneInfo tzinfo)
        {
            var _dts     = evt.dtstart;
            var _dtstart = new DateTime(_dts.Year, _dts.Month, _dts.Day, _dts.Hour, _dts.Minute, _dts.Second);

            evt.dtstart = TimeZoneInfo.ConvertTimeToUtc(_dtstart, tzinfo);

            if (evt.dtend != null)
            {
                var _dte   = evt.dtend;
                var _dtend = new DateTime(_dte.Year, _dte.Month, _dte.Day, _dte.Hour, _dte.Minute, _dte.Second);
                evt.dtend = TimeZoneInfo.ConvertTimeToUtc(_dtend, tzinfo);
            }

            return(evt);
        }
コード例 #2
0
ファイル: EventStore.cs プロジェクト: mikesavior/elmcity
        public static bool SimilarButNonIdenticalUrls(ZonelessEvent evt1, ZonelessEvent evt2, int min_length)
        {
            if (evt1.url == null || evt1.url.Length < min_length || evt2.url == null || evt2.url.Length < min_length)
            {
                return(false);
            }

            if (evt1.url.Substring(0, min_length) == evt2.url.Substring(0, min_length))
            {
                if (evt1.url != evt2.url)
                {
                    return(true);
                }
            }

            return(false);
        }
コード例 #3
0
 // take a string representation of a set of events, in some format
 // take a per-event renderer for that format
 // take an event object
 // call the renderer to add the event object to the string representation
 // currently uses: RenderEvtAsHtml, RenderEvtAsXml
 private void AppendEvent(StringBuilder eventstring, EventRenderer event_renderer, ZonelessEvent evt, Dictionary<string,object> args)
 {
     eventstring.Append(event_renderer(evt, this.calinfo, args ) );
 }
コード例 #4
0
 private static void UpdateSourcesDict(Dictionary<string, int> sources_dict, TimeOfDay current_time_of_day, ZonelessEvent evt, string datekey)
 {
     var source_key = MakeSourceKey(current_time_of_day, datekey, evt);
     sources_dict.IncrementOrAdd(source_key);
 }
コード例 #5
0
ファイル: EventStore.cs プロジェクト: jalbertbowden/elmcity
 public static bool IsZeroHourMinSec(ZonelessEvent evt)
 {
     return (evt.dtstart.Hour == 0 && evt.dtstart.Minute == 0 && evt.dtstart.Second == 0);
 }
コード例 #6
0
 public static bool FeedComesFrom(ZonelessEvent evt, string source)
 {
     if (evt.source.StartsWith(source))
         return true;
     foreach (var url_and_source in evt.urls_and_sources)
         if (url_and_source.Value.StartsWith(source))
             return true;
     return false;
 }
コード例 #7
0
        public string RenderEvtAsHtml(ZonelessEvent evt, Calinfo calinfo, Dictionary<string,object> args)
        {
            if (evt.urls_and_sources == null)
                evt.urls_and_sources = new Dictionary<string, string>() { { evt.url, evt.source } };

            string dtstart;
             if (evt.allday && evt.dtstart.Hour == 0)
                dtstart = "  ";
            else
                dtstart = evt.dtstart.ToString("ddd hh:mm tt");

            var month_day = evt.dtstart.ToString("M/d");

            string categories = "";
            List<string> catlist_links = new List<string>();
            if (!String.IsNullOrEmpty(evt.categories))
            {
                List<string> catlist = evt.categories.Split(',').ToList();
                foreach (var cat in catlist)
                {
                    var category_url = string.Format("/{0}/html?view={1}", this.id, cat);
                    catlist_links.Add(string.Format(@"<a title=""open the {1} view"" href=""{0}"">{1}</a>", category_url, cat));
                }
                categories = string.Format(@" <span class=""cat"">{0}</span>", string.Join(", ", catlist_links.ToArray()));
            }

            string label = "e" + this.event_counter.ToString();
            String description = ( String.IsNullOrEmpty(evt.description) || evt.description.Length < 10 ) ? "" : evt.description.UrlsToLinks();
            string show_desc = ( ! String.IsNullOrEmpty(description) ) ? String.Format(@"<span class=""sd""><a title=""show description ({0} chars)"" href=""javascript:show_desc('{1}')"">...</a></span>", description.Length, label) : "";

            if (args.ContainsKey("inline_descriptions") && (bool)args["inline_descriptions"] == true) // for view_calendar
            {
                var location = string.IsNullOrEmpty(evt.location) ? "" : String.Format("{0}<br/><br/>", evt.location);
                show_desc = String.Format(@"<div style=""text-indent:0""><p>{0}</div>", location + description);
            }

            if (args.ContainsKey("show_desc") && (bool)args["show_desc"] == false)  // in case need to suppress, not used yet
                show_desc = "";

            string add_to_cal = String.Format(@"<span class=""atc""><a title=""add to calendar"" href=""javascript:add_to_cal('{0}')"">+</a></span>", label);

            if (args.ContainsKey("add_to_cal") && (bool)args["add_to_cal"] == false) // for view_calendar
                add_to_cal = "";

            string visibility = "";
            string more = "";
            string source_key = "";
            string source_attr = "";
            int sequence_count = 1;
            int sequence_position = 1;
            string show_more_call;

            if (evt.urls_and_sources.Count == 1)
            {
                source_attr = MakeSourceAttr(evt);
                sequence_count = (int)args["sequence_count"];
                source_key = (string)args["source_key"];
                sequence_position = (int)args["sequence_position"];
            }

            visibility = (sequence_count > 1 && sequence_position > 1) ? @" style=""display:none"" " : "";

            if (sequence_count > 1 && sequence_position == 1)
            {
                show_more_call = "javascript:show_more('" + source_key + "')";
                more = string.Format(@" <span class=""{0}""><a title=""show {2} more from {3}"" href=""{1}"">show {2} more</a></span>",
                    source_key,
                    show_more_call,
                    sequence_count - 1,
                    evt.source
                    );
            }
            else
            {
                more = "";
            }

            var html = string.Format(
            @"<a name=""{0}""></a>
            <div id=""{0}"" class=""bl {10} {12}"" {13} xmlns:v=""http://rdf.data-vocabulary.org/#"" typeof=""v:Event"" >
            <span class=""md"">{14}</span>
            <span class=""st"" property=""v:startDate"" content=""{1}"">{2}</span>
            <span href=""{3}"" rel=""v:url""></span>
            <span class=""ttl"">{4}</span>
            <span class=""src"" property=""v:description"">{5}</span> {6}
            {7}
            {8}
            {9}
            {11}
            </div>",
            label,                                                  // 0
            String.Format("{0:yyyy-MM-ddTHH:mm}", evt.dtstart),     // 1
            dtstart,                                                // 2
            evt.url,                                                // 3
            MakeTitleForRDFa(evt),                                  // 4
            evt.urls_and_sources.Keys.Count == 1 ? evt.source : "", // 5    suppress source if multiple
            categories,                                             // 6
            MakeGeoForRDFa(evt),                                    // 7
            show_desc,                                              // 8
            add_to_cal,                                             // 9
            source_attr,                                            // 10
            more,                                                   // 11
            source_key,                                             // 12
            visibility,                                             // 13
            month_day												// 14
            );

            this.event_counter += 1;
            return html;
        }
コード例 #8
0
ファイル: CalendarRenderer.cs プロジェクト: judell/elmcity
        // render a single event as an xml element
        private string RenderEvtAsXml(ZonelessEvent evt, Calinfo calinfo, Dictionary<string,object> args)
        {
            var xml = new StringBuilder();
            xml.Append("<event>\n");
            xml.Append(string.Format("<title>{0}</title>\n", HttpUtility.HtmlEncode(evt.title)));
            xml.Append(string.Format("<url>{0}</url>\n", HttpUtility.HtmlEncode(evt.url)));
            xml.Append(string.Format("<source>{0}</source>\n", HttpUtility.HtmlEncode(evt.source)));
            xml.Append(string.Format("<dtstart>{0}</dtstart>\n", evt.dtstart.ToString(DATETIME_FORMAT_FOR_XML)));
            if (evt.dtend != null)
                xml.Append(string.Format("<dtend>{0}</dtend>\n", evt.dtend.ToString(DATETIME_FORMAT_FOR_XML)));
            xml.Append(string.Format("<allday>{0}</allday>\n", evt.allday));
            xml.Append(string.Format("<categories>{0}</categories>\n", HttpUtility.HtmlEncode(evt.categories)));
            xml.Append(string.Format("<description>{0}</description>\n", HttpUtility.HtmlEncode(evt.description)));
            xml.Append(string.Format("<location>{0}</location>\n", HttpUtility.HtmlEncode(evt.location)));

            var lat = ! String.IsNullOrEmpty(evt.lat) ? evt.lat : "";
            var lon = ! String.IsNullOrEmpty(evt.lon) ? evt.lon : "";
            xml.Append(string.Format("<lat>{0}</lat>\n", lat));
            xml.Append(string.Format("<lon>{0}</lon>\n", lon));

            xml.Append("</event>\n");
            return xml.ToString();
        }
コード例 #9
0
ファイル: CalendarRenderer.cs プロジェクト: judell/elmcity
        public static string MakeTitleForRDFa(ZonelessEvent evt, string dom_id, Dictionary<string,object> args)
        {
            var is_eventsonly = args.HasValue("eventsonly", true);
            var coalesced_links = BuildCoalescedLinks(evt, dom_id);
            bool is_coalesced = !String.IsNullOrEmpty(coalesced_links);

            // case 1: eventsonly, coalesced
            // <span class="ttl"><a target="elmcity" property="v:summary" title="open event page on source site" href="http://www.harriscenter.org/calendar">Homeschool Program: Biographies of Famous Birds</a></span>
            //
            // case 2: eventsonly, not coalesced
            // <span class="ttl"><span property="v:summary">Crazy Quilters</span> [<a target="elmcity" title="gilsum church" href="http://gilsum.org/church.aspx">&nbsp;1&nbsp;</a><a target="elmcity" title="town of gilsum" href="http://gilsum.org/">&nbsp;2&nbsp;</a>]</span>
            //
            // case 3: not eventsonly, coalesced
            // <span class="ttl"><span property="v:summary"><a href="javascript:show_desc('e3')">Crazy Quilters</a></span> [<a title="gilsum church" href="http://gilsum.org/church.aspx">&nbsp;1&nbsp;</a><a title="town of gilsum" href="http://gilsum.org/">&nbsp;2&nbsp;</a>]</span>
            //
            // case 4: not eventsonly, not coalesced
            // <span class="ttl"><a property="v:summary" title="see details" href='javascript:show_desc("e2")'>Lunchtime Rallies at Central Square</a></span>

            //  <span class="ttl"><span property="v:summary">Crazy Quilters</span> [<a target="elmcity" title="gilsum church" href="http://gilsum.org/church.aspx">&nbsp;1&nbsp;</a><a target="elmcity" title="town of gilsum" href="http://gilsum.org/">&nbsp;2&nbsp;</a>]</span>
            // otherwise this
            // <span class="ttl"><span property="v:summary"><a href="javascript:show_desc('e3')">Crazy Quilters</a></span> [<a title="gilsum church" href="http://gilsum.org/church.aspx">&nbsp;1&nbsp;</a><a title="town of gilsum" href="http://gilsum.org/">&nbsp;2&nbsp;</a>]</span>

            TitleType title_type;

            if (is_coalesced)
                title_type = is_eventsonly ? TitleType.EventsOnlyCoalesced : TitleType.NotEventsOnlyCoalesced;
            else
                title_type = is_eventsonly ? TitleType.EventsOnlyNotCoalesced : TitleType.NotEventsOnlyNotCoalesced;

            string title;

            if ( title_type == TitleType.EventsOnlyCoalesced )
                title = string.Format("<span property=\"v:summary\">{0}</span>", evt.title);
            else
                title = string.Format("<a property=\"v:summary\" title=\"{0}\" href=\"{1}\">{2}</a>",
                    is_eventsonly ? "open event page on source site": "see details",
                    is_eventsonly ? evt.url : string.Format("javascript:show_desc('{0}')", dom_id),
                    evt.title);

            if (is_coalesced)
                title += coalesced_links;

            return title;
        }
コード例 #10
0
ファイル: CalendarRenderer.cs プロジェクト: judell/elmcity
 private static string MassageDescription(ZonelessEvent evt)
 {
     string description = "";
     if (!String.IsNullOrEmpty(evt.description) )
         description = evt.description.Replace("'", "\\'").Replace("\n", "<br>").Replace("\r", "");
     string location = "";
     if (!String.IsNullOrEmpty(evt.location))
         location = String.Format(@"<p class=""elmcity_info_para""><b>Location</b>: {0}</p>", evt.location.Replace("'", "\\'")).Replace("\n", " ").Replace("\r", "");
     description = ("<span class=\"desc\">" + location + @"<p class=""elmcity_info_para""><b>Description</b>: " + description + "</p></span>").UrlsToLinks();
     return description;
 }
コード例 #11
0
ファイル: CalendarRenderer.cs プロジェクト: judell/elmcity
 private string MakeGeoForRDFa(ZonelessEvent evt)
 {
     string geo = "";
     if (evt.lat != null && evt.lon != null)
         geo = string.Format(
     @"<span rel=""v:location"">
     <span rel=""v:geo"">
        <span typeof=""v:Geo"">
       <span property=""v:latitude"" content=""{0}"" ></span>
       <span property=""v:longitude"" content=""{1}"" ></span>
        </span>
     </span>
       </span>",
         evt.lat,
         evt.lon
         );
     return geo;
 }
コード例 #12
0
ファイル: CalendarRenderer.cs プロジェクト: judell/elmcity
        private static string BuildCoalescedLinks(ZonelessEvent evt, string dom_id)
        {
            if (evt.urls_and_sources.Keys.Count == 1) // nothing to coalesce
                return "";

            string coalesced_links = " [";
            int count = 0;
            foreach (var url in evt.urls_and_sources.Keys)
            {
                var source = evt.urls_and_sources[url];
                count++;
                coalesced_links += string.Format(@"<a target=""{0}"" title=""{1}"" href=""{2}"">&nbsp;{3}&nbsp;</a>",
                    Configurator.default_html_window_name,
                    source,
                    url,
                    count);
            }
            coalesced_links += "]";
            return coalesced_links;
        }
コード例 #13
0
ファイル: EventStore.cs プロジェクト: jalbertbowden/elmcity
 public void AddEvent(string title, string url, string source, string lat, string lon, DateTime dtstart, DateTime dtend, bool allday, string categories, string description, string location)
 {
     var evt = new ZonelessEvent(title: title, url: url, source: source, dtstart: dtstart, dtend: dtend, lat: lat, lon: lon, allday: allday, categories: categories, description: description, location: location);
     evt.NormalizeTitle();
     this.events.Add(evt);
 }
コード例 #14
0
ファイル: EventStore.cs プロジェクト: jalbertbowden/elmcity
        // recover the UTC datetime that was in the original ZonedEvent,
        // used by CalendarRenderer.RenderJson
        public static ZonelessEvent UniversalFromLocalAndTzinfo(ZonelessEvent evt, TimeZoneInfo tzinfo)
        {
            var _dts = evt.dtstart;
            var _dtstart = new DateTime(_dts.Year, _dts.Month, _dts.Day, _dts.Hour, _dts.Minute, _dts.Second);
            evt.dtstart = TimeZoneInfo.ConvertTimeToUtc(_dtstart, tzinfo);

            if (evt.dtend != null)
            {
                var _dte = evt.dtend;
                var _dtend = new DateTime(_dte.Year, _dte.Month, _dte.Day, _dte.Hour, _dte.Minute, _dte.Second);
                evt.dtend = TimeZoneInfo.ConvertTimeToUtc(_dtend, tzinfo);
            }

            return evt;
        }
コード例 #15
0
 private string MakeGeoForRDFa(ZonelessEvent evt)
 {
     string geo = "";
     if (this.calinfo.hub_enum == HubType.where)
         geo = string.Format(
     @"<span rel=""v:location"">
     <span rel=""v:geo"">
        <span typeof=""v:Geo"">
       <span property=""v:latitude"" content=""{0}"" ></span>
       <span property=""v:longitude"" content=""{1}"" ></span>
        </span>
     </span>
       </span>",
         evt.lat != null ? evt.lat : this.calinfo.lat,
         evt.lon != null ? evt.lon : this.calinfo.lon
         );
     return geo;
 }
コード例 #16
0
ファイル: CalendarRenderer.cs プロジェクト: judell/elmcity
        public string RenderEvtAsCsv(ZonelessEvent evt, Calinfo calinfo, Dictionary<string, object> args)
        {
            var line = (string) args["csv_fields_template"];

            var date_fmt = "yyyy-MM-dd";
            var time_fmt = "hh:mm:ss";
            line = line.Replace("__title__", evt.title.EscapeValueForCsv());
            line = line.Replace("__start_day__", evt.dtstart.ToString(date_fmt));
            line = line.Replace("__start_time__", evt.dtstart.ToString(time_fmt));
            if (evt.dtend != DateTime.MinValue)
            {
                line = line.Replace("__stop_day__", evt.dtstart.ToString(date_fmt));
                line = line.Replace("__stop_time__", evt.dtstart.ToString(time_fmt));
            }
            else
            {
                line = line.Replace("__stop_day__", "");
                line = line.Replace("__stop_time__", "");
            }
            line = line.Replace("__uid__", evt.hash);
            line = line.Replace("__description__", evt.description.EscapeValueForCsv());
            line = line.Replace("__location__", evt.location.EscapeValueForCsv());
            line = line.Replace("__url__", evt.url.ToString().EscapeValueForCsv());
            line = line.Replace("__categories__", evt.categories.EscapeValueForCsv());

            return line + "\n";
        }
コード例 #17
0
        // render a single event as an xml element
        private string RenderEvtAsXml(ZonelessEvent evt, Calinfo calinfo, Dictionary<string,object> args)
        {
            var xml = new StringBuilder();
            xml.Append("<event>\n");
            xml.Append(string.Format("<title>{0}</title>\n", HttpUtility.HtmlEncode(evt.title)));
            xml.Append(string.Format("<url>{0}</url>\n", HttpUtility.HtmlEncode(evt.url)));
            xml.Append(string.Format("<source>{0}</source>\n", HttpUtility.HtmlEncode(evt.source)));
            xml.Append(string.Format("<dtstart>{0}</dtstart>\n", evt.dtstart.ToString(DATETIME_FORMAT_FOR_XML)));
            if (evt.dtend != null)
                xml.Append(string.Format("<dtend>{0}</dtend>\n", evt.dtend.ToString(DATETIME_FORMAT_FOR_XML)));
            xml.Append(string.Format("<allday>{0}</allday>\n", evt.allday));
            xml.Append(string.Format("<categories>{0}</categories>\n", HttpUtility.HtmlEncode(evt.categories)));
            xml.Append(string.Format("<description>{0}</description>\n", HttpUtility.HtmlEncode(evt.description)));
            xml.Append(string.Format("<location>{0}</location>\n", HttpUtility.HtmlEncode(evt.location)));

            //if (this.calinfo.hub_type == HubType.where.ToString())
            if (calinfo.hub_enum == HubType.where)
            {
                var lat = evt.lat != null ? evt.lat : this.calinfo.lat;
                var lon = evt.lon != null ? evt.lon : this.calinfo.lon;
                xml.Append(string.Format("<lat>{0}</lat>\n", lat));
                xml.Append(string.Format("<lon>{0}</lon>\n", lon));
            }
            xml.Append("</event>\n");
            return xml.ToString();
        }
コード例 #18
0
ファイル: CalendarRenderer.cs プロジェクト: judell/elmcity
        public string RenderEvtAsHtml(ZonelessEvent evt, Calinfo calinfo, Dictionary<string,object> args)
        {
            if (evt.urls_and_sources == null)
                evt.urls_and_sources = new Dictionary<string, string>() { { evt.url, evt.source } };

            string dtstart;
             if (evt.allday && evt.dtstart.Hour == 0)
                dtstart = "  ";
            else
                dtstart = evt.dtstart.ToString("ddd hh:mm tt");

            var month_day = evt.dtstart.ToString("M/d");

            string categories = "";
            List<string> catlist_links = new List<string>();
            if (!String.IsNullOrEmpty(evt.categories))
            {
                List<string> catlist = Utils.GetTagListFromTagString(evt.categories);
                if (args.ContainsKey("hub_tags") )  // exclude autogenerated hub names
                {
                    var hub_tags = (List<string>)args["hub_tags"];
                    catlist = catlist.FindAll(c => hub_tags.Contains(c) == false);
                }

                // catlist = catlist.FindAll(c => c.Contains("{") == false); // don't show squiggly tags inline?
                // actually leave them in so client can show related images. curator can suppress display if desired using css

                foreach (var cat in catlist)
                {
                    var category_url = string.Format("javascript:show_view('{0}')", cat);
                    catlist_links.Add(string.Format(@"<a title=""open the {1} view"" href=""{0}"">{1}</a>", category_url, cat));
                }
                categories = string.Format(@" <span class=""cat"">{0}</span>", string.Join(", ", catlist_links.ToArray()));
            }

            String description = ( String.IsNullOrEmpty(evt.description) || evt.description.Length < 10 ) ? "" : evt.description.UrlsToLinks();

            string dom_id = "e" + evt.uid;

            string expander = "";
            if ( ! String.IsNullOrEmpty(description) && args.HasValue("eventsonly",true) )
                expander = String.Format(@"<span class=""sd""><a title=""show description"" href=""javascript:show_desc('{0}')"">...</a></span>", dom_id);

            string add_to_cal = String.Format(@"<span class=""atc""><a title=""add to calendar"" href=""javascript:add_to_cal('{0}')"">+</a></span>", dom_id);

            if ( args.HasValue("add_to_cal",false) ) // for view_calendar
                add_to_cal = "";

            string visibility = "";
            string more = "";
            string source_key = "";
            //string source_attr = "";  // not needed,
            int sequence_count = 1;
            int sequence_position = 1;
            string show_more_call;

            if (evt.urls_and_sources.Count == 1)
            {
                sequence_count = (int)args["sequence_count"];
                source_key = (string)args["source_key"];
                sequence_position = (int)args["sequence_position"];
            }

            visibility = (sequence_count > 1 && sequence_position > 1) ? @" style=""display:none"" " : "";

            if (sequence_count > 1 && sequence_position == 1)
            {
                show_more_call = "javascript:show_more('" + source_key + "')";
                more = string.Format(@" <span class=""{0}""><a title=""show {2} more from {3}"" href=""{1}"">show {2} more</a></span>",
                    source_key,
                    show_more_call,
                    sequence_count - 1,
                    evt.source
                    );
            }
            else
            {
                more = "";
            }

            var html = string.Format(
            @"<div id=""{0}"" class=""bl {12}"" {13} xmlns:v=""http://rdf.data-vocabulary.org/#"" typeof=""v:Event"" >
            <span style=""display:none"" class=""uid"">{15}</span>
            <span style=""display:none"" class=""hash"">{16}</span>
            <span class=""md"">{14}</span>
            <span class=""st"" property=""v:startDate"" content=""{1}"">{2}</span>
            <span href=""{3}"" rel=""v:url""></span>
            <span class=""ttl"">{4}</span>
            <span class=""src"" property=""v:description"">{5}</span> {6}
            {7}
            {8}
            {9}
            {11}
            </div>",
            dom_id,                                                 // 0
            String.Format("{0:yyyy-MM-ddTHH:mm}", evt.dtstart),     // 1
            dtstart,                                                // 2
            evt.url,                                                // 3
            MakeTitleForRDFa(evt, dom_id, args),                    // 4
            evt.urls_and_sources.Keys.Count == 1 ? evt.source : "", // 5 suppress source if multiple
            categories,                                             // 6
            MakeGeoForRDFa(evt),                                    // 7
            expander,                                               // 8
            add_to_cal,                                             // 9
            "",														// 10 was source_attr, not needed
            more,                                                   // 11
            source_key,                                             // 12
            visibility,                                             // 13
            month_day,												// 14
            evt.uid,												// 15
            evt.hash												// 16
            );

            this.event_counter += 1;
            return html;
        }
コード例 #19
0
        public static string MakeTitleForRDFa(ZonelessEvent evt)
        {
            if (evt.urls_and_sources.Keys.Count == 1)
            {
                return string.Format("<a target=\"{0}\" property=\"v:summary\" title=\"{1}\" href=\"{2}\">{3}</a>",
                    Configurator.default_html_window_name,
                    //evt.source,
                    "open event page on source site",
                    evt.url,
                    evt.title);
            }

            if (evt.urls_and_sources.Keys.Count > 1)
            {
                var evt_title = @"<span property=""v:summary"">" + evt.title + "</span> [";
                int count = 0;
                foreach (var url in evt.urls_and_sources.Keys )
                {
                    var source = evt.urls_and_sources[url];
                    count++;
                    evt_title += string.Format(@"<a target=""{0}"" title=""{1}"" href=""{2}"">&nbsp;{3}&nbsp;</a>",
                        Configurator.default_html_window_name,
                        source,
                        url,
                        count);
                }
                evt_title += "]";
                return evt_title;
            }
            GenUtils.PriorityLogMsg("warning", "MakeTitleForRDFa: no title", null);
            return "";
        }
コード例 #20
0
ファイル: CalendarRenderer.cs プロジェクト: judell/elmcity
        // render a single event as text
        public string RenderEvtAsText(ZonelessEvent evt, Calinfo calinfo, Dictionary<string, object> args)
        {
            var text = new StringBuilder();

            text.AppendLine(evt.title);
            var start = evt.dtstart.ToString("M/d/yyyy h:m tt").Replace(":0 ", " ");
            text.AppendLine(start);
            if ( ! String.IsNullOrEmpty(evt.source) )
                text.AppendLine(evt.source);
            if ( ! String.IsNullOrEmpty(evt.location) )
                text.AppendLine(evt.location);
            if ( ! String.IsNullOrEmpty(evt.description) && evt.description != evt.location)
                text.AppendLine(evt.description);
            text.AppendLine();

            return text.ToString();
        }
コード例 #21
0
        public string RenderEvtAsListItem(ZonelessEvent evt)
        {
            if (evt.urls_and_sources == null)
                evt.urls_and_sources = new Dictionary<string, string>() { { evt.url, evt.source } };

            string dtstart;
            if (evt.allday && evt.dtstart.Hour == 0)
                dtstart = "";
            else
                dtstart = evt.dtstart.ToString("ddd hh:mm tt");

            return string.Format(@"<li>{0} <a href=""{1}"">{2}</a> {3}</li>",
                dtstart,
                evt.urls_and_sources.First().Key,
                evt.title,
                evt.urls_and_sources.First().Value);
        }
コード例 #22
0
 private static string MakeSourceAttr(ZonelessEvent evt)
 {
     var re_source_attr = new Regex(@"[^\w]+");
     return re_source_attr.Replace(evt.source, "");
 }
コード例 #23
0
ファイル: EventStore.cs プロジェクト: mikesavior/elmcity
        public void AddEvent(string title, string url, string source, string lat, string lon, DateTime dtstart, DateTime dtend, bool allday, string categories, string description, string location)
        {
            var evt = new ZonelessEvent(title: title, url: url, source: source, dtstart: dtstart, dtend: dtend, lat: lat, lon: lon, allday: allday, categories: categories, description: description, location: location);

            this.events.Add(evt);
        }
コード例 #24
0
        private static string MakeSourceKey(TimeOfDay current_time_of_day, string datekey, ZonelessEvent evt)
        {
            var source_attr = MakeSourceAttr(evt);

            return source_attr + "_" + datekey + "_" + string.Format("{0:HHmm}", evt.dtstart);
        }
コード例 #25
0
ファイル: EventStore.cs プロジェクト: mikesavior/elmcity
 public static bool IsZeroHourMinSec(ZonelessEvent evt)
 {
     return(evt.dtstart.Hour == 0 && evt.dtstart.Minute == 0 && evt.dtstart.Second == 0);
 }
コード例 #26
0
ファイル: EventStore.cs プロジェクト: jalbertbowden/elmcity
        public static bool SimilarButNonIdenticalUrls(ZonelessEvent evt1, ZonelessEvent evt2, int min_length)
        {
            if (evt1.url == null || evt1.url.Length < min_length || evt2.url == null || evt2.url.Length < min_length )
                return false;

            if (evt1.url.Substring(0, min_length) == evt2.url.Substring(0, min_length))
                if (evt1.url != evt2.url)
                    return true;

            return false;
        }