Skip to content

Commit b587984

Browse files
committed
Breadcrumb, attribution blocks. How deps. are loaded.
1 parent 547d48c commit b587984

File tree

11 files changed

+149
-198
lines changed

11 files changed

+149
-198
lines changed

.bowerrc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
{
2+
"analytics": false,
3+
"directory": "static/bower_components"
4+
}

Makefile

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ PATH := bin:${PATH}
33
DATE := `date '+%Y%m%d'`
44

55

6-
build: src/ node_modules/ static/assets/css/highlight.css
6+
build: src/ node_modules/ static/bower_components/ static/assets/css/highlight.css
77
time npm run build
88

99

@@ -15,16 +15,18 @@ src:
1515
cd ..;\
1616
fi
1717

18+
static/bower_components/: node_modules/
19+
node_modules/.bin/bower install
1820

19-
static/assets/css/highlight.css: node_modules/
21+
static/assets/css/highlight.css: node_modules
2022
cp node_modules/highlight.js/styles/solarized_dark.css static/assets/css/highlight.css
2123

2224

23-
node_modules: package.json
25+
node_modules/: package.json
2426
npm install
2527

2628

27-
rsync:
29+
rsync: build
2830
rsync -az --delete --progress --exclude=".git" build/ upstream-docs1.staging.wpdn:/srv/webapps/docs/build/
2931
rsync -az config/nginx/ upstream-docs1.staging.wpdn:/etc/nginx/docs/
3032

bower.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"name": "generator-docs",
3+
"version": "2.0.0",
4+
"description": "WebPlatform Docs Static site generatora static site generator.",
5+
"homepage": "https://github.com/webplatform/generator-docs#readme",
6+
"license": "CC-BY-3.0",
7+
"authors": [
8+
"Renoir Boulanger <[email protected]>"
9+
],
10+
"ignore": [
11+
"build",
12+
"node_modules",
13+
"bower_components"
14+
],
15+
"dependencies": {
16+
"jquery": "~1.11",
17+
"vue": "~0.12",
18+
"ie7-js": "*"
19+
}
20+
}

layouts/default.hbs

