Use comments instead of a cutoff line.
As per request of michael
This commit is contained in:
18
rtv/docs.py
18
rtv/docs.py
@@ -45,15 +45,11 @@ Submission Mode
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
COMMENT_FILE = """
|
COMMENT_FILE = """
|
||||||
--% {0} %--
|
# All lines starting with a # will be ignored
|
||||||
Do not edit the line above.
|
#
|
||||||
Type your comment above the line.
|
# If there is only whitespace left then the comment
|
||||||
All text below the line will be discarded.
|
# will not be posted.
|
||||||
|
#
|
||||||
If there is nothing but whitespace above the line
|
# Replying to {author}'s {type}
|
||||||
then the comment will be discarded.
|
{content}
|
||||||
|
|
||||||
Replying to {1}'s {2}
|
|
||||||
|
|
||||||
{3}
|
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ import curses
|
|||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
import os
|
import os
|
||||||
from uuid import uuid4
|
|
||||||
from tempfile import NamedTemporaryFile
|
from tempfile import NamedTemporaryFile
|
||||||
from subprocess import Popen
|
from subprocess import Popen
|
||||||
|
|
||||||
@@ -248,13 +247,19 @@ class SubmissionPage(BasePage):
|
|||||||
curses.flash()
|
curses.flash()
|
||||||
return
|
return
|
||||||
|
|
||||||
|
if data['type'] is 'Submission':
|
||||||
cid = str(uuid4())
|
content = data['text']
|
||||||
if data['type'] == 'Submission':
|
|
||||||
info = (data['author'], 'submission', data['text'])
|
|
||||||
else:
|
else:
|
||||||
info = (data['author'], 'comment', data['body'])
|
content = data['body']
|
||||||
comment_info = COMMENT_FILE.format(cid, *info)
|
|
||||||
|
# Comment out every line of the content
|
||||||
|
content = '\n'.join(['#|' + line for line in content.split('\n')])
|
||||||
|
|
||||||
|
info = {'author': data['author'],
|
||||||
|
'type': data['type'],
|
||||||
|
'content': content}
|
||||||
|
|
||||||
|
comment_info = COMMENT_FILE.format(**info)
|
||||||
|
|
||||||
with NamedTemporaryFile(prefix='rtv-comment-', mode='w+') as fp:
|
with NamedTemporaryFile(prefix='rtv-comment-', mode='w+') as fp:
|
||||||
fp.write(comment_info)
|
fp.write(comment_info)
|
||||||
@@ -270,8 +275,8 @@ class SubmissionPage(BasePage):
|
|||||||
curses.doupdate()
|
curses.doupdate()
|
||||||
|
|
||||||
fp.seek(0)
|
fp.seek(0)
|
||||||
comment_text = fp.read().split('--% ' + cid + ' %--')[0]
|
comment_text = '\n'.join([line for line in fp.read().split('\n')
|
||||||
|
if not line.startswith("#")])
|
||||||
|
|
||||||
if comment_text is None or comment_text.isspace():
|
if comment_text is None or comment_text.isspace():
|
||||||
return
|
return
|
||||||
|
|||||||
Reference in New Issue
Block a user