2 // Generates the Mono RSS feed
15 static int item_count
;
18 static int GetMonth (string s
)
30 case "Oct": return 10;
31 case "Nov": return 11;
32 case "Dec": return 12;
34 throw new Exception ("Can not parse month name: " + s
);
37 static int GetDay (string s
)
41 if (Char
.IsDigit (s
[1])){
42 d
= d
* 10 + (s
[1] - '0');
47 static void PopulateRSS (StreamReader input
)
51 while ((s
= input
.ReadLine ()) != null){
53 if (s
.StartsWith ("@item "))
57 if (s
== null || !s
.StartsWith ("@item ")){
58 Console
.WriteLine ("Could not find beginning of text to RSS");
63 string description
= "";
65 if (s
.StartsWith ("@item ")){
66 if (item_count
++ > 25)
70 i
.Description
= description
;
74 string title
= s
.Substring (6);
75 string link
= "http://www.go-mono.com/index.html#";
76 foreach (char ch
in title
){
84 DateTime dt
= new DateTime (2004, GetMonth (s
.Substring (6, 3)), GetDay (s
.Substring (10, 2)));
85 i
.PubDate
= dt
.ToString ("R");
87 description
+= "\n" + (s
== "\n" ? "<p>" : s
);
90 } while ((s
= input
.ReadLine ()) != null);
93 i
.Description
= description
;
97 static void MakeRSS (string input
, string output
)
100 c
= rss
.NewChannel ("Mono Project News", "http://www.go-mono.com");
102 c
.Title
= "Mono Project News";
103 c
.Link
= "http://www.go-mono.com";
105 "News from the Mono project: a portable implementation of the .NET Framework";
106 c
.WebMaster
= "webmaster@go-mono.com";
107 c
.ManagingEditor
= "miguel@ximian.com";
108 string t
= File
.GetLastWriteTime (input
).ToString ("r");
112 using (FileStream fs
= new FileStream (input
, FileMode
.Open
)){
113 using (StreamReader input_stream
= new StreamReader (fs
)){
115 PopulateRSS (input_stream
);
117 Console
.WriteLine ("{0} failure while loading: {1}", line
, input
);
123 rss
.XmlDocument
.Save (output
);
126 static int Main (string [] args
)
128 switch (args
.Length
){
130 MakeRSS ("index", "index.rss");
133 MakeRSS (args
[0], args
[1]);
137 Console
.WriteLine ("Usage is: mono-rss [input output.rss]");