diff --git a/.dockerignore b/.dockerignore index 2f466f03..6f653735 100644 --- a/.dockerignore +++ b/.dockerignore @@ -2,3 +2,5 @@ # Docker will have its own cache of node packages and its own python venv node_modules/ .venv/ +# Prevent accidental inclusion: +comments.db diff --git a/CHANGES.rst b/CHANGES.rst index 6474ab03..e303396d 100644 --- a/CHANGES.rst +++ b/CHANGES.rst @@ -11,11 +11,13 @@ New Features - Make for syntax highlighting (`#998`_, pkvach) - Add search for comments by URL in the admin interface (`#1000`_, pkvach) - Add CSS variables for better organization and flexibility (`#1001`_, pkvach) +- Add support for comment search by Thread URL in admin interface (`#1020`_, pkvach) .. _#966: https://github.com/posativ/isso/pull/966 .. _#998: https://github.com/isso-comments/isso/pull/998 .. _#1000: https://github.com/isso-comments/isso/pull/1000 .. _#1001: https://github.com/isso-comments/isso/pull/1001 +.. _#1020: https://github.com/isso-comments/isso/pull/1020 Breaking Changes ^^^^^^^^^^^^^^^^ @@ -42,6 +44,7 @@ Bugfixes & Improvements - Fix total comments count calculation (`#997`_, pkvach) - Fix newline character handling in data-isso-* i18n strings (`#992`_, pkvach) - Add link logging for management of new comments in Stdout (`#1016`_, pkvach) +- Change logging to include datetime and loglevel (`#1023`_, ix5) - Make 'text' field in 'comments' table NOT NULL and handling data migration (`#1019`_, pkvach) .. _#951: https://github.com/posativ/isso/pull/951 @@ -53,6 +56,7 @@ Bugfixes & Improvements .. _#997: https://github.com/isso-comments/isso/pull/997 .. _#992: https://github.com/isso-comments/isso/pull/992 .. _#1016: https://github.com/isso-comments/isso/pull/1016 +.. _#1023: https://github.com/isso-comments/isso/pull/1023 .. _#1019: https://github.com/isso-comments/isso/pull/1019 0.13.1.dev0 (2023-02-05) diff --git a/docker-compose.yml b/docker-compose.yml index fc36eef2..8576987f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -5,13 +5,17 @@ services: # Isso server should always reflect production image isso-server: - image: isso + image: isso:latest container_name: isso-server build: context: . dockerfile: Dockerfile - # No need to set entrypoint, image already provides CMD - #command: /isso/bin/isso -c /config/isso.cfg run + # No need to set command/entrypoint, image already provides both + # For reference: + #command: /isso/bin/isso run # standalone + # Using both ENTRYPOINT and CMD: + #entrypoint: /isso/bin/gunicorn -b 0.0.0.0:8080 -w 4 --preload --worker-tmp-dir /dev/shm + #command: isso.run environment: ISSO_SETTINGS: "/config/isso-dev.cfg" ISSO_ENDPOINT: "http://isso-dev.local:8080" @@ -37,7 +41,7 @@ services: - isso-dev.local - localhost volumes: - - ./db:/db/ + - ./db:/db/ # unused by default isso-dev.cfg - type: bind source: ./contrib/isso-dev.cfg target: /config/isso-dev.cfg diff --git a/docs/docs/reference/markdown-config.rst b/docs/docs/reference/markdown-config.rst index 51cc6489..c91c3912 100644 --- a/docs/docs/reference/markdown-config.rst +++ b/docs/docs/reference/markdown-config.rst @@ -127,8 +127,15 @@ The following **additional options** are available: +==========================================================+===========================+ | Ignore indented code blocks | ``disable-indented-code`` | +----------------------------------------------------------+---------------------------+ -| Parse inline LaTeX-style math blocks, such as | ``math`` | -| inline ``$equations$`` or display ``$$equations$$`` | | +| Ignore inline LaTeX-style math blocks, such as | ``math`` | +| inline ``$equations$`` or display ``$$equations$$``, | | +| allowing them to be processed separately with a | | +| JavaScript library. | | +| **Note:** This extension will *not* render equations | | +| or any form of math, it just marks them to be ignored by | | +| the markdown parser. A library such as | | +| `MathJax `_ | | +| or `KaTeX `_ is needed for that. | | +----------------------------------------------------------+---------------------------+ | Normally, everything between two ``_underscores_`` would | ``no-intra-emphasis`` | | be rendered with *emphasis*. This option disables | | @@ -140,15 +147,19 @@ The following **additional options** are available: | multiple footnotes by different commenters on the same | | | page could clash due to duplicate links to footnotes. | | +----------------------------------------------------------+---------------------------+ -| Use two ``=`` signs like ``==this==`` to highlight text | ``highlight`` | +| Use two ``=`` signs like ``==this==`` to highlight text. | ``highlight`` | +----------------------------------------------------------+---------------------------+ | Text inside quotes gets a special "quote" class. | ``quote`` | | Perhaps useful for styling in CSS | | +----------------------------------------------------------+---------------------------+ -| Enable Markdown tables | ``tables`` | +| Enable Markdown tables. | ``tables`` | +| **Note:** The ```` and all other ````-related | | +| tags need to be allowed under ``allowed-elements`` for | | +| this to work. Also, a table cannot be surrounded by | | +| anything other than blank lines to render properly. | | +----------------------------------------------------------+---------------------------+ | Instead of ``_underscore`` resulting in *emphasis*, | ``underline`` | -| the resulting text will be... underlined | | +| the resulting text will be... underlined. | | +----------------------------------------------------------+---------------------------+ .. todo:: ``no-intra-emphasis`` should be made default diff --git a/isso/__init__.py b/isso/__init__.py index 53d34c09..d92247e3 100644 --- a/isso/__init__.py +++ b/isso/__init__.py @@ -69,10 +69,11 @@ from isso.ext.notifications import Stdout, SMTP +LOG_FORMAT = "%(asctime)s:%(levelname)s: %(message)s" logging.getLogger('werkzeug').setLevel(logging.WARN) logging.basicConfig( level=logging.INFO, - format="%(asctime)s %(levelname)s: %(message)s") + format=LOG_FORMAT) logger = logging.getLogger("isso") @@ -280,6 +281,7 @@ def main(): if conf.get("general", "log-file"): handler = logging.FileHandler(conf.get("general", "log-file")) + handler.setFormatter(logging.Formatter(LOG_FORMAT)) logger.addHandler(handler) logging.getLogger("werkzeug").addHandler(handler) diff --git a/isso/css/admin.css b/isso/css/admin.css index e834545a..bf854852 100644 --- a/isso/css/admin.css +++ b/isso/css/admin.css @@ -176,3 +176,70 @@ a { width: 100%; margin-top: 1em; } + + +.search-tooltip { + position: relative; + display: inline-block; + cursor: pointer; + user-select: none; +} + +.search-tooltip-icon { + display: inline-block; + width: 1.2em; + height: 1.2em; + border-radius: 50%; + background: #fffaf3; + font-family: serif; + font-weight: bold; + text-align: center; + color: #000; + line-height: 1.1em; + border: 1px solid rgba(0, 0, 0, 0.2); + box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1); +} + +.search-tooltip .search-tooltip-text { + visibility: hidden; + width: 370px; + background-color: #555; + color: #fff; + text-align: left; + border-radius: 6px; + padding: 8px; + position: absolute; + z-index: 1; + bottom: 125%; + left: 50%; + margin-left: -185px; +} + +/* Tooltip arrow */ +.search-tooltip .search-tooltip-text::after { + content: ""; + position: absolute; + top: 100%; + left: 50%; + margin-left: -5px; + border-width: 5px; + border-style: solid; + border-color: #555 transparent transparent transparent; +} + +.search-tooltip .show { + visibility: visible; + -webkit-animation: fadeIn 1s; + animation: fadeIn 1s; +} + +/* Add animation (fade in the tooltip) */ +@-webkit-keyframes fadeIn { + from {opacity: 0;} + to {opacity: 1;} +} + +@keyframes fadeIn { + from {opacity: 0;} + to {opacity: 1;} +} \ No newline at end of file diff --git a/isso/db/comments.py b/isso/db/comments.py index dc33bc0f..c41c77fe 100644 --- a/isso/db/comments.py +++ b/isso/db/comments.py @@ -181,7 +181,7 @@ def count_modes(self): return dict(comment_count) def fetchall(self, mode=5, after=0, parent='any', order_by='id', - limit=100, page=0, asc=1, comment_id=None): + limit=100, page=0, asc=1, comment_id=None, thread_uri=None): """ Return comments for admin with :param:`mode`. """ @@ -201,6 +201,9 @@ def fetchall(self, mode=5, after=0, parent='any', order_by='id', if comment_id: sql.append('comments.id = ? ') sql_args = [comment_id] + elif thread_uri: + sql.append('threads.uri = ? ') + sql_args = [thread_uri] else: sql.append('comments.mode = ? ') sql_args = [mode] diff --git a/isso/js/admin.js b/isso/js/admin.js index 5b1e5086..e6cc6462 100644 --- a/isso/js/admin.js +++ b/isso/js/admin.js @@ -125,3 +125,7 @@ function send_edit(com_id, hash, isso_host_script) { stop_edit(com_id, true); } +function toggleTooltip(tooltipContainer) { + const tooltipText = tooltipContainer.querySelector(".search-tooltip-text"); + tooltipText.classList.toggle("show"); +} \ No newline at end of file diff --git a/isso/js/tests/integration/puppet.test.js b/isso/js/tests/integration/puppet.test.js index e77070be..5b55caa1 100644 --- a/isso/js/tests/integration/puppet.test.js +++ b/isso/js/tests/integration/puppet.test.js @@ -118,7 +118,7 @@ test("should fill Postbox with valid data and receive 201 reply", async () => { ]); const expected = { - "id": expect.any(Number), + "id": 1, "parent": null, "created": expect.any(Number), "modified": null, @@ -204,8 +204,13 @@ test("should execute GET/PUT/POST/DELETE requests correctly", async () => { { waitUntil: 'load' } ); + await expect(page).toMatchElement( + '#isso-1 .isso-text', + { text: 'A comment' }, + ); + // Relies on cookies from page.cookies, sent automatically - let postData = { + let putData = { //id: 1, text: 'New comment body', author: 'Commenter #2', @@ -217,7 +222,7 @@ test("should execute GET/PUT/POST/DELETE requests correctly", async () => { let editHandler = request => { let data = { 'method': 'PUT', - 'postData': JSON.stringify(postData), + 'postData': JSON.stringify(putData), 'headers': { ...request.headers(), 'Content-Type': 'application/json', @@ -246,7 +251,6 @@ test("should execute GET/PUT/POST/DELETE requests correctly", async () => { let deleteHandler = request => { let data = { 'method': 'DELETE', - //'postData': JSON.stringify({id: 1}), 'headers': { ...request.headers(), 'Content-Type': 'application/json', diff --git a/isso/templates/admin.html b/isso/templates/admin.html index a6220301..b799f3e2 100644 --- a/isso/templates/admin.html +++ b/isso/templates/admin.html @@ -74,8 +74,15 @@

Administration