Skip to content

Commit 440fa4c

Browse files
committed
Work in progress on using perl6.org design for docs
Unfortunately I can't go much further without making Pod::To::HTML more flexible. Right now it hard-codes too much HTML.
1 parent e15d434 commit 440fa4c

File tree

3 files changed

+63
-44
lines changed

3 files changed

+63
-44
lines changed

htmlify.p6

Lines changed: 33 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -45,45 +45,46 @@ my @menu =
4545
# ('formalities','' ) => ();
4646
;
4747

48-
my $head = slurp 'template/head.html';
49-
sub header-html ($current-selection = 'nothing selected') is cached {
48+
my $head = slurp 'template/head.html';
49+
50+
sub header-html ($selection) is cached {
5051
state $header = slurp 'template/header.html';
52+
my $with-active = $header.subst(
53+
/\<(li id="nav-$selection")\>/,
54+
{ "<$/[0] class="active">" });
55+
56+
state $sub-menu-pos = ($header ~~ /SUBMENU/).from;
57+
if $sub-menu-pos >= 0 {
58+
my $sub-menu-items = '';
59+
state %sub-menus = @menu>>.key>>[0] Z=> @menu>>.value;
60+
if %sub-menus{$current-selection} -> $_ {
61+
$sub-menu-items = [~]
62+
q[<div class="menu-items darker-green">],
63+
qq[<a class="menu-item" href="/$current-selection.html">All</a>],
64+
.map({qq[
65+
<a class="menu-item" href="/$current-selection\-$_.html">
66+
{.wordcase}
67+
</a>
68+
]}),
69+
q[</div>];
70+
}
5171

52-
my $menu-items = [~]
53-
q[<div class="menu-items dark-green">],
54-
@menu>>.key.map(-> ($dir, $name) {qq[
55-
<a class="menu-item {$dir eq $current-selection ?? "selected darker-green" !! ""}"
56-
href="/$dir.html">
57-
{ $name || $dir.wordcase }
58-
</a>
59-
]}), #"
60-
q[</div>];
61-
62-
my $sub-menu-items = '';
63-
state %sub-menus = @menu>>.key>>[0] Z=> @menu>>.value;
64-
if %sub-menus{$current-selection} -> $_ {
65-
$sub-menu-items = [~]
66-
q[<div class="menu-items darker-green">],
67-
qq[<a class="menu-item" href="/$current-selection.html">All</a>],
68-
.map({qq[
69-
<a class="menu-item" href="/$current-selection\-$_.html">
70-
{.wordcase}
71-
</a>
72-
]}),
73-
q[</div>]
74-
}
75-
76-
state $menu-pos = ($header ~~ /MENU/).from;
77-
$header.subst('MENU', :p($menu-pos), $menu-items ~ $sub-menu-items);
72+
$header.subst('SUBMENU', :p($sub-menu), $sub-menu-items);
73+
}
7874
}
7975

8076
sub p2h($pod, $selection = 'nothing selected', :$pod-path = 'unknown') {
81-
pod2html $pod,
77+
my $html = pod2html $pod,
8278
:url(&url-munge),
8379
:$head,
84-
:header(header-html $selection),
80+
:header(header-html($selection)),
8581
:footer(footer-html($pod-path)),
86-
:default-title("Perl 6 Documentation"),
82+
:default-title("Perl 6 Documentation");
83+
84+
# Pod::To::HTML should really not be injecting styles/classes/etc without
85+
# any way to override them but it does :(
86+
$html.subst(rx{class="pod"}, q{class="bg"});
87+
return $html;
8788
}
8889

8990
sub recursive-dir($dir) {
@@ -643,6 +644,7 @@ sub write-index-files () {
643644
say 'Writing html/index.html ...';
644645
spurt 'html/index.html',
645646
p2h(EVAL(slurp('doc/HomePage.pod') ~ "\n\$=pod"),
647+
selected => 'home',
646648
pod-path => 'HomePage.pod');
647649

648650
say 'Writing html/language.html ...';

template/head.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
<meta name=viewport content="width=device-width, initial-scale=1">
22
<link rel="icon" href="/favicon.ico" type="image/x-icon" />
3-
<link rel="stylesheet" type="text/css" href="/css/style.css" media="screen" title="default" />
3+
4+
<link rel="stylesheet" type="text/css" href="http://perl6.org/bootstrap/css/bootstrap.min.css">
5+
<link rel="stylesheet" type="text/css" href="http://perl6.org/bootstrap/css/bootstrap-theme.min.css">
6+
<link rel="stylesheet" type="text/css" href="http://perl6.org/style.css">
7+
48
<link type="text/css" href="/css/custom-theme/jquery-ui.css" rel="stylesheet" />
59
<link type="text/css" href="/css/pygments.css" rel="stylesheet" />
610
<noscript> <style> #search { visibility: hidden; } </style> </noscript>

template/header.html

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,27 @@
1-
<div id="header" class="pretty-box green">
2-
<a href="/"
3-
><img src="/images/camelia-small.png" alt="Camelia" id="logo"
4-
>&nbsp;Perl 6 Documentation</a
5-
>
6-
<div id="search" class="ui-widget">
7-
<div class="green"><input placeholder="Search" autofocus id="query" title="Enter Perl 6 document to search for"></div>
1+
<nav class="navbar navbar-fixed-top navbar-inverse">
2+
<div class="container">
3+
<div class="navbar-header">
4+
<button type="button" class="navbar-toggle collapsed"
5+
data-toggle="collapse" data-target="#navbar"
6+
aria-expanded="false" aria-controls="navbar">
7+
<span class="sr-only">Toggle navigation</span>
8+
<span class="icon-bar"></span>
9+
<span class="icon-bar"></span>
10+
<span class="icon-bar"></span>
11+
</button>
812
</div>
9-
<div class="menu">
10-
MENU
13+
<div id="navbar" class="collapse navbar-collapse">
14+
<ul class="nav navbar-nav">
15+
<li id="nav-home"><a href="/">Home</a></li>
16+
<li id="nav-language"><a href="/language.html">Language</a></li>
17+
<li id="nav-types" class="active"><a href="/types.html">Types</a></li>
18+
<li id="nav-routines"><a href="/routines.html">Routines</a></li>
19+
</ul>
20+
<form class="navbar-form navbar-right" role="search">
21+
<div class="form-group">
22+
<input type="text" class="form-control" placeholder="Search" id="query" title="Enter Perl 6 document to search for" autofocus>
23+
</div>
24+
</form>
1125
</div>
12-
</div>
13-
<div id="content-wrapper">
14-
<div id="content" class="pretty-box yellow">
26+
</div>
27+
</nav>

0 commit comments

Comments
 (0)