Skip to content

Commit

Permalink
View manual fragments as sub-pages of the documentation on the website.
Browse files Browse the repository at this point in the history
  • Loading branch information
norm committed Apr 15, 2010
1 parent 325b517 commit b7196bb
Show file tree
Hide file tree
Showing 19 changed files with 1,094 additions and 141 deletions.
14 changes: 14 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Copyright (c) 2010, Mark Norman Francis. All rights reserved.

Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:

* Redistributions of source code must retain the above copyright notice,
this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
* Neither the name of the copyright holder nor the names of any
contributors may be used to endorse or promote products derived from
this software without specific prior written permission.

THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
56 changes: 52 additions & 4 deletions cssprepare.com/app.psgi
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ use IO::All -utf8;
use Plack::App::File;
use Plack::Builder;
use Plack::Request;
use Pod::POM;
use Pod::POM::View::InlineHTML;
use Pod::POM::View::HTML;
use Storable;
use Text::Template;

Expand Down Expand Up @@ -108,12 +111,14 @@ sub process_css {
}
sub get_filename {
my $sha1 = shift;
my $filename = shift // 'unknown_file';
my $filename = shift
// 'unknown_file';

return unless defined $sha1;
return unless $sha1 =~ m{ [A-Za-z0-9+_]{27} }x;

my $base = $ENV{'CSS_PREPARE_STORE'} // 'store/';
my $base = $ENV{'CSS_PREPARE_STORE'}
// 'store/';
my $subdir = substr( $sha1, 0, 2 );
my $target = "${base}/${subdir}/${sha1}/${filename}";

Expand Down Expand Up @@ -176,10 +181,53 @@ sub is_flagged {
my $target = get_filename( $sha1, 'flagged' );
return ( -f $target );
}
sub pod_to_html {
my $page = shift;

# state %pod_cache;
# my $html = $pod_cache{ $page };

# if ( !defined $html ) {
my %PAGES = (
default => 'lib/CSS/Prepare/Manual/Introduction.pod',
deploying => 'lib/CSS/Prepare/Manual/Deploying.pod',
features => 'lib/CSS/Prepare/Manual/Features.pod',
hacks => 'lib/CSS/Prepare/Manual/Hacks.pod',
hierarchy => 'lib/CSS/Prepare/Manual/Hierarchy.pod',
optimising => 'lib/CSS/Prepare/Manual/Optimising.pod',
'command-line' => 'bin/cssprepare',
);
my $file = $PAGES{ $page }
// $PAGES{'default'};

my $parser = Pod::POM->new();
my $pom = $parser->parse_file( $file );
my $viewer = Pod::POM::View::InlineHTML->new( header_level => 2 );

my $html = $viewer->print( $pom );
# $pod_cache{ $page } = $html;
# }

return $html;
}


my $documentation_page = sub { return render( 'documentation.html', {} ); };
my $problems_page = sub { return render( 'problems.html', {} ); };
my $documentation_page = sub {
my $environment = shift;
my $request = Plack::Request->new( $environment );

my( undef, $page ) = split m{/}, $request->path_info;
$page = 'introduction'
unless $page;

return render(
'documentation.html',
{
page => $page,
content => pod_to_html( $page ),
}
);
};
my $home_page = sub {
my $environment = shift;
my $request = Plack::Request->new( $environment );
Expand Down
1 change: 1 addition & 0 deletions cssprepare.com/bin
1 change: 1 addition & 0 deletions cssprepare.com/lib/CSS
Loading

0 comments on commit b7196bb

Please sign in to comment.