30 | {% trans %}From here you can search these documents. Enter your search 31 | words into the box below and click "search". Note that the search 32 | function will automatically search for all of the words. Pages 33 | containing fewer words won't appear in the result list.{% endtrans %} 34 |
35 | 40 | {% if search_performed %} 41 |{{ _("Your search did not match any documents. Please make sure that all words are spelled correctly and that you've selected enough categories.") }}
44 | {% endif %} 45 | {% endif %} 46 |This is a link to a thead, which will display a comment counter: 20 | How many Comments?
21 | 22 |Below is the actual comment field.
23 |A comment with
5 |code blocks
6 | New line: preformatted
7 |
8 | Double newline
9 |
A comment with
5 |code blocks
6 | New line: preformatted
7 |
8 | Double newline
9 |
"
10 | `;
11 |
12 | exports[`Simple comment text should render on one line 1`] = `"A comment
"`; 13 | -------------------------------------------------------------------------------- /isso/js/tests/unit/comment-loader.test.js: -------------------------------------------------------------------------------- 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 | test('Create comment loader', () => { 13 | // Set up our document body 14 | document.body.innerHTML = 15 | '' + 16 | // Note: `src` and `data-isso` need to be set, 17 | // else `api` fails to initialize! 18 | // data-isso-id needed for insert_loader api.fetch() 19 | ''; 22 | 23 | const isso = require("app/isso"); 24 | const $ = require("app/dom"); 25 | 26 | const config = require("app/config"); 27 | const i18n = require("app/i18n"); 28 | const svg = require("app/svg"); 29 | 30 | const template = require("app/template"); 31 | template.set("pluralize", i18n.pluralize); 32 | 33 | let comment = { 34 | 'id': null, 35 | 'hidden_replies': 5, 36 | } 37 | 38 | var isso_thread = $('#isso-thread'); 39 | isso_thread.append(''); 40 | 41 | isso.insert_loader(comment, null); 42 | 43 | // Will create a `.snap` file in `./__snapshots__/`. 44 | // Don't forget to check in those files when changing anything! 45 | expect(isso_thread.innerHTML).toMatchSnapshot(); 46 | }); 47 | -------------------------------------------------------------------------------- /isso/js/tests/unit/comment.test.js: -------------------------------------------------------------------------------- 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 | 13 | test('Rendered comment should match snapshot', () => { 14 | // Set up our document body 15 | document.body.innerHTML = 16 | '' + 17 | // Note: `src` and `data-isso` need to be set, 18 | // else `api` fails to initialize! 19 | // data-isso-id needed for insert_loader api.fetch() 20 | ''; 23 | 24 | const isso = require("app/isso"); 25 | const $ = require("app/dom"); 26 | const config = require("app/config"); 27 | const template = require("app/template"); 28 | 29 | const i18n = require("app/i18n"); 30 | const svg = require("app/svg"); 31 | 32 | template.set("conf", config); 33 | template.set("i18n", i18n.translate); 34 | template.set("pluralize", i18n.pluralize); 35 | template.set("svg", svg); 36 | 37 | let comment = { 38 | "id": 2, 39 | "created": 1651788192.4473603, 40 | "mode": 1, 41 | "text": "A comment with
\ncode blocks\nNew line: preformatted\n\nDouble newline\n
",
42 | "author": "John",
43 | "website": "http://website.org",
44 | "hash": "4505c1eeda98",
45 | "parent": null,
46 | }
47 |
48 | // globals.offset.localTime() will be passed to i18n.ago()
49 | // localTime param will then be called as localTime.getTime()
50 | jest.mock('app/globals', () => ({
51 | offset: {
52 | localTime: jest.fn(() => ({
53 | getTime: jest.fn(() => 0),
54 | })),
55 | },
56 | }));
57 |
58 | var isso_thread = $('#isso-thread');
59 | isso_thread.append('');
60 |
61 | isso.insert({ comment, scrollIntoView: false, offset: 0 });
62 |
63 | // Will create a `.snap` file in `./__snapshots__/`.
64 | // Don't forget to check in those files when changing anything!
65 | expect(isso_thread.innerHTML).toMatchSnapshot();
66 | });
67 |
--------------------------------------------------------------------------------
/isso/js/tests/unit/config.test.js:
--------------------------------------------------------------------------------
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("Client configuration - no languages", () => {
18 | // Mock navigator.languages = []
19 | global.languages = jest.spyOn(navigator, "languages", "get")
20 | global.languages.mockReturnValue([]);
21 |
22 | // Mock navigator.language = null
23 | global.language = jest.spyOn(navigator, "language", "get")
24 | global.language.mockReturnValue(null);
25 |
26 | let config = require("app/config");
27 |
28 | /* Expected:
29 | * - no config["lang"]
30 | * - navigator.languages empty
31 | * - fall back on navigator.language
32 | * - navigator.language empty
33 | * - fall back on navigator.userLanguage
34 | * - navigator.userLanguage empty
35 | * (jsdom doesn't set it)
36 | * - config["default-lang"] = "en"
37 | * - final manual insertion of "en"
38 | */
39 | let expected_langs = ["en", "en"];
40 |
41 | expect(config["langs"]).toStrictEqual(expected_langs);
42 | });
43 |
44 | test("data-isso-* i18n strings should be accepted with newline characters", () => {
45 |
46 | document.body.innerHTML =
47 | '' +
48 | // Note: `src` and `data-isso` need to be set,
49 | // else `api` fails to initialize!
50 | '';
28 |
29 | let placeholder = 'Type here'
30 | let html = "A comment
", 44 | "author": "John", 45 | "website": "http://website.org", 46 | "hash": "4505c1eeda98", 47 | } 48 | let rendered = template.render("comment", {"comment": comment}); 49 | let el = $.htmlify(rendered); 50 | expect($('.isso-text', el).innerHTML).toMatchSnapshot(); 51 | 52 | }); 53 | 54 | test('Code blocks in rendered comment should not be clipped', () => { 55 | let comment = { 56 | "id": 2, 57 | "created": 1651788192.4473603, 58 | "mode": 1, 59 | "text": "A comment with
\ncode blocks\nNew line: preformatted\n\nDouble newline\n
",
60 | "author": "John",
61 | "website": "http://website.org",
62 | "hash": "4505c1eeda98",
63 | }
64 | let rendered = template.render("comment", {"comment": comment});
65 | let el = $.htmlify(rendered);
66 | expect($('.isso-text', el).innerHTML).toMatchSnapshot();
67 | });
68 |
--------------------------------------------------------------------------------
/isso/js/tests/unit/timezone-utc.test.js:
--------------------------------------------------------------------------------
1 | // https://stackoverflow.com/questions/56261381/how-do-i-set-a-timezone-in-my-jest-config/56482581#56482581
2 | // Requires global-setup.js
3 |
4 | test('Timezones should always be UTC', () => {
5 | expect(new Date().getTimezoneOffset()).toBe(0);
6 | });
7 |
--------------------------------------------------------------------------------
/isso/js/tests/unit/utils.test.js:
--------------------------------------------------------------------------------
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 | const utils = require("app/utils");
11 |
12 | test("Pad string with zeros", function() {
13 | let to_be_padded = "12345";
14 | let pad_to = 10;
15 | let padding_char = "0";
16 | let expected = "0000012345"
17 | expect(utils.pad(to_be_padded, pad_to, padding_char)).toStrictEqual(expected);
18 | });
19 |
--------------------------------------------------------------------------------
/isso/run.py:
--------------------------------------------------------------------------------
1 | # -*- encoding: utf-8 -*-
2 |
3 | import os
4 | import sys
5 |
6 | from isso import config, make_app
7 |
8 | # Mock make_app because it is run by pytest
9 | # with the --doctest-modules flag
10 | # which will fail because make_app will exit
11 | # without valid configuration
12 | # https://stackoverflow.com/a/44595269/1279355
13 | if "pytest" in sys.modules:
14 | make_app = lambda config, multiprocessing: True # noqa
15 |
16 | application = make_app(
17 | config.load(
18 | config.default_file(),
19 | os.environ.get('ISSO_SETTINGS')),
20 | multiprocessing=True)
21 |
--------------------------------------------------------------------------------
/isso/templates/disabled.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |