Skip to content

Commit a795151

Browse files
committed
js, config: Add option to show/hide website field in comment form
Add a configuration option `website-field` to control whether the Website input is shown in the comment form. Default is true for backward compatibility. Closes #916
1 parent 9846da2 commit a795151

7 files changed

Lines changed: 107 additions & 4 deletions

File tree

CHANGES.rst

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,16 @@
11
Changelog for Isso
22
==================
33

4+
%(version)s (%(date)s)
5+
--------------------
6+
7+
New Features
8+
^^^^^^^^^^^^
9+
10+
- Add option to show/hide website field in comment form (`#1111`_, pkvach)
11+
12+
.. _#1111: https://github.com/isso-comments/isso/pull/1111
13+
414
0.14.0 (2026-03-26)
515
--------------------
616

docs/docs/reference/server-config.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -348,6 +348,7 @@ for IPv4, ``/48`` for IPv6).
348348
reply-to-self = false
349349
require-author = false
350350
require-email = false
351+
website-field = true
351352
352353
enabled
353354
Enable guard, recommended in production. Not useful for debugging
@@ -385,6 +386,14 @@ require-email
385386

386387
Default: ``false``
387388

389+
website-field
390+
Whether to show the website input field in the comment form. Set to
391+
``false`` to hide the website field entirely (no CSS hacks needed).
392+
393+
Default: ``true``
394+
395+
.. versionadded:: 0.14.1
396+
388397
.. _configure-markup:
389398

390399
Markup

isso/isso.cfg

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -195,6 +195,10 @@ require-author = false
195195
# done on the provided address). Do not forget to configure the client.
196196
require-email = false
197197

198+
# Whether to show the website input field in the comment form.
199+
# Set to false to hide the website field entirely.
200+
website-field = true
201+
198202

199203
[markup]
200204
# Customize markup and sanitized HTML. Currently, only Markdown (via mistune or misaka) is

isso/js/app/isso.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ var Postbox = function(parent) {
1717
el = $.htmlify(template.render("postbox", {
1818
"author": JSON.parse(localStorage.getItem("isso-author")),
1919
"email": JSON.parse(localStorage.getItem("isso-email")),
20-
"website": JSON.parse(localStorage.getItem("isso-website")),
20+
"website": config["website-field"] !== false ? JSON.parse(localStorage.getItem("isso-website")) : null,
2121
"preview": ''
2222
}));
2323

@@ -103,7 +103,8 @@ var Postbox = function(parent) {
103103

104104
var author = $("[name=author]", el).value || null,
105105
email = $("[name=email]", el).value || null,
106-
website = $("[name=website]", el).value || null;
106+
websiteEl = config["website-field"] !== false ? $('[name=website]', el) : null,
107+
website = websiteEl ? websiteEl.value || null : null;
107108

108109
try {
109110
localStorage.setItem("isso-author", JSON.stringify(author));

isso/js/app/templates/postbox.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,10 @@ var html = function (globals) {
2828
+ "<label for='isso-postbox-email'>" + i18n('postbox-email') + "</label>"
2929
+ "<input id='isso-postbox-email' type='email' name='email' placeholder='" + i18n('postbox-email-placeholder') + "' value='" + (email ? email : '') + "' />"
3030
+ "</p>"
31-
+ "<p class='isso-input-wrapper'>"
31+
+ (conf["website-field"] !== false ? "<p class='isso-input-wrapper'>"
3232
+ "<label for='isso-postbox-website'>" + i18n('postbox-website') + "</label>"
3333
+ "<input id='isso-postbox-website' type='text' name='website' placeholder='" + i18n('postbox-website-placeholder') + "' value='" + (website ? website : '') + "' />"
34-
+ "</p>"
34+
+ "</p>" : "")
3535
+ "<p class='isso-post-action'>"
3636
+ "<input type='submit' value='" + i18n('postbox-submit') + "' />"
3737
+ "</p>"
Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
/**
2+
* @jest-environment jsdom
3+
*/
4+
5+
/* Keep the above exactly as-is!
6+
* https://jestjs.io/docs/configuration#testenvironment-string
7+
* https://jestjs.io/docs/configuration#testenvironmentoptions-object
8+
*/
9+
10+
"use strict";
11+
12+
beforeEach(() => {
13+
jest.resetModules();
14+
document.body.innerHTML = '';
15+
});
16+
17+
test('Website field hidden when website-field=false', () => {
18+
document.body.innerHTML =
19+
'<div id="isso-thread"></div>' +
20+
'<script src="http://isso.api/js/embed.min.js" data-isso="/"></script>';
21+
22+
const isso = require("app/isso");
23+
const $ = require("app/dom");
24+
25+
const config = Object.assign({}, require("app/config"), {'website-field': false});
26+
27+
const i18n = require("app/i18n");
28+
const svg = require("app/svg");
29+
const template = require("app/template");
30+
31+
template.set("conf", config);
32+
template.set("i18n", i18n.translate);
33+
template.set("pluralize", i18n.pluralize);
34+
template.set("svg", svg);
35+
36+
const isso_thread = $('#isso-thread');
37+
isso_thread.append('<div id="isso-root"></div>');
38+
isso_thread.append(new isso.Postbox(null));
39+
40+
// Website input should not be present
41+
expect(document.querySelector('#isso-postbox-website')).toBeNull();
42+
expect(document.querySelector('[name=website]')).toBeNull();
43+
44+
// Author and email fields should still be present
45+
expect(document.querySelector('#isso-postbox-author')).not.toBeNull();
46+
expect(document.querySelector('#isso-postbox-email')).not.toBeNull();
47+
});
48+
49+
test('Website field shown when website-field=true (default)', () => {
50+
document.body.innerHTML =
51+
'<div id="isso-thread"></div>' +
52+
'<script src="http://isso.api/js/embed.min.js" data-isso="/"></script>';
53+
54+
const isso = require("app/isso");
55+
const $ = require("app/dom");
56+
57+
const config = Object.assign({}, require("app/config"), {'website-field': true});
58+
59+
const i18n = require("app/i18n");
60+
const svg = require("app/svg");
61+
const template = require("app/template");
62+
63+
template.set("conf", config);
64+
template.set("i18n", i18n.translate);
65+
template.set("pluralize", i18n.pluralize);
66+
template.set("svg", svg);
67+
68+
const isso_thread = $('#isso-thread');
69+
isso_thread.append('<div id="isso-root"></div>');
70+
isso_thread.append(new isso.Postbox(null));
71+
72+
// Website input should be present
73+
expect(document.querySelector('#isso-postbox-website')).not.toBeNull();
74+
expect(document.querySelector('[name=website]')).not.toBeNull();
75+
});

isso/views/comments.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -199,6 +199,10 @@ def __init__(self, isso, hasher):
199199
self.public_conf["reply-to-self"] = isso.conf.getboolean("guard", "reply-to-self")
200200
self.public_conf["require-email"] = isso.conf.getboolean("guard", "require-email")
201201
self.public_conf["require-author"] = isso.conf.getboolean("guard", "require-author")
202+
try:
203+
self.public_conf["website-field"] = isso.conf.getboolean("guard", "website-field")
204+
except NoOptionError:
205+
self.public_conf["website-field"] = True
202206
self.public_conf["reply-notifications"] = isso.conf.getboolean("general", "reply-notifications")
203207
self.public_conf["gravatar"] = isso.conf.getboolean("general", "gravatar")
204208

0 commit comments

Comments
 (0)