changement de noms et correction ticket caractères accentués par composition

pull/13/head
Nicolas Sanchez 3 years ago
parent 53986db3f7
commit cf7243bf61

36
Cargo.lock generated

@ -435,6 +435,24 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "cheezenotes"
version = "0.1.0"
dependencies = [
"actix-files",
"actix-web",
"askama",
"askama_actix",
"clap",
"git2",
"lazy_static",
"mongodb",
"regex",
"rusqlite",
"serde",
"serde_json",
]
[[package]]
name = "chrono"
version = "0.4.23"
@ -1249,24 +1267,6 @@ dependencies = [
"digest",
]
[[package]]
name = "mdnotes"
version = "0.1.0"
dependencies = [
"actix-files",
"actix-web",
"askama",
"askama_actix",
"clap",
"git2",
"lazy_static",
"mongodb",
"regex",
"rusqlite",
"serde",
"serde_json",
]
[[package]]
name = "memchr"
version = "2.5.0"

@ -1,5 +1,5 @@
[package]
name = "mdnotes"
name = "cheezenotes"
version = "0.1.0"
edition = "2021"

@ -1,4 +1,4 @@
mdnotes
cheezenotes
======
Notes utilisant la syntaxe MarkDown pour être rapide et facile à modifier.

@ -1,5 +1,5 @@
# RustyNotes
L'objectif de RustyNotes est de pouvoir saisir des notes avec un minimum de formatage le plus rapidement possible.
# CheezeNotes
L'objectif de CheezeNotes est de pouvoir saisir des notes avec un minimum de formatage le plus rapidement possible.
> Cette page est un bac à sable. Les modifications ne seront jamais enregistrées.
> Pour réinitialiser la page, il suffit de la recharger.
## Utilisation
@ -13,6 +13,8 @@ Il y a 4 niveaux de titres :
- `## titre 2`
- `### titre 3`
- `#### titre 4`
- `##### titre 5`
- `###### titre 6`
### **Gras**, *italic* etc.
|:Syntaxe:|:Résultat:|:Ok ?:|
|:`**gras**`|:**gras**|:|
@ -23,6 +25,7 @@ Il y a 4 niveaux de titres :
|`___gras_italic___`|___gras_italic___|Non|
|`__*gras_italic*__`|__*gras_italic*__||
|````texte formaté````|`texte formaté`||
| `````````|```||
### Liens
Pour une url longue à laquelle on veut associer un libellé plus parlant, on choisira la syntaxe complète :
- [Wikipedia Markdown](https://fr.wikipedia.org/wiki/Markdown)

@ -6,7 +6,7 @@ pub struct Arguments {
#[arg(short, long, default_value_t = String::from("127.0.0.1"))]
pub ip: String,
/// Port to listen to
#[arg(short, long, default_value_t = 8081)]
#[arg(short, long, default_value_t = 8333)]
pub port: u16,
/// root of the url ending and starting with /
#[arg(short, long, default_value_t = String::from("/"))]

@ -1,8 +1,8 @@
use actix_web::{web, App, HttpServer};
use actix_files;
use mdnotes::commons::{Arguments, AppData};
use mdnotes::{ page, index };
use cheezenotes::commons::{Arguments, AppData};
use cheezenotes::{ page, index };
#[actix_web::main]
async fn main() -> std::io::Result<()> {

@ -37,9 +37,9 @@ async fn page(path: web::Path<(String,)>, data: web::Data<AppData>) -> impl Resp
#[put("/page/{page}")]
async fn save_page(body: String, path: web::Path<(String,)>) -> impl Responder {
let pagename = &path.0;
if pagename == "index" {
/*if pagename == "index" {
return HttpResponse::Ok();
}
}*/
let filename = String::from("pages/") + pagename.as_str() + ".md";
let mut file = match fs::File::create(&filename) {
Ok(f) => f,

@ -55,7 +55,7 @@ textarea#ta {
background-color: #cceeff;
}
div#mdnotes {
div#cheezenotes {
margin-top: 3rem;
margin-left: auto;
margin-right: auto;
@ -70,27 +70,27 @@ div#mdnotes {
overflow-x: auto;
}
div#mdnotes div.mdnotes_line {
div#cheezenotes div.cheezenotes_line {
/* Pour firefox : white-space: pre; */
}
div#mdnotes span.tokenfictif {
div#cheezenotes span.tokenfictif {
font-weight: 1;
color: #1353b3;
}
div#mdnotes:focus {
div#cheezenotes:focus {
outline: none;
}
div#mdnotes div.line {
div#cheezenotes div.line {
border-bottom: 1px solid #dddddd;
padding-top: 0rem;
margin-top: 0rem;
font-size: 8pt;
}
div#mdnotes div.h1 {
div#cheezenotes div.h1 {
font-size: 3rem;
margin-top: 1.5rem;
margin-bottom: 1.3rem;
@ -98,26 +98,37 @@ div#mdnotes div.h1 {
border-bottom: 1px solid #dddddd;
}
div#mdnotes div.h2 {
div#cheezenotes div.h2 {
font-size: 2.3rem;
margin-top: 1rem;
margin-bottom: 1rem;
}
div#mdnotes div.h3 {
div#cheezenotes div.h3 {
font-size: 1.8rem;
margin-top: 0.8rem;
margin-bottom: 0.8rem;
}
div#mdnotes div.h4 {
font-style: italic;
font-size: 1.4rem;
div#cheezenotes div.h4 {
font-size: 1.5rem;
margin-top: 0.5rem;
margin-bottom: 0.5rem;
}
div#cheezenotes div.h5 {
font-size: 1.3rem;
margin-top: 0.5rem;
margin-bottom: 0.5rem;
}
div#cheezenotes div.h6 {
font-size: 1.2rem;
margin-top: 0.5rem;
margin-bottom: 0.5rem;
}
div#mdnotes div.bq1 {
div#cheezenotes div.bq1 {
padding-top: 0.3rem;
padding-bottom: 0.3rem;
padding-left: .9rem;
@ -125,7 +136,7 @@ div#mdnotes div.bq1 {
border-left: .3rem solid #446699;
}
div#mdnotes div.bq2 {
div#cheezenotes div.bq2 {
padding-top: 0.3rem;
padding-bottom: 0.3rem;
padding-left: .6rem;
@ -133,7 +144,7 @@ div#mdnotes div.bq2 {
border-left: .6rem solid #5577aa;
}
div#mdnotes div.bq3 {
div#cheezenotes div.bq3 {
padding-top: 0.3rem;
padding-bottom: 0.3rem;
padding-left: .3rem;
@ -141,111 +152,111 @@ div#mdnotes div.bq3 {
border-left: .9rem solid #6688bb;
}
div#mdnotes div.ul1 { display:list-item; list-style-position: inside; padding-left: 2.2rem; padding-bottom: .2rem; padding-top: .2rem; }
div#mdnotes div.ul1.bq1 { padding-left: 1.9rem; }
div#mdnotes div.ul1.bq2 { padding-left: 1.6rem; }
div#mdnotes div.ul1.bq3 { padding-left: 1.3rem; }
div#cheezenotes div.ul1 { display:list-item; list-style-position: inside; padding-left: 2.2rem; padding-bottom: .2rem; padding-top: .2rem; }
div#cheezenotes div.ul1.bq1 { padding-left: 1.9rem; }
div#cheezenotes div.ul1.bq2 { padding-left: 1.6rem; }
div#cheezenotes div.ul1.bq3 { padding-left: 1.3rem; }
div#mdnotes div.ul2 { display:list-item; list-style-position: inside; list-style-type: circle; padding-left: 2.7rem; padding-bottom: .2rem; padding-top: .2rem; }
div#mdnotes div.ul2.bq1 { padding-left: 2.4rem; }
div#mdnotes div.ul2.bq2 { padding-left: 2.1rem; }
div#mdnotes div.ul2.bq3 { padding-left: 1.8rem; }
div#cheezenotes div.ul2 { display:list-item; list-style-position: inside; list-style-type: circle; padding-left: 2.7rem; padding-bottom: .2rem; padding-top: .2rem; }
div#cheezenotes div.ul2.bq1 { padding-left: 2.4rem; }
div#cheezenotes div.ul2.bq2 { padding-left: 2.1rem; }
div#cheezenotes div.ul2.bq3 { padding-left: 1.8rem; }
div#mdnotes div.ul3 { display:list-item; list-style-position: inside; list-style-type: square; padding-left: 3.2rem; padding-bottom: .2rem; padding-top: .2rem; }
div#mdnotes div.ul3.bq1 { padding-left: 2.9rem; }
div#mdnotes div.ul3.bq2 { padding-left: 2.6rem; }
div#mdnotes div.ul3.bq3 { padding-left: 2.3rem; }
div#cheezenotes div.ul3 { display:list-item; list-style-position: inside; list-style-type: square; padding-left: 3.2rem; padding-bottom: .2rem; padding-top: .2rem; }
div#cheezenotes div.ul3.bq1 { padding-left: 2.9rem; }
div#cheezenotes div.ul3.bq2 { padding-left: 2.6rem; }
div#cheezenotes div.ul3.bq3 { padding-left: 2.3rem; }
div#mdnotes div.ol1 { padding-left: 2.2rem; padding-bottom: .2rem; padding-top: .2rem; }
div#mdnotes div.ol1.bq1 { padding-left: 1.9rem; }
div#mdnotes div.ol1.bq2 { padding-left: 1.6rem; }
div#mdnotes div.ol1.bq3 { padding-left: 1.3rem; }
div#cheezenotes div.ol1 { padding-left: 2.2rem; padding-bottom: .2rem; padding-top: .2rem; }
div#cheezenotes div.ol1.bq1 { padding-left: 1.9rem; }
div#cheezenotes div.ol1.bq2 { padding-left: 1.6rem; }
div#cheezenotes div.ol1.bq3 { padding-left: 1.3rem; }
div#mdnotes div.ol2 { padding-left: 2.7rem; padding-bottom: .2rem; padding-top: .2rem; }
div#mdnotes div.ol2.bq1 { padding-left: 2.4rem; }
div#mdnotes div.ol2.bq2 { padding-left: 2.1rem; }
div#mdnotes div.ol2.bq3 { padding-left: 1.8rem; }
div#cheezenotes div.ol2 { padding-left: 2.7rem; padding-bottom: .2rem; padding-top: .2rem; }
div#cheezenotes div.ol2.bq1 { padding-left: 2.4rem; }
div#cheezenotes div.ol2.bq2 { padding-left: 2.1rem; }
div#cheezenotes div.ol2.bq3 { padding-left: 1.8rem; }
div#mdnotes div.ol3 { padding-left: 3.2rem; padding-bottom: .2rem; padding-top: .2rem; }
div#mdnotes div.ol3.bq1 { padding-left: 2.9rem; }
div#mdnotes div.ol3.bq2 { padding-left: 2.6rem; }
div#mdnotes div.ol3.bq3 { padding-left: 2.3rem; }
div#cheezenotes div.ol3 { padding-left: 3.2rem; padding-bottom: .2rem; padding-top: .2rem; }
div#cheezenotes div.ol3.bq1 { padding-left: 2.9rem; }
div#cheezenotes div.ol3.bq2 { padding-left: 2.6rem; }
div#cheezenotes div.ol3.bq3 { padding-left: 2.3rem; }
div#mdnotes span.oltoken {
div#cheezenotes span.oltoken {
display: inline-block;
width: 2rem;
}
div#mdnotes span.lefttablespacer {
div#cheezenotes span.lefttablespacer {
display: inline-block;
}
div#mdnotes span.righttablespacer {
div#cheezenotes span.righttablespacer {
display: inline-block;
}
div#mdnotes div.tablerow {
div#cheezenotes div.tablerow {
margin-top: .5rem;
margin-bottom: .9rem;
overflow-x: visible;
}
div#mdnotes span.tablerow {
div#cheezenotes span.tablerow {
white-space: nowrap;
overflow-x: visible;
border-bottom: 1px solid #dddddd;
padding-bottom: 0.4rem;
}
div#mdnotes div.firsttablerow {
div#cheezenotes div.firsttablerow {
margin-top: 1.5rem;
}
div#mdnotes div.firsttablerow span.tablerow {
div#cheezenotes div.firsttablerow span.tablerow {
margin-bottom: 1.5rem;
border-bottom: 1px solid #666666;
font-weight: bold;
}
div#mdnotes div.lasttablerow {
div#cheezenotes div.lasttablerow {
margin-bottom: 1.5rem;
}
div#mdnotes div.lasttablerow span.tablerow {
div#cheezenotes div.lasttablerow span.tablerow {
margin-bottom: 1.5rem;
border-bottom: none;
}
div#mdnotes div.mdnotes_line span.token {
div#cheezenotes div.cheezenotes_line span.token {
font-weight: 1;
color: #1353b3;
overflow: hidden;
}
div#mdnotes div.mdnotes_line span.token {
div#cheezenotes div.cheezenotes_line span.token {
font-size: 0;
}
div#mdnotes:focus div.mdnotes_line span.token {
div#cheezenotes:focus div.cheezenotes_line span.token {
font-size: inherit;
}
div#mdnotes div.body {
div#cheezenotes div.body {
margin-top: 0.5rem;
margin-bottom: 0.5rem;
}
div#mdnotes span.bold {
div#cheezenotes span.bold {
font-weight: bold;
}
div#mdnotes span.italic {
div#cheezenotes span.italic {
font-style: italic;
}
div#mdnotes span.mono {
div#cheezenotes span.mono {
font-family: monospace;
color: #885511;
color: #555555;
}