Lines changed: 20 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,16 @@
77
<link rel="stylesheet" href="/assets/css/highlight.css" />
88
<link rel="shortcut icon" href="/favicon.ico" />
99
<meta name="viewport" content="width=device-width" />
10-
<!--[if lt IE 7]><script src="//www.webplatform.org/assets/bower_components/ie7-js/lib/IE7.js"></script><![endif]-->
11-
<!--[if lt IE 8]><script src="//www.webplatform.org/assets/bower_components/ie7-js/lib/IE8.js"></script><![endif]-->
12-
<!--[if lt IE 9]><script src="//www.webplatform.org/assets/bower_components/ie7-js/lib/IE9.js"></script><![endif]-->
13-
<!--[if lt IE 9]><script src="//docs.webplatform.org/w/extensions/WebPlatformDocs/skin/html5shiv.js"></script><![endif]-->
10+
<!--[if lt IE 7]><script src="/bower_components/ie7-js/lib/IE7.js"></script><![endif]-->
11+
<!--[if lt IE 8]><script src="/bower_components/ie7-js/lib/IE8.js"></script><![endif]-->
12+
<!--[if lt IE 9]><script src="/bower_components/ie7-js/lib/IE9.js"></script><![endif]-->
1413
<!--[if lt IE 8]><link rel="stylesheet" href="//www.webplatform.org/assets/css/ie7.css"><![endif]-->
1514
{{>metadata}}
16-
15+
<script src="/bower_components/jquery/dist/jquery.min.js"></script>
16+
<script src="/bower_components/vue/dist/vue.min.js"></script>
1717
</head>
1818
<body class="mediawiki ltr sitedir-ltr skin-webplatform action-view">
19+
{{#readiness_marker}}{{readiness}}{{/readiness_marker}}
1920
<header id="mw-head" class="noprint">
2021
<div class="container">
2122
<div id="p-logo">
@@ -49,25 +50,34 @@
4950
<a id="top"></a>
5051
<div class="tool-area">
5152
<div id="hierarchy-menu">
52-
<ol id="breadcrumb-info" class="breadcrumbs">
53-
<li><a href="/">DOCS</a></li>
54-
</ol>
53+
{{>breadcrumb}}
5554
</div>
5655
<div class="toolbar">
56+
{{#if uri}}
57+
{{! If we do not have an uri front matter, we might }}
58+
{{! not want edit buttons. Notice that we gotta }}
59+
{{! make sure the content pages always has an uri }}
60+
{{! front-matter. }}
5761
<div><a class="highlighted edit button" text="Edit" href="https://github.com/webplatform/docs/blob/master">Edit</a></div>
5862
<div class="dropdown"><a class="tools button">Tools</a>
5963
<ul>
60-
<li><a href="?action=history" rel="archives">History</a></li>
64+
<li><a data-pivot-trigger="history" href="?action=history" rel="archives">History</a></li>
6165
</ul>
6266
</div>
67+
{{/if}}
6368
</div>
6469
</div>
6570
<div id="page">
6671
<div id="page-content">
6772
<div id="main-content">
6873
<h1>{{title}}</h1>
74+
<section class="contents-pivot" data-pivot="contents">
6975
{{{ contents }}}
7076
{{>attributions}}
77+
</section>
78+
<section class="contents-pivot pivot-history" data-pivot="history" style="display:none" id="history">
79+
80+
</section>
7181
</div>
7282
<div class="topics-nav">
7383
<ul>
@@ -99,7 +109,6 @@
99109
</ul -->
100110
</div>
101111
</footer>
102-
<script src="/assets/js/dependencies.js" async defer></script>
103-
<script src="/assets/js/docs.js" async defer></script>
112+
<script src="/assets/js/docs.js"></script>
104113
</body>
105114
</html>

lib/handlebars/index.js

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,32 @@ module.exports = function () {
1010
'use strict';
1111
var md = new Remarkable();
1212

13-
Handlebars.registerHelper('markdown', function(options) {
14-
var text = md.render(options.fn(this));
15-
return new Handlebars.SafeString( text );
13+
Handlebars.registerHelper('markdown', function markdownRendererHelper (options) {
14+
var text = md.render(options.fn(this));
15+
return new Handlebars.SafeString(text);
16+
});
17+
18+
Handlebars.registerHelper('breadcrumbize', function breadcrumbizeHelper (options) {
19+
var fragments = options.fn(this).split('/')
20+
, subpath = '/'
21+
, out = '';
22+
23+
fragments.forEach(function(str, index, full){
24+
subpath += str + '/';
25+
out += '<li><a href="' + subpath + '">' + str + '</a></li>';
26+
});
27+
28+
return new Handlebars.SafeString(out);
29+
});
30+
31+
Handlebars.registerHelper('readiness_marker', function readinessHelper (options) {
32+
var label = options.fn(this)
33+
, className = label.replace(/\s/g, '_')
34+
, template = '<div class="readiness-state ' + className + '"><p>This page is <a>' + label + '</a></p></div>';
35+
36+
if ( label !== null ) {
37+
return new Handlebars.SafeString(template);
38+
}
1639
});
1740

1841
};

package.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,9 @@
2222
"serve": "node serve",
2323
"build": "node build"
2424
},
25-
"dependencies": {
25+
"devDependencies": {
26+
"bower": "*",
27+
"express": "^4.13.3",
2628
"handlebars": "^2.0",
2729
"remarkable": "^1.6.0",
2830
"highlight.js": "^8.8.0",
@@ -31,8 +33,5 @@
3133
"metalsmith-changed": "~0.2",
3234
"metalsmith-layouts": "~1.4",
3335
"metalsmith-markdown-remarkable": "^0.1.1"
34-
},
35-
"devDependencies": {
36-
"express": "^4.13.3"
3736
}
3837
}

partials/attributions.hbs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
1+
{{#if attributions}}
12
<h2>Attributions</h2>
23
<ul>
34
{{#attributions}}
45
<li>{{#markdown}}{{.}}{{/markdown}}</li>
56
{{/attributions}}
6-
</ul>
7+
</ul>
8+
{{else}}
9+
<!-- Attributions: None declared for this document. -->
10+
{{/if}}

partials/breadcrumb.hbs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
<ol id="breadcrumb-info" class="breadcrumbs">
2+
<li><a href="/">DOCS</a></li>
3+
{{#if uri}}
4+
{{#breadcrumbize}}{{uri}}{{/breadcrumbize}}
5+
{{/if}}
6+
</ol>

partials/metadata.hbs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,3 @@
11
{{#readiness}}<meta name="readiness" content="{{.}}" />{{/readiness}}
22
{{#standardization_status}}<meta name="standardization" content="{{.}}" />{{/standardization_status}}
33
{{#summary}}<meta name="description" content="{{.}}" />{{/summary}}
4-
{{#each attributions}}
5-
<meta name="attribution" content="{{.}}" />
6-
{{/each}}

0 commit comments

Comments
 (0)