Skip to content

Commit 0ed6179

Browse files
committed
Add JS generated TOC to each page
1 parent 00f6f86 commit 0ed6179

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+181
-66
lines changed

_includes/base-scripts

+2
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
<script src="{{"/assets/js/browser.min.js" | relative_url}}"></script>
44
<script src="{{"/assets/js/breakpoints.min.js" | relative_url}}"></script>
55
<script src="{{"/assets/js/util.js" | relative_url}}"></script>
6+
<script src="{{"/assets/js/jquery.toc.js" | relative_url}}"></script>
67
<script src="{{"/assets/js/main.js" | relative_url}}"></script>
78
<script src="{{"/assets/js/ham_nav.js" | relative_url}}"></script>
89
<script src="{{"/assets/js/lightbox.min.js" | relative_url}}"></script>
10+

_layouts/page.html

+3
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,9 @@ <h1><strong>{{page.title}}</strong></h1>
2828
<div class="box alt"></div>
2929
<!-- Page content -->
3030
<div id="content" class="page-content">
31+
<div class="toc">
32+
<ol data-toc="#content" data-toc-headings="h1,h2,h3,h4,h5,h6"></ol>
33+
</div>
3134
{{content}}
3235
</div>
3336
</div>

assets/css/debo.css

+36
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,40 @@ a.thumbnail:hover {
2424

2525
.bc {
2626
font-style: italic;
27+
}
28+
29+
#info-box {
30+
float: right;
31+
min-width: 500px;
32+
}
33+
34+
.toc {
35+
margin-right: 40px;
36+
max-width: 500px;
37+
margin-bottom: 20px;
38+
float: left;
39+
}
40+
41+
.toc ol {
42+
margin: 0;
43+
padding-left: 1.4em;
44+
border-left: 1px solid black;
45+
}
46+
47+
.toc > ol {
48+
background: #f1f1f4;
49+
border: none;
50+
padding: 20px 40px 20px 40px;
51+
}
52+
53+
.toc a {
54+
color: black;
55+
}
56+
57+
.toc ol li {
58+
margin-bottom: 0px;
59+
}
60+
61+
.page-content h1, h2 {
62+
clear: left;
2763
}

assets/js/jquery.toc.js

+113
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
/*
2+
* Table of Contents jQuery Plugin - jquery.toc
3+
*
4+
* Copyright 2013-2016 Nikhil Dabas
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
7+
* in compliance with the License. You may obtain a copy of the License at
8+
*
9+
* http://www.apache.org/licenses/LICENSE-2.0
10+
*
11+
* Unless required by applicable law or agreed to in writing, software distributed under the License
12+
* is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
13+
* or implied. See the License for the specific language governing permissions and limitations
14+
* under the License.
15+
*/
16+
17+
(function ($) {
18+
"use strict";
19+
20+
// Builds a list with the table of contents in the current selector.
21+
// options:
22+
// content: where to look for headings
23+
// headings: string with a comma-separated list of selectors to be used as headings, ordered
24+
// by their relative hierarchy level
25+
var toc = function (options) {
26+
return this.each(function () {
27+
var root = $(this),
28+
data = root.data(),
29+
thisOptions,
30+
stack = [root], // The upside-down stack keeps track of list elements
31+
listTag = this.tagName,
32+
currentLevel = 0,
33+
headingSelectors;
34+
35+
// Defaults: plugin parameters override data attributes, which override our defaults
36+
thisOptions = $.extend(
37+
{content: "body", headings: "h1,h2,h3"},
38+
{content: data.toc || undefined, headings: data.tocHeadings || undefined},
39+
options
40+
);
41+
headingSelectors = thisOptions.headings.split(",");
42+
43+
// Set up some automatic IDs if we do not already have them
44+
$(thisOptions.content).find(thisOptions.headings).attr("id", function (index, attr) {
45+
// In HTML5, the id attribute must be at least one character long and must not
46+
// contain any space characters.
47+
//
48+
// We just use the HTML5 spec now because all browsers work fine with it.
49+
// https://mathiasbynens.be/notes/html5-id-class
50+
var generateUniqueId = function (text) {
51+
// Generate a valid ID. Spaces are replaced with underscores. We also check if
52+
// the ID already exists in the document. If so, we append "_1", "_2", etc.
53+
// until we find an unused ID.
54+
55+
if (text.length === 0) {
56+
text = "?";
57+
}
58+
59+
var baseId = text.replace(/\s+/g, "_"), suffix = "", count = 1;
60+
61+
while (document.getElementById(baseId + suffix) !== null) {
62+
suffix = "_" + count++;
63+
}
64+
65+
return baseId + suffix;
66+
};
67+
68+
return attr || generateUniqueId($(this).text());
69+
}).each(function () {
70+
// What level is the current heading?
71+
var elem = $(this), level = $.map(headingSelectors, function (selector, index) {
72+
return elem.is(selector) ? index : undefined;
73+
})[0];
74+
75+
if (level > currentLevel) {
76+
// If the heading is at a deeper level than where we are, start a new nested
77+
// list, but only if we already have some list items in the parent. If we do
78+
// not, that means that we're skipping levels, so we can just add new list items
79+
// at the current level.
80+
// In the upside-down stack, unshift = push, and stack[0] = the top.
81+
var parentItem = stack[0].children("li:last")[0];
82+
if (parentItem) {
83+
stack.unshift($("<" + listTag + "/>").appendTo(parentItem));
84+
}
85+
} else {
86+
// Truncate the stack to the current level by chopping off the 'top' of the
87+
// stack. We also need to preserve at least one element in the stack - that is
88+
// the containing element.
89+
stack.splice(0, Math.min(currentLevel - level, Math.max(stack.length - 1, 0)));
90+
}
91+
92+
// Add the list item
93+
$("<li/>").appendTo(stack[0]).append(
94+
$("<a/>").text(elem.text()).attr("href", "#" + elem.attr("id"))
95+
);
96+
97+
currentLevel = level;
98+
});
99+
});
100+
}, old = $.fn.toc;
101+
102+
$.fn.toc = toc;
103+
104+
$.fn.toc.noConflict = function () {
105+
$.fn.toc = old;
106+
return this;
107+
};
108+
109+
// Data API
110+
$(function () {
111+
toc.call($("[data-toc]"));
112+
});
113+
}(window.jQuery));

