page comment option

pull/1/head
Yax 5 years ago
parent 6469c911cd
commit f8a10d9b70

@ -1,10 +1,64 @@
<div class="comment-detail">
<img src="https://www.gravatar.com/avatar/{{ avatar }}.jpg" style="float:left; margin-right:10px" height="32" width="32">
<div class="comment-body">
<span class="comment-author">{{ site_start }}{{ author }}{{ site_end }}</span>
</span><span> - {{ date }}</span>
<p>{{ content }}</p>
</div>
<div class="comment-separator"></div>
{{ comments }}
<div id="comment-form">
<strong>Votre commentaire</strong>
<form role="form" action="/newcomment" autocomplete="off" method="post">
<fieldset>
<input id="author" name="author" type="text" placeholder="Nom ou Surnom" required>
<input id="site" name="site" type="text" placeholder="Site Web">
<input style="display:none" id="email" name="email" type="text"
placeholder="Adresse email pour Gravatar (non publié)" onchange="grabatar()">
<img src="" id="gravatar" height="32" width="32" style="display:none">
<input class="hidden" id="token" name="token" type="text" placeholder="Blog"
value="{{ stacosys_token }}">
<input class="hidden" id="url" name="url" type="text" placeholder="Article"
value="/{{ post_url }}/">
<label class="remarque">Remarque</label>
<input class="remarque" name="remarque"
pattern="[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$"
placeholder="nom@domaine.com">
</fieldset>
<fieldset>
<textarea id="message" name="message" rows="4"
placeholder="Votre commentaire (texte simple ou Markdown)" required></textarea>
<div id="preview-container" style="display:none">
<p>Prévisualisation :</p>
<div id="preview" class="preview-markdown"></div>
</div>
</fieldset>
<fieldset>
<div>
<em>Le site Web est optionel</em><br>
<em>Le message peut être rédigé au format <a href="http://daringfireball.net/projects/markdown/"
target="_blank">Markdown</a></em>
</div>
<div id="helpgravatar" style="display:none">
<em>L'e-mail sert uniquement à retrouver votre <a href="https://fr.gravatar.com/">Gravatar</a></em>
</div>
</fieldset>
<button type="submit" class="button--primary">Envoyer</button>
<button id="markdown" style="display:none" onclick="preview_markdown(); return false"
class="button--info">Prévisualiser</button>
</form>
</div>
<script type="text/javascript"><!--
function grabatar() {
var gravatar = document.getElementById("gravatar");
var email = document.getElementById("email");
var md5avatar = md5(email.value);
gravatar.src = "http://www.gravatar.com/avatar/" + md5avatar + ".jpg";
email.value = md5avatar;
gravatar.style.display = '';
}
function showbonus() {
document.getElementById("email").style.display = '';
document.getElementById("markdown").style.display = '';
document.getElementById("helpgravatar").style.display = '';
}
window.onload = showbonus;
--></script>

@ -3,69 +3,6 @@
<p class="meta-post">{{ category_label}}<span>{{ friendly_date }}</span></p>
{{ content }}
<div class="comment-separator"></div>
{{ comments }}
<div id="comment-form">
<strong>Votre commentaire</strong>
<form role="form" action="/newcomment" autocomplete="off" method="post">
<fieldset>
<input id="author" name="author" type="text" placeholder="Nom ou Surnom" required>
<input id="site" name="site" type="text" placeholder="Site Web">
<input style="display:none" id="email" name="email" type="text"
placeholder="Adresse email pour Gravatar (non publié)" onchange="grabatar()">
<img src="" id="gravatar" height="32" width="32" style="display:none">
<input class="hidden" id="token" name="token" type="text" placeholder="Blog"
value="{{ stacosys_token }}">
<input class="hidden" id="url" name="url" type="text" placeholder="Article"
value="/{{ post_url }}/">
<label class="remarque">Remarque</label>
<input class="remarque" name="remarque"
pattern="[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,4}$"
placeholder="nom@domaine.com">
</fieldset>
<fieldset>
<textarea id="message" name="message" rows="4"
placeholder="Votre commentaire (texte simple ou Markdown)" required></textarea>
<div id="preview-container" style="display:none">
<p>Prévisualisation :</p>
<div id="preview" class="preview-markdown"></div>
</div>
</fieldset>
<fieldset>
<div>
<em>Le site Web est optionel</em><br>
<em>Le message peut être rédigé au format <a href="http://daringfireball.net/projects/markdown/"
target="_blank">Markdown</a></em>
</div>
<div id="helpgravatar" style="display:none">
<em>L'e-mail sert uniquement à retrouver votre <a href="https://fr.gravatar.com/">Gravatar</a></em>
</div>
</fieldset>
<button type="submit" class="button--primary">Envoyer</button>
<button id="markdown" style="display:none" onclick="preview_markdown(); return false"
class="button--info">Prévisualiser</button>
</form>
</div>
{{ comment }}
</div>
<script type="text/javascript"><!--
function grabatar() {
var gravatar = document.getElementById("gravatar");
var email = document.getElementById("email");
var md5avatar = md5(email.value);
gravatar.src = "http://www.gravatar.com/avatar/" + md5avatar + ".jpg";
email.value = md5avatar;
gravatar.style.display = '';
}
function showbonus() {
document.getElementById("email").style.display = '';
document.getElementById("markdown").style.display = '';
document.getElementById("helpgravatar").style.display = '';
}
window.onload = showbonus;
--></script>

@ -202,7 +202,7 @@ def get_friendly_date(date_str):
def make_posts(
src, src_pattern, dst, layout, category_layout, comment_layout, **params
src, src_pattern, dst, layout, category_layout, comment_layout, comment_detail_layout, **params
):
"""Generate posts from posts directory."""
items = []
@ -236,10 +236,18 @@ def make_posts(
tags = get_header_list_value("tag", page_params)
page_params["tags"] = tags
# stacosys comments
# comments
page_comment = page_params.get("comment", "yes")
if page_comment == "no":
is_page_comment_enabled = False
else:
is_page_comment_enabled = True
page_params["comment_count"] = 0
page_params["comments"] = ""
if params["stacosys_url"]:
page_params["comment"] = ""
if params["stacosys_url"] and is_page_comment_enabled:
req_url = params["stacosys_url"] + "/comments"
query_params = dict(
token=params["stacosys_token"], url="/" + page_params["post_url"] + "/"
@ -256,7 +264,7 @@ def make_posts(
site_start = ''
site_end = ''
out_comment = render(
comment_layout,
comment_detail_layout,
author=comment["author"],
avatar=comment.get("avatar", ""),
site_start=site_start,
@ -267,6 +275,7 @@ def make_posts(
out_comments.append(out_comment)
page_params["comments"] = "".join(out_comments)
page_params["comment_count"] = len(comments)
page_params["comment"] = render(comment_layout, **page_params)
content["year"] = page_params["year"]
content["post_url"] = page_params["post_url"]
@ -361,6 +370,7 @@ def main():
category_title_layout = fread("layout/category_title.html")
category_layout = fread("layout/category.html")
comment_layout = fread("layout/comment.html")
comment_detail_layout = fread("layout/comment-detail.html")
rss_xml = fread("layout/rss.xml")
rss_item_xml = fread("layout/rss_item.xml")
sitemap_xml = fread("layout/sitemap.xml")
@ -378,6 +388,7 @@ def main():
post_layout,
category_layout,
comment_layout,
comment_detail_layout,
**params
)

Loading…
Cancel
Save