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;
}