assets/js/main.js

+5
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,9 @@
2929
// Scrolly.
3030
$('.scrolly').scrolly();
3131

32+
// remove TOC if few headings exist
33+
if($('#content h1, #content h2').length < 3) {
34+
$('.toc').remove();
35+
}
36+
3237
})(jQuery);

convert/ij_mw_preprocess_debo.py

+4
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,10 @@ def process_file(str_content):
117117
# perform regex replacements
118118
content_tmp = str_content
119119

120+
content_tmp = re.sub(r'\_\_FORCETOC\_\_[ ]?', r'', content_tmp)
121+
content_tmp = re.sub(r'\_\_TOC\_\_[ ]?', r'', content_tmp)
122+
content_tmp = re.sub(r'\_\_NOTOC\_\_[ ]?', r'', content_tmp)
123+
120124
# fix youtube template
121125
content_tmp = re.sub(r'\{\{[\\]?\#widget\:YouTube\|id\=([^ \|]*)[^\}]*\}\}',
122126
youtube_match, content_tmp)

pages/2015-12-22_-_The_road_to_Java_8.md

-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ description: test description
1010

1111
<div style="float: right; padding-left: 1em">
1212

13-
\_\_TOC\_\_
14-
1513
</div>
1614

1715
For {% include github org='imagej ' repo='imagej ' issue='135 ' label='many reasons ' %}, ImageJ needs to switch to Java 8. Hence, in recent months, the ImageJ team at [LOCI](LOCI "wikilink") has been [taking steps toward migrating ImageJ and Fiji toward Java 8](2015-06-15_-_Major_updates_in_the_works "wikilink"). This week marks a significant milestone in that effort:

pages/2016-05-10_-_ImageJ_HOWTO_-_Java_8,_Java_6,_Java_3D.md

-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ description: test description
1212

1313
However, at the moment, it is still possible to run a (slightly outdated now) version of [Fiji](Fiji "wikilink") with Java 6.
1414

15-
\_\_TOC\_\_
16-
1715
## Current recommendations and possibilities
1816

1917
<table>

pages/3Dscript.md

-2
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ In 3Dscript, animations are defined by a syntax based on natural English languag
3030

