diff --git a/isso/db/comments.py b/isso/db/comments.py
index 6fa911bd..f2aa4fff 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/templates/admin.html b/isso/templates/admin.html
index a6220301..86c61c65 100644
--- a/isso/templates/admin.html
+++ b/isso/templates/admin.html
@@ -74,9 +74,9 @@
Administration
diff --git a/isso/views/comments.py b/isso/views/comments.py
index 14e99cf0..03b53746 100644
--- a/isso/views/comments.py
+++ b/isso/views/comments.py
@@ -116,6 +116,22 @@ def get_comment_id_from_url(comment_url):
return comment_id
+def get_uri_from_url(url):
+ try:
+ # Parse the URL to extract the URI
+ parsed_url = urlsplit(url)
+ except ValueError:
+ # Handle malformed URL
+ return None
+
+ uri = parsed_url.path
+ if not uri:
+ # Handle missing URI
+ return None
+
+ return uri
+
+
class API(object):
FIELDS = set(['id', 'parent', 'text', 'author', 'website',
@@ -1411,8 +1427,8 @@ def login(self, env, req):
Comment ordering
@apiQuery {Number{0,1}} [asc=0]
Ascending
- @apiQuery {String} comment_url
- Search comment by URL
+ @apiQuery {String} comment_search_url
+ Search comments by URL
@apiExample {curl} Listing of published comments:
curl 'https://comments.example.com/admin/?mode=1&page=0&order_by=modified&asc=1' -b cookie.txt
@@ -1433,12 +1449,16 @@ def admin(self, env, req):
order_by = req.args.get('order_by', 'created')
asc = int(req.args.get('asc', 0))
mode = int(req.args.get('mode', 2))
- comment_url = req.args.get('comment_url', '')
-
- # Search for a specific comment by URL
- if comment_url:
- comment_id = get_comment_id_from_url(comment_url)
- comments = self.comments.fetchall(comment_id=comment_id, limit=1) if comment_id else []
+ comment_search_url = req.args.get('comment_search_url', '')
+
+ # Search for comments by URL
+ if comment_search_url:
+ comment_id = get_comment_id_from_url(comment_search_url)
+ uri = get_uri_from_url(comment_search_url)
+ if comment_id or uri:
+ comments = self.comments.fetchall(comment_id=comment_id, thread_uri=uri)
+ else:
+ comments = []
else:
comments = self.comments.fetchall(mode=mode, page=page,
limit=page_size,
@@ -1455,7 +1475,7 @@ def admin(self, env, req):
conf=self.conf, max_page=max_page,
counts=comment_mode_count,
order_by=order_by, asc=asc,
- comment_url=comment_url,
+ comment_search_url=comment_search_url,
isso_host_script=isso_host_script)
"""
@api {get} /latest latest