Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make it possible to identify the page author's comments #844

Merged
merged 6 commits into from
May 7, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions CHANGES.rst
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ Changelog for Isso
in post box (`#861 <https://github.com/posativ/isso/pull/861>`_, ix5)
- Re-enable ``no-intra-emphasis`` misaka extension in default config.
- Allow ``sup`` and ``sub`` HTML elements by default
- Add ``data-isso-page-author-hashes`` option to client which makes it possible
to style comments and replies made by the page's author(s).

.. _Gravatar: Image requests: http://en.gravatar.com/site/implement/images/

Expand Down
44 changes: 44 additions & 0 deletions docs/docs/reference/client-config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ preferably in the script tag which embeds the JS:
data-isso-vote="true"
data-isso-vote-levels=""
data-isso-feed="false"
data-isso-page-author-hashes="f124cf6b2f01,7831fe17a8cd"
data-isso-reply-notifications-default-enabled="false"
src="/prefix/js/embed.js"></script>

Expand Down Expand Up @@ -143,6 +144,49 @@ data-isso-feed
thread. The link will only be valid if the appropriate setting, in
``[rss]`` section, is also enabled server-side.

data-isso-page-author-hashes
Provide the hash (or list of hashes) of the current page's author. Any
comments made by those authors will be given the ``isso-is-page-author``
class. This can be styled using CSS.

The hash of a user can be found by checking the ``data-hash`` parameter on the
BBaoVanC marked this conversation as resolved.
Show resolved Hide resolved
``<div>`` tag containing their comment. This is what the element looks like:

.. code-block:: html

<div class="isso-comment isso-no-votes" id="isso-14" data-hash="41faef0a49fc">

According to this example, your script tag would look something like this:

.. code-block:: html

<script src="..." data-isso-page-author-hashes="41faef0a49fc"></script>

When adding multiple hashes to support multiple page authors, separate the
hashes by a command and/or space. All of the following are acceptable
(although the hashes are made up):

- ``data-isso-page-author-hashes="86g7n8g67nm,8m787mg8"``
- ``data-isso-page-author-hashes="86g7n8g67nm 8m787mg8"``
- ``data-isso-page-author-hashes="86g7n8g67nm, 8m787mg8"``

For example, these CSS rules make the page author's name a sort of
turquoise color, and the comment's background a lighter version of that:

.. code-block:: css

.isso-comment.isso-is-page-author > .isso-text-wrapper {
background-color: #bae0ea;
}

.isso-comment.isso-is-page-author > .isso-text-wrapper > .isso-comment-header > .isso-author {
color: #19798d;
}


.. versionadded:: 0.13


data-isso-reply-notifications-default-enabled
Set to ``true`` to make the reply notifications checkbox on the postbox be
checked by default. Otherwise, the user will have to manually opt-in to
Expand Down
10 changes: 7 additions & 3 deletions isso/css/isso.css
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@

BBaoVanC marked this conversation as resolved.
Show resolved Hide resolved
#isso-root .isso-comment {
max-width: 68em;
padding-top: 0.95em;
margin: 0.95em auto;
}
#isso-root .isso-preview .isso-comment {
padding-top: 0;
Expand All @@ -43,11 +41,12 @@
#isso-root .isso-comment:not(:first-of-type),
.isso-follow-up .isso-comment {
border-top: 1px solid rgba(0, 0, 0, 0.1);
margin-bottom: 0.5em;
}
.isso-comment > .isso-avatar {
display: block;
float: left;
margin: 3px 15px 0 0;
margin: 0.95em 0.95em 0;
}
.isso-comment > .isso-avatar > svg {
max-width: 48px;
Expand All @@ -58,6 +57,7 @@
}
.isso-comment > .isso-text-wrapper {
display: block;
padding: 0.95em;
}
.isso-comment .isso-follow-up {
padding-left: calc(7% + 20px);
Expand Down Expand Up @@ -92,6 +92,10 @@
font-weight: bold;
color: #555;
}
.isso-comment > .isso-text-wrapper > .isso-comment-header .isso-page-author-suffix {
font-weight: bold;
color: #2c2c2c;
}
.isso-comment > .isso-text-wrapper > .isso-textarea-wrapper .isso-textarea,
.isso-comment > .isso-text-wrapper > .isso-textarea-wrapper .isso-preview {
margin-top: 0.2em;
Expand Down
6 changes: 5 additions & 1 deletion isso/js/app/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ var config = {
"#be5168", "#f19670", "#e4bf80", "#447c69"].join(" "),
"vote": true,
"vote-levels": null,
"feed": false
"feed": false,
"page-author-hashes": "",
};

