Created
December 1, 2012 03:20
-
-
Save anazawa/4180405 to your computer and use it in GitHub Desktop.
Blosxom plugin: mt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| package mt; | |
| use strict; | |
| use warnings; | |
| use parent 'Blosxom::Plugin'; | |
| use Text::MicroTemplate qw/encoded_string/; | |
| __PACKAGE__->load_components( 'DataSection' ); | |
| sub start { | |
| my $pkg = shift; | |
| $pkg->merge_data_section_into( \%blosxom::template ); | |
| return 1; | |
| } | |
| sub interpolate { | |
| my $pkg = shift; | |
| my $mt = Text::MicroTemplate->new( package_name => 'blosxom' ); | |
| return sub { | |
| my ( $template, @args ) = @_; | |
| $mt->parse( $template )->build->( @args )->as_string; | |
| }; | |
| } | |
| sub story { | |
| my ( $pkg, $path, $fn, $story, $title, $body ) = @_; | |
| $$body = encoded_string( $$body ); | |
| return; | |
| } | |
| sub render_file { | |
| my ( $file, @args ) = @_; | |
| my $path_info = $blosxom::path_info; | |
| my ( $chunk, $flavour ) = $file =~ /(.*)\.([^.]*)/; | |
| my $template = $blosxom::template->( $path_info, $chunk, $flavour ); | |
| $blosxom::interpolate->( $template, @args ); | |
| } | |
| 1; | |
| __DATA__ | |
| @@ content_type.html | |
| text/html | |
| @@ head.html | |
| <html> | |
| <head> | |
| <link rel="alternate" type="application/rss+xml" title="RSS" href="<?= "$url/index.rss" ?>" /> | |
| <title><?= "$blog_title $path_info_da $path_info_mo $path_info_yr" ?> | |
| </title> | |
| </head> | |
| <body> | |
| <center> | |
| <font size="+3"><?= $blog_title ?></font><br /> | |
| <?= "$path_info_da $path_info_mo $path_info_yr" ?> | |
| </center> | |
| <p /> | |
| <p> | |
| <a name="<?= $fn ?>"><b><?= $title =></b></a><br /> | |
| <?= $body ?><br /> | |
| <br /> | |
| posted at: <?= $ti ?> | path: <a href="<?= "$url$path" ?>"><?= $path ?> </a> | <a href="<?= "$url/$yr/$mo_num/$da#$fn" ?>">permanent link to this entry</a> | |
| </p> | |
| @@ date.html | |
| <h3><?= "$dw, $da $mo $yr" ?></h3> | |
| @@ foot.html | |
| <p /> | |
| <center> | |
| <a href="http://www.blosxom.com/"><img src="http://www.blosxom.com/images/pb_blosxom.gif" border="0" /></a> | |
| </center> | |
| </body> | |
| </html> | |
| @@ content_type.rss | |
| text/xml | |
| @@ head.rss | |
| ?= '<?xml version="1.0"?>' | |
| <!-- name="generator" content="blosxom/<?= $version ?>" --> | |
| <!DOCTYPE rss PUBLIC "-//Netscape Communications//DTD RSS 0.91//EN" "http://my.netscape.com/publish/formats/rss-0.91.dtd"> | |
| <rss version="0.91"> | |
| <channel> | |
| <title><?= "$blog_title $path_info_da $path_info_mo $path_info_yr" ?></title> | |
| <link><?= $url ?></link> | |
| <description><?= $blog_description ?></description> | |
| <language><?= $blog_language ?></language> | |
| @@ story.rss | |
| <item> | |
| <title><?= $title ?></title> | |
| <link><?= "$url/$yr/$mo_num/$da#$fn" ?></link> | |
| <description><?= $body ?></description> | |
| </item> | |
| @@ date.rss | |
| @@ foot.rss | |
| </channel> | |
| </rss> | |
| @@ content_type.error | |
| text/html | |
| @@ head.error | |
| <html> | |
| <body> | |
| <p><font color="red">Error: I'm afraid this is the first I've heard of a "<?= $flavour ?>" flavoured Blosxom. Try dropping the "/+<?= $flavour ?>" bit from the end of the URL.</font> | |
| @@ story.error | |
| <p><b><?= $title ?></b><br /> | |
| <?= $body ?> <a href="<?= "$url/$yr/$mo_num/$da#fn.$default_flavour" ?>">#</a></p> | |
| @@ date.error | |
| <h3><?= "$dw, $da $mo $yr" ?></h3> | |
| @@ foot.error | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment