Skip to content
This repository has been archived by the owner on Nov 3, 2023. It is now read-only.

Commit

Permalink
Add support for comments to lame blog
Browse files Browse the repository at this point in the history
svn path=/trunk/lb/; revision=70573
  • Loading branch information
migueldeicaza committed Jan 6, 2007
1 parent 9114343 commit 5e56455
Show file tree
Hide file tree
Showing 8 changed files with 53 additions and 3 deletions.
29 changes: 29 additions & 0 deletions README
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ This is Lame Blog.
InputEncoding="utf-8"
OutputEncoding="utf-8"
AnalyticsStub="analytics"
CommentsStub="comments"
/>

The various parameters should be self explanatory.
Expand All @@ -46,6 +47,14 @@ This is Lame Blog.

~/activity/2003/oct-01.html

For files with the HTML ending, it assumes that the title for
the blog entry will be the first line (which should be tagged
with <h1>title</h1>).

For text files, the first line should be formatted like this:

@This is my Title

To add multiple entries per day, append a -N to the entry:

~/activity/2003/oct-01-1.html
Expand All @@ -68,6 +77,26 @@ This is Lame Blog.
The AnalyticsStub is the file provided to you by google as the
stub that you must insert

* Commands

The following commands can be used in your individual blog entries:

#include file

Will include the contents of "file" into the blog entry

#pic filename,caption

Will generate the code to center the image stored in
filename with the given caption.

#comment, #comments

Will enable the entry to have comments. To activate
comments, you need to get a comment hosting provider,
and then paste the stub into the file `comments', or
the file referenced in the config.xml CommentsStub
field

Enjoy,
Miguel de Icaza (miguel@gnu.org)
2 changes: 2 additions & 0 deletions comments
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
| <a href="javascript:HaloScan('@ENTRY_PERMALINK@');" target="_self">
<script type="text/javascript">postCount('@ENTRY_PERMALINK@');</script>Comments</a>
1 change: 1 addition & 0 deletions config.cs
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ public class Config {
[XmlAttribute] public string Prefix;
[XmlAttribute] public string BlogTemplate;
[XmlAttribute] public string EntryTemplate;
[XmlAttribute] public string CommentsStub;

public bool Parse (string[] args)
{
Expand Down
1 change: 1 addition & 0 deletions config.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,5 @@ RSSFileName="miguel"
InputEncoding="utf-8"
OutputEncoding="utf-8"
AnalyticsStub="analytics"
CommentsStub="comments"
/>
6 changes: 4 additions & 2 deletions entry
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@
@ENTRY_BODY@
</div>

<div class='footer'>Posted by @COPYRIGHT@ on <a href="@ENTRY_URL_PERMALINK@">@ENTRY_DATECAPTION@</a> |
<div class='footer'>Posted by @COPYRIGHT@ on <a href="@ENTRY_URL_PERMALINK@">@ENTRY_DATECAPTION@</a>
@COMMENTS@
<!--|
<a href="http://www.digg.com/submit?phase=2&url=@ENTRY_URL_PERMALINK@">Digg It</a> |
<a href="http://reddit.com/submit?url=@ENTRY_URL_PERMALINK@">Reddit</a>
<a href="http://reddit.com/submit?url=@ENTRY_URL_PERMALINK@">Reddit</a>-->

</div><p>
14 changes: 14 additions & 0 deletions lb.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ class DayEntry : IComparable {
public string Caption = "";
public string DateCaption;
public string Category = "";
public bool Comments;

Blog blog;
public string extra = "";
Expand Down Expand Up @@ -220,6 +221,9 @@ void Load (StreamReader i, bool is_html)
sb.Append (String.Format ("<p><center><a href=\"{0}pic.php?name={1}&caption={2}\"><img border=0 src=\"{3}/pictures/small-{1}\"></a><p>{2}</center></p>", blog_base, filename, caption, blog.config.BlogImageBasedir));
continue;

} else if (s.StartsWith ("#comment")){
Comments = true;
continue;
}
sb.Append (s);
}
Expand Down Expand Up @@ -299,6 +303,7 @@ class Blog {
public DateTime pubDate = new DateTime (1, 1, 1);
string entry_template;
string analytics = "";
string comments = "";
Hashtable category_entries = new Hashtable ();

ArrayList entries = new ArrayList ();
Expand All @@ -324,6 +329,9 @@ public Blog (Config config)

if (config.AnalyticsStub != null && config.AnalyticsStub.Length > 0)
analytics = File.OpenText (config.AnalyticsStub).ReadToEnd ();
if (config.CommentsStub != null && config.CommentsStub.Length > 0){
comments = File.OpenText (config.CommentsStub).ReadToEnd ();
}
}

void LoadDirectory (DirectoryInfo dir)
Expand Down Expand Up @@ -399,6 +407,12 @@ void Render (TextWriter o, IList entries, int idx, string blog_base, bool includ
substitutions.Add ("@ENTRY_CATEGORY_PATHS@", category_paths);
substitutions.Add ("@BLOGWEBDIR@", config.BlogWebDirectory);
substitutions.Add ("@ENTRY_URL_PERMALINK@", Path.Combine (config.BlogWebDirectory, d.PermaLink));
if (d.Comments){
StringWriter rendered_comment = new StringWriter (new StringBuilder (comments.Length));
Translate (comments, rendered_comment, substitutions);
substitutions.Add ("@COMMENTS@", rendered_comment.ToString ());
} else
substitutions.Add ("@COMMENTS@", "");

StringWriter body = new StringWriter (new StringBuilder (d.Body.Length));
Translate (d.Body, body, substitutions);
Expand Down
2 changes: 1 addition & 1 deletion log-style.css
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ blockquote {
}

.blogentry h1 {
font-family: Verdana
font-family: Verdana;
font-size: smaller;
margin-left: -1em;
border-bottom: 2px solid #dddddd;
Expand Down
1 change: 1 addition & 0 deletions template
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
<link rel='stylesheet' href='@BASEDIR@log-style.css' type='text/css'>
<link rel="alternate" type="application/rss+xml" title="RSS" href="http://tirania.org/blog/miguel.rss2"/>
<script src='@BASEDIR@prettyprint.js' type='text/javascript'>
<script type="text/javascript" src="http://www.haloscan.com/load/migueldeicaza"> </script>
</script>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" >
@ANALYTICS@
Expand Down

0 comments on commit 5e56455

Please sign in to comment.