diff --git a/static/blog-blanc&noir.css b/static/blog-blanc&noir.css index 273b37c..a72338e 100644 --- a/static/blog-blanc&noir.css +++ b/static/blog-blanc&noir.css @@ -118,11 +118,23 @@ ul { } + .text-article p { padding-left: 2vw; padding-right:2vw; } +.text-article pre { + padding-left: 2vw; + padding-right:2vw; +} + +.text-article blockquote { + padding-left: 2vw; + padding-right:2vw; +} + + .text-article h2, h3, h4, h5 { padding-left: 1vw; padding-right:1vw; diff --git a/static/blog-noir&blanc.css b/static/blog-noir&blanc.css index efe42c4..8e064ae 100644 --- a/static/blog-noir&blanc.css +++ b/static/blog-noir&blanc.css @@ -123,6 +123,16 @@ a { padding-right:2vw; } +.text-article pre { + padding-left: 2vw; + padding-right:2vw; +} + +.text-article blockquote { + padding-left: 2vw; + padding-right:2vw; +} + .text-article h2, h3, h4, h5 { padding-left: 1vw; padding-right:1vw; diff --git a/static/blog-orange&noir.css b/static/blog-orange&noir.css index 23c6e3d..3102f28 100644 --- a/static/blog-orange&noir.css +++ b/static/blog-orange&noir.css @@ -124,6 +124,16 @@ padding-right:2vw; } + .text-article pre { + padding-left: 2vw; + padding-right:2vw; +} + +.text-article blockquote { + padding-left: 2vw; + padding-right:2vw; +} + .text-article h2, h3, h4, h5 { padding-left: 1vw; padding-right:1vw; diff --git a/static/blog-orangina.css b/static/blog-orangina.css index bfe2e10..4a5d990 100644 --- a/static/blog-orangina.css +++ b/static/blog-orangina.css @@ -123,6 +123,16 @@ a { padding-right:2vw; } +.text-article pre { + padding-left: 2vw; + padding-right:2vw; +} + +.text-article blockquote { + padding-left: 2vw; + padding-right:2vw; +} + .text-article h2, h3, h4, h5 { padding-left: 1vw; padding-right:1vw; diff --git a/static/blog.css b/static/blog.css index f593a67..1d3853e 100644 --- a/static/blog.css +++ b/static/blog.css @@ -1,8 +1,7 @@ /* kitoy */ :root - { - + { --color-background: #202020; --color-title: #fdfdfd; --color-text: #dddddd; @@ -59,64 +58,64 @@ a { } - .date { - margin-bottom: 0; - } +.date { + margin-bottom: 0; +} - .slug { - //margin-left: 1rem; - text-align: left; - margin-bottom: 2rem; - } +.slug { + //margin-left: 1rem; + text-align: left; + margin-bottom: 2rem; +} - .readmore { - text-align: right; - } +.readmore { + text-align: right; +} - pre { - white-space: pre-wrap; /* css-3 */ - white-space: -moz-pre-wrap; /* Mozilla, since 1999 */ - white-space: -pre-wrap; /* Opera 4-6 */ - white-space: -o-pre-wrap; /* Opera 7 */ - word-wrap: break-word; /* Internet Explorer 5.5+ */ - } +pre { + white-space: pre-wrap; /* css-3 */ + white-space: -moz-pre-wrap; /* Mozilla, since 1999 */ + white-space: -pre-wrap; /* Opera 4-6 */ + white-space: -o-pre-wrap; /* Opera 7 */ + word-wrap: break-word; /* Internet Explorer 5.5+ */ +} - ul { - list-style-type: none; - margin: 0; - padding: 0; - } - +ul { + list-style-type: none; + margin: 0; + padding: 0; +} - .articles { - max-width: 80%; - margin-left: auto; - margin-right: auto; - margin-top: 5rem; - margin-bottom: 3rem; - padding:0.5em; - border: 7px double; - border-color: var(--text-color); - border-radius: 10px 10px 10px 10px; - line-height: 1.5; - letter-spacing: 0.1vw; - text-align: justify; - } - .articles ul { - list-style-type: disc; - margin: 5vw; - padding-top: 1vw; - padding-bottom: 1vw; - padding-left: 1.5vw; - } +.articles { + max-width: 80%; + margin-left: auto; + margin-right: auto; + margin-top: 5rem; + margin-bottom: 3rem; + padding:0.5em; + border: 7px double; + border-color: var(--text-color); + border-radius: 10px 10px 10px 10px; + line-height: 1.5; + letter-spacing: 0.1vw; + text-align: justify; +} + +.articles ul { + list-style-type: disc; + margin: 5vw; + padding-top: 1vw; + padding-bottom: 1vw; + padding-left: 1.5vw; +} .head-article { - text-align: center; - } + text-align: center; +} .text-article p { @@ -124,13 +123,23 @@ a { padding-right:2vw; } +.text-article pre { + padding-left: 2vw; + padding-right:2vw; +} + +.text-article blockquote { + padding-left: 2vw; + padding-right:2vw; +} + + .text-article h2, h3, h4, h5 { padding-left: 1vw; padding-right:1vw; - + } - .index { text-align: left; } @@ -141,52 +150,50 @@ a { margin-right: auto; width: 50%; margin-bottom: 2vw; - } - .articles .description { +.articles .description { font-weight: 300; font-style: italic; font-size: 1.5vw; padding-bottom: 30px; - color: ; - } +} - .pagination a { +.pagination a { border: 1px solid; border-color: $color_title; padding: 3px; font-size: 13px; } - .center { - margin: auto; - width: 50%; +.center { + margin: auto; + width: 50%; padding: 10px; +} + +.contact{ + text-align:center; } - .contact{ - text-align:center; - } - - footer { - position: relative; - bottom:0px; - width: 100%; - text-align:center; - padding-bottom:1vw; - } +footer { + position: relative; + bottom:0px; + width: 100%; + text-align:center; + padding-bottom:1vw; +} - @media only screen and (max-width: 980px) - { - - .articles .description { +@media only screen and (max-width: 980px) +{ + + .articles .description { font-size: 4vw; - } - + } + .articles { margin-left: auto; position: relative; diff --git a/static/code.css b/static/code.css new file mode 100644 index 0000000..4a82fbb --- /dev/null +++ b/static/code.css @@ -0,0 +1,79 @@ +pre { line-height: 125%; } +td.linenos .normal { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; } +span.linenos { color: inherit; background-color: transparent; padding-left: 5px; padding-right: 5px; } +td.linenos .special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; } +span.linenos.special { color: #000000; background-color: #ffffc0; padding-left: 5px; padding-right: 5px; } +.codehilite .hll { background-color: #ffffcc } +.codehilite { background-color: rgba(200,200,200,0.1); + margin: 2vw; + padding-bottom: 1vw; + padding-top: 1vw; + } +.codehilite .c { color: #3D7B7B; font-style: italic } /* Comment */ +.codehilite .err { border: 1px solid #F00 } /* Error */ +.codehilite .k { color: #008000; font-weight: bold } /* Keyword */ +.codehilite .o { color: #666 } /* Operator */ +.codehilite .ch { color: #3D7B7B; font-style: italic } /* Comment.Hashbang */ +.codehilite .cm { color: #3D7B7B; font-style: italic } /* Comment.Multiline */ +.codehilite .cp { color: #9C6500 } /* Comment.Preproc */ +.codehilite .cpf { color: #3D7B7B; font-style: italic } /* Comment.PreprocFile */ +.codehilite .c1 { color: #3D7B7B; font-style: italic } /* Comment.Single */ +.codehilite .cs { color: #3D7B7B; font-style: italic } /* Comment.Special */ +.codehilite .gd { color: #A00000 } /* Generic.Deleted */ +.codehilite .ge { font-style: italic } /* Generic.Emph */ +.codehilite .ges { font-weight: bold; font-style: italic } /* Generic.EmphStrong */ +.codehilite .gr { color: #E40000 } /* Generic.Error */ +.codehilite .gh { color: #077080; font-weight: bold } /* Generic.Heading */ +.codehilite .gi { color: #008400 } /* Generic.Inserted */ +.codehilite .go { color: #717171 } /* Generic.Output */ +.codehilite .gp { color: #077080; font-weight: bold } /* Generic.Prompt */ +.codehilite .gs { font-weight: bold } /* Generic.Strong */ +.codehilite .gu { color: #800080; font-weight: bold } /* Generic.Subheading */ +.codehilite .gt { color: #04D } /* Generic.Traceback */ +.codehilite .kc { color: #008000; font-weight: bold } /* Keyword.Constant */ +.codehilite .kd { color: #008000; font-weight: bold } /* Keyword.Declaration */ +.codehilite .kn { color: #008000; font-weight: bold } /* Keyword.Namespace */ +.codehilite .kp { color: #008000 } /* Keyword.Pseudo */ +.codehilite .kr { color: #008000; font-weight: bold } /* Keyword.Reserved */ +.codehilite .kt { color: #B00040 } /* Keyword.Type */ +.codehilite .m { color: #666 } /* Literal.Number */ +.codehilite .s { color: #BA2121 } /* Literal.String */ +.codehilite .na { color: #687822 } /* Name.Attribute */ +.codehilite .nb { color: #008000 } /* Name.Builtin */ +.codehilite .nc { color: #00F; font-weight: bold } /* Name.Class */ +.codehilite .no { color: #800 } /* Name.Constant */ +.codehilite .nd { color: #A2F } /* Name.Decorator */ +.codehilite .ni { color: #717171; font-weight: bold } /* Name.Entity */ +.codehilite .ne { color: #CB3F38; font-weight: bold } /* Name.Exception */ +.codehilite .nf { color: #00F } /* Name.Function */ +.codehilite .nl { color: #767600 } /* Name.Label */ +.codehilite .nn { color: #00F; font-weight: bold } /* Name.Namespace */ +.codehilite .nt { color: #008000; font-weight: bold } /* Name.Tag */ +.codehilite .nv { color: #79499C } /* Name.Variable */ +.codehilite .ow { color: #A2F; font-weight: bold } /* Operator.Word */ +.codehilite .w { color: #BBB } /* Text.Whitespace */ +.codehilite .mb { color: #666 } /* Literal.Number.Bin */ +.codehilite .mf { color: #666 } /* Literal.Number.Float */ +.codehilite .mh { color: #666 } /* Literal.Number.Hex */ +.codehilite .mi { color: #666 } /* Literal.Number.Integer */ +.codehilite .mo { color: #666 } /* Literal.Number.Oct */ +.codehilite .sa { color: #BA2121 } /* Literal.String.Affix */ +.codehilite .sb { color: #BA2121 } /* Literal.String.Backtick */ +.codehilite .sc { color: #BA2121 } /* Literal.String.Char */ +.codehilite .dl { color: #BA2121 } /* Literal.String.Delimiter */ +.codehilite .sd { color: #BA2121; font-style: italic } /* Literal.String.Doc */ +.codehilite .s2 { color: #BA2121 } /* Literal.String.Double */ +.codehilite .se { color: #AA5D1F; font-weight: bold } /* Literal.String.Escape */ +.codehilite .sh { color: #BA2121 } /* Literal.String.Heredoc */ +.codehilite .si { color: #A45A77; font-weight: bold } /* Literal.String.Interpol */ +.codehilite .sx { color: #008000 } /* Literal.String.Other */ +.codehilite .sr { color: #A45A77 } /* Literal.String.Regex */ +.codehilite .s1 { color: #BA2121 } /* Literal.String.Single */ +.codehilite .ss { color: #19177C } /* Literal.String.Symbol */ +.codehilite .bp { color: #008000 } /* Name.Builtin.Pseudo */ +.codehilite .fm { color: #00F } /* Name.Function.Magic */ +.codehilite .vc { color: #19177C } /* Name.Variable.Class */ +.codehilite .vg { color: #19177C } /* Name.Variable.Global */ +.codehilite .vi { color: #19177C } /* Name.Variable.Instance */ +.codehilite .vm { color: #19177C } /* Name.Variable.Magic */ +.codehilite .il { color: #666 } /* Literal.Number.Integer.Long */ diff --git a/static/pywallter.css b/static/pywallter.css index e6790e9..5884c8e 100644 --- a/static/pywallter.css +++ b/static/pywallter.css @@ -65,9 +65,10 @@ main > nav article { - text-align: center; - width: 30vw; - height: 35vw; + width: 44vw; + max-height: 35vw; + margin-left: auto; + margin-right: auto; } article > header { diff --git a/templates/blog.html b/templates/blog.html index 9788ba8..fefaad8 100644 --- a/templates/blog.html +++ b/templates/blog.html @@ -2,7 +2,7 @@ Article de {{ post_info.author }} - + diff --git a/templates/edit_article.html b/templates/edit_article.html index 955ead1..eb6eadf 100644 --- a/templates/edit_article.html +++ b/templates/edit_article.html @@ -7,11 +7,11 @@ {% block main %} -
+


- +
@@ -51,7 +51,8 @@ Publier cet article dans le blog général - +
+
@@ -59,5 +60,6 @@ {% block js %} {% include '_js_editor.html' %} +{% include '_js_htmx.html' %} {% endblock %} diff --git a/views/blog.py b/views/blog.py index c770db8..9819757 100644 --- a/views/blog.py +++ b/views/blog.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- -from flask import Blueprint, render_template, session, redirect, url_for, request, flash, abort, Flask +from flask import Blueprint, render_template, session, redirect, url_for, request, flash, abort, Flask, make_response import time from markupsafe import escape import sqlite3 @@ -24,6 +24,9 @@ DOSSIER_PERSO = app.config.get('DOSSIER_APP')+'/' DOSSIER_PUBLIC = app.config.get('DOSSIER_PUBLIC')+'/' TITLE_SERVER = app.config.get('TITLE_SERVER') DESC_SERVER = app.config.get('DESC_SERVER') +MARKDOWN_EXT=["extra", "toc", "codehilite", + "nl2br", "extra", "admonition", + "sane_lists", "smarty"] ################################################################################ @blog.route('/myblog/new-article/', methods=['GET', 'POST']) @@ -82,6 +85,28 @@ def edit(title): oldpost=post) +@blog.route('/myblog/update/', methods=['POST']) +@login_required +def update(title): + user='%s'% escape(session['username']) + folder_blog = DOSSIER_PERSO + user + "/blog/articles/" + newtitle = str(request.form['title']) + subtitle = str(request.form['subtitle']) + category = str(request.form['category']) + newcontent = str(request.form['content']) + newstatus = str(request.form['status']) + updated = time.strftime("%d/%m/%Y à %H:%M:%S") + conn = sqlite3.connect(DATABASE) + cursor = conn.cursor() + if 'blog-unified' in request.form.keys(): + newstatus = newstatus+'_unified' + + cursor.execute("""UPDATE Blog_posts SET title=?, subtitle=?, category=?, last_updated=?, status=?, content=? WHERE title=? AND author=?""", (newtitle, subtitle, category, updated, newstatus, newcontent, title, user)) + conn.commit() + conn.close() + response = """ <p class="center success" >Article mis à jour le """+ updated +""" .</p>""" + return response + @blog.route('/myblog/list-articles/', methods=['GET']) @login_required def list_articles_blog(): @@ -239,7 +264,7 @@ def viewauthorrss(author): if list_posts != None: last_build=last_article_date[0] for post in list_posts: - posts=[dict(title=post[0], subtitle=post[1], content=markdown(post[2]), creation_date=post[3], author=post[4], status=post[5])] + posts + posts=[dict(title=post[0], subtitle=post[1], content=markdown(post[2], extensions=MARKDOWN_EXT), creation_date=post[3], author=post[4], status=post[5])] + posts return render_template('blog_rss.xml', base_url=BASE_URL, @@ -261,7 +286,7 @@ def viewPrivateArticle(username, title): conn.close() if post != None: post_info = (dict(title=post[0], subtitle=post[1], creation_date=post[3], last_updated=post[4],author=post[5])) - content = markdown(post[2]) + content = markdown(post[2], extensions=MARKDOWN_EXT) return render_template('blog.html', post_info=post_info, content=content) else: return redirect(url_for('blog'), code=404) @@ -278,7 +303,7 @@ def viewArticle(username, title): conn.close() if post != None: post_info = (dict(title=post[0], subtitle=post[1], creation_date=post[3], last_updated=post[4],author=post[5])) - content= markdown(post[2]) + content= markdown(post[2], extensions=MARKDOWN_EXT) return render_template('blog.html', post_info=post_info, content=content) else: @@ -299,7 +324,7 @@ def viewrss(): if list_posts != None: last_build=last_article_date[0] for post in list_posts: - posts=[dict(title=post[0], subtitle=post[1], content=markdown(post[2]), creation_date=post[3], author=post[4], status=post[5])] + posts + posts=[dict(title=post[0], subtitle=post[1], content=markdown(post[2], extensions=MARKDOWN_EXT), creation_date=post[3], author=post[4], status=post[5])] + posts return render_template('blog_rss.xml', base_url=BASE_URL,