Commits

Anonymous committed dacbd59

Added the RSS feed management to the shlomif_hsite community on LiveJournal.
Now the news items are automatically fetched, etc.

  • Participants
  • Parent commits b750ac9

Comments (0)

Files changed (7)

 * Feed the RSS feed of shlomif_hsite from LJ to the homepage front page,
 and old-news page. (with links to the comments).
  
+* Fix the expanded thing in H::W::NM.
+
     News:
     -----
 

bin/fetch-shlomif_hsite-feed.pl

+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use lib "./lib";
+
+use Shlomif::Homepage::Rss;
+
+my $feed = Shlomif::Homepage::Rss->new();
+$feed->run();
+

lib/Shlomif/Homepage/News.pm

+package Shlomif::Homepage::News;
+
+use strict;
+use warnings;
+
+use base 'HTML::Widgets::NavMenu::Object';
+use base 'Class::Accessor';
+
+use DateTime;
+
+__PACKAGE__->mk_accessors(qw(
+    dir
+    items
+    num_on_front
+    ));
+
+my @old_news_items = 
+(
+    {
+        'date' => "22-Mar-2005",
+        'body' => <<"EOF",
+<p class="newsitem">
+I added a <a href="links.html#pictures">section to my links collection with
+links to my favourite collections of pictures and wallpapers</a>. Otherwise,
+I now <a href="http://www.livejournal.com/users/shlomif/">cross-post my 
+weblog</a> in 
+<a href="http://www.livejournal.com/">LiveJournal.com</a> and you can use
+its commenting system to post comments to its entries. 
+</p>
+
+<p class="newsitem">
+<a href="http://jmikmod.berlios.de/">MikMod for Java has moved to a new 
+homepage</a> at Berlios where I hope other people would be able to
+contribute to it more efficiently than before. 
+<a href="http://gimp-test.berlios.de/">The Gimp Automated Testing 
+Framework</a> is a new project of mine. Check it out if you're interested.
+</p>
+EOF
+    },
+    {
+        'date' => "19-May-2005",
+        'body' => <<"EOF",
+<p class="newsitem">
+The full but incomplete text of <a href="humour/human-hacking/">"The Human 
+Hacking Field Guide"</a> is now available online for your reading pleasure.
+</p>
+EOF
+    },
+    {
+        'date' => "22-May-2005",
+        'body' => <<"EOF",
+<p class="newsitem">
+I now have <a href="./me/personal-ad.html">a personal ad</a>. I'm
+looking for a girlfriend who lives in Central Israel.
+</p>
+EOF
+    },
+    {
+        'date' => "26-Jun-2005",
+        'body' => <<"EOF",
+<p class="newsitem">
+Several new additions were added to the site. The <a href="./art/">art
+section</a> now contains two new pieces. I also added 
+<a href="./open-source/bits.html#old_pmwiki_revert">a new script</a>
+to the "Open Source Bits and Bobs section". Several new programs were
+added to <a href="./open-source/favourite/index.html.wml">my favourite
+free software</a>. Some new languages were added to
+<a href="./humour/ways_to_do_it.html">the "Ways to do it" according
+to the programming languages of the World</a> page. 
+</p>
+
+<p class="newsitem">
+Some of my newer projects are now mentioned in my resume&eacute;s. I added
+a link to <a href="./lecture/LAMP/slides/">a presentation about Web 
+Publishing using LAMP</a>. Finally, 
+<a href="./philosophy/obj-oss/">the Objectivism and Open Source</a>
+essay was expanded with two new chapters.
+</p>
+EOF
+    },
+    {
+        'date' => "5-Oct-2005",
+        'body' => <<"EOF",
+<p class="newsitem">
+Added <a href="./philosophy/computers/when-c-is-best/">the "When C is the
+Best" essay</a>. Also now that the software patents threat in Europe has
+been eliminated, I have removed the notice box, and replaced my top-left
+icon with <a href="./images/shlomif-homepage-logo.png">a personal
+logo</a> based on <a href="http://ars.userfriendly.org/cartoons/?id=20030803&amp;mode=classic">EvilPHish 
+from UserFriendly</a>.
+</p>
+
+<p class="newsitem">
+Finally, several fortunes were added to
+<a href="http://vipe.technion.ac.il/~shlomif/humour/fortunes/">the fortune
+cookies collection</a> and it now also contains a collection of quotes by
+<a href="http://www.paulgraham.com/">Paul Graham</a>.
+</p>
+
+EOF
+    },
+    {
+        'date' => "15-Oct-2005",
+        'body' => <<"EOF",
+<p class="newsitem">
+The past few days have seen the move to a new hosting provider with much
+better bandwidth to outside Israel. It should be much more faster and
+responsive to most people. Other than that, the web-site has seen many
+style and content changes:
+</p>
+
+<ol class="newsitem">
+<li>
+A computer music file that I created when I was in high school, with my
+friend, was added to the <a href="./art/">art section</a>.
+</li>
+<li>
+New section navigation menus were added to 
+<a href="./philosophy/">the Essays
+and Articles section</a>, <a href="./open-source/">the Software
+section</a>, and <a href="http://vipe.technion.ac.il/~shlomif/lecture/">the
+Lectures section</a>. They will allow the main navigation menu to be
+less crowded, and will give way for a faster update of the site.
+</li>
+<li>
+Many typos were corrected in <a href="./DeCSS/">the DeCSS page</a>.
+</li>
+<li>
+The <a href="./links.html">Links Page</a> was updated.
+</li>
+<li>
+Several new essays and articles are now part of 
+the <a href="./philosophy/">Philosophy
+section</a>. Especially note 
+<a href="./philosophy/computers/when-c-is-the-best/">the "When C is the
+Best" essay</a> which started 
+<a href="http://osnews.com/comment.php?news_id=12189">an active discussion 
+in OSNews</a>.
+</li>
+<li>
+I now have <a href="./philosophy/books-recommends/">a list of recommended
+books</a>. 
+</li>
+</ol>
+
+<p class="newsitem">
+There's still some more ground to cover on my part, but the homepage should
+still be much better than it was 10 days ago.
+</p>
+EOF
+    },
+);
+
+sub file_to_news_item
+{
+    my $self = shift;
+    my $filename = shift;
+    my $text = do {
+        local $/;
+        open my $file, "<", $self->dir()."/".$filename;
+        <$file>;
+    };
+    $text =~ s!<p>!<p class="newsitem">!g;
+    $text =~ s!<ol>!<ol class="newsitem">!g;
+    $text =~ s!<ul>!<ol class="newsitem">!g;
+    $filename =~ /^(\d{4})-(\d{2})-(\d{2})\.html$/;
+    my ($y, $m, $d) = ($1, $2, $3);
+    my $date = DateTime->new(year => $y, month => $m, day => $d);
+    return
+        +{
+            'date' => (sprintf("%.2d", $date->day()) . "-" . $date->month_abbr(). "-" . $date->year()),
+            'body' => $text,
+        };
+}
+
+sub calc_rss_items
+{
+    my $self = shift;
+
+    opendir my $dir, $self->dir();
+    my @files = readdir($dir);
+    closedir($dir);
+    @files = (grep { /^\d{4}-\d{2}-\d{2}\.html$/ } @files);
+    @files = sort { $a cmp $b } @files;
+    return [
+        map {
+            $self->file_to_news_item($_)
+        } @files
+        ];
+}
+
+sub calc_items
+{
+    my $self = shift;
+    return [@old_news_items, @{$self->calc_rss_items()}];
+}
+
+sub initialize
+{
+    my $self = shift;
+
+    $self->dir("../lib/feeds/shlomif_hsite");
+    $self->num_on_front(7);
+
+    $self->items($self->calc_items());
+
+    return 0;
+}
+
+sub get_item_html
+{
+    my $self = shift;
+    my $item = shift;
+    return "<h3 class=\"newsitem\">" . $item->{'date'} . "</h3>\n\n" .
+        $item->{'body'};
+}
+
+sub render_items
+{
+    my $self = shift;
+    my $items = shift;
+    return join("\n\n", (map { $self->get_item_html($_) } @$items));
+}
+
+sub render_front_page
+{
+    my $self = shift;
+    my @items = reverse(@{$self->items()});
+    return $self->render_items([@items[0..($self->num_on_front()-1)]]);
+}
+
+sub render_old
+{
+    my $self = shift;
+    my @items = @{$self->items()};
+    return $self->render_items([reverse(@items[0 .. (@items - $self->num_on_front())])]);
+}
+
+1;
+

