Skip to content

Instantly share code, notes, and snippets.

@tsibley
Created September 21, 2011 15:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tsibley/1232457 to your computer and use it in GitHub Desktop.
Save tsibley/1232457 to your computer and use it in GitHub Desktop.
#!/bin/bash
middleware=""
if [[ "$1" == "markdown" || "$1" == "md" || "$1" == "wiki" ]]; then
wikilinks=0
if [[ "$1" == "wiki" ]]; then wikilinks=1; fi
shift
middleware='
enable_if { $_[0]->{REQUEST_URI} =~ /\.(md|mkdwn|markdown)$/ }
SimpleContentFilter => filter => sub {
use Text::MultiMarkdown qw(markdown);
$_ = markdown($_, {use_wikilinks=>'"$wikilinks"'})
};
enable_if { $_[0]->{REQUEST_URI} =~ /\.(md|mkdwn|markdown)$/ }
Header => set => [qw(Content-Type text/html)];
enable Expires =>
content_type => qr/./,
expires => "now plus 1 second";'
fi
plackngo --port 4242 -MPlack::App::Directory -e "$middleware; Plack::App::Directory->new({ root => '.' })->to_app" "$@"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment