diff --git a/webapp_profile.py b/webapp_profile.py index cb4146239..16bfc14f2 100644 --- a/webapp_profile.py +++ b/webapp_profile.py @@ -60,21 +60,51 @@ from webapp_post import individualPostAsHtml from webapp_timeline import htmlIndividualShare +def _beginEditSection(label: str) -> str: + """returns the html for begining a dropdown section on edit profile screen + """ + return \ + '
' + label + '\n' + \ + '
' + + +def _endEditSection() -> str: + """returns the html for ending a dropdown section on edit profile screen + """ + return '
\n' + + def _editText(label: str, name: str, value: str = "") -> str: """Returns html for editing a text field """ + if value is None: + value = '' return \ '
\n' + \ ' \n' +def _editCheckBox(label: str, name: str, checked: bool = False) -> str: + """Returns html for editing a checkbox field + """ + checkedStr = '' + if checked: + checkedStr = ' checked' + + return \ + ' ' + label + '
\n' + + def _editTextArea(label: str, name: str, value: str = "", height: int = 600, placeholder: str = "", spellcheck: bool = False) -> str: """Returns html for editing a textarea field """ + if value is None: + value = '' return \ '
\n' + \ ' ' - else: - instanceStr += \ - ' ' + instanceStr = _beginEditSection(translate['Instance Settings']) instanceStr += \ - ' ' - if customSubmitText: - instanceStr += \ - '
' - else: - instanceStr += \ - '
' - + _editText(translate['Instance Title'], + 'instanceTitle', instanceTitle) + instanceStr += '
\n' + instanceStr += \ + _editText(translate['Instance Short Description'], + 'instanceDescriptionShort', instanceDescriptionShort) + instanceStr += '
\n' + instanceStr += \ + _editTextArea(translate['Instance Description'], + 'instanceDescription', instanceDescription, 200, + '', True) + instanceStr += \ + _editText(translate['Custom post submit button text'], + 'customSubmitText', customSubmitText) + instanceStr += '
\n' instanceStr += \ ' ' + \ @@ -1190,64 +1182,51 @@ def _htmlEditProfileInstance(baseDir: str, translate: {}, translate['Show numbers of accounts within instance metadata'] if getConfigParam(baseDir, "showNodeInfoAccounts"): instanceStr += \ - ' ' + \ - nodeInfoStr + '
\n' + _editCheckBox(nodeInfoStr, 'showNodeInfoAccounts', True) else: instanceStr += \ - ' ' + \ - nodeInfoStr + '
\n' + _editCheckBox(nodeInfoStr, 'showNodeInfoAccounts', False) nodeInfoStr = \ translate['Show version number within instance metadata'] if getConfigParam(baseDir, "showNodeInfoVersion"): instanceStr += \ - ' ' + \ - nodeInfoStr + '
\n' + _editCheckBox(nodeInfoStr, 'showNodeInfoVersion', True) else: instanceStr += \ - ' ' + \ - nodeInfoStr + '
\n' + _editCheckBox(nodeInfoStr, 'showNodeInfoVersion', False) if getConfigParam(baseDir, "verifyAllSignatures"): instanceStr += \ - ' ' + \ - translate['Verify all signatures'] + '
\n' + _editCheckBox(translate['Verify all signatures'], + 'verifyallsignatures', True) else: instanceStr += \ - ' ' + \ - translate['Verify all signatures'] + '
\n' + _editCheckBox(translate['Verify all signatures'], + 'verifyallsignatures', False) instanceStr += translate['Enabling broch mode'] + '
\n' if getConfigParam(baseDir, "brochMode"): instanceStr += \ - ' ' + \ - translate['Broch mode'] + '
\n' + _editCheckBox(translate['Broch mode'], 'brochMode', True) else: instanceStr += \ - ' ' + \ - translate['Broch mode'] + '
\n' + _editCheckBox(translate['Broch mode'], 'brochMode', False) # Instance type instanceStr += \ '

