-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Etienne Gandrille
committed
Oct 20, 2018
1 parent
5ccba7e
commit 6be70aa
Showing
4 changed files
with
450 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,99 @@ | ||
[% SET indexTitle = "Bienvenue !" %] | ||
[% SET indexTitle = title %] | ||
|
||
[% SET indexMessage = "<p>Vous trouverez ici quelques notes personelles à propos de mon installation Linux. Il s'agit pour moi d'un aide mémoire, facilement accessible quel que soit l'ordinateur à partir duquel je me connecte.</p><p>Ces notes ne sont en aucun cas des cours et encore moins une documentation de référence !</p>" %] | ||
[% SET indexMessage = "" %] | ||
|
||
[% options.empty_lines = "remove" %] | ||
[% options.line_breaks = "default" %] | ||
|
||
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> | ||
<html> | ||
<head> | ||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"> | ||
<title>[% title %]</title> | ||
<meta name="generator" content="[% generator.name %]"> | ||
<meta name="viewport" content="width=device-width"> | ||
<link rel="stylesheet" href="[% resource('style.css') %]" type="text/css"/> | ||
</head> | ||
<body> | ||
<div class="wrapper"> | ||
<div id="navigation"> | ||
[% index() %] | ||
</div> | ||
<div id="content"> | ||
[% FOR page IN pages %] | ||
|
||
[% IF links.get("index") %] | ||
[% SET idx = links.get("index") %] | ||
[% IF idx.name == page.name %] | ||
[% SET isIndex = 'true' %] | ||
[% ELSE %] | ||
[% SET isIndex = 'false' %] | ||
[% END %] | ||
[% ELSE %] | ||
[% SET isIndex = 'false' %] | ||
[% END %] | ||
|
||
[% IF isIndex == 'true' %] | ||
<h1>[% indexTitle %] <a name='[% anchor(page) %]'></a></h1> | ||
<p>[% indexMessage %]</p> | ||
[% ELSE %] | ||
<h1>[% page.title %] <a name='[% anchor(page) %]'></a></h1> | ||
<div id="toc"> | ||
<div class="toctitle">Contents</div> | ||
<ul id="tocdata"></ul> | ||
</div> | ||
[% END %] | ||
|
||
[% page.body %] | ||
|
||
<div class="footblock"> | ||
[% FOR file IN page.attachments %] | ||
[% IF loop.first %] | ||
<hr class='footrule'> | ||
<b>Attachments</b> | ||
<ul> | ||
[% END %] | ||
<li><a href="[% uri(file) %]">[% file.basename %] ([% file.size %])</a></li> | ||
[% IF loop.last %] | ||
</ul> | ||
[% END %] | ||
[% END %] | ||
</div> | ||
<div class="footblock"> | ||
[% FOR link IN page.backlinks %] | ||
[% IF loop.first %] | ||
<hr class='footrule'> | ||
<b>Backlinks:</b> | ||
[% END %] | ||
<a href='[% uri(link) %]'>[% link.name %]</a> | ||
[% IF not loop.last %], [% END %] | ||
[% END %] | ||
</div> | ||
[% IF not loop.last %]<hr class='pageseparator'/>[% END %] | ||
[% END %] | ||
</div> | ||
<div id="credits"> | ||
<p>Proudly Powered by <a href="http://zim-wiki.org">[% generator.name %]</a>.</p> | ||
<p>Template by <a href="https://github.com/gandrille/zim-simple-web-template">Etienne Gandrille</a>, based on <a href="https://github.com/jaap-karssenberg/zim-desktop-wiki/blob/master/data/templates/html/ZeroFiveEight.html">ZeroFiveEight</a> and using <a href="https://ndabas.github.io/toc/">JQuery Toc Plugin</a>.</p> | ||
</div> | ||
</div> | ||
|
||
<script src="[% resource('jquery-1.12.4.min.js') %]" type="text/javascript"></script> | ||
<script src="[% resource('jquery-toc-0.4.0.js') %]" type="text/javascript"></script> | ||
|
||
<script type="text/javascript"> | ||
if ($("h2").length != 0) | ||
$("#tocdata").toc({content: "div#content", headings: "h2,h3,h4"}); | ||
else | ||
$("#toc").hide(); | ||
[% IF links.get("index") %] | ||
$("#navigation").children("ul").prepend("<li class='index-item'><a href='[% uri(links.get("index")) %]'>[% gettext("Index") %]</a></li>"); | ||
[% END %] | ||
</script> | ||
|
||
</body> | ||
</html> | ||
|
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
/* | ||
* Table of Contents jQuery Plugin - jquery.toc | ||
* | ||
* Copyright 2013-2016 Nikhil Dabas | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except | ||
* in compliance with the License. You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software distributed under the License | ||
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express | ||
* or implied. See the License for the specific language governing permissions and limitations | ||
* under the License. | ||
*/ | ||
|
||
(function ($) { | ||
"use strict"; | ||
|
||
// Builds a list with the table of contents in the current selector. | ||
// options: | ||
// content: where to look for headings | ||
// headings: string with a comma-separated list of selectors to be used as headings, ordered | ||
// by their relative hierarchy level | ||
var toc = function (options) { | ||
return this.each(function () { | ||
var root = $(this), | ||
data = root.data(), | ||
thisOptions, | ||
stack = [root], // The upside-down stack keeps track of list elements | ||
listTag = this.tagName, | ||
currentLevel = 0, | ||
headingSelectors; | ||
|
||
// Defaults: plugin parameters override data attributes, which override our defaults | ||
thisOptions = $.extend( | ||
{content: "body", headings: "h1,h2,h3"}, | ||
{content: data.toc || undefined, headings: data.tocHeadings || undefined}, | ||
options | ||
); | ||
headingSelectors = thisOptions.headings.split(","); | ||
|
||
// Set up some automatic IDs if we do not already have them | ||
$(thisOptions.content).find(thisOptions.headings).attr("id", function (index, attr) { | ||
// In HTML5, the id attribute must be at least one character long and must not | ||
// contain any space characters. | ||
// | ||
// We just use the HTML5 spec now because all browsers work fine with it. | ||
// https://mathiasbynens.be/notes/html5-id-class | ||
var generateUniqueId = function (text) { | ||
// Generate a valid ID. Spaces are replaced with underscores. We also check if | ||
// the ID already exists in the document. If so, we append "_1", "_2", etc. | ||
// until we find an unused ID. | ||
|
||
if (text.length === 0) { | ||
text = "?"; | ||
} | ||
|
||
var baseId = text.replace(/\s+/g, "_"), suffix = "", count = 1; | ||
|
||
while (document.getElementById(baseId + suffix) !== null) { | ||
suffix = "_" + count++; | ||
} | ||
|
||
return baseId + suffix; | ||
}; | ||
|
||
return attr || generateUniqueId($(this).text()); | ||
}).each(function () { | ||
// What level is the current heading? | ||
var elem = $(this), level = $.map(headingSelectors, function (selector, index) { | ||
return elem.is(selector) ? index : undefined; | ||
})[0]; | ||
|
||
if (level > currentLevel) { | ||
// If the heading is at a deeper level than where we are, start a new nested | ||
// list, but only if we already have some list items in the parent. If we do | ||
// not, that means that we're skipping levels, so we can just add new list items | ||
// at the current level. | ||
// In the upside-down stack, unshift = push, and stack[0] = the top. | ||
var parentItem = stack[0].children("li:last")[0]; | ||
if (parentItem) { | ||
stack.unshift($("<" + listTag + "/>").appendTo(parentItem)); | ||
} | ||
} else { | ||
// Truncate the stack to the current level by chopping off the 'top' of the | ||
// stack. We also need to preserve at least one element in the stack - that is | ||
// the containing element. | ||
stack.splice(0, Math.min(currentLevel - level, Math.max(stack.length - 1, 0))); | ||
} | ||
|
||
// Add the list item | ||
$("<li/>").appendTo(stack[0]).append( | ||
$("<a/>").text(elem.text()).attr("href", "#" + elem.attr("id")) | ||
); | ||
|
||
currentLevel = level; | ||
}); | ||
}); | ||
}, old = $.fn.toc; | ||
|
||
$.fn.toc = toc; | ||
|
||
$.fn.toc.noConflict = function () { | ||
$.fn.toc = old; | ||
return this; | ||
}; | ||
|
||
// Data API | ||
$(function () { | ||
toc.call($("[data-toc]")); | ||
}); | ||
}(window.jQuery)); |
Oops, something went wrong.