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

View File

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