Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

* lb.cs: Configuration data are now loaded from config.xml

        * config.cs: Ditto
        * config.xml: Ditto
        * TODO: Ditto

svn path=/trunk/lb/; revision=20559
  • Loading branch information...
commit fa15edac92af56ceced72176da62e37fce5d60a9 1 parent 8e046ee
Martin Willemoes Hansen authored
Showing with 52 additions and 17 deletions.
  1. +4 −0 ChangeLog
  2. +0 −3  TODO
  3. +14 −0 config.cs
  4. +11 −0 config.xml
  5. +20 −13 lb.cs
  6. +3 −1 makefile
View
4 ChangeLog
@@ -5,6 +5,10 @@
* template: Added correct header, ie not xhtml but html.
Corrected some xhtml to html bugs.
Added link to check if correct html is used.
+ * lb.cs: Configuration data are now loaded from config.xml
+ * config.cs: Ditto
+ * config.xml: Ditto
+ * TODO: Ditto
2003-11-27 Jackson Harper <jackson@ximian.com>
View
3  TODO
@@ -4,6 +4,3 @@ place. Anyways, here it is:
* Individual entries link to all.html, which is one directory above.
* Probably use the template system used in monologue
-
-* Use an XmlSerializer to load config data, instead of being hardcoded
- to use by miguel only
View
14 config.cs
@@ -0,0 +1,14 @@
+using System.Xml.Serialization;
+
+public class Config {
+ [XmlAttribute] public string Author;
+ [XmlAttribute] public string BlogDirectory;
+ [XmlAttribute] public string BlogFileName;
+ [XmlAttribute] public string BlogWebDirectory;
+ [XmlAttribute] public string Copyright;
+ [XmlAttribute] public string Description;
+ [XmlAttribute] public string ManagingEditor;
+ [XmlAttribute] public string Link;
+ [XmlAttribute] public string Title;
+ [XmlAttribute] public string RSSFileName;
+}
View
11 config.xml
@@ -0,0 +1,11 @@
+<config
+Author="Miguel de Icaza (miguel@ximian.com)"
+BlogDirectory="/home/miguel/activity"
+BlogFileName="activity-log.php"
+BlogWebDirectory="http://primates.ximian.com/~miguel/"
+Copyright="Miguel de Icaza"
+Description="Miguel de Icaza's web log"
+ManagingEditor="miguel@ximian.com"
+Title="Miguel de Icaza"
+RSSFileName="miguel"
+/>
View
33 lb.cs
@@ -25,6 +25,8 @@
using System.Collections;
using System.Globalization;
using System.Web;
+using System.Xml;
+using System.Xml.Serialization;
using Rss;
class DayEntry : IComparable {
@@ -33,13 +35,14 @@ class DayEntry : IComparable {
public string Caption;
Blog blog;
- public const string blog_base = "http://primates.ximian.com/~miguel/";
+ public string blog_base;
const string code_style = "style=\"border-style: solid; background: #ddddff; border-width: 1px; padding: 2pt;\"";
const string shell_style = "style=\"border-style: solid; background: #000000; color: #777777; border-width: 1px; padding: 2pt;\"";
public DayEntry (Blog blog, string file)
{
this.blog = blog;
+ blog_base = blog.config.BlogWebDirectory;
ParseDate (file);
using (FileStream i = File.OpenRead (file)){
@@ -200,6 +203,7 @@ string Include (string file, out string caption)
}
class Blog {
+ public Config config;
ArrayList entries = new ArrayList ();
public int Entries {
@@ -208,9 +212,10 @@ class Blog {
}
}
- public Blog ()
+ public Blog (Config config)
{
- string [] years = Directory.GetDirectories ("/home/miguel/activity");
+ this.config = config;
+ string [] years = Directory.GetDirectories (config.BlogDirectory);
foreach (string year in years){
string [] days = Directory.GetFiles (year);
@@ -298,12 +303,12 @@ RssChannel MakeChannel ()
{
RssChannel c = new RssChannel ();
- c.Title = "Miguel de Icaza";
- c.Link = new Uri ("http://primates.ximian.com/~miguel/activity-log.php");
- c.Description = "Miguel de Icaza's web log";
- c.Copyright = "Miguel de Icaza";
+ c.Title = config.Title;
+ c.Link = new Uri (config.BlogWebDirectory + config.BlogFileName);
+ c.Description = config.Description;
+ c.Copyright = config.Copyright;
c.Generator = "lb#";
- c.ManagingEditor = "miguel@ximian.com";
+ c.ManagingEditor = config.ManagingEditor;
c.PubDate = System.DateTime.Now;
return c;
@@ -321,10 +326,10 @@ public void RenderRSS (RssVersion version, string output, int start, int end)
DayEntry d = (DayEntry) entries [idx];
RssItem item = new RssItem ();
- item.Author = "Miguel de Icaza (miguel@ximian.com)";
+ item.Author = config.Author;
item.Description = d.Body;
item.Guid = new RssGuid ();
- item.Guid.Name = "http://primates.ximian.com/~miguel/all.html#" + HttpUtility.UrlEncode (d.Date.ToString ());
+ item.Guid.Name = config.BlogWebDirectory + "all.html#" + HttpUtility.UrlEncode (d.Date.ToString ());
item.Link = new Uri (item.Guid.Name);
item.Guid.PermaLink = DBBool.True;
item.PubDate = d.Date;
@@ -370,13 +375,15 @@ class LB {
static void Main ()
{
- Blog b = new Blog ();
+ Config config = (Config)
+ new XmlSerializer (typeof (Config)).Deserialize (new XmlTextReader ("config.xml"));
+ Blog b = new Blog (config);
- b.RenderHtml ("template", "activity-log.php", 0, 30, "");
+ b.RenderHtml ("template", config.BlogFileName, 0, 30, "");
b.RenderHtml ("template", "all.html", 0, b.Entries, "");
b.RenderArchive ("template");
- b.RenderRSS ("miguel", 0, 30);
+ b.RenderRSS (config.RSSFileName, 0, 30);
File.Copy ("log-style.css", "texts/log-style.css", true);
}
View
4 makefile
@@ -1,6 +1,8 @@
+ASSEMBLIES= -r:RSS.NET.dll \
+ -r:System.Web
lb.exe: lb.cs
- mcs -g lb.cs -out:lb.exe -r:RSS.NET.dll -r:System.Web
+ mcs $(ASSEMBLIES) -g lb.cs config.cs -out:lb.exe
b: lb.exe
mono --debug lb.exe
Please sign in to comment.
Something went wrong with that request. Please try again.