Code totaly rewritted + added pad(url:) support

This commit is contained in:
Ventricule 2018-03-16 15:05:56 +01:00
commit baf91773ec
114 changed files with 4192 additions and 429 deletions

View file

@ -0,0 +1,22 @@
title: Libreto
logo : http://libreto.net/assets/images/libretonet.png
introduction: >
Libreto is a collaborative notebook based on [framapad](https://framapad.org).
It can become a mini-website, a workshop logbook or the tool to write a collective book.
Libreto is free and minimal.
No registration, no connection, anyone can write a Libreto.
create: Create libreto
colophon: >
Libreto is under [GNU/GPLv3 License](https://www.gnu.org/licenses/gpl-3.0.en.html)
Use and modify on [GitHub](https://github.com/Ventricule/libreto)
A project initiated by [Pierre Tandille](http://lecollecteur.fr)

View file

@ -0,0 +1,26 @@
title: Libreto
logo : http://libreto.net/assets/images/libretonet.png
introduction: >
Libreto est un carnet de note collaboratif fondé sur [etherpad](http://etherpad.org/).
Il peut devenir un mini-site, le carnet de bord d'un workshop ou le support de rédaction d'un livre collectif.
Libreto est libre, gratuit, et minimaliste.
Pas d'inscription, pas de connexion, tout le monde peut écrire un Libreto.
create: Créer un Libreto
colophon: >
Libreto est sous [licence GNU/GPLv3](https://www.gnu.org/licenses/gpl-3.0.en.html).
N'hésitez pas à participer sur [GitHub](https://github.com/Ventricule/libreto).
Un projet initié par [Pierre Tandille](http://lecollecteur.fr).

View file

@ -0,0 +1,45 @@
title: Libreto
read: Read
write: Write
export: Export
download: Download
update: Update
credits: |
**Crédits**
Graphisme & programmation : [Pierre Tandille](http://lecollecteur.fr)
Typographies : [HK Grotesk](https://hanken.co), [Spun Gold](http://www.co-bay.com/dasein), [Jean-Luc](http://www.carvalho-bernau.com)
Pads : [Etherpad](http://etherpad.org/), [Framapad](http://framapad.org), [Fairkom Board](https://board.net/)
about: |
**About Libreto**
Un Libreto est un carnet de note collaboratif fondé sur framapad. Libreto est libre, gratuit, et minimaliste. [Plus d'infos](http://libreto.net)
help: |
## Bienvenue ! — [Libreto](http://libreto.net) est un outil d'écriture et de publication collaboratif basé sur [etherpad](https://etherpad.org).
**Pour commencer :**
- Rédigez la liste de vos pads
- Rechargez la page
- Lancez-vous : écrivez sur vos pads !
**Pour partager / collaborer :**
- Sélectionnez et copiez l'URL
- Partagez-là !
**Pour diffuser :**
- exportez sous forme de livre, de PDF ou de document ODT
**Pour personnaliser :**
- Créez une feuille de style en ajoutant un pad style.css à votre menu
## Plus d'options :
**Menu**
*Exemple :*
Mon pad (url: http://url.pad)
*Options :*
**url** : adresse d'un pad existant
**color** : [nom d'une couleur](https://htmlcolorcodes.com/color-names) / [code hexadecimal](https://htmlcolorcodes.com/color-chart)
**visibility** : visible / private / hidden
**Exporter un livre**
Créez une feuille de style pour le livre en ajoutant un pad book.css à votre menu

View file

@ -0,0 +1,46 @@
title: Libreto
read: Lire
write: Écrire
export: Exporter
download: Télécharger
update: Mettre à jour
credits: |
**Crédits**
Graphisme & programmation : [Pierre Tandille](http://lecollecteur.fr)
Typographies : [HK Grotesk](https://hanken.co), [Spun Gold](http://www.co-bay.com/dasein), [Jean-Luc](http://www.carvalho-bernau.com)
Pads : [Etherpad](http://etherpad.org/), [Framapad](http://framapad.org), [Fairkom Board](https://board.net/)
about: |
**À propos**
Un Libreto est un carnet de note collaboratif fondé sur framapad. Libreto est libre, gratuit, et minimaliste. [Plus d'infos](http://libreto.net)
help: |
## Bienvenue ! — [Libreto](http://libreto.net) est un outil d'écriture et de publication collaboratif basé sur [etherpad](https://etherpad.org).
**Pour commencer :**
- Rédigez la liste de vos pads
- Rechargez la page
- Lancez-vous : écrivez sur vos pads !
**Pour partager / collaborer :**
- Sélectionnez et copiez l'URL
- Partagez-là !
**Pour diffuser :**
- exportez sous forme de livre, de PDF ou de document ODT
**Pour personnaliser :**
- Créez une feuille de style en ajoutant un pad style.css à votre menu
----
**Menu**
Pour chaque pad, vous pouvez ajoutez des options entre parenthèses. Exemple :
`Mon pad (url: http://url.pad color: blue)`
*Options disponibles*
**url** : adresse d'un pad existant
**color** : [nom d'une couleur](https://htmlcolorcodes.com/color-names) / [code hexadecimal](https://htmlcolorcodes.com/color-chart)
**visibility** : visible / private / hidden
----
**Exporter un livre**
Créez une feuille de style pour le livre en ajoutant un pad book.css à votre menu

View file

@ -0,0 +1,2 @@
</body>
</html>

12
views/snippets/header.php Normal file
View file

@ -0,0 +1,12 @@
<?php global $libreto ?>
<!doctype html>
<html lang="fr">
<head>
<meta charset="utf-8">
<title><?= $libreto->name() ?> - Libreto</title>
<link rel="stylesheet" media="screen" href="https://fontlibrary.org/face/belgica-belgika" type="text/css"/>
<link rel="stylesheet" href="/libreto/assets/style.css">
<script src="http://code.jquery.com/jquery-3.3.1.min.js"></script>
<script type="text/javascript" src="/libreto/assets/script.js"></script>
</head>
<body>

View file

@ -0,0 +1,17 @@
<?php global $libreto ?>
<header class="<?= count($libreto->pads()->children()) > 1 ? 'close' : 'open' ?>">
<div class="full">
<?= l("help") ?>
<hr>
<div class="colophon">
<div><?= l('about') ?></div>
<div><?= l('credits') ?></div>
</div>
<button class="switch">×</button>
</div>
<div class="reduced">
<p class="instance_name"><a href="<?= $libreto->options('url') ?>"><?= $libreto->options('name') ?></a></p>
<p class="libreto_name"><?= $libreto->name() ?></p>
<button class="switch">?</button>
</div>
</header>

25
views/snippets/nav.php Normal file
View file

@ -0,0 +1,25 @@
<?php global $libreto ?>
<nav>
<ul class="helpers">
<li class='switcher_button <?= $_SESSION['mode'] == 'read' ? 'active' : ''; ?>'><a href="?mode=read"><?= l("read", false) ?></a></li>
<li class='switcher_button <?= $_SESSION['mode'] == 'write' ? 'active' : ''; ?>'><a href="?mode=write"><?= l("write", false) ?></a></li>
</ul>
<ul class="menu">
<?php foreach ($libreto->pads()->children() as $pad): ?>
<li class='pad_button <?= $pad->selected() ? "active" : false ?> <?= $pad->type() ?>'>
<a href='<?= $pad->url() ?>' target='myframe' style='color: <?= $pad->color() ?>' data-name='<?= $pad->name(); ?>' data-name-encoded='<?= urlencode(strtolower($pad->name())) ?>'><?= $pad->name() ?></a>
</li>
<?php endforeach; ?>
</ul>
<?php if($_SESSION['mode']=="write"): ?>
<ul class="helpers">
<li class=""><a href='/bindery/<?= $libreto->name() ?>' class="" data-name-encoded=''><?= l("export", false) ?></a></li>
<li class=""><a href='/export/<?= $libreto->name() ?>' class="" data-name-encoded='' download><?= l("download", false) ?></a></li>
<li class='' style="flex: 0;"><a href='' class="refresh" data-name-encoded='' alt='<?= l("update", false) ?>'></a></li>
</ul>
<?php endif; ?>
</nav>

View file

@ -0,0 +1,73 @@
<?php
global $libreto;
?>
<!doctype html>
<html lang="fr">
<head>
<meta charset="utf-8">
<title><?= $libreto->name() ?> - Libreto</title>
</head>
<body>
<script src="/libreto/assets/js/bindery.umd.js"></script>
<script src="/libreto/assets/js/bindery-controls.min.js"></script>
<link rel="stylesheet" href="/libreto/assets/style-reader.css">
<style><?= $libreto->pads()->find('book.css') ? $libreto->pads()->find('book.css')->css() : ''; ?></style>
<script>
Bindery.makeBook({
content: {
selector: '.content',
url: '/reader/<?= $libreto->name() ?>/',
},
view: Bindery.View.PRINT,
ControlsComponent: BinderyControls,
printSetup: {
paper: Bindery.Paper.AUTO_MARKS,
layout: Bindery.Layout.SPREADS,
marks: Bindery.Marks.BOTH,
},
pageSetup: {
size: { width: '14.5cm', height: '20cm' },
margin: {
top: '2cm',
bottom: '2cm',
inner: '2cm',
outer: '2cm',
},
},
rules: [
Bindery.PageBreak({
selector: 'h2',
position: 'before',
continue: 'next',
}),
Bindery.PageBreak({
selector: 'h1',
position: 'before',
continue: 'right',
}),
Bindery.RunningHeader({
render: (page) => {
if (page.isEmpty) return '';
if (page.isLeft) {
let section = Object.values(page.heading)[0];
return `${page.number} · ${section} `;
} else if (page.isRight) {
let section = Object.values(page.heading).splice(1).join(' ');
if (section !== '') return `${section} · ${page.number}`;
else return `${page.number}`;
}
},
}),
Bindery.Footnote({
selector: 'a',
render: (element, number) => {
return '<i>' + number + '</i>: ' + element.href;
}
}),
Bindery.FullBleedPage({ selector: '.fullpage', continue: 'next' }),
]
})
</script>
</body>
</html>

View file

@ -0,0 +1,3 @@
<?php
global $libreto;
$libreto->export();

37
views/templates/home.php Normal file
View file

@ -0,0 +1,37 @@
<?php global $libreto ?>
<?php
if(isset($_POST['new_name'])):
if($new_name = $_POST['new_name']) :
header('Location: ' . $libreto->options('url') . '/' . urlencode($new_name) );
endif;
endif;
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="x-ua-compatible" content="ie=edge">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Libreto</title>
<link rel="stylesheet" href="/libreto/assets/style-index.css">
</head>
<body>
<article>
<?= l('introduction') ?>
<div class="create_libreto">
<form action="" method="POST">
<input type="input" autofocus="autofocus" onfocus="this.select()" name="new_name" />
<button type="submit" /><?= l("create", false) ?></button>
</form>
</div>
</article>
<div class="colophon" markdown="1">
<?= l('colophon') ?>
</div>
</body>
</html>

View file

@ -0,0 +1,17 @@
<?php global $libreto ?>
<?php snippet('header') ?>
<div id="container">
<?php snippet('introduction') ?>
<?php snippet('nav') ?>
<article>
<?php
if ($libreto->pads()->selected()) :
$iframe = $libreto->pads()->selected()->url();
else :
header('Location: ?mode=write');
endif;
?>
<iframe id="framepad" name="myframe" width=600 height=400 src="<?= $iframe ?>"></iframe>
</article>
</div>
<?php snippet('footer') ?>

View file

@ -0,0 +1,36 @@
<?php
global $libreto;
?>
<!doctype html>
<html lang="fr">
<head>
<meta charset="utf-8">
<title><?= $libreto->name() ?> - Libreto</title>
<link rel="stylesheet" href="/libreto/assets/style-reader.css">
<style>
<?= $libreto->pads()->css() ?>
</style>
</head>
<body>
<main class="content">
<?php
if ($libreto->router()->pad()) :
?>
<?= $libreto->pads()->selected()->html() ?>
<?php
else:
?>
<h1><?= $this->name() ?></h1>
<?php
$pads = $this->pads()->children('visible');
foreach($pads as $pad) :
?>
<h2><?= $pad->name() ?></h2>
<div><?= $pad->html() ?></div>
<?php
endforeach;
endif;
?>
</main>
</body>
</html>