From bf346d1bd70d37f6ad17e01493b47b25c8adb121 Mon Sep 17 00:00:00 2001 From: Pavel Kvach Date: Sun, 28 Apr 2024 01:03:50 +0300 Subject: [PATCH] admin: Add support for comment search by Thread URL in admin interface See: - https://github.com/isso-comments/isso/issues/642 - https://github.com/isso-comments/isso/pull/1000 --- CHANGES.rst | 2 ++ isso/css/admin.css | 67 +++++++++++++++++++++++++++++++++++++++ isso/db/comments.py | 5 ++- isso/js/admin.js | 4 +++ isso/templates/admin.html | 11 +++++-- isso/views/comments.py | 40 +++++++++++++++++------ 6 files changed, 117 insertions(+), 12 deletions(-) diff --git a/CHANGES.rst b/CHANGES.rst index 9997aad41..fc3f0f91e 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 ^^^^^^^^^^^^^^^^ diff --git a/isso/css/admin.css b/isso/css/admin.css index e834545a8..bf854852e 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 6fa911bdf..f2aa4fffb 100644 --- a/isso/db/comments.py +++ b/isso/db/comments.py @@ -167,7 +167,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`. """ @@ -187,6 +187,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 5b1e5086c..e6cc64624 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/templates/admin.html b/isso/templates/admin.html index a6220301b..b799f3e28 100644 --- a/isso/templates/admin.html +++ b/isso/templates/admin.html @@ -74,8 +74,15 @@

Administration