\n' + \ - ' ' + \ - translate['This is a media instance'] + '
\n' + \ - ' ' + \ - translate['This is a blogging instance'] + '
\n' + \ - ' ' + \ - translate['This is a news instance'] + '
\n' + \ - ' \n' + translate['Type of instance'] + '
\n' + instanceStr += \ + _editCheckBox(translate['This is a media instance'], + 'mediaInstance', mediaInstanceStr) + instanceStr += \ + _editCheckBox(translate['This is a blogging instance'], + 'blogsInstance', blogsInstanceStr) + instanceStr += \ + _editCheckBox(translate['This is a news instance'], + 'newsInstance', newsInstanceStr) + + instanceStr += _endEditSection() # Role assignments section moderators = '' @@ -1330,15 +1309,14 @@ def _htmlEditProfileInstance(baseDir: str, translate: {}, ' \n' + \ - '
\n' + '
\n' YTReplacementDomain = getConfigParam(baseDir, "youtubedomain") if not YTReplacementDomain: YTReplacementDomain = '' peertubeStr += \ - ' \n' + \ - ' \n' + _editText(translate['YouTube Replacement Domain'], + 'ytdomain', YTReplacementDomain) + peertubeStr += _endEditSection() libretranslateUrl = getConfigParam(baseDir, 'libretranslateUrl') libretranslateApiKey = getConfigParam(baseDir, 'libretranslateApiKey') @@ -1356,12 +1334,17 @@ def _htmlEditProfileDangerZone(translate: {}) -> str: editProfileForm = \ '
' + \ translate['Danger Zone'] + '\n' + \ - '
\n' + \ + '
\n' + + editProfileForm = \ '
\n' + \ - ' ' + \ - translate['Deactivate this account'] + '
\n' + \ + translate['Danger Zone'] + '
\n' + + editProfileForm = \ + _editCheckBox(translate['Deactivate this account'], + 'deactivateThisAccount', False) + + editProfileForm = \ '
\n' return editProfileForm @@ -1683,20 +1666,6 @@ def _htmlEditProfileBackground(newsInstance: bool, translate: {}) -> str: return editProfileForm -def _beginEditSection(label: str) -> str: - """returns the html for begining a dropdown section on edit profile screen - """ - return \ - '
' + label + '\n' + \ - '
' - - -def _endEditSection() -> str: - """returns the html for ending a dropdown section on edit profile screen - """ - return '
\n' - - def _htmlEditProfileContactInfo(nickname: str, emailAddress: str, xmppAddress: str, @@ -1747,33 +1716,26 @@ def _htmlEditProfileOptions(manuallyApprovesFollowers: str, """ editProfileForm = '
\n' editProfileForm += \ - ' ' + translate['Approve follower requests'] + '
\n' + _editCheckBox(translate['Approve follower requests'], + 'approveFollowers', manuallyApprovesFollowers) editProfileForm += \ - ' ' + translate['This is a bot account'] + '
\n' + _editCheckBox(translate['This is a bot account'], + 'isBot', isBot) editProfileForm += \ - ' ' + \ - translate['This is a group account'] + '
\n' + _editCheckBox(translate['This is a group account'], + 'isGroup', isGroup) editProfileForm += \ - ' ' + \ - translate['Only people I follow can send me DMs'] + '
\n' + _editCheckBox(translate['Only people I follow can send me DMs'], + 'followDMs', followDMs) editProfileForm += \ - ' ' + \ - translate['Remove Twitter posts'] + '
\n' + _editCheckBox(translate['Remove Twitter posts'], + 'removeTwitter', removeTwitter) editProfileForm += \ - ' ' + \ - translate['Notify when posts are liked'] + '
\n' + _editCheckBox(translate['Notify when posts are liked'], + 'notifyLikes', notifyLikes) editProfileForm += \ - ' ' + \ - translate["Don't show the Like button"] + '
\n' + _editCheckBox(translate["Don't show the Like button"], + 'hideLikeButton', hideLikeButton) editProfileForm += '
\n' return editProfileForm @@ -1917,9 +1879,8 @@ def _htmlEditProfileTopBanner(baseDir: str, if scheduledPostsExist(baseDir, nickname, domain): editProfileForm += '
\n' editProfileForm += \ - ' ' + \ - translate['Remove scheduled posts'] + '
\n' + _editCheckBox(translate['Remove scheduled posts'], + 'removeScheduledPosts', False) editProfileForm += '
\n' return editProfileForm