diff options
author | Julian Blake Kongslie <jblake@omgwallhack.org> | 2010-07-07 12:13:45 -0700 |
---|---|---|
committer | Julian Blake Kongslie <jblake@omgwallhack.org> | 2010-07-07 12:13:45 -0700 |
commit | 6805e21a08f773dc4066c179dd78537c4dc339fb (patch) | |
tree | acd87ed5479d3507b3c905add6c02c4c16c444db | |
parent | c7cc5c118d0174a4048504e16949124d167d4b1f (diff) | |
download | piny-code-6805e21a08f773dc4066c179dd78537c4dc339fb.tar.gz piny-code-6805e21a08f773dc4066c179dd78537c4dc339fb.zip |
Lots of stuff for manipulating IkiWiki setup scripts.
-rwxr-xr-x | srv/almighty_ikiwiki_template.setup | 77 | ||||
-rw-r--r-- | usr/src/libpiny/Build.PL | 2 | ||||
-rw-r--r-- | usr/src/libpiny/debian/changelog | 6 | ||||
-rw-r--r-- | usr/src/libpiny/lib/IkiWiki/FakeSetup.pm | 89 |
4 files changed, 173 insertions, 1 deletions
diff --git a/srv/almighty_ikiwiki_template.setup b/srv/almighty_ikiwiki_template.setup new file mode 100755 index 0000000..4cba4b2 --- /dev/null +++ b/srv/almighty_ikiwiki_template.setup @@ -0,0 +1,77 @@ +#!/usr/bin/perl +# Configuration file for ikiwiki. +# Passing this to ikiwiki --setup will make ikiwiki generate wrappers and +# build the wiki. +# +# Remember to re-run ikiwiki --setup any time you edit this file. + +use IkiWiki::Setup::Standard { + # wikiname => "', # LATER MODIFIED BY LATER MODIFIED BY PINY + # adminemail => "', # LATER MODIFIED BY LATER MODIFIED BY PINY + # srcdir => "', # LATER MODIFIED BY PINY + # destdir => "', # LATER MODIFIED BY PINY + # url => "', # LATER MODIFIED BY PINY + # cgiurl => "', # LATER MODIFIED BY PINY + # historyurl => "', # LATER MODIFIED BY PINY + # diffurl => "', # LATER MODIFIED BY PINY + + templatedir => "/srv/templates", # TODO: user-customizable templates + underlaydir => "/etc/ikiwiki/share/underlay", + + rcs => "git", + gitorigin_branch => "origin", + gitmaster_branch => "master", + + # wrappers => [ ], controlled by piny + + # Generate rss feeds for blogs? + rss => 1, + # Generate atom feeds for blogs? + atom => 0, + # Include discussion links on all pages? + discussion => 0, + # To exclude files matching a regexp from processing. This adds to + # the default exclude list. + #exclude => qr/*\.wav/, + # To change the extension used for generated html files. + #htmlext => "htm", + # Time format (for strftime) + #timeformat => "%c", + # Locale to use. Must be a UTF-8 locale. + #locale => "en_US.UTF-8", + # Only send cookies over SSL connections. + sslcookie => 1, + # Logging settings: + verbose => 0, + syslog => 1, + # To link to user pages in a subdirectory of the wiki. + #userdir => "users", + # To create output files named page.html rather than page/index.html. + usedirs => 1, + # Simple spam prevention: require an account-creation password. + #account_creation_password => "example", + # Use new "!"-prefixed preprocessor directive syntax + prefix_directives => 1, + httpauth => 1, + # To add plugins, list them here. + add_plugins => [qw{sidebar toc meta table tag graphviz httpauth img attachment rename remove map teximg version edittemplate}], + disable_plugins => [qw{openid passwordauth}], + teximg_prefix => "\\documentclass{scrartcl} +\\usepackage[version=3]{mhchem} +\\usepackage{amsmath} +\\usepackage{amsfonts} +\\usepackage{amssymb} +\\pagestyle{empty} +\\newcommand{\\unit}[1]{\\ensuremath{\\, \\mathrm{#1}}} +\\begin{document}", + + teximg_dvipng => 1, + + # For use with the tag plugin, make all tags be located under a + # base page. + tagbase => "tag", + + # For use with the search plugin if your estseek.cgi is located + # somewhere else. + #estseek => "/usr/lib/estraier/estseek.cgi", +}; diff --git a/usr/src/libpiny/Build.PL b/usr/src/libpiny/Build.PL index 8639991..09cf3fb 100644 --- a/usr/src/libpiny/Build.PL +++ b/usr/src/libpiny/Build.PL @@ -2,7 +2,7 @@ use Module::Build; Module::Build->new ( module_name => 'Piny' , license => 'BSD-3' - , dist_version => '0.5' + , dist_version => '0.6' , requires => { 'Moose' => 0 , 'Email::Valid::Loose' => 0 diff --git a/usr/src/libpiny/debian/changelog b/usr/src/libpiny/debian/changelog index 79952b6..df872b4 100644 --- a/usr/src/libpiny/debian/changelog +++ b/usr/src/libpiny/debian/changelog @@ -1,3 +1,9 @@ +libpiny-perl (0.6) unstable; urgency=low + + * Added IkiWiki::FakeSetup for manipulating IkiWiki setup scripts. + + -- Julian Blake Kongslie <jblake@omgwallhack.org> Wed, 07 Jul 2010 12:12:37 -0700 + libpiny-perl (0.5) unstable; urgency=low * Allow listing repos and querying access rights. diff --git a/usr/src/libpiny/lib/IkiWiki/FakeSetup.pm b/usr/src/libpiny/lib/IkiWiki/FakeSetup.pm new file mode 100644 index 0000000..8a8b2d2 --- /dev/null +++ b/usr/src/libpiny/lib/IkiWiki/FakeSetup.pm @@ -0,0 +1,89 @@ +package IkiWiki::FakeSetup; + +use strict; +use warnings; + +use Data::Dumper qw( ); +use Exporter qw( import ); + +our @EXPORT_OK = qw( readSetup writeSetup ); + +sub readSetup { + my ( $setupfile ) = @_; + + # Sorry about the use of globals but it's hard to share lexicals with dynamically generated source. + $IkiWiki::FakeSetup::package = undef; + @IkiWiki::FakeSetup::args = (); + + sub inc { + my ( $self, $file ) = @_; + + my $package = $file; + $package =~ s/\//::/g; + $package =~ s/\.pm//; + + my @src = + ( "package $package;\n" + , "sub import {\n" + , " my ( \$class, \@args ) = \@_;\n" + , " print 'in import\\n';" + , " \$IkiWiki::FakeSetup::package = \$class;\n" + , " \@IkiWiki::FakeSetup::args = \@args;\n" + , "}\n" + , "1;\n" + ); + + return sub { if ( scalar @src ) { $_ = shift @src; return 1; } else { return 0; } }; + + }; + + eval { + my @oldINC = @INC; + @INC = ( ".", \&inc ); + + my %oldINC = %INC; + %INC = ( ); + + do $setupfile; + + @INC = @oldINC; + %INC = %oldINC; + }; + + return ( $IkiWiki::FakeSetup::package, @IkiWiki::FakeSetup::args ); + +} + +sub writeSetup { + my ( $package, @args ) = @_; + + my $d = Data::Dumper->new( \@args ); + $d->Terse( 1 ); + + return "#!/usr/bin/perl\n\nuse $package " . $d->Dump( ) . ";\n"; +} + +1; + +__END__ + +Because it may not be completely obvious, here's how you would use this: + +#!/usr/bin/perl + +use strict; +use warnings; + +use IkiWiki::FakeSetup qw( readSetup writeSetup ); + +# This reads the setup file, returning the package it uses and any configuration it passed to that package. +my ( $package, $config ) = readSetup( "almighty_ikiwiki_template.setup" ); + +# Make changes to the configuration. +$config->{"srcdir"} = "/some/dir"; +$config->{"adminemail"} = "somejerk\@jerkville.com"; + +# Open a new file, and write the changed configuration to it. +open( SETUP, ">", "almighty_ikiwiki_template_changed.setup" ); +print SETUP writeSetup( $package, $config ); +close( SETUP ); |