lib/Shlomif/Homepage/Rss.pm

+package Shlomif::Homepage::Rss;
+
+use strict;
+use warnings;
+
+use base 'HTML::Widgets::NavMenu::Object';
+use base 'Class::Accessor';
+
+use XML::Feed;
+use CGI;
+
+__PACKAGE__->mk_accessors(qw(
+    feed
+));
+    
+sub initialize
+{
+    my $self = shift;
+    my $feed = XML::Feed->parse(URI->new("http://www.livejournal.com/community/shlomif_hsite/data/atom"))
+        or die XML::Feed->errstr;
+    $self->feed($feed);
+
+    return 0;
+}
+
+sub run
+{
+    my $self = shift;
+    foreach my $entry ($self->feed()->entries())
+    {
+        my $text = $entry->content()->body() . "\n\n" . "<p><a href=\"" . CGI::escapeHTML($entry->link()) . "\">See comments and comment on this.</a></p>\n";
+        my $issued = $entry->issued();
+        my $filename = "lib/feeds/shlomif_hsite/" . $issued->ymd() . ".html";
+        open O, ">", $filename;
+        print O $text;
+        close(O);
+        system("svn", "add", $filename);
+    }
+}
+
+1;
+

lib/feeds/shlomif_hsite/2005-10-28.html