@ -8,7 +8,7 @@ function getStartPositionInLine() {
let position = range.startOffset;
if (obj.nodeName == 'DIV' && obj.classList.contains('mdnotes_line')) {
if (obj.nodeName == 'DIV' && obj.classList.contains('cheezenotes_line')) {
return [obj, position];
}
@ -22,9 +22,9 @@ function getStartPositionInLine() {
} else if (obj.length != null) {
position += obj.length;
}
} else if (obj.parentNode != null && obj.parentNode.classList != null && !obj.parentNode.classList.contains('mdnotes_line')) {
} else if (obj.parentNode != null && obj.parentNode.classList != null && !obj.parentNode.classList.contains('cheezenotes_line')) {
obj = obj.parentNode;
} else if (obj.parentNode != null && obj.parentNode.classList != null && obj.parentNode.classList.contains('mdnotes_line')) {
} else if (obj.parentNode != null && obj.parentNode.classList != null && obj.parentNode.classList.contains('cheezenotes_line')) {
line = obj.parentNode;
obj = null;
} else {

@ -20,9 +20,9 @@ function ontextarea(e) {
function onsave(e) {
let saveButton = document.getElementById('saveButton');
saveButton.disabled = true;
let text = save(document.getElementById('ta'), document.getElementById('mdnotes'));
let text = save(document.getElementById('ta'), document.getElementById('cheezenotes'));
var xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
xhttp.onreadystatechange = function () {
if (this.readyState == 4 && this.status != 200) {
saveButton.disabled = false;
alert(xhttp.responseText);
@ -33,11 +33,16 @@ function onsave(e) {
}
function onload(e) {
load(document.getElementById('ta'), document.getElementById('mdnotes'));
load(document.getElementById('ta'), document.getElementById('cheezenotes'));
}
function onedit(e) {
console.log('onedit');
if (e.inputType == 'insertCompositionText') {
e.preventDefault();
return false;
}
timeoutSave();
saveButton.disabled = false;
let ret = getStartPositionInLine();
@ -45,14 +50,14 @@ function onedit(e) {
let position = ret[1];
if (line.innerText == '\n') {
line.className = 'mdnotes_line';
line.className = 'cheezenotes_line';
line.classList.add('body');
return;
}
let prevline = line.previousSibling;
if (prevline != null && prevline.innerText == '\n') {
prevline.className = 'mdnotes_line';
prevline.className = 'cheezenotes_line';
prevline.classList.add('body');
}
@ -84,35 +89,35 @@ function onkeydown(e) {
return false;
}
function onkeypress(e) {
function onkeyup(e) {
if (e.key !== 'Escape') {
return true;
return true;
}
e.preventDefault();
document.getElementById('mdnotes').blur();
if (saveButton.disabled == false) {
onsave();
}
return false;
e.preventDefault();
document.getElementById('cheezenotes').blur();
if (saveButton.disabled == false) {
onsave();
}
return false;
}
function onkeyup(e) {
function onkeypress(e) {
if (e.key !== 'Escape') {
return true;
}
e.preventDefault();
document.getElementById('mdnotes').blur();
if (saveButton.disabled == false) {
onsave();
}
return false;
e.preventDefault();
document.getElementById('cheezenotes').blur();
if (saveButton.disabled == false) {
onsave();
}
return false;
}
function onpaste(e) {
e.preventDefault();
timeoutSave();
let data = e.clipboardData.getData('text/plain');
appendData(document.getElementById('mdnotes'), data);
appendData(document.getElementById('cheezenotes'), data);
saveButton.disabled = false;
return false;
}
@ -123,11 +128,11 @@ function oncopy(e) {
function onlockbutton(e) {
let lockButton = document.getElementById('lockButton');
let mdnotes = document.getElementById('mdnotes');
let cheezenotes = document.getElementById('cheezenotes');
if (lockButton.checked) {
mdnotes.contentEditable = false;
cheezenotes.contentEditable = false;
} else {
mdnotes.contentEditable = true;
cheezenotes.contentEditable = true;
}
}
@ -147,21 +152,21 @@ function init(pagename = null) {
/*if (pagename != null) {
window.history.replaceState(null, '', '/page/' + pagename);
}*/
let mdnotesdiv = document.getElementById('mdnotes');
dpwidth(mdnotesdiv);
mdnotesdiv.addEventListener('input', onedit);
mdnotesdiv.addEventListener('keyup', onkeyup);
mdnotesdiv.addEventListener('keypress', onkeypress);
mdnotesdiv.addEventListener('keydown', onkeydown);
mdnotesdiv.addEventListener('paste', onpaste);
mdnotesdiv.addEventListener('copy', oncopy);
mdnotesdiv.addEventListener('blur', () => {redrawTables(mdnotesdiv); onsave()});
mdnotesdiv.addEventListener('focus', () => {redrawTables(mdnotesdiv, dpwidth());});
mdnotesdiv.addEventListener('drag', ondrag);
mdnotesdiv.addEventListener('dragenter', ondragenter);
mdnotesdiv.addEventListener('dragleave', ondragleave);
let cheezenotesdiv = document.getElementById('cheezenotes');
dpwidth(cheezenotesdiv);
cheezenotesdiv.addEventListener('input', onedit);
cheezenotesdiv.addEventListener('keyup', onkeyup);
cheezenotesdiv.addEventListener('keypress', onkeypress);
cheezenotesdiv.addEventListener('keydown', onkeydown);
cheezenotesdiv.addEventListener('paste', onpaste);
cheezenotesdiv.addEventListener('copy', oncopy);
cheezenotesdiv.addEventListener('blur', () => { redrawTables(cheezenotesdiv); onsave() });
cheezenotesdiv.addEventListener('focus', () => { redrawTables(cheezenotesdiv, dpwidth()); });
cheezenotesdiv.addEventListener('drag', ondrag);
cheezenotesdiv.addEventListener('dragenter', ondragenter);
cheezenotesdiv.addEventListener('dragleave', ondragleave);
let saveButton = document.getElementById('saveButton');
saveButton.disabled = true;

@ -80,16 +80,16 @@ function emsp() {
function onlinkin(e) {
let link = e.currentTarget;
if (document.getElementById('mdnotes') !== document.activeElement) {
document.getElementById('mdnotes').contentEditable = false;
if (document.getElementById('cheezenotes') !== document.activeElement) {
document.getElementById('cheezenotes').contentEditable = false;
}
}
function onlink(e) {
let mdnotes = document.getElementById('mdnotes');
if (mdnotes.contentEditable == 'false') {
let cheezenotes = document.getElementById('cheezenotes');
if (cheezenotes.contentEditable == 'false') {
e.preventDefault();
mdnotes.contentEditable = true;
cheezenotes.contentEditable = true;
let link = e.currentTarget;
if (link.host !== document.location.host) {
open(link.href);
@ -103,16 +103,16 @@ function onlink(e) {
}
function onlinkout(e) {
let mdnotes = document.getElementById('mdnotes');
if (mdnotes.contentEditable == 'false') {
mdnotes.contentEditable = true;
let cheezenotes = document.getElementById('cheezenotes');
if (cheezenotes.contentEditable == 'false') {
cheezenotes.contentEditable = true;
}
}
function formatLine(line) {
let token = null;
let elem = document.createElement('div');
elem.classList.add('mdnotes_line');
elem.classList.add('cheezenotes_line');
if (line == '' || line == '\n') {
elem.classList.add('body');
elem.innerHTML = '<br>';
@ -129,9 +129,15 @@ function formatLine(line) {
ret = removeLink(line);
console.log('removeLink ' + ret[0]);
if (line.match(/^\s*-{3,}\s*$/)) {
token = /^(\s*-{3,}\s*)$/
if (line.match(/^\s*_{3,}\s*$/)) {
token = /^(\s*_{3,}\s*)$/
elem.classList.add('line');
} else if (line.match(/^\s*######(\s|$)/i)) {
token = /^(\s*######(\s|$))/i;
elem.classList.add('h6');
} else if (line.match(/^\s*#####(\s|$)/i)) {
token = /^(\s*#####(\s|$))/i;
elem.classList.add('h5');
} else if (line.match(/^\s*####(\s|$)/i)) {
token = /^(\s*####(\s|$))/i;
elem.classList.add('h4');
@ -282,11 +288,11 @@ function addTableLine(line) {
return line;
}
function redrawTables(mdnotes, dpwidth = 0) {
if (mdnotes.childNodes.length == 0) {
function redrawTables(cheezenotes, dpwidth = 0) {
if (cheezenotes.childNodes.length == 0) {
return;
}
let child = mdnotes.childNodes[0];
let child = cheezenotes.childNodes[0];
let firsttableline = null;
while(child != null) {
if (firsttableline == null) {

@ -13,8 +13,8 @@
</head>
<body>
<div id="buttons"><button id="saveButton">💾</button> <input type="checkbox" id="taButton" /><label id="taButtonLabel" for="taButton">📋</label> <input type="checkbox" id="lockButton" /><label id="lockButtonLabel" for="lockButton">&#128065</label></div>
<div class="ta"><textarea id="ta" class="mdnotes" spellcheck="false">{{md}}</textarea></body><div>
<div id="mdnotes" class="mdnotes" contenteditable="true" spellcheck="false"></div>
<div class="ta"><textarea id="ta" class="cheezenotes" spellcheck="false">{{md}}</textarea></body><div>
<div id="cheezenotes" class="cheezenotes" contenteditable="true" spellcheck="false"></div>
<script type="module">
import { init } from '{{ root|safe }}static/modules/cheezenotes.js';

Loading…
Cancel
Save