using System;
using System.IO;
using System.Xml;
+using System.Text;
using RSS;
class X {
static RSS.RSS rss;
static Channel c;
static int item_count;
+ static int line;
+ static int GetMonth (string s)
+ {
+ switch (s){
+ case "Jan": return 1;
+ case "Feb": return 2;
+ case "Mar": return 3;
+ case "Apr": return 4;
+ case "May": return 5;
+ case "Jun": return 6;
+ case "Jul": return 7;
+ case "Aug": return 8;
+ case "Sep": return 9;
+ case "Oct": return 10;
+ case "Nov": return 11;
+ case "Dec": return 12;
+ }
+ throw new Exception ("Can not parse month name: " + s);
+ }
+
+ static int GetDay (string s)
+ {
+ int d = s [0] - '0';
+
+ if (Char.IsDigit (s [1])){
+ d = d * 10 + (s [1] - '0');
+ }
+ return d;
+ }
+
static void PopulateRSS (StreamReader input)
{
string s;
while ((s = input.ReadLine ()) != null){
+ line++;
if (s.StartsWith ("@item "))
break;
}
- if (!s.StartsWith ("@item ")){
+ if (s == null || !s.StartsWith ("@item ")){
Console.WriteLine ("Could not find beginning of text to RSS");
return;
}
string description = "";
do {
if (s.StartsWith ("@item ")){
+ if (item_count++ > 25)
+ break;
+
if (i != null){
i.Description = description;
description = "";
}
- if (item_count++ > 74)
- break;
-
string title = s.Substring (6);
string link = "http://www.go-mono.com/index.html#";
foreach (char ch in title){
i = c.NewItem ();
i.Title = title;
i.Link = link;
+ DateTime dt = new DateTime (2004, GetMonth (s.Substring (6, 3)), GetDay (s.Substring (10, 2)));
+ i.PubDate = dt.ToString ("R");
} else {
description += "\n" + (s == "\n" ? "<p>" : s);
}
+ line++;
} while ((s = input.ReadLine ()) != null);
- if (i != null)
+ if (i != null){
i.Description = description;
+ }
}
static void MakeRSS (string input, string output)
c.Link = "http://www.go-mono.com";
c.Description =
"News from the Mono project: a portable implementation of the .NET Framework";
+ c.WebMaster = "webmaster@go-mono.com";
+ c.ManagingEditor = "miguel@ximian.com";
+ string t = File.GetLastWriteTime (input).ToString ("r");
+ c.PubDate = t;
+ c.LastBuildDate = t;
using (FileStream fs = new FileStream (input, FileMode.Open)){
using (StreamReader input_stream = new StreamReader (fs)){
- PopulateRSS (input_stream);
+ try {
+ PopulateRSS (input_stream);
+ } catch {
+ Console.WriteLine ("{0} failure while loading: {1}", line, input);
+ throw;
+ }
}
}