+<p>
+Since the last update to its changes log, 
+<a href="http://www.shlomifish.org/">Shlomi Fish' personal site</a>
+has seen a great deal of changes. Here is a list of the most major ones:
+</p>
+
+<ol>
+<li>
+<a href="http://www.shlomifish.org/personal.html">The Bio Page</a> was 
+sectioned into several headings, and more links and material were added.
+</li>
+<li>
+The old <a href="http://www.shlomifish.org/wonderous.html">"Wonderous are
+the Ways of Microsoft"</a> humorous (but real) bit was integrated into
+the common look and feel of the site, and re-linked from there.
+</li>
+<li>
+<a href="http://www.shlomifish.org/humour/stories/">An index page</a>
+was created for the stories as part of the global humour section.
+</li>
+<li>
+<a href="http://www.shlomifish.org/links.html">The Links Page</a> was heavily
+re-organized and expanded. Now, each one of its section has an anchor for 
+easy linking to that part of the page.
+</li>
+<li>
+A New Essay - 
+<a href="http://www.shlomifish.org/philosophy/computers/open-source/gpl-bsd-and-suckerism/">"The
+GPL, the BSD License and Being a Sucker"</a> was added. It aims to dispel
+the common belief that one is being a sucker while releasing open source 
+software under non-<a href="http://www.gnu.org/licenses/gpl-faq.html">GPL</a> 
+licenses.
+</li>
+<li>
+A New Essay - 
+<a href="http://www.shlomifish.org/philosophy/case-for-file-swapping/">"The 
+Case for File Swapping"</a> was added. This essay touches upon the many points
+of the Internet sharing and downloading of files (including media files such as
+music files or video), and dispels most of the myths about why it's illegal or
+immoral.
+</li>
+</ol>
+
+<p>
+I still have several new essays in the pipe, and I also need to do some
+cleanups to the site. One enhancement will also involve tweaking the 
+site flow engine that is used by the site.
+</p>
+
+<p>
+But until then - enjoy!
+</p>
+
+<p><a href="http://www.livejournal.com/community/shlomif_hsite/312.html">See comments and comment on this.</a></p>

t2/index.html.wml

 
 <h2>News</h2>
 
