forked from indymedia/epicyon
Displaying questions
parent
ec66ac56a8
commit
8997b77277
|
@ -482,6 +482,17 @@ a:link {
|
||||||
background-color: #999;
|
background-color: #999;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.question {
|
||||||
|
font-size: var(--font-size);
|
||||||
|
}
|
||||||
|
|
||||||
|
input[type=radio] {
|
||||||
|
width: 32px;
|
||||||
|
margin : 0;
|
||||||
|
padding : 0;
|
||||||
|
opacity : 0;
|
||||||
|
}
|
||||||
|
|
||||||
input[type=text], select, textarea {
|
input[type=text], select, textarea {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
padding: 12px;
|
padding: 12px;
|
||||||
|
|
3
posts.py
3
posts.py
|
@ -1803,7 +1803,8 @@ def createBoxBase(baseDir: str,boxname: str, \
|
||||||
# must be a "Note" or "Announce" type
|
# must be a "Note" or "Announce" type
|
||||||
with open(filePath, 'r') as file:
|
with open(filePath, 'r') as file:
|
||||||
postStr = file.read()
|
postStr = file.read()
|
||||||
if '"Note"' in postStr or '"Announce"' in postStr:
|
if '"Note"' in postStr or '"Announce"' in postStr or \
|
||||||
|
('"Question"' in postStr and '"Create"' in postStr):
|
||||||
isPost=True
|
isPost=True
|
||||||
if boxname=='dm':
|
if boxname=='dm':
|
||||||
if '#Public' in postStr or '/followers' in postStr:
|
if '#Public' in postStr or '/followers' in postStr:
|
||||||
|
|
|
@ -1374,6 +1374,26 @@ def followerApprovalActive(baseDir: str,nickname: str,domain: str) -> bool:
|
||||||
manuallyApprovesFollowers=actorJson['manuallyApprovesFollowers']
|
manuallyApprovesFollowers=actorJson['manuallyApprovesFollowers']
|
||||||
return manuallyApprovesFollowers
|
return manuallyApprovesFollowers
|
||||||
|
|
||||||
|
def insertQuestion(nickname: str,content: str,postJsonObject: {}) -> str:
|
||||||
|
""" Inserts question selection into a post
|
||||||
|
"""
|
||||||
|
if not isQuestion(postJsonObject):
|
||||||
|
return content
|
||||||
|
if len(postJsonObject['object']['oneOf'])==0:
|
||||||
|
return content
|
||||||
|
content+='<div class="question">'
|
||||||
|
content+='<form method="POST" action="/users/'+nickname+'/question">'
|
||||||
|
content+='<input type="hidden" name="messageId" value="'+postJsonObject['id']+'">'
|
||||||
|
for choice in postJsonObject['object']['oneOf']:
|
||||||
|
if not choice.get('type'):
|
||||||
|
continue
|
||||||
|
if not choice.get('name'):
|
||||||
|
continue
|
||||||
|
content+='<input type="radio" name="answer" value="'+choice['name']+'"> '+choice['name']+'<br>'
|
||||||
|
content+='<input type="submit" value="Submit">'
|
||||||
|
content+='</form></div>'
|
||||||
|
return content
|
||||||
|
|
||||||
def individualPostAsHtml(pageNumber: int,baseDir: str, \
|
def individualPostAsHtml(pageNumber: int,baseDir: str, \
|
||||||
session,wfRequest: {},personCache: {}, \
|
session,wfRequest: {},personCache: {}, \
|
||||||
nickname: str,domain: str,port: int, \
|
nickname: str,domain: str,port: int, \
|
||||||
|
@ -1705,6 +1725,7 @@ def individualPostAsHtml(pageNumber: int,baseDir: str, \
|
||||||
if not postJsonObject['object']['sensitive']:
|
if not postJsonObject['object']['sensitive']:
|
||||||
contentStr=postJsonObject['object']['content']+attachmentStr
|
contentStr=postJsonObject['object']['content']+attachmentStr
|
||||||
contentStr=addEmbeddedElements(contentStr)
|
contentStr=addEmbeddedElements(contentStr)
|
||||||
|
contentStr=insertQuestion(nickname,contentStr,postJsonObject)
|
||||||
else:
|
else:
|
||||||
postID='post'+str(createPassword(8))
|
postID='post'+str(createPassword(8))
|
||||||
contentStr=''
|
contentStr=''
|
||||||
|
@ -1718,6 +1739,7 @@ def individualPostAsHtml(pageNumber: int,baseDir: str, \
|
||||||
contentStr+='<div class="cwText" id="'+postID+'">'
|
contentStr+='<div class="cwText" id="'+postID+'">'
|
||||||
contentStr+=postJsonObject['object']['content']+attachmentStr
|
contentStr+=postJsonObject['object']['content']+attachmentStr
|
||||||
contentStr=addEmbeddedElements(contentStr)
|
contentStr=addEmbeddedElements(contentStr)
|
||||||
|
contentStr=insertQuestion(nickname,contentStr,postJsonObject)
|
||||||
contentStr+='</div>'
|
contentStr+='</div>'
|
||||||
|
|
||||||
if postJsonObject['object'].get('tag'):
|
if postJsonObject['object'].get('tag'):
|
||||||
|
@ -1732,6 +1754,18 @@ def individualPostAsHtml(pageNumber: int,baseDir: str, \
|
||||||
contentStr+footerStr+ \
|
contentStr+footerStr+ \
|
||||||
'</div>\n'
|
'</div>\n'
|
||||||
|
|
||||||
|
def isQuestion(postObjectJson: {}) -> bool:
|
||||||
|
""" is the given post a question?
|
||||||
|
"""
|
||||||
|
if postObjectJson['type']=='Create':
|
||||||
|
if isinstance(postObjectJson['object'], dict):
|
||||||
|
if postObjectJson['object'].get('type'):
|
||||||
|
if postObjectJson['object']['type']=='Question':
|
||||||
|
if postObjectJson['object'].get('oneOf'):
|
||||||
|
if isinstance(postObjectJson['object']['oneOf'], list):
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
def htmlTimeline(pageNumber: int,itemsPerPage: int,session,baseDir: str, \
|
def htmlTimeline(pageNumber: int,itemsPerPage: int,session,baseDir: str, \
|
||||||
wfRequest: {},personCache: {}, \
|
wfRequest: {},personCache: {}, \
|
||||||
nickname: str,domain: str,port: int,timelineJson: {}, \
|
nickname: str,domain: str,port: int,timelineJson: {}, \
|
||||||
|
@ -1834,7 +1868,8 @@ def htmlTimeline(pageNumber: int,itemsPerPage: int,session,baseDir: str, \
|
||||||
if item['type']=='Create' or item['type']=='Announce':
|
if item['type']=='Create' or item['type']=='Announce':
|
||||||
itemCtr+=1
|
itemCtr+=1
|
||||||
avatarUrl=getPersonAvatarUrl(baseDir,item['actor'],personCache)
|
avatarUrl=getPersonAvatarUrl(baseDir,item['actor'],personCache)
|
||||||
tlStr+=individualPostAsHtml(pageNumber, \
|
tlStr+= \
|
||||||
|
individualPostAsHtml(pageNumber, \
|
||||||
baseDir,session,wfRequest,personCache, \
|
baseDir,session,wfRequest,personCache, \
|
||||||
nickname,domain,port,item,avatarUrl,True, \
|
nickname,domain,port,item,avatarUrl,True, \
|
||||||
allowDeletion, \
|
allowDeletion, \
|
||||||
|
|
Loading…
Reference in New Issue