Edit replacement words within profile

main
Bob Mottram 2020-02-19 19:06:23 +00:00
parent 5a87a60114
commit 6942c21fd3
2 changed files with 22 additions and 0 deletions

View File

@ -4320,6 +4320,16 @@ class PubServer(BaseHTTPRequestHandler):
else: else:
if os.path.isfile(filterFilename): if os.path.isfile(filterFilename):
os.remove(filterFilename) os.remove(filterFilename)
# word replacements
switchFilename= \
self.server.baseDir+'/accounts/'+ \
nickname+'@'+self.server.domain+'/replacewords.txt'
if fields.get('switchWords'):
with open(switchFilename, "w") as switchfile:
switchfile.write(fields['switchWords'])
else:
if os.path.isfile(switchFilename):
os.remove(switchFilename)
# save blocked accounts list # save blocked accounts list
blockedFilename= \ blockedFilename= \
self.server.baseDir+'/accounts/'+ \ self.server.baseDir+'/accounts/'+ \

View File

@ -647,6 +647,12 @@ def htmlEditProfile(translate: {},baseDir: str,path: str,domain: str,port: int,h
with open(filterFilename, 'r') as filterfile: with open(filterFilename, 'r') as filterfile:
filterStr=filterfile.read() filterStr=filterfile.read()
switchStr=''
switchFilename=baseDir+'/accounts/'+nickname+'@'+domain+'/replacewords.txt'
if os.path.isfile(switchFilename):
with open(switchFilename, 'r') as switchfile:
switchStr=switchfile.read()
blockedStr='' blockedStr=''
blockedFilename=baseDir+'/accounts/'+nickname+'@'+domain+'/blocking.txt' blockedFilename=baseDir+'/accounts/'+nickname+'@'+domain+'/blocking.txt'
if os.path.isfile(blockedFilename): if os.path.isfile(blockedFilename):
@ -779,9 +785,15 @@ def htmlEditProfile(translate: {},baseDir: str,path: str,domain: str,port: int,h
editProfileForm+=' <input type="checkbox" class="profilecheckbox" name="removeTwitter" '+removeTwitter+'>'+translate['Remove Twitter posts']+'<br>' editProfileForm+=' <input type="checkbox" class="profilecheckbox" name="removeTwitter" '+removeTwitter+'>'+translate['Remove Twitter posts']+'<br>'
if path.startswith('/users/'+adminNickname+'/'): if path.startswith('/users/'+adminNickname+'/'):
editProfileForm+=' <input type="checkbox" class="profilecheckbox" name="mediaInstance" '+mediaInstanceStr+'>'+translate['This is a media instance']+'<br>' editProfileForm+=' <input type="checkbox" class="profilecheckbox" name="mediaInstance" '+mediaInstanceStr+'>'+translate['This is a media instance']+'<br>'
editProfileForm+=' <br><b><label class="labels">'+translate['Filtered words']+'</label></b>' editProfileForm+=' <br><b><label class="labels">'+translate['Filtered words']+'</label></b>'
editProfileForm+=' <br><label class="labels">'+translate['One per line']+'</label>' editProfileForm+=' <br><label class="labels">'+translate['One per line']+'</label>'
editProfileForm+=' <textarea id="message" name="filteredWords" style="height:200px">'+filterStr+'</textarea>' editProfileForm+=' <textarea id="message" name="filteredWords" style="height:200px">'+filterStr+'</textarea>'
editProfileForm+=' <br><b><label class="labels">'+translate['Word Replacements']+'</label></b>'
editProfileForm+=' <br><label class="labels">A -> B</label>'
editProfileForm+=' <textarea id="message" name="switchWords" style="height:200px">'+switchStr+'</textarea>'
editProfileForm+=' <br><b><label class="labels">'+translate['Blocked accounts']+'</label></b>' editProfileForm+=' <br><b><label class="labels">'+translate['Blocked accounts']+'</label></b>'
editProfileForm+=' <br><label class="labels">'+translate['Blocked accounts, one per line, in the form nickname@domain or *@blockeddomain']+'</label>' editProfileForm+=' <br><label class="labels">'+translate['Blocked accounts, one per line, in the form nickname@domain or *@blockeddomain']+'</label>'
editProfileForm+=' <textarea id="message" name="blocked" style="height:200px">'+blockedStr+'</textarea>' editProfileForm+=' <textarea id="message" name="blocked" style="height:200px">'+blockedStr+'</textarea>'