3131
![3Dscript-wiki-01.jpg](/images/pages/3Dscript-wiki-01.jpg "3Dscript-wiki-01.jpg")
3232

33-
\_\_TOC\_\_
34-
3533
## Publication
3634

3735
- {% include publication content='3Dscript' %}

pages/Annotating_Images.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ categories: Cookbook,Tutorials
88
description: test description
99
---
1010

11-
\_\_FORCETOC\_\_ {% include menu-cookbook%}
11+
{% include menu-cookbook%}
1212

1313

1414
## Scale bar

pages/BigDataServerDraft.md

-2
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,6 @@ description: test description
2222
{% endcapture %}
2323
{% include info-box name='BigDataServer ' software='Fiji ' author=author maintainer=maintainer source=source latest-version='1.0.5 ' status='experimental ' category='[Visualization](_Category_Visualization "wikilink"), [Transform](_Category_Transform "wikilink") ' %}
2424

25-
\_\_TOC\_\_
26-
2725
## Description
2826

2927
BigDataServer is a minimalistic HTTP server that serves XML/HDF5 datasets to the [BigDataViewer](BigDataViewer "wikilink") Fiji plugin for visualisation.

pages/CIP.md

-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ categories:
88
description: test description
99
---
1010

11-
\_\_TOC\_\_
12-
1311
{% include info-box software='ImageJ/Fiji ' name='CIP ' update-site='CIP ' author='[Benoit Lombardot](User_Benoit "wikilink") ' maintainer='[Benoit Lombardot](User_Benoit "wikilink") ' released='January 2018 ' filename='CIP update site ' source='https://github.com/benoalo/CIP ' category='[Scripting](_Category_Scripting "wikilink") ' %}
1412

1513
![CIP: ](/images/pages/CIP basic concept.PNG "CIP: ")

pages/CIP_Format.md

-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ categories:
88
description: test description
99
---
1010

11-
\_\_TOC\_\_
12-
1311
This page provides user documentation for the Format category of the [CIP](CIP "wikilink") scripting package.
1412

1513
{% include cip content='Navigation' %}

pages/CIP_Math.md

-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ categories:
88
description: test description
99
---
1010

11-
\_\_TOC\_\_
12-
1311
This page provides user documentation for the Math category of the [CIP](CIP "wikilink") scripting package
1412

1513
{% include cip content='Navigation' %}

pages/CIP_Segmentation.md

-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ categories:
88
description: test description
99
---
1010

11-
\_\_TOC\_\_
12-
1311
This page describes the segmentation function of the [CIP scripting](CIP "wikilink") package
1412

1513
{% include cip content='Navigation' %}

pages/CIP_Utilities.md

-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ categories:
88
description: test description
99
---
1010

11-
\_\_TOC\_\_
12-
1311
This page provides user documentation for the utility functions of the [CIP](CIP "wikilink") package
1412

1513
{% include cip content='Navigation' %}

pages/Color_Image_Processing.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ categories: Cookbook,Tutorials
88
description: test description
99
---
1010

11-
\_\_FORCETOC\_\_ {% include menu-cookbook%}
11+
{% include menu-cookbook%}
1212

1313

1414
## Types of color images

pages/Developing_Plugins_for_ImageJ_1.x.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ description: test description
1010

1111
{% include imagej1 content='This page explains how to develop plugins with the ImageJ 1.x API. If you start developing a new plugin today, it is highly recommended to [develop for ImageJ2](Writing_plugins "wikilink").' %}
1212

13-
\_\_FORCETOC\_\_ {% include develop-menu content='tutorials' %}{% include project content='ImageJ1 | describes content related to' %}
13+
{% include develop-menu content='tutorials' %}{% include project content='ImageJ1 | describes content related to' %}
1414

1515
# Plugin, script or macro?
1616

pages/Diadem_Challenge_Data.md

-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ This page describes how to visualize the various data sets provided as part of t
1212

1313
If you have any comments or suggestions relating to this page, please email <em>mark-diadem</em> at <em>longair</em> dot <em>net</em>.
1414

15-
\_\_TOC\_\_
16-
1715
## Olfactory Project Neurons
1816