-<h3 class="newsitem">15-Oct-2005</h3>
+<:{
+use Shlomif::Homepage::News;
 
-<p class="newsitem">
-The past few days have seen the move to a new hosting provider with much
-better bandwidth to outside Israel. It should be much more faster and
-responsive to most people. Other than that, the web-site has seen many
-style and content changes:
-</p>
-
-<ol class="newsitem">
-<li>
-A computer music file that I created when I was in high school, with my
-friend, was added to the <a href="$(ROOT)/art/">art section</a>.
-</li>
-<li>
-New section navigation menus were added to 
-<a href="$(ROOT)/philosophy/">the Essays
-and Articles section</a>, <a href="$(ROOT)/open-source/">the Software
-section</a>, and <a href="<rellink host="vipe" url="lecture/" />">the
-Lectures section</a>. They will allow the main navigation menu to be
-less crowded, and will give way for a faster update of the site.
-</li>
-<li>
-Many typos were corrected in <a href="$(ROOT)/DeCSS/">the DeCSS page</a>.
-</li>
-<li>
-The <a href="$(ROOT)/links.html">Links Page</a> was updated.
-</li>
-<li>
-Several new essays and articles are now part of 
-the <a href="$(ROOT)/philosophy/">Philosophy
-section</a>. Especially note 
-<a href="$(ROOT)/philosophy/computers/when-c-is-the-best/">the "When C is the
-Best" essay</a> which started 
-<a href="http://osnews.com/comment.php?news_id=12189">an active discussion 
-in OSNews</a>.
-</li>
-<li>
-I now have <a href="$(ROOT)/philosophy/books-recommends/">a list of recommended
-books</a>. 
-</li>
-</ol>
-
-<p class="newsitem">
-There's still some more ground to cover on my part, but the homepage should
-still be much better than it was 10 days ago.
-</p>
-
-<h3 class="newsitem">5-Oct-2005</h3>
-
-<p class="newsitem">
-Added <a href="<rellink url="philosophy/computers/when-c-is-best/" host="t2" />">the "When C is the
-Best" essay</a>. Also now that the software patents threat in Europe has
-been eliminated, I have removed the notice box, and replaced my top-left
-icon with <a href="$(ROOT)/images/shlomif-homepage-logo.png">a personal
-logo</a> based on <a href="http://ars.userfriendly.org/cartoons/?id=20030803&amp;mode=classic">EvilPHish 
-from UserFriendly</a>.
-</p>
-
-<p class="newsitem">
-Finally, several fortunes were added to
-<a href="<rellink url="humour/fortunes/" host="vipe" />">the fortune
-cookies collection</a> and it now also contains a collection of quotes by
-<a href="http://www.paulgraham.com/">Paul Graham</a>.
-</p>
-
-<h3 class="newsitem">26-Jun-2005</h3>
-
-<p class="newsitem">
-Several new additions were added to the site. The <a href="$(ROOT)/art/">art
-section</a> now contains two new pieces. I also added 
-<a href="$(ROOT)/open-source/bits.html#old_pmwiki_revert">a new script</a>
-to the "Open Source Bits and Bobs section". Several new programs were
-added to <a href="$(ROOT)/open-source/favourite/index.html.wml">my favourite
-free software</a>. Some new languages were added to
-<a href="$(ROOT)/humour/ways_to_do_it.html">the "Ways to do it" according
-to the programming languages of the World</a> page. 
-</p>
-
-<p class="newsitem">
-Some of my newer projects are now mentioned in my resume&eacute;s. I added
-a link to <a href="$(ROOT)/lecture/LAMP/slides/">a presentation about Web 
-Publishing using LAMP</a>. Finally, 
-<a href="$(ROOT)/philosophy/obj-oss/">the Objectivism and Open Source</a>
-essay was expanded with two new chapters.
-</p>
-
-<h3 class="newsitem">22-May-2005</h3>
-
-<p class="newsitem">
-I now have <a href="$(ROOT)/me/personal-ad.html">a personal ad</a>. I'm
-looking for a girlfriend who lives in Central Israel.
-</p>
-
-<h3 class="newsitem">19-May-2005</h3>
-
-<p class="newsitem">
-The full but incomplete text of <a href="humour/human-hacking/">"The Human 
-Hacking Field Guide"</a> is now available online for your reading pleasure.
-</p>
-
-<h3 class="newsitem">22-Mar-2005</h3>
-
-<p class="newsitem">
-I added a <a href="links.html#pictures">section to my links collection with
-links to my favourite collections of pictures and wallpapers</a>. Otherwise,
-I now <a href="http://www.livejournal.com/users/shlomif/">cross-post my 
-weblog</a> in 
-<a href="http://www.livejournal.com/">LiveJournal.com</a> and you can use
-its commenting system to post comments to its entries. 
-</p>
-
-<p class="newsitem">
-<a href="http://jmikmod.berlios.de/">MikMod for Java has moved to a new 
-homepage</a> at Berlios where I hope other people would be able to
-contribute to it more efficiently than before. 
-<a href="http://gimp-test.berlios.de/">The Gimp Automated Testing 
-Framework</a> is a new project of mine. Check it out if you're interested.
-</p>
+my $news = Shlomif::Homepage::News->new();
+print $news->render_front_page();
+}:>
 
 <h3 class="newsitem"><a href="old-news.html">Old News Items</a></h3>
 

t2/old-news.html.wml

 
 <latemp_subject "Shlomi Fish' Homepage Old News Items" />
 
+<:{
+use Shlomif::Homepage::News;
+
+my $news = Shlomif::Homepage::News->new();
+print $news->render_old();
+}:>
+
 
 <h3 class="newsitem">30-Oct-2004</h3>