Skip to content

Commit

Permalink
Remove email subject in “Help improve this page” and improve componen…
Browse files Browse the repository at this point in the history
…t performance (#115)

* Remove email subject in “Help improve this page” and improve component performance

* Feedback box include: Cache additional  t.html includes

* t.hml: introduces a 'plainText' argument to avoid adding <span lang="en"></span> when no translation exists. This is useful for text inserted in the email body.

* feedback-box.html: Use plain text translations for text inserted into the email body
  • Loading branch information
remibetin authored Nov 5, 2024
1 parent d5ea2c8 commit 5d05fc0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 26 deletions.
38 changes: 13 additions & 25 deletions _includes/feedback-box.html
Original file line number Diff line number Diff line change
@@ -1,40 +1,28 @@
{%- if page.collection -%}{%- assign col = site.collections | where: "label", page.collection | first -%}{%- endif- %}
{%- capture helptitle -%}{% include t.html t="Help improve this page" %}{%- endcapture -%}
{%- if page.feedbackmail -%}
{%- assign feedbackmail = page.feedbackmail -%}
{%- else -%}
{%- assign feedbackmail = "[email protected]" -%}
{%- endif -%}
{%- capture helptitle -%}{% include_cached t.html t="Help improve this page" lang=page.lang %}{%- endcapture -%}
{%- assign feedbackmail = page.feedbackmail | default: "[email protected]"-%}
{% assign reppattern = "$1|" | append: feedbackmail%}
{%- capture helpdesc -%}{% include t.html t="Please share your ideas, suggestions, or comments via e-mail to the publicly-archived list [$1](mailto:$1$2) or via GitHub." replace=reppattern %}{%- endcapture -%}

{%- if page.lang -%}
{%- assign mailsubject = "[" | append: page.lang | append: "] " | append: page.title | url_encode | replace: "+", "%20" -%}
{%- else -%}
{%- assign mailsubject = page.title | url_encode | replace: "+", "%20" -%}
{%- endif -%}

{%- capture helpdesc -%}{% include_cached t.html t="Please share your ideas, suggestions, or comments via e-mail to the publicly-archived list [$1](mailto:$1$2) or via GitHub." replace=reppattern lang=page.lang %}{%- endcapture -%}
{%- capture mailbody -%}
{% include t.html t="[put comment here...]" %}
{% include_cached t.html t="[include a relevant email Subject]" lang=page.lang plainText=true hideTranslationHints=true %}

{% include_cached t.html t="[put comment here...]" lang=page.lang plainText=true hideTranslationHints=true %}

{% if feedbackmail == "[email protected]" %}{% include t.html t="I give permission to share this to a publicly-archived e-mail list." %}{% endif %}
{% if feedbackmail == "[email protected]" %}{% include_cached t.html t="I give permission to share this to a publicly-archived e-mail list." lang=page.lang plainText=true hideTranslationHints=true %}{% endif %}
{%- endcapture -%}
{%- assign mailbody = mailbody | url_encode | replace: "+", "%20" -%}

{%- assign mailparams = "?subject=" | append: mailsubject | append: "&body=" | append: mailbody -%}

{%- include box.html type="start" title=helptitle h=2 class="icon space-above" icon="comments" id="helpimprove" aria_label="feedback" -%}
{%- assign mailparams = "?body=" | append: mailbody -%}
{%- include_cached box.html type="start" title=helptitle h=2 class="icon space-above" icon="comments" id="helpimprove" aria_label="feedback" -%}

{{ helpdesc | replace: "$2", mailparams | markdownify -}}

<div class="button-group">
<a href="{{ "mailto:" | append: feedbackmail | append: mailparams }}" class="button"><span>{% include t.html t="E-mail" %}</span></a>
<a href="{{ "mailto:" | append: feedbackmail | append: mailparams }}" class="button"><span>{% include_cached t.html t="E-mail" lang=page.lang %}</span></a>
{%- unless page.github.hide -%}
{%- capture github-file-path -%}{% include_cached github-file-path.html p=page %}{%- endcapture -%}
<a href="{{ github-file-path }}" class="button"><span>{% include t.html t="Fork &amp; Edit on GitHub" %}</span></a>
<a href="{{ github-file-path }}" class="button"><span>{% include_cached t.html t="Fork &amp; Edit on GitHub" lang=page.lang %}</span></a>
{%- comment -%}<a href="https://github.com/{{repo}}/issues" class="button"><span>List of GitHub Issues</span></a>{%- endcomment -%}
<a href="https://github.com/{{repo}}/issues/new?template=content-issue.yml{%- unless page.lang == 'en' -%}&title={{ "[" | append: page.lang | append: "] " | uri_escape }}{%- endunless -%}{%- if page.github.label -%}&wai-resource-id={{page.github.label}}{%- endif -%}&wai-url={{page.url | absolute_url | uri_escape }}" class="button"><span>{% include t.html t="New GitHub Issue" %}</span></a>
<a href="https://github.com/{{repo}}/issues/new?template=content-issue.yml{%- unless page.lang == 'en' -%}&title={{ "[" | append: page.lang | append: "] " | uri_escape }}{%- endunless -%}{%- if page.github.label -%}&wai-resource-id={{page.github.label}}{%- endif -%}&wai-url={{page.url | absolute_url | uri_escape }}" class="button"><span>{% include_cached t.html t="New GitHub Issue" lang=page.lang %}</span></a>
{%- endunless -%}
</div>

{%- include box.html type="end" -%}
{%- include_cached box.html type="end" -%}
6 changes: 5 additions & 1 deletion _includes/t.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,11 @@
{%- assign phrase=source[pagelang] -%}
{%- else -%}
{%- unless site.hideTranslationHints or include.hideTranslationHints or site.published == true %}<mark lang="en">Needs Translation</mark> {% endunless -%}
{%- assign phrase=include.t | prepend: '<span lang="en">' | append: '</span>' -%}
{%- unless include.plainText %}
{%- assign phrase=include.t | prepend: '<span lang="en">' | append: '</span>' -%}
{%- else %}
{%- assign phrase=include.t -%}
{% endunless -%}
{%- endif -%}
{%- if include.replace -%}
{%- assign replacements = include.replace | split: "||" -%}
Expand Down

0 comments on commit 5d05fc0

Please sign in to comment.