1917
This data set [is described here](http://www.diademchallenge.org/olfactory_projection_fibers_readme.html). I will go through loading the example "OP\_1". Each image stack in this data set is distributed as a directory of TIFF files, one per slice. To load such a stack, go to {% include bc content='File | Import | Image Sequence'%} and select the file "1.tif". You should be shown a dialog like this:

pages/Docker.md

-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ categories: Docker
88
description: test description
99
---
1010

11-
\_\_TOC\_\_
12-
1311
[Docker](https://www.docker.com/whatisdocker/) provides a platform for distribution of application state. This facilitates the highest level of scientific [reproducibility](reproducibility "wikilink") - as a Docker image can bundle operating system, Java version, update site and plugin state, and even sample data. These images can then be reused by remote users and scientists worldwide, with no dependency concerns (beyond Docker itself).
1412

1513
# Pre-Requisites

pages/Fiji%2FDownloads.md

-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ description: test description
1010

1111
<div style="float: right">
1212

13-
\_\_TOC\_\_
14-
1513
</div>
1614

1715
{% include project content='Fiji' %}

pages/FilamentDetector.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ description: test description
2020
{% capture source%}
2121
{% include github org='hadim ' repo='FilamentDetector ' %}
2222
{% endcapture %}
23-
{% include info-box name='FilamentDetector ' logo=' ' software='Fiji ' author=author maintainer=maintainer source=source released='13/10/2017 ' status='v0.1.1, alpha ' category='Tracking, Detection ' %} \_\_TOC\_\_
23+
{% include info-box name='FilamentDetector ' logo=' ' software='Fiji ' author=author maintainer=maintainer source=source released='13/10/2017 ' status='v0.1.1, alpha ' category='Tracking, Detection ' %}
2424

2525
## Presentation
2626

pages/Getting_started_with_MaMuT.md

-2
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,6 @@ If you find MaMuT useful for your research, please cite it:
1616

1717
{% include publication content='MaMuT' %}
1818

19-
\_\_TOC\_\_
20-
2119
## Installation.
2220

2321
MaMuT is a Fiji plugin that depends on its components to run. Download Fiji from [its website](https://fiji.sc/#download) if you do not have it already.

pages/How_to_contribute_to_an_existing_plugin_or_library.md

-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ description: test description
1414

1515
<div style="float: left; padding-right: 1em">
1616

17-
\_\_TOC\_\_
18-
1917
</div>
2018

2119
{% include develop-menu content='tutorials' %}== Introduction == Sometimes you may want to contribute to an already existing ImageJ plugin or library. For example, a bug is found in one plugin and you want to fix it, or you would like to improve one library by adding more functions. This tutorial describes step by step how to do it with a practical case.

pages/Image_Intensity_Processing.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ categories: Cookbook,Tutorials
88
description: test description
99
---
1010

11-
\_\_FORCETOC\_\_ {% include menu-cookbook%}
11+
{% include menu-cookbook%}
1212

1313

1414
## Brightness and Contrast

pages/Image_Synthesizer.md

-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,6 @@ description: test description
1010

1111
{% include info-box software='ImageJ / Fiji plugins ' name='Image Synthesizer ' maintainer='Maximilian Maske ' author='Maximilian Maske ' released='19.03.2018 ' latest-version='24.05.2020 ' category='[Plugins](_Category_Plugins "wikilink") ' website='http://wiki.imagej.net/Image\_Synthesizer ' %}
1212

13-
\_\_TOC\_\_
14-
1513
## Overview of 'Image Synthesizer'
1614

1715
This plugin generates images from mathematical functions and primitive patterns in all ImageJ image types. It can be used to generate synthetic test-cards to analyze for example the behavior of filter-operations or to test the functionality of various algorithms in image-processing. The tool can also be used in a teaching environment, where example images for presentations can be prepared or even to demonstrate basic principles of digital image processing (e.g. by showing the relation between function values and the generated images). Further on an artistic use to create images stacks or videos is also imaginable.

pages/ImgLib2_-_Getting_Started.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ description: test description
99
---
1010

1111
{% include imglibmenu%}
12-
\_\_TOC\_\_
12+
1313

1414
## Creating and Displaying an Image
1515

pages/Interactive_Watershed.md

-2
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,6 @@ categories: Plugins,Segmentation
88
description: test description
99
---
1010

11-
\_\_TOC\_\_
12-
1311

1412
{% capture source%}
1513
{% include github org='mpicbg-scicomp ' repo='Interactive-H-Watershed ' %}

0 commit comments

Comments
 (0)