summaryrefslogtreecommitdiffstats
path: root/aurweb/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'aurweb/scripts')
-rwxr-xr-xaurweb/scripts/rendercomment.py35
1 files changed, 35 insertions, 0 deletions
diff --git a/aurweb/scripts/rendercomment.py b/aurweb/scripts/rendercomment.py
new file mode 100755
index 00000000..593cd36a
--- /dev/null
+++ b/aurweb/scripts/rendercomment.py
@@ -0,0 +1,35 @@
+#!/usr/bin/python3
+
+import sys
+import bleach
+
+import aurweb.db
+
+
+def get_comment(conn, commentid):
+ cur = conn.execute('SELECT Comments FROM PackageComments WHERE ID = ?',
+ [commentid])
+ return cur.fetchone()[0]
+
+
+def save_rendered_comment(conn, commentid, html):
+ conn.execute('UPDATE PackageComments SET RenderedComment = ? WHERE ID = ?',
+ [html, commentid])
+
+
+def main():
+ commentid = int(sys.argv[1])
+
+ conn = aurweb.db.Connection()
+
+ html = get_comment(conn, commentid)
+ html = html.replace('\n', '<br>')
+ html = bleach.clean(html, tags=['br'])
+ save_rendered_comment(conn, commentid, html)
+
+ conn.commit()
+ conn.close()
+
+
+if __name__ == '__main__':
+ main()