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

Highlighting for author comments #321

Closed
wants to merge 1 commit into from
Closed
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
1 change: 1 addition & 0 deletions isso/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ def __init__(self, conf):
self.signer = URLSafeTimedSerializer(self.db.preferences.get("session-key"))
self.markup = html.Markup(conf.section('markup'))
self.hasher = hash.new(conf.section("hash"))
self.author = self.hasher.uhash(conf.get('general', 'author'));

super(Isso, self).__init__(conf)

Expand Down
5 changes: 5 additions & 0 deletions isso/css/isso.css
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,11 @@
color: #AAA;
}

.isso-highlight {
padding: 0em 0em 0.5em 0.5em;
background-color: rgba(200, 200, 200, 0.4);
}

.isso-comment {
max-width: 68em;
padding-top: 0.95em;
Expand Down
15 changes: 15 additions & 0 deletions isso/js/app/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,20 @@ define(["app/lib/promise", "app/globals"], function(Q, globals) {
return deferred.promise;
};

var author = function() {
var deferred = Q.defer();
curl("GET", endpoint + "/author", null, function(rv) {
if (rv.status === 200) {
deferred.resolve(JSON.parse(rv.body));
} else if (rv.status === 404) {
deferred.resolve({author: ""});
} else {
deferred.reject(rv.body);
}
});
return deferred.promise;
};

var like = function(id) {
var deferred = Q.defer();
curl("POST", endpoint + "/id/" + id + "/like", null,
Expand All @@ -201,6 +215,7 @@ define(["app/lib/promise", "app/globals"], function(Q, globals) {
view: view,
fetch: fetch,
count: count,
author: author,
like: like,
dislike: dislike
};
Expand Down
2 changes: 2 additions & 0 deletions isso/js/app/isso.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ define(["app/dom", "app/utils", "app/config", "app/api", "app/jade", "app/i18n",

"use strict";

api.author().then(function(rv) { config["blogauthor"] = rv; });

var Postbox = function(parent) {

var localStorage = utils.localStorageImpl,
Expand Down
2 changes: 1 addition & 1 deletion isso/js/app/text/comment.jade
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
div(class='isso-comment' id='isso-#{comment.id}')
div(class=(comment.hash == conf.blogauthor) ? 'isso-comment isso-highlight' : 'isso-comment' id='isso-#{comment.id}')
if conf.avatar
div(class='avatar')
svg(data-hash='#{comment.hash}')
Expand Down
10 changes: 10 additions & 0 deletions isso/views/comments.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ class API(object):
('new', ('POST', '/new')),
('count', ('GET', '/count')),
('counts', ('POST', '/count')),
('author', ('GET', '/author')),
('view', ('GET', '/id/<int:id>')),
('edit', ('PUT', '/id/<int:id>')),
('delete', ('DELETE', '/id/<int:id>')),
Expand Down Expand Up @@ -480,6 +481,15 @@ def counts(self, environ, request):

return JSON(self.comments.count(*data), 200)

def author(self, environ, request):

rv = self.isso.author

if rv == "":
raise NotFound

return JSON(rv, 200)

def preview(self, environment, request):
data = request.get_json()

Expand Down
4 changes: 4 additions & 0 deletions share/isso.conf
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ name =
#
host =

# The email address you use on this website.
# This will identify you as the author of the site via highlighted comments.
author =

# time range that allows users to edit/remove their own comments.
# It supports years, weeks, days, hours, minutes, seconds.
# 3h45m12s equals to 3 hours, 45 minutes and 12 seconds.
Expand Down