Adding gravatar support and nice time display, and classes and div's for

customizing comment formatting.
This commit is contained in:
leetNightshade 2018-06-29 17:06:21 -07:00
parent 43a70fe64a
commit 94134e2575
2 changed files with 151 additions and 122 deletions

View File

@ -14,8 +14,8 @@ de:
EMAIL_FOOTER: ''
NAME: Name:
EMAIL: Email:
WRITTEN_ON: geschrieben am
BY: von
WRITTEN_ON: am
BY: Von
NAME_LABEL: "Name"
NAME_PLACEHOLDER: "Namen eingeben"
EMAIL_LABEL: "Email"
@ -44,8 +44,8 @@ en:
EMAIL_FOOTER: ''
NAME: Name:
EMAIL: Email:
WRITTEN_ON: Written on
BY: by
WRITTEN_ON: on
BY: By
NAME_LABEL: "Name"
NAME_PLACEHOLDER: "Enter your name"
EMAIL_LABEL: "Email"
@ -74,8 +74,8 @@ es:
EMAIL_FOOTER: ''
NAME: Nombre:
EMAIL: Email:
WRITTEN_ON: Escrito en
BY: por
WRITTEN_ON: en
BY: Por
NAME_LABEL: "Nombre"
NAME_PLACEHOLDER: "Escriba su nombre"
EMAIL_LABEL: "Email"
@ -104,8 +104,8 @@ fr:
EMAIL_FOOTER: ''
NAME: Nom :
EMAIL: E-mail :
WRITTEN_ON: Écrit le
BY: par
WRITTEN_ON: le
BY: Par
NAME_LABEL: "Nom"
NAME_PLACEHOLDER: "Indiquez votre nom"
EMAIL_LABEL: "E-mail"
@ -134,8 +134,8 @@ hr:
EMAIL_FOOTER: ''
NAME: Ime:
EMAIL: Email:
WRITTEN_ON: Napisano je na
BY: od
WRITTEN_ON: na
BY: Od
NAME_LABEL: "Ime"
NAME_PLACEHOLDER: "Unesite ime"
EMAIL_LABEL: "Email adresa"
@ -164,8 +164,8 @@ it:
EMAIL_FOOTER: ''
NAME: Nome:
EMAIL: Email:
WRITTEN_ON: Scritto il
BY: da
WRITTEN_ON: il
BY: Da
NAME_LABEL: "Nome"
NAME_PLACEHOLDER: "Inserisci il tuo nome"
EMAIL_LABEL: "Email"
@ -194,7 +194,7 @@ ja:
EMAIL_FOOTER: ''
NAME: 名前 :
EMAIL: メールアドレス :
WRITTEN_ON: 書かれた
WRITTEN_ON:
BY:
NAME_LABEL: "名前"
NAME_PLACEHOLDER: "お名前を"
@ -224,8 +224,8 @@ pl:
EMAIL_FOOTER: ''
NAME: Imię:
EMAIL: Email:
WRITTEN_ON: Napisany przez
BY: przez
WRITTEN_ON: na
BY: Przez
ru:
PLUGIN_COMMENTS:
@ -243,8 +243,8 @@ ru:
EMAIL_FOOTER: ''
NAME: Имя:
EMAIL: Email:
WRITTEN_ON: Написан в
BY: от
WRITTEN_ON: на
BY: От
pt-br:
PLUGIN_COMMENTS:
@ -262,8 +262,8 @@ pt-br:
EMAIL_FOOTER: ''
NAME: Name:
EMAIL: Email:
WRITTEN_ON: Publicado em
BY: por
WRITTEN_ON: em
BY: Por
NAME_LABEL: "Nome"
NAME_PLACEHOLDER: "Escreva seu nome"
EMAIL_LABEL: "E-mail"
@ -292,8 +292,8 @@ ro:
EMAIL_FOOTER: ''
NAME: 'Nume:'
EMAIL: 'Adresă de email:'
WRITTEN_ON: 'Scris în data de'
BY: 'de către'
WRITTEN_ON: 'pe'
BY: 'De'
NAME_LABEL: "Numele"
NAME_PLACEHOLDER: "Introduceți numele Dvs."
EMAIL_LABEL: "Email"
@ -322,8 +322,8 @@ no:
EMAIL_FOOTER: ''
NAME: Navn:
EMAIL: Epost:
WRITTEN_ON: Skrevet
BY: av
WRITTEN_ON:
BY: Av
NAME_LABEL: "Navn"
NAME_PLACEHOLDER: "Skriv ditt navn"
EMAIL_LABEL: "Epost"

