Commit 544e8973 authored by Corentin Bettiol's avatar Corentin Bettiol 💻
Browse files

MAINT: use ParseDown to render markdown in blog posts & projects

The previous editor was a simple div that had contentEditable set to True and some small js code to create titles, images, center things....

It was too hard to type using this badly-created half-finished wysiwyg editor, so I switched to ParseDown.

Previous posts will render correctly since html code is saved with content in database, and new posts will only save markdown content, and will render to html only in views.

Less clicks, more typing, yay!
parent d2a3ae10
......@@ -190,7 +190,7 @@ a:hover{
display: inline-block;
}
input, textarea, .wysiwyg{
input, textarea{
width: 50%;
border: none;
padding: 10px;
......@@ -205,28 +205,10 @@ input, textarea, .wysiwyg{
transition: border-left 0.05s, padding-left 0.05s;
}
.input input, .input textarea, .wysiwyg{
.input input, .input textarea{
margin: 0 0 0 20px;
}
.wysiwyg{
display: flex;
align-items: center;
flex-direction: column;
}
.wysiwyg button{
border: none;
padding: 2px;
font-size: 1em;
margin: 0 2px;
cursor: pointer;
min-width: 20px;
text-align: center;
display: inline-block;
background-color: #ccc;
}
input:hover, input:focus, textarea:hover, textarea:focus{
border-left: 3px solid #ccc;
......@@ -268,6 +250,10 @@ form .small{
justify-content: center;
}
#inputContent{
height: 15em;
}
#listAdmin{
display: flex;
flex-wrap: wrap;
......@@ -506,7 +492,7 @@ Media Queries
}
@media all and (max-width: 700px){
input, textarea, label, #editContent, .wysiwyg{
input, textarea, label, #editContent{
width: 100%;
}
......@@ -663,12 +649,3 @@ Fonts
font-display: swap;
src: url('../fonts/sharetechmono.woff2')
}
.sticky_wysiwyg{
position: sticky;
top: 0;
background-color: rgba(255,255,255,0.7);
padding: 5px;
width: 100%;
text-align: center;
}
*{color:#1f1f2e}#page{padding:0;width:100%;margin:auto;font-size:1.5em;font-family:sans-serif;background-color:#ddd}#header{padding:2px;display:flex;flex-direction:row;align-items:center;font-family:sharetechmono;font-weight:700;background-color:#f0f0f0;border-bottom:5px solid #aaa;justify-content:space-between}#pageTitle,article h3,article h4,article p,article pre,article ul{width:90%;max-width:1000px;margin:30px auto}hr{width:50%;height:3px;border:none;background-color:#aaa}.input{width:90%;margin:30px auto}.covercontainer section,.simple section{width:100%;max-width:800px;margin:auto}#logo,h1{vertical-align:middle;width:auto;margin:auto;display:flex}#logo{width:45px;height:45px;margin-right:15px}#title{width:auto;margin:auto;display:flex;color:#2e2e2e;text-shadow:0 0 3px #69f}#menu{margin:auto}h2{margin:0;padding:0;font-size:1.5em;max-width:280px;overflow:hidden;font-weight:400;white-space:nowrap;display:inline-block;text-overflow:ellipsis}h3 a{text-decoration:none;text-align:center;display:block;background-color:rgba(200,200,200,.9);transition:background-color .8s,text-shadow .3s,box-shadow .3s,color .3s;padding:5px;border-radius:5px}h3 a:hover{color:#1f1f2e;background-color:rgba(200,200,200,.3);box-shadow:0 0 10px 10px rgba(200,200,200,.3);text-shadow:0 0 8px #c8c8ff,0 0 2px #c8c8ff;transition:background-color .3s,text-shadow .3s,box-shadow .2s,color .3s}#listMenu{padding:0;display:flex;margin:15px 0;flex-wrap:wrap;flex-direction:row;list-style-type:none;justify-content:space-around}#listMenu a{padding:7px;margin:10px;text-decoration:none;border-bottom:0 solid #888;transition:color .2s,background-color .2s,padding .1s,border-bottom .1s}#listMenu h2:hover{padding-bottom:5px}#listMenu a:hover{color:#47476b;padding-bottom:0;border-bottom:5px solid #aaa;background-color:#f0f0f0;transition:color .2s,background-color .2s,padding .1s}article{margin:20px 0;padding:5px 15px;overflow-wrap:anywhere;background-color:#f0f0f0;border-bottom:3px solid #aaa}#listMenu h2{padding-bottom:5px}#listMenu .selected{padding-bottom:0;border-bottom:5px solid #aaa}article .postInfos{box-sizing:border-box;margin-bottom:0;padding:10px;font-size:.8em}.covercontainer .postInfos{background-color:rgba(240,240,240,.6);box-shadow:0 0 5px 3px rgba(240,240,240,.6)}#footer{width:98%;padding:1%;margin:auto;font-size:.8em;text-align:center;background-color:#f0f0f0}a{transition:color .3s}a:hover{color:#55a;transition:color .3s}#editContent{width:100%;margin-top:5px;min-height:15em;overflow:scroll;resize:both;white-space:pre-wrap;display:inline-block}.wysiwyg,input,textarea{width:50%;border:none;padding:10px;display:block;font-size:1em;margin:15px auto;padding-left:13px;box-sizing:border-box;background-color:#fff;border-left:0 solid #ccc;border-bottom:3px solid #aaa;transition:border-left 50ms,padding-left 50ms}.input input,.input textarea,.wysiwyg{margin:0 0 0 20px}.wysiwyg{display:flex;align-items:center;flex-direction:column}.wysiwyg button{border:none;padding:2px;font-size:1em;margin:0 2px;cursor:pointer;min-width:20px;text-align:center;display:inline-block;background-color:#ccc}input:focus,input:hover,textarea:focus,textarea:hover{border-left:3px solid #ccc;transition:border-left 50ms}input[type=submit]{border:none;padding-left:13px;background-color:#ccc;transition:background-color .3s}input[type=submit]:hover{background-color:#ddd;transition:background-color .3s}label{width:250px;padding:10px;display:inline-block;background-color:#d9d9d9}label .large{width:300px}form .small{font-size:.7em}.input{display:flex;flex-wrap:wrap;align-items:flex-start;justify-content:center}#listAdmin{display:flex;flex-wrap:wrap;margin:auto}#listAdmin article{flex:50%;box-sizing:border-box}#listAdmin h3{margin:auto;text-align:center}#listAdmin article:first-child{border-right:5px solid #ccc}.listAdmin{display:flex;align-items:center;justify-content:space-evenly}.listAdmin b{width:50%;display:inline-block;border-right:1px solid #ccc}.listAdmin span{padding:3px}.postInfos{width:100%}.button{padding:5px;margin-left:2px;text-decoration:none;background-color:#d9d9d9;transition:background-color .3s,color .3s}.button:hover{background-color:#f0f0f0;transition:background-color .3s,color .3s}#toggle,.nav-label{height:0;display:none;background-color:#f0f0f0}.paging{width:80%;display:flex;max-width:400px;font-size:1.5em;margin:20px auto;font-family:monospace;justify-content:space-around}.paging a,.paging em{width:30px}.paging span{width:46px}.paging a,.paging em{margin:3px;padding:5px;text-align:center}.paging a{text-decoration:none;background-color:rgba(240,240,240,.8);border-bottom:0 solid rgba(12,12,12,.4);transition:border-bottom .1s,padding-bottom .1s}.paging a:hover{padding-bottom:0;border-bottom-width:5px;transition:border-bottom .1s,padding-bottom .1s}.paging em{color:rgba(12,12,12,.5)}.paging .current{opacity:1;background-color:#ccc}.alignleft{text-align:left}.aligncenter{text-align:center}.alignright{text-align:right}.tag{margin:0 3px}.tag a{margin:2px;padding:2px 7px;text-decoration:none;background-color:#ddd;transition:background-color .2s}.tag a:hover{background-color:#f0f0f0;transition:background-color .2s}img:not(.coverImg){max-width:75%}pre{background-color:#ddd;border-left:5px solid #b5b5b5;white-space:pre-wrap}code{margin:5px}.covercontainer{padding:0;overflow:hidden}.cover{min-height:305px;position:relative;overflow:hidden}.cover img{right:-800px;left:-800px;bottom:0;min-width:100%;top:0;max-height:100%;overflow:hidden;margin:auto}.cover .postInfos,.cover h3,.cover img{position:absolute}.cover h3{top:40%;right:0;left:0}.cover .postInfos{bottom:0}#listAdmin{width:90%}li{line-height:1.8em}@media all and (max-width:1500px){*{font-size:.9em}#title{font-size:1.3em;justify-content:space-around}#header{font-size:1.2em}.cover h3{width:60%}}@media all and (max-width:1075px){#header,#title{padding-top:5px;flex-direction:column}#title{margin:0;text-align:center}#logo{width:auto;height:auto;margin:auto}.cover h3{top:45%}}@media all and (max-width:700px){#editContent,.wysiwyg,input,label,textarea{width:100%}label{margin-right:20px}#menu{width:100%}#listMenu{flex-direction:column;justify-content:center}#listMenu a{overflow:hidden;white-space:nowrap;text-overflow:ellipsis}#listMenu a,#listMenu h2,#listMenu li{padding:0;width:90%;display:block;margin:2px auto;text-align:center}#listMenu a:hover{padding-bottom:2px}.cover{min-height:250px}.cover h3{width:90%}}@media all and (max-width:500px){article{padding:5px}#logo{width:45px;height:45px}#header{margin-top:30px}#toggle{left:-9999px;position:absolute}.nav-label{top:0;padding:0;width:50px;height:50px;opacity:.6;position:fixed;display:inline-block;background-size:50px 50px;background-size:50px 50px;transition:transform .3s ease;background-image:url(/img/mobile-menu-icon.png)}#listMenu{top:0;width:100%;margin:auto;position:fixed;background-color:#f0f0f0;transition:border-bottom .3s}#listMenu li{max-height:0;margin:0 auto;transition:max-height .45s}#listMenu a{opacity:0;padding:0;max-height:0;overflow:hidden;transition:max-height .3s ease,opacity .3s,padding .3s}#listMenu a:hover{padding:0;border-bottom:0}#listMenu .selected{padding:0;opacity:.5;max-height:300px;border-bottom:0 solid #000}#listMenu .selected:hover{padding:0;border-bottom:0 solid #000}#toggle:checked~#listMenu{border-bottom:5px solid #aaa;transition:border-bottom .3s}#toggle:checked~#listMenu li{max-height:300px;transition:max-height .45s}#toggle:checked~#listMenu a{opacity:1;padding:3px 0;max-height:300px;transition:max-height .3s,opacity .3s,padding .3s}#toggle:checked~.nav-label{transform:rotate(180deg);background-size:50px 50px;transition:transform .3s ease;background-image:url(/img/mobile-menu-icon-close.png)}#toggle:checked~#listMenu .selected{background-color:#ccc}}@font-face{font-family:sharetechmono;font-display:swap;src:url(../fonts/sharetechmono.woff2)}.sticky_wysiwyg{position:sticky;top:0;background-color:rgba(255,255,255,.7);padding:5px;width:100%;text-align:center}
\ No newline at end of file
*{color:#1f1f2e}#page{padding:0;width:100%;margin:auto;font-size:1.5em;font-family:sans-serif;background-color:#ddd}#header{padding:2px;display:flex;flex-direction:row;align-items:center;font-family:sharetechmono;font-weight:700;background-color:#f0f0f0;border-bottom:5px solid #aaa;justify-content:space-between}#pageTitle,article h3,article h4,article p,article pre,article ul{width:90%;max-width:1000px;margin:30px auto}hr{width:50%;height:3px;border:none;background-color:#aaa}.input{width:90%;margin:30px auto}.covercontainer section,.simple section{width:100%;max-width:800px;margin:auto}#logo,h1{vertical-align:middle;width:auto;margin:auto;display:flex}#logo{width:45px;height:45px;margin-right:15px}#title{width:auto;margin:auto;display:flex;color:#2e2e2e;text-shadow:0 0 3px #69f}#menu{margin:auto}h2{margin:0;padding:0;font-size:1.5em;max-width:280px;overflow:hidden;font-weight:400;white-space:nowrap;display:inline-block;text-overflow:ellipsis}h3 a{text-decoration:none;text-align:center;display:block;background-color:rgba(200,200,200,.9);transition:background-color .8s,text-shadow .3s,box-shadow .3s,color .3s;padding:5px;border-radius:5px}h3 a:hover{color:#1f1f2e;background-color:rgba(200,200,200,.3);box-shadow:0 0 10px 10px rgba(200,200,200,.3);text-shadow:0 0 8px #c8c8ff,0 0 2px #c8c8ff;transition:background-color .3s,text-shadow .3s,box-shadow .2s,color .3s}#listMenu{padding:0;display:flex;margin:15px 0;flex-wrap:wrap;flex-direction:row;list-style-type:none;justify-content:space-around}#listMenu a{padding:7px;margin:10px;text-decoration:none;border-bottom:0 solid #888;transition:color .2s,background-color .2s,padding .1s,border-bottom .1s}#listMenu h2:hover{padding-bottom:5px}#listMenu a:hover{color:#47476b;padding-bottom:0;border-bottom:5px solid #aaa;background-color:#f0f0f0;transition:color .2s,background-color .2s,padding .1s}article{margin:20px 0;padding:5px 15px;overflow-wrap:anywhere;background-color:#f0f0f0;border-bottom:3px solid #aaa}#listMenu h2{padding-bottom:5px}#listMenu .selected{padding-bottom:0;border-bottom:5px solid #aaa}article .postInfos{box-sizing:border-box;margin-bottom:0;padding:10px;font-size:.8em}.covercontainer .postInfos{background-color:rgba(240,240,240,.6);box-shadow:0 0 5px 3px rgba(240,240,240,.6)}#footer{width:98%;padding:1%;margin:auto;font-size:.8em;text-align:center;background-color:#f0f0f0}a{transition:color .3s}a:hover{color:#55a;transition:color .3s}#editContent{width:100%;margin-top:5px;min-height:15em;overflow:scroll;resize:both;white-space:pre-wrap;display:inline-block}input,textarea{width:50%;border:none;padding:10px;display:block;font-size:1em;margin:15px auto;padding-left:13px;box-sizing:border-box;background-color:#fff;border-left:0 solid #ccc;border-bottom:3px solid #aaa;transition:border-left 50ms,padding-left 50ms}.input input,.input textarea{margin:0 0 0 20px}input:focus,input:hover,textarea:focus,textarea:hover{border-left:3px solid #ccc;transition:border-left 50ms}input[type=submit]{border:none;padding-left:13px;background-color:#ccc;transition:background-color .3s}input[type=submit]:hover{background-color:#ddd;transition:background-color .3s}label{width:250px;padding:10px;display:inline-block;background-color:#d9d9d9}label .large{width:300px}form .small{font-size:.7em}.input{display:flex;flex-wrap:wrap;align-items:flex-start;justify-content:center}#inputContent{height:15em}#listAdmin{display:flex;flex-wrap:wrap;margin:auto}#listAdmin article{flex:50%;box-sizing:border-box}#listAdmin h3{margin:auto;text-align:center}#listAdmin article:first-child{border-right:5px solid #ccc}.listAdmin{display:flex;align-items:center;justify-content:space-evenly}.listAdmin b{width:50%;display:inline-block;border-right:1px solid #ccc}.listAdmin span{padding:3px}.postInfos{width:100%}.button{padding:5px;margin-left:2px;text-decoration:none;background-color:#d9d9d9;transition:background-color .3s,color .3s}.button:hover{background-color:#f0f0f0;transition:background-color .3s,color .3s}#toggle,.nav-label{height:0;display:none;background-color:#f0f0f0}.paging{width:80%;display:flex;max-width:400px;font-size:1.5em;margin:20px auto;font-family:monospace;justify-content:space-around}.paging a,.paging em{width:30px}.paging span{width:46px}.paging a,.paging em{margin:3px;padding:5px;text-align:center}.paging a{text-decoration:none;background-color:rgba(240,240,240,.8);border-bottom:0 solid rgba(12,12,12,.4);transition:border-bottom .1s,padding-bottom .1s}.paging a:hover{padding-bottom:0;border-bottom-width:5px;transition:border-bottom .1s,padding-bottom .1s}.paging em{color:rgba(12,12,12,.5)}.paging .current{opacity:1;background-color:#ccc}.alignleft{text-align:left}.aligncenter{text-align:center}.alignright{text-align:right}.tag{margin:0 3px}.tag a{margin:2px;padding:2px 7px;text-decoration:none;background-color:#ddd;transition:background-color .2s}.tag a:hover{background-color:#f0f0f0;transition:background-color .2s}img:not(.coverImg){max-width:75%}pre{background-color:#ddd;border-left:5px solid #b5b5b5;white-space:pre-wrap}code{margin:5px}.covercontainer{padding:0;overflow:hidden}.cover{min-height:305px;position:relative;overflow:hidden}.cover img{right:-800px;left:-800px;bottom:0;min-width:100%;top:0;max-height:100%;overflow:hidden;margin:auto}.cover .postInfos,.cover h3,.cover img{position:absolute}.cover h3{top:40%;right:0;left:0}.cover .postInfos{bottom:0}#listAdmin{width:90%}li{line-height:1.8em}@media all and (max-width:1500px){*{font-size:.9em}#title{font-size:1.3em;justify-content:space-around}#header{font-size:1.2em}.cover h3{width:60%}}@media all and (max-width:1075px){#header,#title{padding-top:5px;flex-direction:column}#title{margin:0;text-align:center}#logo{width:auto;height:auto;margin:auto}.cover h3{top:45%}}@media all and (max-width:700px){#editContent,input,label,textarea{width:100%}label{margin-right:20px}#menu{width:100%}#listMenu{flex-direction:column;justify-content:center}#listMenu a{overflow:hidden;white-space:nowrap;text-overflow:ellipsis}#listMenu a,#listMenu h2,#listMenu li{padding:0;width:90%;display:block;margin:2px auto;text-align:center}#listMenu a:hover{padding-bottom:2px}.cover{min-height:250px}.cover h3{width:90%}}@media all and (max-width:500px){article{padding:5px}#logo{width:45px;height:45px}#header{margin-top:30px}#toggle{left:-9999px;position:absolute}.nav-label{top:0;padding:0;width:50px;height:50px;opacity:.6;position:fixed;display:inline-block;background-size:50px 50px;background-size:50px 50px;transition:transform .3s ease;background-image:url('/img/mobile-menu-icon.png')}#listMenu{top:0;width:100%;margin:auto;position:fixed;background-color:#f0f0f0;transition:border-bottom .3s}#listMenu li{max-height:0;margin:0 auto;transition:max-height .45s}#listMenu a{opacity:0;padding:0;max-height:0;overflow:hidden;transition:max-height .3s ease,opacity .3s,padding .3s}#listMenu a:hover{padding:0;border-bottom:0}#listMenu .selected{padding:0;opacity:.5;max-height:300px;border-bottom:0 solid #000}#listMenu .selected:hover{padding:0;border-bottom:0 solid #000}#toggle:checked~#listMenu{border-bottom:5px solid #aaa;transition:border-bottom .3s}#toggle:checked~#listMenu li{max-height:300px;transition:max-height .45s}#toggle:checked~#listMenu a{opacity:1;padding:3px 0;max-height:300px;transition:max-height .3s,opacity .3s,padding .3s}#toggle:checked~.nav-label{transform:rotate(180deg);background-size:50px 50px;transition:transform .3s ease;background-image:url('/img/mobile-menu-icon-close.png')}#toggle:checked~#listMenu .selected{background-color:#ccc}}@font-face{font-family:sharetechmono;font-display:swap;src:url('../fonts/sharetechmono.woff2')}
\ No newline at end of file
// vous voulez du code sale ?
let textarea = document.getElementById("inputContent");
let div = document.getElementById("editContent");
div.oninput = (e) => update("text");
textarea.oninput = (e) => update("div");
textarea.value = div.innerHTML;
document.execCommand('defaultParagraphSeparator', false, 'p');
function update(whichOneIsTheOneToUpdate){
if(whichOneIsTheOneToUpdate == "text"){
console.log(div.innerHTML);
textarea.value = div.innerHTML;
}
else if(whichOneIsTheOneToUpdate == "div")
div.innerHTML = textarea.value;
}
function isOrContains(node, container) {
while (node) {
if (node === container) {
return true;
}
node = node.parentNode;
}
return false;
}
function wysiwyg_selection(){
let sel = window.getSelection();
return isOrContains(sel.getRangeAt(0).commonAncestorContainer, div);
}
function wysiwyg_sel_length(){
return window.getSelection().toString().length;
}
// les remplacements intéressants
function wysiwyg_link(){
let link = prompt("Entrez l'adresse du lien.");
let t = window.getSelection();
if(wysiwyg_selection()){
// si du texte est sélectionné
if(t.toString().length != 0){
t = t.getRangeAt(0);
// on crée un lien autours de la sélection
let l = document.createElement("a");
l.href = link;
t.surroundContents(l);
}
// sinon on demande d'entrer le texte à afficher, puis on le poste à la fin de l'article
else{
let txt = prompt("Entrez le texte à afficher.");
if(!txt)
txt = link;
let l = document.createElement("a");
l.href = link;
l.innerHTML = txt;
div.appendChild(l);
}
update("text");
}
}
function wysiwyg(txt){
if(wysiwyg_selection() && wysiwyg_sel_length() > 1){
let t = window.getSelection().getRangeAt(0);
t.surroundContents(document.createElement(txt));
update("text");
}
}
function wysiwyg_title(){
if(wysiwyg_selection() && wysiwyg_sel_length() > 1){
let t = window.getSelection().anchorNode.parentNode;
t.outerHTML = "<h4>"+ window.getSelection() +"</h4>";
update("text");
}
}
function wysiwyg_img(){
let src = prompt("Entrez l'adresse de l'image.");
let desc = prompt("Entrez la description de l'image.");
let t = window.getSelection();
// si on a un point d'encrage dans la div
if(wysiwyg_selection()){
if(t.toString().length == 0){
t = t.getRangeAt(0);
let l = document.createElement("img");
l.src = src;
l.alt = desc;
t.surroundContents(l);
update("text");
}
}
}
function wysiwyg_align(position){
if(wysiwyg_selection()){
let t = window.getSelection().anchorNode;
// si c'est une image
if(t.childNodes[0] != null && t.childNodes[0].nodeName == "IMG"){
// on aligne le parent de l'image (un <p> en général)
t.childNodes[0].parentNode.className = position;
}
// sinon, si c'est pas la div d'édition
if(t.parentElement.id != "editContent")
// on aligne l'élément sélectionné
t.parentElement.className = position;
update("text");
}
}
function wysiwyg_list(){
if(wysiwyg_selection()){
let t = window.getSelection().getRangeAt(0);
t.surroundContents(document.createElement("li"));
let parent = document.createElement("ul");
parent.appendChild(t.extractContents());
t.commonAncestorContainer.appendChild(parent);
update("text");
}
}
function wysiwyg_code(){
if(wysiwyg_selection()){
let t = window.getSelection().getRangeAt(0);
t.surroundContents(document.createElement("code"));
let parent = document.createElement("pre");
parent.appendChild(t.extractContents());
t.commonAncestorContainer.appendChild(parent);
update("text");
}
}
\ No newline at end of file
The MIT License (MIT)
Copyright (c) 2013-2018 Emanuil Rusev, erusev.com
Permission is hereby granted, free of charge, to any person obtaining a copy of
this software and associated documentation files (the "Software"), to deal in
the Software without restriction, including without limitation the rights to
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
the Software, and to permit persons to whom the Software is furnished to do so,
subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
This diff is collapsed.
......@@ -15,8 +15,8 @@ class BlogManager extends Base
$this->title = htmlspecialchars($title);
$this->cover = $cover;
$this->offset = intval($offset);
$this->content = htmlspecialchars($content);
$this->shortContent = htmlspecialchars($shortContent);
$this->content = $content;
$this->shortContent = $shortContent;
$this->id = htmlspecialchars($id);
$this->tags = htmlspecialchars($tags);
}
......@@ -28,6 +28,7 @@ class BlogManager extends Base
// si on tente d'accéder à une page qui ne comporte aucun article (genre la page 2 lol)
// la blague du commentaire précédent vous est présentée par "le site de dev qui comporte 4 posts tout au plus"
// blague obsolète lol
if($req->rowCount() == 0 && $page != 1)
header('Location:/');
......@@ -151,7 +152,7 @@ class BlogManager extends Base
// on enlève les vieux tags
$tag->deleteTag($this->id);
// on ajout les nouveaux
// on ajoute les nouveaux
$tag->addTag($this->tags, $this->id);
}
......
......@@ -9,14 +9,15 @@ class ProjectManager extends Base
function __construct($name, $link, $cover, $offset, $src, $content, $shortContent, $id)
{
parent::__construct(); // like antibiotics
$this->name = htmlspecialchars($name);
$this->link = htmlspecialchars($link);
$this->cover = $cover;
$this->offset = intval($offset);
$this->src = $src;
$this->content = htmlspecialchars($content);
$this->shortContent = htmlspecialchars($shortContent);
$this->content = $content;
$this->shortContent = $shortContent;
$this->id = htmlspecialchars($id);
}
......
......@@ -25,11 +25,6 @@
</p>
</section>
<section class="input">
<label for="inputCoverOffset">Offset de la cover:</label>
<input type="number" name="offset" placeholder="(en % de vh)" id="inputCoverOffset" />
</section>
<section class="input">
<label for="inputCoverSrc">Source de la cover:</label>
<input type="text" name="src" placeholder="Description de la cover" id="inputCoverSrc" />
......@@ -49,17 +44,10 @@
<label for="inputTags">Tags</label>
<textarea name="tags" id="inputTags"></textarea>
</section>
<section class="input">
<label for="inputContent">Contenu (code)</label>
<textarea name="content" id="inputContent"></textarea>
</section>
<section class="input">
<label for="editContent">Contenu</label>
<article class="wysiwyg">
<?php require("wysiwyg.php"); ?>
</article>
<label for="inputContent">Contenu</label>
<textarea name="content" id="inputContent"></textarea>
</section>
<input type="submit" value="Envoyer" />
......
......@@ -46,17 +46,10 @@
</section>
<section class="input">
<label for="inputContent">Description (code)</label>
<label for="inputContent">Description</label>
<textarea name="content" id="inputContent"></textarea>
</section>
<section class="input">
<label for="editContent">Description</label>
<article class="wysiwyg">
<?php require("wysiwyg.php"); ?>
</article>
</section>
<input type="submit" value="Envoyer" />
</form>
......
......@@ -46,17 +46,10 @@
</article>
<section class="input">
<label for="inputContent">Description (code)</label>
<label for="inputContent">Description</label>
<textarea name="content" id="inputContent"><?php echo $project['content']; ?></textarea>
</section>
<section class="input">
<label for="editContent">Description</label>
<article class="wysiwyg">
<?php require("wysiwyg.php"); ?>
</article>
</section>
<input type="submit" value="Éditer" />
</form>
......
......@@ -63,17 +63,10 @@
</section>
<article class="input">
<label for="inputContent">Contenu (code)</label>
<label for="inputContent">Contenu</label>
<textarea name="content" id="inputContent"><?php echo $blogpost['content']; ?></textarea>
</article>
<section class="input">
<label for="editContent">Contenu</label>
<article class="wysiwyg">
<?php require("wysiwyg.php"); ?>
</article>
</section>
<input type="submit" value="Éditer" />
</form>
......
<div class="sticky_wysiwyg">
<button type="button" onclick="wysiwyg('h4')" title="title">📌</button>
<button type="button" onclick="wysiwyg('b')" title="bold"><b>B</b></button>
<button type="button" onclick="wysiwyg('i')" title="italic"><i>i</i></button>
<button type="button" onclick="wysiwyg('u')" title="underline"><u>U</u></button>
<button type="button" onclick="wysiwyg_img()" title="image">📷</button>
<button type="button" onclick="wysiwyg_align('alignleft')" title="align left"></button>
<button type="button" onclick="wysiwyg_align('aligncenter')" title="center"></button>
<button type="button" onclick="wysiwyg_align('alignright')" title="align right"></button>
<button type="button" onclick="wysiwyg_list()" title="list">📋</button>
<button type="button" onclick="wysiwyg_link()" title="link">🔗</button>
<button type="button" onclick="wysiwyg_code()" title="code">🎲</button>
</div>
<?php if(isset($blogpost)) { ?>
<div id="editContent" contentEditable="true"><?php echo htmlspecialchars_decode($blogpost['content']); ?></div>
<?php } else if(isset($project)) { ?>
<div id="editContent" contentEditable="true"><?php echo htmlspecialchars_decode($project['content']); ?></div>
<?php } else { ?>
<div id="editContent" contentEditable="true"><p>Text</p></div>
<?php } ?>
......@@ -6,6 +6,9 @@
exit();
}
require_once('site/libs/Parsedown.php');
$parsed = new Parsedown();
// liste des tags
$tags = "";
if(isset($blogpost['tags']) && $blogpost['tags'])
......@@ -43,10 +46,10 @@
<?php
// si on est sur un post de blog (et pas sur une page listant des posts de blog) on affiche l'article
if(isset($_GET['action']) && $_GET['action'] == 'blog' && !isset($_GET['page']))
echo htmlspecialchars_decode($blogpost['content']);
echo $parsed->text($blogpost['content']);
// sinon si on est sur l'accueil ou sur une page listant des posts de blog on affiche le résumé
else
echo "<p>". nl2br($blogpost['shortContent']) ."</p>";
echo $parsed->text($blogpost['shortContent']);
?>
</section>
</article>
<article>
<h3>18/01/2022</h3>
<ul>
<li>Passage au markdown pour la rédaction du contenu, affichage via la lib <a href="https://github.com/erusev/parsedown">Parsedown</a>.</li>
<li><b>À partir de maintenant (depuis plusieurs (dizaines) de mois en fait), je ne pense plus éditer ce fichier. Les logs (moches) restent consultables sur <a href="https://git.bitmycode.com/sodimel/l3m-website/-/commits/master/">le repo</a>.</b></li>
</ul>
</article>
<article>
<h3>XX/XX/2021</h3>
<ul>
<li>Quelques petites màj d'optimisation :
<ul>
<li>MAINT: update projects : add external project link in post infos, replace link in project title</li>
<li>MAINT: replace cover bg by img tag & add lazy load</li>
<li>FEAT: wysiwyg buttons are now sticky</li>
<li>MAINT: update robots.txt to disallow jetsli.de crawler</li>
</ul>
</li>
</ul>
</article>
<article>
<h3>22/05/2021</h3>
<ul>
......
......@@ -4,6 +4,9 @@
exit();
}
require_once('site/libs/Parsedown.php');
$parsed = new Parsedown();
// thx https://iovs.arvojournals.org/article.aspx?articleid=2166061
// french = 249 wpm
$nbwords = str_word_count($project['content']);
......@@ -23,6 +26,6 @@
</p>
</section>
<?php
echo htmlspecialchars_decode($project['content']);
echo $parsed->text($project['content']);
?>
</article>
......@@ -4,6 +4,9 @@
exit();
}
require_once('site/libs/Parsedown.php');
$parsed = new Parsedown();
foreach ($projects as $project){
$exist = true;
......@@ -25,7 +28,7 @@
</p>
</section>
<p>
<?php echo $project['shortContent']; ?>
<?php echo $parsed->text($project['shortContent']); ?>
</p>
<p>
<span class="postInfos"><a href="/project/<?php echo $project['slug']; ?>">Lire la suite.</a></span>
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment