Rework website structure

This commit is contained in:
Quentin 2020-04-18 17:17:54 +02:00
parent ef35a40059
commit 2ea473d3bd
23 changed files with 132 additions and 87 deletions

1
.gitignore vendored
View File

@ -1,2 +1,3 @@
static/
node_modules/
*.swp

View File

@ -1,4 +1,3 @@
#!/bin/bash
rm -rf static/
npm install
node render.js

View File

@ -10,7 +10,7 @@ const log = process.env.VERBOSE ? console.log : unit
const walk = async (path, filename) => {
log('[walk]', path)
const type = await fs.lstat(path)
if (type.isFile()) return {type: 'file', path: path, name: filename || path}
if (type.isFile()) return {type: 'file', path: path, name: filename || path, tags:[]}
if (!type.isDirectory()) return null
const files = await fs.readdir(path)
@ -18,6 +18,7 @@ const walk = async (path, filename) => {
type: 'folder',
path: path,
name: filename || path,
tags: [],
children: await Promise.all(files.map(file => walk(`${path}/${file}`, file)))
}
}
@ -32,6 +33,7 @@ const is_static = suffixl(...ext_static)
const is_md = suffixl(...ext_md)
const is_pug = suffixl(...ext_pug)
const is_templated = f => is_md(f) /* || is_rst(f) */
const is_document = f => is_templated(f) || is_pug(f)
const prefix = file => ext => file.substring(0, ext.length) == ext ? ext : null
const prefixl = (...l) => file => l.find(prefix(file))
@ -54,12 +56,41 @@ const propagate_md_layout = (tree, markdown_template) => {
const elagate = tree => {
if (tree.type != 'folder') return tree
const lh = e => log('[elegate]', e.path) && false
const lh = e => log('[elagate]', e.path) && false
tree.children = tree.children.filter(e => !(e.name[0] == '_') || lh(e))
tree.children.forEach(elagate)
return tree
}
const tag_document = tree => {
if (tree.type == 'file' && is_document(tree.name)) {
tree.tags.push('document_leaf', 'document')
log('[tag_document]', tree.path, 'document_leaf')
} else if (tree.type == 'folder') {
tree.children.forEach(tag_document)
if(tree.children.some(c => c.tags.includes('document'))) {
tree.tags.push('document_branch', 'document')
log('[tag_document]', tree.path, 'document_branch')
}
}
return tree
}
const reference_index = indexes => tree => {
if (tree.type != 'folder') return tree;
const index = tree.children.find(e => indexes.includes(e.name))
if (index) {
tree.index = index
tree.tags.push('has_index')
log('[reference_index]', tree.path, index.name)
index.tags.push('is_index')
}
tree.children.forEach(reference_index(indexes))
return tree;
}
const propagate_nice_name = prefix => tree => {
const without_prefix = tree.path.substring(prefix.length)
const splitted = without_prefix.split('/').filter(v => v.length > 0)
@ -90,10 +121,12 @@ const prepare_copy = (old_prefix, new_prefix, exts) => tree => {
const prepare_pug = (old_prefix, new_prefix) => tree => {
if (tree.type == 'file' && is_pug(tree.name)) {
tree.old_url = tree.url
tree.url = rm_prefix(old_prefix)(rm_suffix(...ext_pug)(tree.path)) + '.html'
tree.generate = {
cmd: 'pug',
src: tree.path,
out: new_prefix + rm_prefix(old_prefix)(rm_suffix(...ext_pug)(tree.path)) + '.html'
out: new_prefix + tree.url
}
log('[prepare_pug]',tree.generate.src,'->',tree.generate.out)
}
@ -106,11 +139,13 @@ const prepare_pug = (old_prefix, new_prefix) => tree => {
const prepare_md = (old_prefix, new_prefix) => tree => {
if (tree.type == 'file' && is_md(tree.name)) {
tree.old_url = tree.url
tree.url = rm_prefix(old_prefix)(rm_suffix(...ext_md)(tree.path)) + '.html'
tree.generate = {
cmd: 'pug',
src: tree.template.path,
markdown: tree.path,
out: new_prefix + rm_prefix(old_prefix)(rm_suffix(...ext_md)(tree.path)) + '.html'
out: new_prefix + tree.url
}
log('[prepare_md]',tree.generate.markdown,'+',tree.generate.src,'->',tree.generate.out)
}
@ -170,16 +205,35 @@ const do_pug = (prt, root) => async tree => {
return tree
}
const rm_tree = t => {
if (t.type == 'file') {
log('[do_clean] file', t.path)
return fs.unlink(t.path)
}
return Promise
.all(t.children.map(rm_tree))
.then(_ => {
log('[do_clean] path', t.path)
return fs.rmdir(t.path)
})
}
const do_clean = path => tree => walk(path).then(rm_tree).then(_ => tree)
const conf = { src: './src', dest: './static'}
walk(conf.src)
.then(propagate_md_layout)
.then(elagate)
.then(tag_document)
.then(reference_index(['index.md', 'index.pug']))
.then(propagate_nice_name(conf.src))
.then(prepare_copy(conf.src, conf.dest))
.then(prepare_pug(conf.src, conf.dest))
.then(prepare_md(conf.src, conf.dest))
.then(prepare_folder(conf.src, conf.dest))
//.then(v => {log(v) ; return v})
.then(do_clean(conf.dest))
.then(do_folder)
.then(do_copy)
.then(do_pug())

View File

@ -1,11 +0,0 @@
### Statuts de l'association
Depuis janvier 2020, Deuxfleurs est constitué en association loi 1901.
Vous trouverez [ici](/Documentation/Association/Statuts/) les statuts de l'association.
### Comptes rendus d'AG
Les comptes-rendus d'AG sont disponibles aux liens suivants:
- [13 janvier 2020 (AG constitutive)](/Documentation/Association/AG1/)

View File

@ -1,14 +0,0 @@
extends ../_layout.pug
prepend root
- title = element.nice_path[element.nice_path.length - 1]
block content
.container.spacing
nav
strong
a(href="/Documentation") Documentation
+menu(root.children.find(e => e.nice_name == "Documentation"))
main.spacing
!= markdown

View File

@ -37,7 +37,7 @@ Voilà les conclusions que nous avons tirées de nos tests :
Nous avons donc demandé à Adrien quels étaient les ports ouverts par défaut dans le mode élevé de sa box :
![Livebox Parefeu Personnalisé](livebox_parefeu_personnalise.png)
![Livebox Parefeu Personnalisé](Assets/livebox_parefeu_personnalise.png)
Nous avons dans un premier temps retenu le port `995/tcp` pour Jitsi, le port UDP ne pouvant être changé (limitation de Jitsi).
Cependant, pour des raisons de sécurité, les navigateurs ne peuvent pas utiliser les ports en dessous de `1024/*`, à l'exception des ports `80/tcp` et `443/tcp` comme l'indique ;'issue [#3583](https://bugs.chromium.org/p/webrtc/issues/detail?id=3583) de Chromium.
@ -76,7 +76,7 @@ WebRTC fonctionne en deux étapes :
Le serveur de signaling Jitsi n'est autre que le serveur de chat prosody.
Pour ça, prosody est exposé à travers HTTP grâce au protocole BOSH (XMPP overs HTTPS).
Une fois l'offre reçue ([exemple](exemple_offre.txt)), elle est enregistrée dans le navigateur à l'aide de `setRemoteDescription` pour initialiser le data plane.
Une fois l'offre reçue ([exemple](Assets/exemple_offre.txt)), elle est enregistrée dans le navigateur à l'aide de `setRemoteDescription` pour initialiser le data plane.
On peut débugger le signaling WebRTC sous Chromium avec [chrome://webrtc-internarls](chrome://webrtc-internals/).
Quand plus de deux participants sont connectés dans la conversation, Jitsi n'envoie pas les offres de chaque participant aux autres participants. À la place, elle envoie qu'une seule offre, celle de son VideoBridge.

View File

@ -16,9 +16,12 @@ block root
.menu-item
a(href='https://guichet.deuxfleurs.fr') compte
span  | 
.menu-item
a(href='/Documentation') doc
span  | 
h1 #{title}
block main
main
.container.spacing
nav
strong
a(href="/") Accueil
+menu(root)
block content

7
src/_markdown.pug Normal file
View File

@ -0,0 +1,7 @@
extends ./_layout.pug
prepend root
- title = element.nice_path[element.nice_path.length - 1]
block content
!= markdown

View File

@ -1,7 +1,13 @@
mixin menu(o)
ul
each val in o.children
- if (val.type == 'folder')
- if (val.type == 'folder' && val.tags.includes('document'))
li
- if (val.tags.includes('has_index'))
a(href=val.url)= val.nice_name
- else
span= val.nice_name
+menu(val)
- else if (val.type == 'file' && val.tags.includes('document') && !val.tags.includes('is_index'))
li
a(href=val.url)= val.nice_name
+menu(val)

View File

@ -67,7 +67,7 @@ header > .container > .menu-item > img {
vertical-align: -9px;
}
header > .container > .menu-item > a,span {
header > .container > .menu-item > a, header > .container > .menu-item > span {
font-size: 30px;
color: white;
text-decoration: none;

View File

@ -4,12 +4,12 @@ prepend root
- title = "deuxfleurs"
block content
.container.spacing
.chapeau ⇨ protège votre vie privée
.chapeau ⇨ défend vos libertés et vos droits
.chapeau ⇨ ne vous manipule pas
.chapeau ⇨ promeut la sobriété numérique
section.spacing
h2 nos services permettent de
.list