View File

@ -1,114 +1,143 @@
{% if grav.twig.enable_comments_plugin %}
{% set scope = scope ?: 'data.' %}
{% set scope = scope ?: 'data.' %}
{% if grav.twig.pingbacks_enabled %}
{% if grav.twig.pingbacks|length %}
{% set comments_visible = false %}
{% for pingback in grav.twig.pingbacks %}
{% if pingback.approved == "true" %}
{% set comments_visible = true %}
{% endif %}
{% endfor %}
{% if grav.twig.pingbacks_enabled %}
{% if grav.twig.pingbacks|length %}
{% set comments_visible = false %}
{% for pingback in grav.twig.pingbacks %}
{% if pingback.approved == "true" %}
{% set comments_visible = true %}
{% endif %}
{% endfor %}
{% if comments_visible %}
<h3>{{'PLUGIN_COMMENTS.COMMENTS_PINGBACKS'|t}}</h3>
{% if comments_visible %}
<h3>{{'PLUGIN_COMMENTS.COMMENTS_PINGBACKS'|t}}</h3>
<table>
{% for pingback in grav.twig.pingbacks %}
{% if pingback.approved == "true" %}
<tr>
<td>
{{pingback.text}}
<br />
{{'PLUGIN_COMMENTS.WRITTEN_ON'|t}} {{pingback.date|e}} {{'PLUGIN_COMMENTS.BY'|t}}
{% if pingback.site %}
<a href="{{pingback.site}}">{{pingback.author}}</a>
{% else %}
{{pingback.author}}
{% endif %}
</td>
</tr>
{% endif %}
{% endfor %}
</table
{% endif %}
</table>
{% endif %}
{% endif %}
<table>
{% for pingback in grav.twig.pingbacks %}
{% if pingback.approved == "true" %}
<tr>
<td>
<article id="pingback-{{loop.index0}}" class="pingback" itemtype="http://schema.org/UserComments">
<header class="pingback-meta">
<span class="pingback-author" itemprop="author" itemscope itemtype="http://schema.org/Person">
{{'PLUGIN_COMMENTS.BY'|t}}
<span itemprop="name">
{% if pingback.site %}
<a href="{{pingback.site}}">{{pingback.author}}</a>
{% else %}
{{pingback.author}}
{% endif %}
</span>
</span>
<a href="{{uri.url(true)}}#pingback-{{loop.index0}}" title="Link to this pingback" itemprop="url">
<time class="pingback-date" datetime="{{pingback.date|e}}" itemprop="commentTime">
{{pingback.date|nicetime(false)}}
</time>
</a>
</header>
<div class="pingback-content" itemprop="commentText">
{{pingback.text}}
</div>
</article>
</td>
</tr>
{% endif %}
{% endfor %}
</table
{% endif %}
</table>
{% endif %}
{% endif %}
{% if grav.twig.commenting_enabled %}
<h3>{{'PLUGIN_COMMENTS.ADD_COMMENT'|t}}</h3>
{% if grav.twig.commenting_enabled %}
<h3>{{'PLUGIN_COMMENTS.ADD_COMMENT'|t}}</h3>
<form name="{{ grav.config.plugins.comments.form.name }}"
action="{{ grav.config.plugins.comments.form.action ? base_url ~ grav.config.plugins.comments.form.action : page.url }}"
method="{{ grav.config.plugins.comments.form.method|upper|default('POST') }}">
<form name="{{ grav.config.plugins.comments.form.name }}"
action="{{ grav.config.plugins.comments.form.action ? base_url ~ grav.config.plugins.comments.form.action : page.url }}"
method="{{ grav.config.plugins.comments.form.method|upper|default('POST') }}">
{% for field in grav.config.plugins.comments.form.fields %}
{% set value = form.value(field.name) %}
{% if field.evaluateDefault %}
{% set value = evaluate(field.evaluateDefault) %}
{% endif %}
{% if config.plugins.login.enabled and grav.user.authenticated %}
{% if field.name == 'name' %}
<input type="hidden" name="{{ (scope ~ field.name)|fieldName }}" value="{{grav.user.fullname}}">
{% elseif field.name == 'email' %}
<input type="hidden" name="{{ (scope ~ field.name)|fieldName }}" value="{{grav.user.email}}">
{% else %}
<div>
{% include "forms/fields/#{field.type}/#{field.type}.html.twig" %}
</div>
{% endif %}
{% else %}
<div>
{% include "forms/fields/#{field.type}/#{field.type}.html.twig" %}
</div>
{% endif %}
{% endfor %}
{% include "forms/fields/formname/formname.html.twig" %}
{% for field in grav.config.plugins.comments.form.fields %}
{% set value = form.value(field.name) %}
{% if field.evaluateDefault %}
{% set value = evaluate(field.evaluateDefault) %}
{% endif %}
{% if config.plugins.login.enabled and grav.user.authenticated %}
{% if field.name == 'name' %}
<input type="hidden" name="{{ (scope ~ field.name)|fieldName }}" value="{{grav.user.fullname}}">
{% elseif field.name == 'email' %}
<input type="hidden" name="{{ (scope ~ field.name)|fieldName }}" value="{{grav.user.email}}">
{% else %}
<div>
{% include "forms/fields/#{field.type}/#{field.type}.html.twig" %}
</div>
{% endif %}
{% else %}
<div>
{% include "forms/fields/#{field.type}/#{field.type}.html.twig" %}
</div>
{% endif %}
{% endfor %}
{% include "forms/fields/formname/formname.html.twig" %}
<div class="buttons">
{% for button in grav.config.plugins.comments.form.buttons %}
<button class="button" type="{{ button.type|default('submit') }}">{{ button.value|t|default('Submit') }}</button>
{% endfor %}
</div>
<div class="buttons">
{% for button in grav.config.plugins.comments.form.buttons %}
<button class="button" type="{{ button.type|default('submit') }}">{{ button.value|t|default('Submit') }}</button>
{% endfor %}
</div>
{{ nonce_field('form', 'form-nonce')|raw }}
</form>
{{ nonce_field('form', 'form-nonce')|raw }}
</form>
<div class="alert">{{ form.message }}</div>
{% endif %}
<div class="alert">{{ form.message }}</div>
{% endif %}
{% if grav.twig.comments|length %}
{% if grav.twig.comments|length %}
<h3>{{'PLUGIN_COMMENTS.COMMENTS'|t}}</h3>
<h3>{{'PLUGIN_COMMENTS.COMMENTS'|t}}</h3>
<table>
{% set comments_visible = false %}
{% for comment in grav.twig.comments %}
{% if comment.approved == "true" %}
{% set comments_visible = true %}
<tr>
<td>
{{comment.text}}
<br />
{{'PLUGIN_COMMENTS.WRITTEN_ON'|t}} {{comment.date|e}} {{'PLUGIN_COMMENTS.BY'|t}}
{% if comment.site %}
<a href="{{comment.site}}">{{comment.author}}</a>
{% else %}
{{comment.author}}
{% endif %}
</td>
</tr>
{% endif %}
{% endfor %}
<table class="comments">
{% set comments_visible = false %}
{% for comment in grav.twig.comments %}
{% if comment.approved == "true" %}
{% set comments_visible = true %}
<tr>
<td>
<article id="comment-{{loop.index0}}" class="comment" itemtype="http://schema.org/UserComments">
<header class="comment-meta">
<span class="comment-author" itemprop="author" itemscope itemtype="http://schema.org/Person">
<img class="comment-avatar" itemprop="image" src="https://www.gravatar.com/avatar/{{comment.email|ltrim()|rtrim()|md5}}?size=30&d=identicon">
{{'PLUGIN_COMMENTS.BY'|t}}
<span itemprop="name">
{% if comment.site %}
<a href="{{comment.site}}">{{comment.author}}</a>
{% else %}
{{comment.author}}
{% endif %}
</span>
</span>
<a href="{{uri.url(true)}}#comment-{{loop.index0}}" title="Link to this comment" itemprop="url">
<time class="comment-date" datetime="{{comment.date|e}}" itemprop="commentTime">
{{comment.date|nicetime(false)}}
</time>
</a>
</header>
<div class="comment-content" itemprop="commentText">
{{comment.text}}
</div>
</article>
</td>
</tr>
{% endif %}
{% endfor %}
{% if not comments_visible %}
<tr>
<td>
{{'PLUGIN_COMMENTS.COMMENTS_NONE'|t}}
</td>
</tr>
{% endif %}
</table>
{% endif %}
{% if not comments_visible %}
<tr>
<td>
{{'PLUGIN_COMMENTS.COMMENTS_NONE'|t}}
</td>
</tr>
{% endif %}
</table>
{% endif %}
{% endif %}