Skip to content

Commit 5ee44e2

Browse files
Using bootstrap menu and autogenerated Table of contents like at SeLite.github.io.
1 parent 986b80f commit 5ee44e2

File tree

9 files changed

+271
-7
lines changed

9 files changed

+271
-7
lines changed

.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
nbproject
2+
_site
3+
Gemfile.lock

404.md

+25
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
---
2+
layout: default
3+
permalink: /404.html
4+
---
5+
* TOC
6+
{:toc}
7+
8+
<style type="text/css">
9+
#toc-in-contents .divider {
10+
height: 0;
11+
margin: 9px 0;
12+
overflow: hidden;
13+
}
14+
</style>
15+
16+
<script type="text/javascript">
17+
if( !/^\/404(\.md)?/.test( location.pathname ) ) {
18+
document.write( "Given address " +location.href+ " doesn't exist. Please, locate a page below." );
19+
}
20+
</script>
21+
22+
{% comment %}The following element can't be a span, but it must be a div. Otherwise Jekyll autogenerated a closing tag for it.{% endcomment %}
23+
<div id="toc-in-contents">
24+
{% include toc.md %}
25+
</div>

CustomizingHtmlOutput.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
---
22
layout: default
33
---
4+
* TOC
5+
{:toc}
46

5-
# Html Presentation
7+
# HTML Presentation
68

79
By default Daisy Diff is using the [Dojo Toolkit](http://www.dojotoolkit.org/) for presentation of the html output. This offers annotation tooltips on the result that allow the user to move back and forth between differences.
810

Development.md

+2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
---
22
layout: default
33
---
4+
* TOC
5+
{:toc}
46

57
# Installing
68
* Clone (or download) from our GitHub [repository](https://github.com/DaisyDiff/DaisyDiff).

Examples.md

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
---
22
layout: default
33
---
4+
* TOC
5+
{:toc}
46

5-
BBC News example
7+
# BBC News example
68

79
This example uses the BBC news archive site to compare the news page at different times on a given day. The page can load slowly due to the slow servers at archive.org. The page layout is somewhat shifted in the example because the page is not hosted on the BBC servers.
810
Result

Papers.md

+4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
---
22
layout: default
33
---
4+
* TOC
5+
{:toc}
6+
7+
# Papers
48

59
* [http://pages.cs.wisc.edu/~yuanwang/papers/xdiff.pdf](http://pages.cs.wisc.edu/~yuanwang/papers/xdiff.pdf)
610
* [https://sourceforge.net/projects/diffxml/files/documentation/1.0/dissertation.ps/download](https://sourceforge.net/projects/diffxml/files/documentation/1.0/dissertation.ps/download)

_includes/toc.md

+40
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
{% comment %}
2+
This page doesn't have YAML Front Matter block (which would be between ---- and ----). Otherwise, such YAML would show up as page content this when file is included from _layouts/default.md.
3+
This page has to be .md rather than .html, so that we can use it with Markdown Viewer add-on (see https://selite.github.io/DocumentationStandard). Only when it's an .md file, Markdown Viewer automatically changes the local links that don't contain .md extension to contain .md extension. (Otherwise the referenced files won't open locally in Firefox.)
4+
5+
To test links from this webpage with Markdown Viewer on Linux/Mac OS, create a symlink to this file from a folder above.
6+
-->
7+
{% endcomment %}
8+
{% if include.asBootstrapMenu %}
9+
{% assign topLiClass = 'class="dropdown"' %}
10+
{% assign luClass = 'class="dropdown-menu"' %}
11+
{% assign caret = '<span class="caret"></span>' %}
12+
{% assign menuOpener= '<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-expanded="false"' %}
13+
{% assign menuCloser= '</a>' %}
14+
{% else %}
15+
{% assign topLiClass = '' %}
16+
{% assign luClass = '' %}
17+
{% assign caret = '' %}
18+
{% assign menuOpener= '<span' %}
19+
{% assign menuCloser= '</span>' %}
20+
{% endif %}
21+
<li {{ topLiClass }}>
22+
{{ menuOpener }} data-group-page-names="./ Examples">DaisyDiff{{ caret }}{{ menuCloser }}
23+
<ul {{ luClass }} role="menu">
24+
<li><a href="./">Overview</a></li>
25+
<li><a href="Examples">Examples</a></li>
26+
<li><a href="Papers">Papers</a></li>
27+
{% comment %}
28+
If you'd like a separator between menu items, or a submenu-like header, use:
29+
<li class="divider"></li>
30+
<li class="dropdown-header">Internal:</li>
31+
{% endcomment %}
32+
</ul>
33+
</li>
34+
<li {{ topLiClass }}>
35+
{{ menuOpener }} data-group-page-names="Development CustomizingHtmlOutput">Development{{ caret }}{{ menuCloser }}
36+
<ul {{ luClass }} role="menu">
37+
<li><a href="Development">Development</a></li>
38+
<li><a href="CustomizingHtmlOutput">CustomizingHtmlOutput</a></li>
39+
</ul>
40+
</li>

_layouts/default.md

+185-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,185 @@
1-
{{ content }}
1+
<!doctype html>
2+
<html xml:lang="en" lang="en">
3+
<head>
4+
<meta charset="utf-8">
5+
<meta http-equiv="X-UA-Compatible" content="IE=edge">
6+
<meta name="viewport" content="width=device-width, initial-scale=1">
7+
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
8+
<!-- Based on http://stackoverflow.com/questions/2268204/favicon-dimensions: 32x32 is the last icon, since Firefox uses the last one. IE requires that I convert .bmp to .ico - it's not enough to rename it, otherwise it won't show up in IE tab. So I used http://image.online-convert.com/convert-to-ico -->
9+
<link rel="icon" type="image/png" href="favicon-16x16.png" sizes="16x16">
10+
<link rel="icon" type="image/png" href="favicon-64x64.png" sizes="64x64">
11+
<link rel="icon" type="image/png" href="favicon-32x32.png" sizes="32x32">
12+
{% comment %} For highlighting the current menu & current menu item in Bootstrap menu.
13+
page.url ends with .html (whether on GitHub and in Jekyll), so I treat it.
14+
The following has to be in three expressions, rather than in one complex expression - otherwise it failed.
15+
{% endcomment %}
16+
{% if page.rss != null %}
17+
<link rel="alternate" type="application/rss+xml" title="RSS feed" href="{{ page.rss }}"/>
18+
{% else %}
19+
<link href="https://github.com/daisydiff/daisydiff.github.io/commits/master.atom" rel="alternate" title="DaisyDiff Documentation updates" type="application/atom+xml">
20+
{% endif %}
21+
{% assign pageNameParts = (page.url | split: '/') %}
22+
{% assign pageNamePartsWithoutSlash = (pageNameParts[1] | split: '.html') %}
23+
24+
{% assign pageName= pageNamePartsWithoutSlash[0] %}
25+
{% assign pageNameInTitleBar= pageName %}
26+
27+
{% comment %} For some reason, pageName=="index" didn't evaluate to true. TODO report {% endcomment %}
28+
{% if pageName == null or pageName contains "index" and "index" contains pageName %}
29+
{% assign pageName = './' %}
30+
{% assign pageNameInTitleBar= 'Overview' %}
31+
{% endif %}
32+
{% capture pageNameInTitleBar %}{{pageNameInTitleBar}}{% if page.title != null %} {{ page.title }}{% endif %}{% endcapture %}
33+
<title>DaisyDiff > {{pageNameInTitleBar}}</title>
34+
<!-- Latest compiled and minified CSS -->
35+
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap.min.css">
36+
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/css/bootstrap-theme.min.css">
37+
<style type="text/css">
38+
/* Based on http://getbootstrap.com/css/#grid-media-queries - @screen-sm-min */
39+
@media (max-width: 767px) {
40+
#toc-desktop-button {display: none;}
41+
}
42+
@media (min-width: 768px) {
43+
#toc-mobile-button {display: none;}
44+
/* Mobiles browsers don't show favicon and title when scrolling down, so let's show both in Bootstrap toolbar (i.e. shown even when Bootstrap menu is vertically collapsed). However, desktop browsers show favicon and title most of the time; also, we don't want favicon and the title in Bootstrap toolbar on desktops, since then there's less space for the menu to show horizontally, which causes the menu to be split across two lines. */
45+
#toc-mobile-title {display: none;}
46+
}
47+
ul.nav > li > a {
48+
padding-left: 2px;
49+
padding-right: 2px;
50+
}
51+
.dropdown-menu[data-placement="left"] {
52+
left: auto;
53+
right: 0px;
54+
}
55+
/* Following, and the respective data-placement="left" in _includes/toc.md, is from https://github.com/twbs/bootstrap/issues/1411 */
56+
.navbar .nav>li>.dropdown-menu[data-placement="left"]:before {
57+
left: auto;
58+
right: 9px;
59+
}
60+
61+
.navbar .nav > li > .dropdown-menu[data-placement="left"]:after {
62+
left: auto;
63+
right: 10px;
64+
}
65+
66+
#markdown-toc-mobile, #markdown-toc-desktop {
67+
/* From bootstrap.min.css */
68+
border: 1px solid rgba(0, 0, 0, 0.15);
69+
box-shadow: 0 6px 12px rgba(0, 0, 0, 0.176);
70+
}
71+
72+
/* Following rules use specific selectors, so that they override bootstrap.min.css. */
73+
/* Highlight the menu that contains a link to the current page. This has to use custom data-child-urls, since there's no way to make a CSS selector depend on the next element(s) - e.g. the following didn't work:
74+
.dropdown-menu > li > a[href^="{{ pageName }}"] ::before ul a {color: green;}
75+
*/
76+
.navbar-default .navbar-nav > li a[data-group-page-names~="{{ pageName }}"] {color: green;}
77+
78+
/* Highlight the menu item that is the current page. The selector is complex, so that it overrides a rule from bootstrap.min.css when in mobile mode */
79+
.navbar-default .navbar-nav .open ul.dropdown-menu > li > a[href="{{ pageName }}"] {color: green;}
80+
/* Only until Jekyll 3 is common. TODO remove then: */
81+
.navbar-default .navbar-nav .open ul.dropdown-menu > li > a[href="{{ pageName }}.html"] {color: green;}
82+
83+
/* Override bootstrap.min.css: */
84+
* code { color: black; }
85+
86+
#navbar-menu .navbar-nav > li > a {
87+
padding-bottom: 2px;
88+
padding-top: 2px;
89+
}
90+
body .navbar {
91+
margin-bottom: 2px;
92+
min-height: 18px;
93+
}
94+
p#toc-mobile-title.navbar-text {
95+
padding: 0px;
96+
margin-top: 0px;
97+
margin-bottom: 0px;
98+
}
99+
.navbar
100+
{
101+
height:unset !important;
102+
}
103+
.navbar-header
104+
{
105+
min-height:16px !important;
106+
}
107+
button.navbar-toggle {
108+
padding: 0px;
109+
margin-top: 0px;
110+
margin-bottom: 0px;
111+
}
112+
</style>
113+
<script type="text/javascript">
114+
// Based on https://github.com/twbs/bootstrap/issues/1768:
115+
function shiftWindow() {
116+
scrollBy( 0, -1*$("#whole-navbar").height() );
117+
}
118+
window.addEventListener("hashchange", shiftWindow);
119+
120+
function load() {
121+
$('body').css( "padding-top", $("#whole-navbar").height() );
122+
if (window.location.hash) {
123+
shiftWindow();
124+
}
125+
$( '#markdown-toc' ).appendTo( '#toc-mobile-div' );
126+
$( '#markdown-toc' ).clone().appendTo( '#toc-desktop-div' );
127+
128+
// After clicking at a link from toc.md, collapse the whole expanded menu (on mobile) or collapse TOC (on desktop)
129+
$( "#toc-mobile-div a" ).click(
130+
function() {
131+
$("#navbar-menu").toggleClass("in");
132+
}
133+
);
134+
$( "#toc-desktop-div a" ).click(
135+
function() {
136+
$("#toc-desktop-div").toggleClass("in");
137+
}
138+
);
139+
}
140+
141+
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
142+
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
143+
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
144+
})(window,document,'script','https://www.google-analytics.com/analytics.js','ga');
145+
ga('create', 'UA-62560081-1', 'auto');
146+
ga('send', 'pageview');
147+
</script>
148+
</head>
149+
<body onload="load()">
150+
<!-- Based on http://getbootstrap.com/examples/navbar-fixed-top/ -->
151+
<nav class="navbar navbar-default navbar-fixed-top">
152+
<div class="container-fluid" id="whole-navbar">
153+
<!-- Brand and toggle get grouped for better mobile display -->
154+
<div class="navbar-header">
155+
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar-menu">
156+
<span class="sr-only">Toggle navigation</span>
157+
<span class="icon-bar"></span>
158+
<span class="icon-bar"></span>
159+
<span class="icon-bar"></span>
160+
</button>
161+
<p class="navbar-text" id="toc-mobile-title" data-toggle="collapse" data-target="#navbar-menu"><img alt="DaisyDiff logo" src="favicon-16x16.png" width="16" height="16"/> {{ pageNameInTitleBar }}</p>
162+
</div>
163+
164+
<!-- Collect the nav links, forms, and other content for toggling -->
165+
<div class="collapse navbar-collapse" id="navbar-menu">
166+
<ul class="nav navbar-nav">
167+
<li id="toc-mobile-button"><a data-toggle="collapse" href="#toc-mobile-div" class="dropdown-toggle" role="button"><em>This page</em><span class="caret"></span></a>
168+
<div id="toc-mobile-div" class="collapse">
169+
</div>
170+
</li>
171+
<li id="toc-desktop-button"><a data-toggle="collapse" href="#toc-desktop-div" class="dropdown-toggle" role="button"><em>This page</em><span class="caret"></span></a>
172+
</li>
173+
{% include toc.md asBootstrapMenu="true" %}
174+
</ul>
175+
</div><!-- /.navbar-collapse -->
176+
<div id="toc-desktop-div" class="collapse">
177+
</div>
178+
</div><!-- /.container-fluid -->
179+
</nav>
180+
{{ content }}
181+
<!-- Based on http://getbootstrap.com/components/#navbar -->
182+
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
183+
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.6/js/bootstrap.min.js"></script>
184+
</body>
185+
</html>

index.md

+6-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
---
22
layout: default
33
---
4+
* TOC
5+
{:toc}
46

57
# What Daisy Diff offers
68

@@ -10,7 +12,7 @@ For example assume that a user has changed a single word in a big paragraph. Mos
1012

1113
DaisyDiff is also used in production (Daisy CMS) and also comes with a business friendly licence.
1214

13-
* [CustomizingHtmlOutput](CustomizingHtmlOutput)
14-
* [Development](Development)
15-
* [Examples](Examples)
16-
* [Papers](Papers)
15+
# Alternatives
16+
17+
* [PrettyDiff](http://prettydiff.com/samples.xhtml)
18+
* [HTML diff](https://www.drupal.org/node/372957) in Drupal

0 commit comments

Comments
 (0)