private void Page_Load(object sender, System.EventArgs e) { BlogXUtils.TrackReferrer(Request, Server); if (!IsPostBack) { } }
private void Page_Load(object sender, System.EventArgs e) { title.Controls.Clear(); title.Controls.Add(new LiteralControl(SiteConfig.GetSiteConfig().Title)); BlogXUtils.TrackReferrer(Request, Server); blogCal.SelectedDate = StartDate; blogCal.VisibleDate = StartDate; }
private void Page_Load(object sender, System.EventArgs e) { BlogXUtils.TrackReferrer(Request, Server); EntryIdCache ecache = new EntryIdCache(); ecache.Ensure(data); Control root = content; string entryId = Request.QueryString["guid"]; if (entryId != null && entryId.Length > 0) { entryId = entryId.ToUpper(); } else { entryId = Request.PathInfo.Substring(1).ToUpper(); } DateTime found = new DateTime(); foreach (EntryIdCacheEntry ece in ecache.Entries) { if (ece.EntryId.ToUpper() == entryId) { found = ece.Date; break; } } foreach (DayEntry day in data.Days) { if (day.Date == found) { day.Load(); DayExtra extra = data.GetDayExtra(day.Date); foreach (Entry entry in day.Entries) { if (entryId.ToUpper() == entry.EntryId.ToUpper()) { EntryView view = (EntryView)LoadControl("EntryView.ascx"); view.DateFormat = "MM/dd/yyyy h:mm tt"; view.Data = data; view.Extra = extra; view.Entry = entry; root.Controls.Add(view); break; } } } } }
private XmlNode GetRssCore(string category, int maxDayCount) { BlogXData.Resolver = new ResolveFileCallback(ResolvePath); RssRoot r = new RssRoot(); RssChannel ch = new RssChannel(); SiteConfig config = SiteConfig.GetSiteConfig(); ch.Title = config.Title; ch.Link = config.Root; ch.Copyright = config.Copyright; ch.ManagingEditor = config.Contact; ch.WebMaster = config.Contact; r.Channels.Add(ch); BlogXData data = new BlogXData(); EntryCollection entries = BuildEntries(data, category, maxDayCount); using (StreamWriter sw = new StreamWriter(Server.MapPath(Path.Combine("logs", "dump.txt")))) { DateTime latest = new DateTime(0); foreach (Entry entry in entries) { DateTime created = entry.Created; if (created > latest) { latest = created; } } HttpRequest req = Context.Request; HttpResponse res = Context.Response; bool notModified = false; // Check the request's if-modified-since field. // If it matches our last build date, then the // caller already has the most recent data and // we can abort the whole process with an // error 304: Not Modified string ifModifiedSince = req.Headers["if-modified-since"]; if (ifModifiedSince != null) { DateTime modDate = latest; modDate = new DateTime(modDate.Year, modDate.Month, modDate.Day, modDate.Hour, modDate.Minute, modDate.Second); try { DateTime ifModDate = DateTime.Parse(ifModifiedSince); notModified = (ifModDate == modDate); } catch {} } // Also check the request for an etag header and // see if it maches our date. The rules are if // both headers are there, they both have to match. But, // if only one header is there only it has to match. string etag = req.Headers["etag"]; if (etag != null) { notModified = (etag.Equals(latest.Ticks.ToString())); } if (notModified) { res.StatusCode = 304; res.SuppressContent = true; return(null); } // Either no one used if-modified-since or we have // new data. Record the last modified time and // etag in the http header for next time. res.Cache.SetLastModified(latest); res.Cache.SetETag(latest.Ticks.ToString()); } BlogXUtils.TrackReferrer(Context.Request, Server); foreach (Entry entry in entries) { RssItem item = new RssItem(); item.Title = entry.Title; item.Guid = item.Link = new Uri(new Uri(config.Root), " PermaLink.aspx/" + entry.EntryId).ToString(); item.Comments = new Uri(new Uri(config.Root), "CommentView.aspx/" + entry.EntryId).ToString(); if (entry.Categories != null && entry.Categories.Length > 0) { item.Category = entry.GetSplitCategories()[0]; } item.PubDate = entry.Created.ToString("R"); if (ch.LastBuildDate == null || ch.LastBuildDate.Length == 0) { ch.LastBuildDate = item.PubDate; } if (entry.Description != null && entry.Description.Trim().Length > 0) { item.Description = entry.Description; } else { item.Description = entry.Content; } XmlDocument doc2 = new XmlDocument(); try { doc2.LoadXml(entry.Content); item.Body = (XmlElement)doc2.SelectSingleNode("//*[local-name() = 'body'][namespace-uri()='http://www.w3.org/1999/xhtml']"); } catch {} ch.Items.Add(item); } XmlSerializer ser = new XmlSerializer(typeof(RssRoot)); StringWriter writer = new StringWriter(); ser.Serialize(writer, r); XmlDocument doc = new XmlDocument(); doc.Load(new StringReader(writer.ToString())); return(doc.FirstChild.NextSibling); }