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

WIP: Users #261

Draft
wants to merge 5 commits into
base: master
Choose a base branch
from
Draft
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
24 changes: 24 additions & 0 deletions docs/docs/configuration/server.rst
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,30 @@ algorithm
Arguments have to be in that order, but can be reduced to `pbkdf2:4096`
for example to override the iterations only.

User
----

Give yourself, your friends and/or your contributors lightweight accounts. These can be used
to later stylize your comments through CSS and distinguish them from the from anonymous commenters.

.. code-block:: ini

[user]
accounts =
Administrator,hunter9
John Smith,passw0rd

accounts
List of protected accounts. Each account is a name / password pair.
If a commenter enters a protected account name, they will be required to enter
the corresponding password in order to post their comment.
The password field will be offered in place of email.

The "sluggified" user names will then be added as CSS classses on the comments.
For the above example, classes will be: `isso-known-user isso-user-administrator`
and `isso-known-user isso-user-john_smith`.


Appendum
--------

Expand Down
18 changes: 18 additions & 0 deletions isso/css/isso.css
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@
#isso-thread .textarea {
min-height: 58px;
outline: 0;
-webkit-transition: border-color 0.3s, color 0.3s;
transition: border-color 0.3s, color 0.3s;
}
#isso-thread .textarea.placeholder {
color: #AAA;
Expand Down Expand Up @@ -184,6 +186,8 @@
line-height: 1.4em;
border: 1px solid rgba(0, 0, 0, 0.2);
box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
-webkit-transition: border-color 0.3s, color 0.3s;
transition: border-color 0.3s, color 0.3s;
}
.isso-postbox > .form-wrapper > .auth-section .post-action {
display: inline-block;
Expand All @@ -206,6 +210,20 @@
.isso-postbox > .form-wrapper > .auth-section .post-action > input:active {
background-color: #BBB;
}
.isso-postbox > .form-wrapper > .auth-section .input-wrapper-password {
display: none;
}
.isso-postbox.isso-postbox-password-mode > .form-wrapper > .auth-section .input-wrapper-password {
display: inline-block;
}
.isso-postbox.isso-postbox-password-mode > .form-wrapper > .auth-section .input-wrapper-email {
display: none;
}
.textarea.has-error,
.isso-postbox > .form-wrapper > .auth-section input.has-error {
border-color: red!important;
color: red;
}
@media screen and (max-width:600px) {
.isso-postbox > .form-wrapper > .auth-section .input-wrapper {
display: block;
Expand Down
27 changes: 21 additions & 6 deletions isso/js/app/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,15 @@ define(["app/lib/promise", "app/globals"], function(Q, globals) {
xhr.open(method, url, true);
xhr.withCredentials = true;
xhr.setRequestHeader("Content-Type", "application/json");
xhr.setRequestHeader("Accept", "application/json");

xhr.onreadystatechange = function () {
if (xhr.readyState === 4) {
onload();
}
};
} catch (exception) {
(reject || console.log)(exception.message);
(reject || console.error)(exception.message);
}

xhr.send(data);
Expand All @@ -89,14 +90,27 @@ define(["app/lib/promise", "app/globals"], function(Q, globals) {
return rv.substring(0, rv.length - 1); // chop off trailing "&"
};

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

var create = function(tid, data) {
var deferred = Q.defer();
curl("POST", endpoint + "/new?" + qs({uri: tid || location}), JSON.stringify(data),
function (rv) {
if (rv.status === 201 || rv.status === 202) {
deferred.resolve(JSON.parse(rv.body));
} else {
deferred.reject(rv.body);
deferred.reject({message: rv.body, status: rv.status});
}
});
return deferred.promise;
Expand All @@ -110,7 +124,7 @@ define(["app/lib/promise", "app/globals"], function(Q, globals) {
} else if (rv.status === 200) {
deferred.resolve(JSON.parse(rv.body));
} else {
deferred.reject(rv.body);
deferred.reject({message: rv.body, status: rv.status});
}
});
return deferred.promise;
Expand All @@ -124,7 +138,7 @@ define(["app/lib/promise", "app/globals"], function(Q, globals) {
} else if (rv.status === 200) {
deferred.resolve(JSON.parse(rv.body) === null);
} else {
deferred.reject(rv.body);
deferred.reject({message: rv.body, status: rv.status});
}
});
return deferred.promise;
Expand Down Expand Up @@ -159,7 +173,7 @@ define(["app/lib/promise", "app/globals"], function(Q, globals) {
} else if (rv.status === 404) {
deferred.resolve({total_replies: 0});
} else {
deferred.reject(rv.body);
deferred.reject({message: rv.body, status: rv.status});
}
});
return deferred.promise;
Expand All @@ -171,7 +185,7 @@ define(["app/lib/promise", "app/globals"], function(Q, globals) {
if (rv.status === 200) {
deferred.resolve(JSON.parse(rv.body));
} else {
deferred.reject(rv.body);
deferred.reject({message: rv.body, status: rv.status});
}
});
return deferred.promise;
Expand All @@ -195,6 +209,7 @@ define(["app/lib/promise", "app/globals"], function(Q, globals) {
endpoint: endpoint,
salt: salt,

info: info,
create: create,
modify: modify,
remove: remove,
Expand Down
8 changes: 8 additions & 0 deletions isso/js/app/dom.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,16 @@ define(function() {
/**
* Shortcut for `Element.addEventListener`, prevents default event
* by default, set :param prevents: to `false` to change that behavior.
* You can also provide an array of types, to listen on multiple events
*/
this.on = function(type, listener, prevent) {
if (Array.isArray(type)) {
var that = this;
type.forEach(function (type) {
Copy link
Contributor

@brad brad Dec 25, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't a different var name be used for the internally-scoped type? Even if just for clarity...

that.on(type, listener, prevent);
});
return;
}
node.addEventListener(type, function(event) {
listener(event);
if (prevent === undefined || prevent) {
Expand Down
1 change: 1 addition & 0 deletions isso/js/app/i18n/bg.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ define({
"postbox-text": "Въведете коментара си тук (поне 3 знака)",
"postbox-author": "Име/псевдоним (незадължително)",
"postbox-email": "Ел. поща (незадължително)",
"postbox-password": "Парола",
"postbox-website": "Уебсайт (незадължително)",
"postbox-submit": "Публикуване",
"num-comments": "1 коментар\n{{ n }} коментара",
Expand Down
1 change: 1 addition & 0 deletions isso/js/app/i18n/cs.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ define({
"postbox-text": "Sem napiště svůj komentář (nejméně 3 znaky)",
"postbox-author": "Jméno (nepovinné)",
"postbox-email": "E-mail (nepovinný)",
"postbox-password": "Heslo",
"postbox-website": "Web (nepovinný)",
"postbox-submit": "Publikovat",
"num-comments": "Jeden komentář\n{{ n }} Komentářů",
Expand Down
1 change: 1 addition & 0 deletions isso/js/app/i18n/de.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ define({
"postbox-text": "Kommentar hier eintippen (mindestens 3 Zeichen)",
"postbox-author": "Name (optional)",
"postbox-email": "Email (optional)",
"postbox-password": "Passwort",
"postbox-website": "Website (optional)",
"postbox-submit": "Abschicken",
"num-comments": "1 Kommentar\n{{ n }} Kommentare",
Expand Down
1 change: 1 addition & 0 deletions isso/js/app/i18n/el_GR.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ define({
"postbox-text": "Γράψτε το σχόλιο εδώ (τουλάχιστον 3 χαρακτήρες)",
"postbox-author": "Όνομα (προαιρετικό)",
"postbox-email": "E-mail (προαιρετικό)",
"postbox-password": "Κωδικός πρόσβασης",
"postbox-website": "Ιστοσελίδα (προαιρετικό)",
"postbox-submit": "Υποβολή",
"num-comments": "Ένα σχόλιο\n{{ n }} σχόλια",
Expand Down
1 change: 1 addition & 0 deletions isso/js/app/i18n/en.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ define({
"postbox-text": "Type Comment Here (at least 3 chars)",
"postbox-author": "Name (optional)",
"postbox-email": "E-mail (optional)",
"postbox-password": "Password",
"postbox-website": "Website (optional)",
"postbox-submit": "Submit",

Expand Down
1 change: 1 addition & 0 deletions isso/js/app/i18n/eo.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ define({
"postbox-text": "Tajpu komenton ĉi-tie (almenaŭ 3 signoj)",
"postbox-author": "Nomo (malnepra)",
"postbox-email": "Retadreso (malnepra)",
"postbox-password": "Pasvorto",
"postbox-website": "Retejo (malnepra)",
"postbox-submit": "Sendu",
"num-comments": "{{ n }} komento\n{{ n }} komentoj",
Expand Down
1 change: 1 addition & 0 deletions isso/js/app/i18n/es.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ define({
"postbox-text": "Escriba su comentario aquí (al menos 3 caracteres)",
"postbox-author": "Nombre (opcional)",
"postbox-email": "E-mail (opcional)",
"postbox-password": "Contraseña",
"postbox-website": "Sitio web (opcional)",
"postbox-submit": "Enviar",
"num-comments": "Un Comentario\n{{ n }} Comentarios",
Expand Down
1 change: 1 addition & 0 deletions isso/js/app/i18n/fr.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ define({
"postbox-text": "Insérez votre commentaire ici (au moins 3 lettres)",
"postbox-author": "Nom (optionnel)",
"postbox-email": "Courriel (optionnel)",
"postbox-password": "Mot de passe",
"postbox-website": "Site web (optionnel)",
"postbox-submit": "Soumettre",
"num-comments": "{{ n }} commentaire\n{{ n }} commentaires",
Expand Down
1 change: 1 addition & 0 deletions isso/js/app/i18n/hr.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ define({
"postbox-text": "Napiši komentar ovdje (najmanje 3 znaka)",
"postbox-author": "Ime (neobavezno)",
"postbox-email": "E-mail (neobavezno)",
"postbox-password": "Lozinka",
"postbox-website": "Web stranica (neobavezno)",
"postbox-submit": "Pošalji",
"num-comments": "Jedan komentar\n{{ n }} komentara",
Expand Down
1 change: 1 addition & 0 deletions isso/js/app/i18n/it.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ define({
"postbox-text": "Scrivi un commento qui (minimo 3 caratteri)",
"postbox-author": "Nome (opzionale)",
"postbox-email": "E-mail (opzionale)",
"postbox-password": "Parola d'ordine",
"postbox-website": "Sito web (opzionale)",
"postbox-submit": "Invia",
"num-comments": "Un Commento\n{{ n }} Commenti",
Expand Down
1 change: 1 addition & 0 deletions isso/js/app/i18n/nl.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ define({
"postbox-text": "Typ reactie hier (minstens 3 karakters)",
"postbox-author": "Naam (optioneel)",
"postbox-email": "E-mail (optioneel)",
"postbox-password": "Wachtwoord",
"postbox-website": "Website (optioneel)",
"postbox-submit": "Versturen",
"num-comments": "Één reactie\n{{ n }} reacties",
Expand Down
1 change: 1 addition & 0 deletions isso/js/app/i18n/pl.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ define({
"postbox-text": "Tutaj wpisz komentarz (co najmniej 3 znaki)",
"postbox-author": "Imię/nick (opcjonalnie)",
"postbox-email": "E-mail (opcjonalnie)",
"postbox-password": "Hasło",
"postbox-website": "Strona (opcjonalnie)",
"postbox-submit": "Wyślij",
"num-comments": "Jeden komentarz\n{{ n }} komentarzy",
Expand Down
1 change: 1 addition & 0 deletions isso/js/app/i18n/ru.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ define({
"postbox-text": "Оставить комментарий (минимум 3 символа)",
"postbox-author": "Имя (необязательно)",
"postbox-email": "Email (необязательно)",
"postbox-password": "Пароль",
"postbox-website": "Сайт (необязательно)",
"postbox-submit": "Отправить",
"num-comments": "{{ n }} комментарий\n{{ n }} комментария\n{{ n }} комментариев",
Expand Down
1 change: 1 addition & 0 deletions isso/js/app/i18n/sv.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ define({
"postbox-text": "Skriv din kommentar här (minst 3 tecken)",
"postbox-author": "Namn (frivilligt)",
"postbox-email": "E-mail (frivilligt)",
"postbox-password": "Lösenord",
"postbox-website": "Hemsida (frivilligt)",
"postbox-submit": "Skicka",
"num-comments": "En kommentar\n{{ n }} kommentarer",
Expand Down
1 change: 1 addition & 0 deletions isso/js/app/i18n/vi.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ define({
"postbox-text": "Nhập bình luận tại đây (tối thiểu 3 ký tự)",
"postbox-author": "Tên (tùy chọn)",
"postbox-email": "E-mail (tùy chọn)",
"postbox-password": "Mật khẩu",
"postbox-website": "Website (tùy chọn)",
"postbox-submit": "Gửi",

Expand Down
1 change: 1 addition & 0 deletions isso/js/app/i18n/zh_CN.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ define({
"postbox-text": "在此输入评论(最少3个字符)",
"postbox-author": "名字(可选)",
"postbox-email": "E-mail(可选)",
"postbox-password": "密码",
"postbox-website": "网站(可选)",
"postbox-submit": "提交",

Expand Down
1 change: 1 addition & 0 deletions isso/js/app/i18n/zh_TW.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ define({
"postbox-text": "在此輸入留言(至少3個字元)",
"postbox-author": "名稱(非必填)",
"postbox-email": "電子信箱(非必填)",
"postbox-password": "密碼",
"postbox-website": "個人網站(非必填)",
"postbox-submit": "送出",

Expand Down
Loading