forked from indymedia/epicyon
Handle citations differently, because mime decoding an array doesn't look feasible
parent
2f1664597d
commit
f04cbd0e21
25
daemon.py
25
daemon.py
|
@ -3053,13 +3053,15 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
baseDir: str, httpPrefix: str,
|
||||
domain: str, domainFull: str,
|
||||
onionDomain: str, i2pDomain: str, debug: bool,
|
||||
defaultTimeline: str) -> None:
|
||||
defaultTimeline: str,
|
||||
newswire: {}) -> None:
|
||||
"""Updates the citations for a blog post after hitting
|
||||
update button on the citations screen
|
||||
"""
|
||||
usersPath = path.replace('/citationsdata', '')
|
||||
actorStr = httpPrefix + '://' + domainFull + usersPath
|
||||
if ' boundary=' in self.headers['Content-type']:
|
||||
if newswire and \
|
||||
' boundary=' in self.headers['Content-type']:
|
||||
boundary = self.headers['Content-type'].split('boundary=')[1]
|
||||
if ';' in boundary:
|
||||
boundary = boundary.split(';')[0]
|
||||
|
@ -3111,14 +3113,20 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
# extract all of the text fields into a dict
|
||||
fields = \
|
||||
extractTextFieldsInPOST(postBytes, boundary, debug)
|
||||
print('citationstest: ' + str(fields))
|
||||
if fields.get('citations'):
|
||||
citations = []
|
||||
for dateStr, item in newswire.items():
|
||||
if fields.get(dateStr):
|
||||
if fields[dateStr] == 'on':
|
||||
citations.append(dateStr)
|
||||
|
||||
if citations:
|
||||
citationsFilename = \
|
||||
baseDir + '/accounts/' + \
|
||||
nickname + '@' + domain + '/.citations.txt'
|
||||
citationsStr = fields['citations']
|
||||
print('DEBUG: citationsStr = ' + citationsStr)
|
||||
# save citations, so that they can be added when
|
||||
citationsStr = ''
|
||||
for citationDate in citations:
|
||||
citationsStr += citationDate + '\n'
|
||||
# save citations dates, so that they can be added when
|
||||
# reloading the newblog screen
|
||||
citationsFile = open(citationsFilename, "w+")
|
||||
if citationsFile:
|
||||
|
@ -11773,7 +11781,8 @@ class PubServer(BaseHTTPRequestHandler):
|
|||
self.server.domainFull,
|
||||
self.server.onionDomain,
|
||||
self.server.i2pDomain, self.server.debug,
|
||||
self.server.defaultTimeline)
|
||||
self.server.defaultTimeline,
|
||||
self.server.newswire)
|
||||
return
|
||||
|
||||
if authorized and self.path.endswith('/newseditdata'):
|
||||
|
|
|
@ -5914,6 +5914,7 @@ def htmlCitations(baseDir: str, nickname: str, domain: str,
|
|||
|
||||
# list of newswire items
|
||||
if newswire:
|
||||
ctr = 0
|
||||
for dateStr, item in newswire.items():
|
||||
publishedDate = \
|
||||
datetime.strptime(dateStr, "%Y-%m-%d %H:%M:%S%z")
|
||||
|
@ -5923,11 +5924,12 @@ def htmlCitations(baseDir: str, nickname: str, domain: str,
|
|||
link = item[1]
|
||||
|
||||
htmlStr += \
|
||||
'<input type="checkbox" name="citations[]" ' + \
|
||||
'value="' + dateStr + '"/>' + \
|
||||
'<input type="checkbox" name="' + dateStr + \
|
||||
'" value="' + dateStr + '"/>' + \
|
||||
'<a href="' + link + '">' + title + '</a> '
|
||||
htmlStr += '<span class="newswireDate">' + \
|
||||
dateShown + '</span><br>\n'
|
||||
ctr += 1
|
||||
|
||||
htmlStr += '</form>\n'
|
||||
return htmlStr + htmlFooter()
|
||||
|
|
Loading…
Reference in New Issue