var js = document.getElementsByTagName("script");
Expand Down Expand Up @@ -82,4 +83,7 @@ config["langs"] = languages;
delete config["lang"];
delete config["default-lang"];

// Convert page-author-hash into a array by splitting at whitespace and/or commas
config["page-author-hashes"] = config["page-author-hashes"].split(/[\s,]+/);

module.exports = config;
1 change: 1 addition & 0 deletions isso/js/app/i18n/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ module.exports = {
"comment-queued": "Comment in queue for moderation.",
"comment-anonymous": "Anonymous",
"comment-hidden": "{{ n }} Hidden",
"comment-page-author-suffix": "Author",

"date-now": "right now",
"date-minute": "a minute ago\n{{ n }} minutes ago",
Expand Down
4 changes: 2 additions & 2 deletions isso/js/app/isso.js
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@ var insert_loader = function(comment, lastcreated) {
entrypoint = $("#isso-root");
comment.name = 'null';
} else {
entrypoint = $("#isso-" + comment.id + " > .isso-text-wrapper > .isso-follow-up");
entrypoint = $("#isso-" + comment.id + " > .isso-follow-up");
ix5 marked this conversation as resolved.
Show resolved Hide resolved
comment.name = comment.id;
}
var el = $.htmlify(template.render("comment-loader", {"comment": comment}));
Expand Down Expand Up @@ -208,7 +208,7 @@ var insert = function(comment, scrollIntoView) {
if (comment.parent === null) {
entrypoint = $("#isso-root");
} else {
entrypoint = $("#isso-" + comment.parent + " > .isso-text-wrapper > .isso-follow-up");
entrypoint = $("#isso-" + comment.parent + " > .isso-follow-up");
}

entrypoint.append(el);
Expand Down
10 changes: 8 additions & 2 deletions isso/js/app/templates/comment.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,22 @@ var html = function (globals) {
var svg = globals.svg;

var author = comment.author ? comment.author : i18n('comment-anonymous');
var isPageAuthor = conf["page-author-hashes"].indexOf(comment.hash) > -1;
var pageAuthorClass = (isPageAuthor ? " isso-is-page-author" : '');

return "" +
"<div class='isso-comment' id='isso-" + comment.id + "'>"
"<div class='isso-comment" + pageAuthorClass + "' id='isso-" + comment.id + "' data-hash='" + comment.hash + "'>"
+ (conf.gravatar ? "<div class='isso-avatar'><img src='" + comment.gravatar_image + "'></div>" : '')
+ (conf.avatar ? "<div class='isso-avatar'><svg data-hash='" + comment.hash + "'</svg></div>" : '')
+ "<div class='isso-text-wrapper'>"
+ "<div class='isso-comment-header' role='meta'>"
+ (comment.website
? "<a class='isso-author' href='" + comment.website + "' rel='nofollow'>" + author + "</a>"
: "<span class='isso-author'>" + author + "</span>")
+ (isPageAuthor
? "<span class='isso-spacer'>&bull;</span>"
+ "<span class='isso-page-author-suffix'>" + i18n('comment-page-author-suffix') + "</span>"
: '' )
+ "<span class='isso-spacer'>&bull;</span>"
+ "<a class='isso-permalink' href='#isso-" + comment.id + "'>"
+ "<time title='" + humanize(comment.created) + "' datetime='" + datetime(comment.created) + "'>" + humanize(comment.created) + "</time>"
Expand All @@ -38,8 +44,8 @@ var html = function (globals) {
+ "<a class='isso-edit' href='#'>" + i18n('comment-edit') + "</a>"
+ "<a class='isso-delete' href='#'>" + i18n('comment-delete') + "</a>"
+ "</div>" // .isso-comment-footer
+ "<div class='isso-follow-up'></div>"
+ "</div>" // .text-wrapper
+ "<div class='isso-follow-up'></div>"
+ "</div>" // .isso-comment
};
module.exports = html;