| package path; |
| |
| use ASF::Util qw/walk_content_tree Load/; |
| use strict; |
| use warnings; |
| |
| my $thrift_snippet_footer = <<'EOT'; # '$snippet' string magically refers to current snippet obj |
| <p class='snippet_footer'> |
| This snippet was generated by {{ site.title }}'s <strong>source tree docs</strong>: |
| <a href="{{ $snippet.pretty_uri }}"</a>{{ $snippet.path }}</a> |
| </p> |
| EOT |
| |
| my %thrift_args = ( |
| conf => Load(join "", <DATA>), # make YAML __DATA__ below available in conf argument |
| preprocess => 1, # enable template preprocessing of .md files |
| repo => 'gitbox/thrift.git', # set snippet default git repo (on gitbox)... |
| template => 'default.html', # set common template argument (mainly for .md files) |
| snippet_footer=> $thrift_snippet_footer,# append this string to each generated snipppet block |
| quick_deps => 1, # short-circuit deps processing to headers only |
| ); |
| |
| my $thrift_page_footer = $thrift_snippet_footer; |
| $thrift_page_footer =~ s/ snippet / page /; # full page 'snippets' |
| |
| # order matters here: first match wins... see http://www.apache.org/dev/cmsref#core-logic |
| |
| our @patterns = ( |
| [qr!^/sitemap\.html$!, sitemap => { %thrift_args, # %thrift_args as overrideable defaults |
| headers => { title => "Sitemap" }, |
| nest => 1, |
| }], |
| [qr!^/index\.html$!, snippet => { %thrift_args, |
| view => 'news_page', |
| headers => { title => "Home" }, |
| }], |
| [qr!/index\.html$!, sitemap => { %thrift_args }], |
| [qr!^/(lib|test)/!, snippet => { %thrift_args, |
| view => [qw/reconstruct trim_local_links single_narrative/], |
| snippet_footer => $thrift_page_footer, # override: these are full pages not snippets |
| }], |
| [qr/\.md(?:text)?$/, snippet => { %thrift_args, |
| view => 'single_narrative', |
| }], |
| ); |
| |
| our %dependencies; # for /sitemap.html and /**/index.html pages whose title + url listings |
| # depend on the other files in the relevant content/ subdirectories. We run |
| # the views for those files in offline mode for performance, since the titles |
| # and urls required do not depend on code snippet contents which take time to |
| # fetch. We could do slightly better if we weren't interested in the actual |
| # build-generated output of those dependent files, which we aren't, but |
| # coding that up as a special case of the standard sitemap view isn't worth |
| # the trouble. |
| # Now watch me bother anyway just to see... ok done with 'quick_deps' support. |
| # Yay it's about a second faster on a full site build for thrift- go team! |
| |
| walk_content_tree { |
| if (/\.md(?:text)?$/ or m!/index\.html$! or m!^/test/!) { |
| # basically grep s/^content//, glob("content/**/*.{md,mdtext}"), |
| # glob("content/**/index.html"), |
| # glob("content/test/**/*"); |
| # if perl's glob was as smart as zsh's glob |
| push @{$dependencies{"/sitemap.html"}}, $_; |
| } |
| if (s!/index\.html$!!) { |
| $dependencies{"$_/index.html"} = [ |
| grep s/^content//, glob("content$_/*.{md,mdtext}"), |
| glob("content$_/*/index.html") |
| ]; |
| } |
| }; |
| |
| delete $dependencies{"/index.html"}; # the home page really doesn't depend on anything else |
| |
| 1; |
| |