Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Flushage

svn path=/trunk/lb/; revision=30072
  • Loading branch information...
commit 7c028b5410fbcdc8f6a9ce1031a2f697876d001d 1 parent 1cf1fd9
@migueldeicaza migueldeicaza authored
Showing with 69 additions and 8 deletions.
  1. +61 −5 lb.cs
  2. +4 −3 makefile
  3. +4 −0 template
View
66 lb.cs
@@ -28,6 +28,8 @@
using System.Xml;
using System.Xml.Serialization;
using Rss;
+using Atom.Core;
+using Atom;
class DayEntry : IComparable {
public DateTime Date;
@@ -376,7 +378,64 @@ public void RenderRSS (RssVersion version, string output, int start, int end)
w.Write (channel);
w.Close ();
}
+
+ //
+ // Atom support is still fairly early, I do not know how to use it completely yet
+ //
+ AtomFeed MakeAtomFeed ()
+ {
+ AtomFeed feed = new AtomFeed ();
+ feed.Title = new AtomContentConstruct("title", config.Title);
+ string url = config.BlogWebDirectory + config.BlogFileName;
+ feed.Author = new AtomPersonConstruct("contributor",
+ config.Copyright, new Uri (url), config.ManagingEditor);
+ feed.Contributors.Add (new AtomPersonConstruct("contributor",
+ config.Copyright, new Uri (url), config.ManagingEditor));
+ feed.Tagline = new AtomContentConstruct("tagline", config.Description);
+ feed.Id = new Uri (url);
+ feed.Copyright = new AtomContentConstruct("copyright", "Copyright © 2003, 2004");
+ feed.Modified = new AtomDateConstruct("modified", DateTime.Now,
+ TimeZone.CurrentTimeZone.GetUtcOffset(DateTime.Now));
+
+ return feed;
+ }
+
+ public void RenderAtom (string output, int start, int end)
+ {
+ AtomFeed feed = MakeAtomFeed();
+
+ Uri url = new Uri(config.BlogWebDirectory + config.BlogFileName);
+
+ for (int i = start; i < end; i++){
+ int idx = entries.Count - i - 1;
+ if (idx < 0)
+ continue;
+
+ DayEntry d = (DayEntry) entries [idx];
+
+ AtomEntry entry = new AtomEntry ();
+ entry.Title = new AtomContentConstruct("title", d.Caption);
+ entry.Modified = new AtomDateConstruct("modified", d.Date, TimeZone.CurrentTimeZone.GetUtcOffset (d.Date));
+ entry.Issued = new AtomDateConstruct("issued", d.Date, TimeZone.CurrentTimeZone.GetUtcOffset (d.Date));
+ entry.Summary = new AtomContentConstruct("summary", d.Body);
+ entry.Contents.Add (new AtomContent (d.Body));
+ entry.Contributors.Add(new AtomPersonConstruct("contributor",
+ config.Copyright, url, config.ManagingEditor));
+ entry.Id = new Uri (config.BlogWebDirectory + "all.html#" + HttpUtility.UrlEncode (d.Date.ToString ()));
+
+ feed.Entries.Add (entry);
+ }
+
+ using (FileStream o = File.Create (output))
+ feed.Save (o);
+ }
+
+ public void RenderRSS (string output, int start, int end)
+ {
+ RenderRSS (RssVersion.RSS20, output + ".rss2", start, end);
+ }
+
public class Article {
public string url, caption;
@@ -394,10 +453,6 @@ public void AddArticle (string url, string caption)
articles.Add (new Article (url, caption));
}
- public void RenderRSS (string output, int start, int end)
- {
- RenderRSS (RssVersion.RSS20, output + ".rss2", start, end);
- }
}
@@ -414,7 +469,8 @@ static void Main ()
b.RenderArchive ("template");
b.RenderRSS (config.RSSFileName, 0, 30);
-
+ b.RenderAtom (config.RSSFileName + ".atom", 0, 30);
+
File.Copy ("log-style.css", "texts/log-style.css", true);
}
}
View
7 makefile
@@ -1,8 +1,9 @@
ASSEMBLIES= -r:RSS.NET.dll \
- -r:System.Web
+ -r:System.Web \
+ -r:Atom.NET.dll
lb.exe: lb.cs
- mcs $(ASSEMBLIES) -g lb.cs config.cs -out:lb.exe
+ mcs $(ASSEMBLIES) -g lb.cs config.cs -out:lb.exe
b: lb.exe
mono --debug lb.exe
@@ -14,5 +15,5 @@ push: b
chmod 644 archive/*/*.html
chmod 644 *html *rss2 *php
rsync -pr -v --rsh=ssh texts archive prettyprint.js \
- log-style.css *.rss2 *.php all.html \
+ log-style.css *.rss2 *.atom *.php all.html \
primates.ximian.com:public_html
View
4 template
@@ -12,6 +12,8 @@
<div id='bloggers'>
<h2>RSS</h2>
<a href="@BASEDIR@@RSSFILENAME@.rss2"><img src="@BASEDIR@xml.gif" alt="xml.gif"></a>
+ <h2>Atom</h2>
+ <a href="@BASEDIR@@RSSFILENAME@.atom">Atom</a>
<p>Email: <a href="mailto:miguel@ximian.com">miguel@ximian.com</a>
@@ -46,6 +48,8 @@
<a href="http://pages.infinit.net/ctech/poupou.rss"><img align="middle" src="@BASEDIR@xml.gif" alt="xml.gif" /></a>
<a href="http://pages.infinit.net/ctech/poupou.html">Sebastien Pouliot</a>
<p>
+ <a href="http://www.usenix.org/events/usenix04/"><img src="http://www.usenix.org/events/usenix04/art/usenix04_button.gif">
+ </a>
<a href="http://www.go-mono.com"><img src="http://www.go-mono.com/images/mono-contributor-static.gif"></a>
</div>
Please sign in to comment.
Something went wrong with that request. Please try again.