Skip to content
Snippets Groups Projects
Commit fa409f74 authored by Baptiste Lemoine's avatar Baptiste Lemoine
Browse files

[feat] fix table of content

parent 2466f8f8
No related branches found
No related tags found
No related merge requests found
Showing with 3074 additions and 3546 deletions
Makefile 0 → 100644
default: convert
convert:
bash publication.sh
clean:
git:
# git add files
#git add whitepaper.md whitepaper.html
#git add chapters/1_intro.md.txt chapters/2_looking_at_Bitcoin.md.txt chapters/3_blockchain.md.txt chapters/4_Web_Of_Trust.md.txt chapters/5_individualized_difficulty.md.txt chapters/6_conclusion.md.txt chapters/9_sources.md.txt
#git add publication.sh
#we want to add the .pdf only for publication
# git add whitepaper.pdf
...@@ -3,6 +3,13 @@ ...@@ -3,6 +3,13 @@
Rédaction d'un Whitepaper pour le projet Duniter. Rédaction d'un Whitepaper pour le projet Duniter.
Je ne suis pas compétent pour entrer dans les détails du projet. Cependant, je le suis assez pour rédiger la majeure partie du texte explicatif. J'invite qui le souhaite à m'accompagner dans cette rédaction. Je ne suis pas compétent pour entrer dans les détails du projet. Cependant, je le suis assez pour rédiger la majeure partie du texte explicatif. J'invite qui le souhaite à m'accompagner dans cette rédaction.
## Installation et compilation sur système Debian
Pour compiler les sources markdown vers les versions html, ebook et pdf vous allez avoir besoin de ces dépendances:
```bash
sudo apt install texlive-latex-base pandoc texlive-fonts-recommended calibre
make
```
## TODO ## TODO
* grouper les assets dans ce dépot dans src/img et non les mettre en hotlink. * grouper les assets dans ce dépot dans src/img et non les mettre en hotlink.
* Table Of Content sur la version HTML. * Table Of Content sur la version HTML.
......
File added
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
File added
File added
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
File added
...@@ -26,9 +26,9 @@ The results of this demonstration implies a monetary creation : ...@@ -26,9 +26,9 @@ The results of this demonstration implies a monetary creation :
Thus, Duniter project will associate a human to a digital identity. It will use a Web of Trust with specific rules. As the number of members may evolve, the Universal Dividend has to be created according to the formula : Thus, Duniter project will associate a human to a digital identity. It will use a Web of Trust with specific rules. As the number of members may evolve, the Universal Dividend has to be created according to the formula :
```
$$ UD(t+1) = UD(t) + c²*( {M(t) \over N(t) }) $$ $$ UD(t+1) = UD(t) + c²*( {M(t) \over N(t) }) $$
```
Duniter is based on a decentralized Blockchain. This technical choice allows irreversibility of transaction and uncensorability of trades and identities. While inspired by Bitcoin, Duniter uses a Web of Trust and the Proof of Work to secure the computation network, thus making obsolete the power race model used in Bitcoin. Duniter is based on a decentralized Blockchain. This technical choice allows irreversibility of transaction and uncensorability of trades and identities. While inspired by Bitcoin, Duniter uses a Web of Trust and the Proof of Work to secure the computation network, thus making obsolete the power race model used in Bitcoin.
The first currency created through Duniter is Ğ1, pronounced "June". It was created on the 8th. March 2017. This whitepaper uses Ğ1 parameters as examples ; however, one can create another libre currency with custom parameters while still using Duniter software. The first currency created through Duniter is Ğ1, pronounced "June". It was created on the 8th. March 2017. This whitepaper uses Ğ1 parameters as examples ; however, one can create another libre currency with custom parameters while still using Duniter software.
...@@ -6,13 +6,13 @@ ...@@ -6,13 +6,13 @@
# ce script doit être lancé dans le dossier contenant les chapitres. # ce script doit être lancé dans le dossier contenant les chapitres.
# dépendances : pandoc # dépendances : pandoc
hash pandoc 2>/dev/null || { echo >&2 "Ce générateur a besoin de la commande pandoc pour fonctionner. Mais cette commande n'est pas installée."; exit 1; } hash pandoc 2>/dev/null || { echo >&2 "Ce générateur a besoin de la commande pandoc pour fonctionner. Mais cette commande n'est pas installée. Fin de l'exécution."; exit 1; }
mkdir -p build/src/js mkdir -p build/src/js
## Clean des dossiers de build et copie des assets ## Clean des dossiers de build et copie des assets
[ -f whitepaper.html ] && rm whitepaper.html [ -f whitepaper.html ] && rm whitepaper.html
rm -rf build rm -rf build temp_whitepaper_html_en temp_whitepaper_html_fr temp_whitepaper_en.md temp_whitepaper_fr.md
mkdir -p build/js mkdir -p build/js
cp src/js/* build/js/ #cp src/js/* build/js/
mkdir build/img mkdir build/img
cp src/img/* build/img/ cp src/img/* build/img/
cp src/*.css build/ cp src/*.css build/
...@@ -43,33 +43,33 @@ cat src/foot.html >> temp_whitepaper_html_fr ...@@ -43,33 +43,33 @@ cat src/foot.html >> temp_whitepaper_html_fr
## Générer le html à partir du md ## Générer le html à partir du md
pandoc -o whitepaper_fr.html temp_whitepaper_html_fr pandoc -o whitepaper_fr.html temp_whitepaper_html_fr
pandoc -o whitepaper_en.html temp_whitepaper_html_en pandoc -o whitepaper_en.html temp_whitepaper_html_en
## déplacer dans le dossier de build
mv temp_whitepaper_fr.md build/whitepaper_fr.md
mv temp_whitepaper_en.md build/whitepaper_en.md
mv whitepaper_fr.html build/whitepaper_fr.html mv whitepaper_fr.html build/whitepaper_fr.html
mv whitepaper_en.html build/whitepaper_en.html mv whitepaper_en.html build/whitepaper_en.html
# clean de fichiers temporaires
rm temp_whitepaper_html_fr temp_whitepaper_html_en
firefox build/whitepaper_en.html
firefox "$PWD/build/whitepaper_en.html"
## add ebook conversion ## add ebook conversion
hash pandoc 2>/dev/null || { echo >&2 "Ce générateur peut utiliser ebook-convert fourni avec Calibre, disponible dans les dépots apt. Mais cette commande n'est pas installée."; exit 1; } hash pandoc 2>/dev/null || { echo >&2 "Ce générateur peut utiliser ebook-convert fourni avec Calibre, disponible dans les dépots apt. Mais cette commande n'est pas installée. Fin de l'exécution."; exit 1; }
ebook-convert build/whitepaper.html build/whitepaper.mobi ebook-convert build/whitepaper_fr.html build/whitepaper_fr.mobi
ebook-convert build/whitepaper.html build/whitepaper.fb2 ebook-convert build/whitepaper_en.html build/whitepaper_en.mobi
ebook-convert build/whitepaper.html build/whitepaper.epub ebook-convert build/whitepaper_fr.html build/whitepaper_fr.fb2
ebook-convert build/whitepaper_en.html build/whitepaper_en.fb2
ebook-convert build/whitepaper_fr.html build/whitepaper_fr.epub
ebook-convert build/whitepaper_en.html build/whitepaper_en.epub
echo "===== ok ebooks" echo "===== ok ebooks"
ls -lArth build ls -lArth build
## Création du fichier lateX et pdf ## Création du fichier lateX et pdf
## Attention, certains caractères (U+2028) ne sont pas acceptés par LaTeX. ## Attention, certains caractères (U+2028) ne sont pas acceptés par LaTeX.
pandoc -o whitepaper.pdf temp_whitepaper.md pandoc -o whitepaper_fr.pdf temp_whitepaper_fr.md
pandoc -o whitepaper_en.pdf temp_whitepaper_en.md
# git add files ## déplacer les md, html et pdf dans le dossier de build
git add whitepaper.md whitepaper.html mv temp_whitepaper_fr.md build/whitepaper_fr.md
git add chapters/1_intro.md.txt chapters/2_looking_at_Bitcoin.md.txt chapters/3_blockchain.md.txt chapters/4_Web_Of_Trust.md.txt chapters/5_individualized_difficulty.md.txt chapters/6_conclusion.md.txt chapters/9_sources.md.txt mv temp_whitepaper_en.md build/whitepaper_en.md
git add publication.sh
#we want to add the .pdf only for publication mv whitepaper_fr.pdf build/whitepaper_fr.pdf
# git add whitepaper.pdf mv whitepaper_en.pdf build/whitepaper_en.pdf
# clean de fichiers temporaires
rm temp_whitepaper_fr.md temp_whitepaper_en.md temp_whitepaper_html_fr temp_whitepaper_html_en missfont.log
...@@ -9,18 +9,53 @@ ...@@ -9,18 +9,53 @@
<link <link
rel='stylesheet' rel='stylesheet'
href='main.css' > href='main.css' >
<script src='js/jquery.js' ></script > <script type='text/javascript' >
<script src='js/toc.js' ></script > /**
<script type='javascript' > * Generates a table of contents for your document based on the headings
if ($) { * present. Anchors are injected into the document and the
$('#whitepaper').tableofcontents({ id: '#toc' }); * entries in the table of contents are linked to them. The table of
* contents will be generated inside of the first element with the id `toc`.
* @param {HTMLDOMDocument} documentRef Optional A reference to the document
* object. Defaults to `document`.
* @author Matthew Christopher Kastor-Inare III
* @version 20130726
* @example
* // call this after the page has loaded
* htmlTableOfContents();
*/
function htmlTableOfContents(documentRef) {
var documentRef = documentRef || document;
var toc = documentRef.getElementById('table_of_contents');
var headings = [].slice.call(documentRef.body.querySelectorAll('h1, h2, h3, h4, h5, h6'));
headings.forEach(function (heading, index) {
var anchor = documentRef.createElement('a');
anchor.setAttribute('name', 'toc' + index);
anchor.setAttribute('id', 'toc' + index);
var link = documentRef.createElement('a');
link.setAttribute('href', '#toc' + index);
link.textContent = heading.textContent;
var div = documentRef.createElement('div');
div.setAttribute('class', heading.tagName.toLowerCase());
div.appendChild(link);
toc.appendChild(div);
heading.parentNode.insertBefore(anchor, heading);
});
}
try {
module.exports = htmlTableOfContents;
} catch (e) {
// module.exports is not defined
console.error('e', e)
} }
</script > </script >
</head > </head >
<body > <body onload='htmlTableOfContents();' >
<main > <main >
<div id='toc' ></div > <nav id='table_of_contents' ></nav >
<article <article
id='whitepaper' id='whitepaper'
class='content' > class='content' >
This diff is collapsed.
(function ($) {
$.fn.tableofcontents = function(options) {
var settings = $.extend({
id: "container", // target element id
css: {
"padding": "3px", // padding size
"border": "solid 1px #CCC", // border style
"width": null // width
}
}, options);
options = $.extend(settings, options);
var target = $(options.id)
.append($("<div></div>").html("Contents").css({ "font-weight": "bold" }))
.append("<ul></ul>")
.css(options.css);
var prevLevel = 0;
var getLevel = function(tagname) {
switch(tagname) {
case "H1": return 1;
case "H2": return 2;
case "H3": return 3;
case "H4": return 4;
case "H5": return 5;
case "H6": return 6;
}
return 0;
};
var getUniqId = function() {
return "__toc_id:" + Math.floor(Math.random() * 100000);
};
this.find("h1, h2, h3, h4, h5, h6").each(function() {
var that = $(this);
var currentLevel = getLevel(that[0].tagName);
if(currentLevel > prevLevel) {
var tmp = $("<ul></ul>").data("level", currentLevel);
target = target.append(tmp);
target = tmp;
}else {
while(target.parent().length && currentLevel <= target.parent().data("level")) {
target = target.parent();
}
}
var txt = that.html();
var txtId = that.attr("id");
if(!!!txtId) {
txtId = getUniqId();
that.attr({ "id": txtId });
}
var alink = $("<a></a>").text(txt).attr({ "href": "#" + txtId });
target.append($("<li></li>").append(alink));
prevLevel = currentLevel;
});
return this;
};
}(jQuery));
html{
background: #999;
}
body { body {
background: #fff;
padding: 4em 6em; padding: 4em 6em;
max-width: 65em; max-width: 65em;
margin: 0 auto; margin: 0 auto;
box-shadow: 0 0 1em #ccc; box-shadow: 0 0 1em #ccc;
margin-left: 550px;
} }
#toc { #table_of_contents {
top: 0px; top: 0px;
left: 0px; left: 0px;
height: 100%; height: 100%;
position: fixed; position: fixed;
background: #333; background: #333;
box-shadow: inset -5px 0 5px 0px #000; box-shadow: inset -5px 0 5px 0px #000;
width: 150px; width: 458px;
padding-top: 20px; padding-top: 20px;
color: #fff; color: #fff;
padding-left: 2em;
overflow: auto;
padding-bottom: 5em;
}
.h2 {
margin-left: 2ch;
font-size: 0.85em;
}
.h3 {
margin-left: 4ch;
font-size: 0.75em;
}
.h4 {
margin-left: 6ch;
font-size: 0.65em;
} }
#toc ul { #table_of_contents ul {
margin: 0; margin: 0;
padding: 0; padding: 0;
list-style: none; list-style: none;
} }
#toc li { #table_of_contents li {
padding: 5px 10px; padding: 5px 10px;
} }
#toc a { #table_of_contents a {
color: #fff; color: #fff;
text-decoration: none; text-decoration: none;
display: block; display: block;
} }
#toc .toc-h2 { #table_of_contents .table_of_contents-h2 {
padding-left: 10px; padding-left: 10px;
} }
#toc .toc-h3 { #table_of_contents .table_of_contents-h3 {
padding-left: 20px; padding-left: 20px;
} }
#toc .toc-active { #table_of_contents .table_of_contents-active {
background: #336699; background: #336699;
box-shadow: inset -5px 0px 10px -5px #000; box-shadow: inset -5px 0px 10px -5px #000;
} }
table tr:nth-of-type(odd) {
background: #dedede;
}
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment