diff --git a/daemon.py b/daemon.py index a75dca7cf..b3c939fcc 100644 --- a/daemon.py +++ b/daemon.py @@ -214,6 +214,7 @@ from utils import hasUsersPath from utils import getFullDomain from utils import removeHtml from utils import isEditor +from utils import isArtist from utils import getImageExtensions from utils import mediaFileMimeType from utils import getCSS @@ -4269,6 +4270,38 @@ class PubServer(BaseHTTPRequestHandler): if checkNameAndBio: redirectPath = 'previewAvatar' + if nickname == adminNickname or \ + isArtist(baseDir, nickname): + # change theme + if fields.get('themeDropdown'): + self.server.themeName = fields['themeDropdown'] + setTheme(baseDir, self.server.themeName, domain, + allowLocalNetworkAccess, systemLanguage) + self.server.textModeBanner = \ + getTextModeBanner(self.server.baseDir) + self.server.iconsCache = {} + self.server.fontsCache = {} + self.server.showPublishAsIcon = \ + getConfigParam(self.server.baseDir, + 'showPublishAsIcon') + self.server.fullWidthTimelineButtonHeader = \ + getConfigParam(self.server.baseDir, + 'fullWidthTimelineButtonHeader') + self.server.iconsAsButtons = \ + getConfigParam(self.server.baseDir, + 'iconsAsButtons') + self.server.rssIconAtTop = \ + getConfigParam(self.server.baseDir, + 'rssIconAtTop') + self.server.publishButtonAtTop = \ + getConfigParam(self.server.baseDir, + 'publishButtonAtTop') + setNewsAvatar(baseDir, + fields['themeDropdown'], + httpPrefix, + domain, + domainFull) + if nickname == adminNickname: # change media instance status if fields.get('mediaInstance'): @@ -4353,36 +4386,6 @@ class PubServer(BaseHTTPRequestHandler): "blogsInstance", self.server.blogsInstance) - # change theme - if fields.get('themeDropdown'): - self.server.themeName = fields['themeDropdown'] - setTheme(baseDir, self.server.themeName, domain, - allowLocalNetworkAccess, systemLanguage) - self.server.textModeBanner = \ - getTextModeBanner(self.server.baseDir) - self.server.iconsCache = {} - self.server.fontsCache = {} - self.server.showPublishAsIcon = \ - getConfigParam(self.server.baseDir, - 'showPublishAsIcon') - self.server.fullWidthTimelineButtonHeader = \ - getConfigParam(self.server.baseDir, - 'fullWidthTimelineButtonHeader') - self.server.iconsAsButtons = \ - getConfigParam(self.server.baseDir, - 'iconsAsButtons') - self.server.rssIconAtTop = \ - getConfigParam(self.server.baseDir, - 'rssIconAtTop') - self.server.publishButtonAtTop = \ - getConfigParam(self.server.baseDir, - 'publishButtonAtTop') - setNewsAvatar(baseDir, - fields['themeDropdown'], - httpPrefix, - domain, - domainFull) - # change instance title if fields.get('instanceTitle'): currInstanceTitle = \ @@ -4953,7 +4956,10 @@ class PubServer(BaseHTTPRequestHandler): # remove a custom font if fields.get('removeCustomFont'): - if fields['removeCustomFont'] == 'on': + if (fields['removeCustomFont'] == 'on' and + (isArtist(baseDir, nickname) or + path.startswith('/users/' + + adminNickname + '/'))): fontExt = ('woff', 'woff2', 'otf', 'ttf') for ext in fontExt: if os.path.isfile(baseDir + @@ -4969,28 +4975,30 @@ class PubServer(BaseHTTPRequestHandler): currTheme = getTheme(baseDir) if currTheme: self.server.themeName = currTheme + allowLocalNetworkAccess = \ + self.server.allowLocalNetworkAccess setTheme(baseDir, currTheme, domain, - self.server.allowLocalNetworkAccess, + allowLocalNetworkAccess, systemLanguage) self.server.textModeBanner = \ - getTextModeBanner(self.server.baseDir) + getTextModeBanner(baseDir) self.server.iconsCache = {} self.server.fontsCache = {} self.server.showPublishAsIcon = \ - getConfigParam(self.server.baseDir, + getConfigParam(baseDir, 'showPublishAsIcon') self.server.fullWidthTimelineButtonHeader = \ - getConfigParam(self.server.baseDir, + getConfigParam(baseDir, 'fullWidthTimeline' + 'ButtonHeader') self.server.iconsAsButtons = \ - getConfigParam(self.server.baseDir, + getConfigParam(baseDir, 'iconsAsButtons') self.server.rssIconAtTop = \ - getConfigParam(self.server.baseDir, + getConfigParam(baseDir, 'rssIconAtTop') self.server.publishButtonAtTop = \ - getConfigParam(self.server.baseDir, + getConfigParam(baseDir, 'publishButtonAtTop') # only receive DMs from accounts you follow @@ -5090,14 +5098,17 @@ class PubServer(BaseHTTPRequestHandler): actorChanged = True # grayscale theme - grayscale = False - if fields.get('grayscale'): - if fields['grayscale'] == 'on': - grayscale = True - if grayscale: - enableGrayscale(baseDir) - else: - disableGrayscale(baseDir) + if path.startswith('/users/' + + adminNickname + '/') or \ + isArtist(baseDir, nickname): + grayscale = False + if fields.get('grayscale'): + if fields['grayscale'] == 'on': + grayscale = True + if grayscale: + enableGrayscale(baseDir) + else: + disableGrayscale(baseDir) # save filtered words list filterFilename = \ diff --git a/translations/ar.json b/translations/ar.json index 840867db3..3c148225a 100644 --- a/translations/ar.json +++ b/translations/ar.json @@ -443,5 +443,6 @@ "Joined": "تاريخ الانضمام", "City for spoofed GPS image metadata": "مدينة للبيانات الوصفية لصور GPS المخادعة", "Occupation": "الاحتلال", - "Artists": "الفنانين" + "Artists": "الفنانين", + "Graphic Design": "التصميم الجرافيكي" } diff --git a/translations/ca.json b/translations/ca.json index f1c1fca10..ac083d8b0 100644 --- a/translations/ca.json +++ b/translations/ca.json @@ -443,5 +443,6 @@ "Joined": "Data d'unió", "City for spoofed GPS image metadata": "Ciutat per a metadades d'imatges GPS falsificades", "Occupation": "Ocupació", - "Artists": "Artistes" + "Artists": "Artistes", + "Graphic Design": "Disseny gràfic" } diff --git a/translations/cy.json b/translations/cy.json index 40b5fe58b..92be8ccfc 100644 --- a/translations/cy.json +++ b/translations/cy.json @@ -443,5 +443,6 @@ "Joined": "Dyddiad ymuno", "City for spoofed GPS image metadata": "Dinas ar gyfer metadata delwedd GPS spoofed", "Occupation": "Ngalwedigaeth", - "Artists": "Artistiaid" + "Artists": "Artistiaid", + "Graphic Design": "Dylunio Graffig" } diff --git a/translations/de.json b/translations/de.json index e41a714ad..9d21db01f 100644 --- a/translations/de.json +++ b/translations/de.json @@ -443,5 +443,6 @@ "Joined": "Verbundenes Datum", "City for spoofed GPS image metadata": "Stadt für gefälschte GPS-Bildmetadaten", "Occupation": "Besetzung", - "Artists": "Künstler" + "Artists": "Künstler", + "Graphic Design": "Grafikdesign" } diff --git a/translations/en.json b/translations/en.json index 59d1dbe25..f7b950842 100644 --- a/translations/en.json +++ b/translations/en.json @@ -443,5 +443,6 @@ "Joined": "Joined", "City for spoofed GPS image metadata": "City for spoofed GPS image metadata", "Occupation": "Occupation", - "Artists": "Artists" + "Artists": "Artists", + "Graphic Design": "Graphic Design" } diff --git a/translations/es.json b/translations/es.json index 9c0a37375..9f79db640 100644 --- a/translations/es.json +++ b/translations/es.json @@ -443,5 +443,6 @@ "Joined": "Fecha unida", "City for spoofed GPS image metadata": "Ciudad para metadatos de imagen GPS falsificados", "Occupation": "Ocupación", - "Artists": "Artistas" + "Artists": "Artistas", + "Graphic Design": "Diseño gráfico" } diff --git a/translations/fr.json b/translations/fr.json index da8960e5f..bdc6e3280 100644 --- a/translations/fr.json +++ b/translations/fr.json @@ -443,5 +443,6 @@ "Joined": "Joint", "City for spoofed GPS image metadata": "Ville pour les métadonnées d'image GPS falsifiées", "Occupation": "Occupation", - "Artists": "Artistes" + "Artists": "Artistes", + "Graphic Design": "Conception graphique" } diff --git a/translations/ga.json b/translations/ga.json index eb408a367..2755d94a0 100644 --- a/translations/ga.json +++ b/translations/ga.json @@ -443,5 +443,6 @@ "Joined": "Dáta comhcheangailte", "City for spoofed GPS image metadata": "Cathair le haghaidh meiteashonraí íomhá GPS spoofed", "Occupation": "Slí bheatha", - "Artists": "Ealaíontóirí" + "Artists": "Ealaíontóirí", + "Graphic Design": "Dearadh grafach" } diff --git a/translations/hi.json b/translations/hi.json index 50d671084..77cd7bb76 100644 --- a/translations/hi.json +++ b/translations/hi.json @@ -443,5 +443,6 @@ "Joined": "दिनांक", "City for spoofed GPS image metadata": "स्पूफ जीपीएस जीपीएस मेटाडेटा के लिए शहर", "Occupation": "व्यवसाय", - "Artists": "कलाकार की" + "Artists": "कलाकार की", + "Graphic Design": "ग्राफ़िक डिज़ाइन" } diff --git a/translations/it.json b/translations/it.json index a3c118e9a..cd8b2cd25 100644 --- a/translations/it.json +++ b/translations/it.json @@ -443,5 +443,6 @@ "Joined": "Unito", "City for spoofed GPS image metadata": "Città per metadati di immagini GPS falsificate", "Occupation": "Occupazione", - "Artists": "Artiste" + "Artists": "Artiste", + "Graphic Design": "Graphic design" } diff --git a/translations/ja.json b/translations/ja.json index efa074b6c..25935464c 100644 --- a/translations/ja.json +++ b/translations/ja.json @@ -443,5 +443,6 @@ "Joined": "参加日", "City for spoofed GPS image metadata": "なりすましGPS画像メタデータの都市", "Occupation": "職業", - "Artists": "アーティスト" + "Artists": "アーティスト", + "Graphic Design": "グラフィックデザイン" } diff --git a/translations/ku.json b/translations/ku.json index 02c086a7a..b4dd76fc2 100644 --- a/translations/ku.json +++ b/translations/ku.json @@ -443,5 +443,6 @@ "Joined": "Beşdarbûna Dîrokê", "City for spoofed GPS image metadata": "Bajar ji bo metadata wêneya GPS ya xapînok", "Occupation": "Sinet", - "Artists": "Hunermend" + "Artists": "Hunermend", + "Graphic Design": "Sêwirana grafîkî" } diff --git a/translations/oc.json b/translations/oc.json index 518eae8fb..b57a869f4 100644 --- a/translations/oc.json +++ b/translations/oc.json @@ -439,5 +439,6 @@ "Joined": "Joined", "City for spoofed GPS image metadata": "City for spoofed GPS image metadata", "Occupation": "Occupation", - "Artists": "Artists" + "Artists": "Artists", + "Graphic Design": "Graphic Design" } diff --git a/translations/pt.json b/translations/pt.json index b879a81e4..aa3508853 100644 --- a/translations/pt.json +++ b/translations/pt.json @@ -443,5 +443,6 @@ "Joined": "Data juntada", "City for spoofed GPS image metadata": "Cidade para metadados de imagem GPS falsificados", "Occupation": "Ocupação", - "Artists": "Artistas" + "Artists": "Artistas", + "Graphic Design": "Design gráfico" } diff --git a/translations/ru.json b/translations/ru.json index 2c69993fe..6aad20e8f 100644 --- a/translations/ru.json +++ b/translations/ru.json @@ -443,5 +443,6 @@ "Joined": "Присоединенная дата", "City for spoofed GPS image metadata": "Город для поддельных метаданных изображения GPS", "Occupation": "Занятие", - "Artists": "Художники" + "Artists": "Художники", + "Graphic Design": "Графический дизайн" } diff --git a/translations/zh.json b/translations/zh.json index 04d1893dc..81287ecc1 100644 --- a/translations/zh.json +++ b/translations/zh.json @@ -443,5 +443,6 @@ "Joined": "加入日期", "City for spoofed GPS image metadata": "欺骗性GPS影像元数据的城市", "Occupation": "职业", - "Artists": "艺人" + "Artists": "艺人", + "Graphic Design": "平面设计" } diff --git a/utils.py b/utils.py index c478158d7..0a54a3148 100644 --- a/utils.py +++ b/utils.py @@ -194,6 +194,34 @@ def isEditor(baseDir: str, nickname: str) -> bool: return False +def isArtist(baseDir: str, nickname: str) -> bool: + """Returns true if the given nickname is an artist + """ + artistsFile = baseDir + '/accounts/artists.txt' + + if not os.path.isfile(artistsFile): + adminName = getConfigParam(baseDir, 'admin') + if not adminName: + return False + if adminName == nickname: + return True + return False + + with open(artistsFile, "r") as f: + lines = f.readlines() + if len(lines) == 0: + adminName = getConfigParam(baseDir, 'admin') + if not adminName: + return False + if adminName == nickname: + return True + for artist in lines: + artist = artist.strip('\n').strip('\r') + if artist == nickname: + return True + return False + + def getImageExtensions() -> []: """Returns a list of the possible image file extensions """ diff --git a/webapp_profile.py b/webapp_profile.py index 5abbea6af..71a4e32df 100644 --- a/webapp_profile.py +++ b/webapp_profile.py @@ -12,6 +12,7 @@ from utils import getOccupationName from utils import getLockedAccount from utils import hasUsersPath from utils import getFullDomain +from utils import isArtist from utils import isDormant from utils import getNicknameFromActor from utils import getDomainFromActor @@ -1292,6 +1293,49 @@ def htmlEditProfile(cssCache: {}, translate: {}, baseDir: str, path: str, peertubeStr = '' adminNickname = getConfigParam(baseDir, 'admin') + + if isArtist(baseDir, nickname) or \ + path.startswith('/users/' + str(adminNickname) + '/'): + graphicsStr = '
' + \ + translate['Graphic Design'] + '\n' + graphicsStr += '
' + + # Themes section + themes = getThemesList(baseDir) + themesDropdown += '

\n' + grayscaleFilename = \ + baseDir + '/accounts/.grayscale' + grayscale = '' + if os.path.isfile(grayscaleFilename): + grayscale = 'checked' + themesDropdown += \ + ' ' + translate['Grayscale'] + '
' + themesDropdown += '
' + if os.path.isfile(baseDir + '/fonts/custom.woff') or \ + os.path.isfile(baseDir + '/fonts/custom.woff2') or \ + os.path.isfile(baseDir + '/fonts/custom.otf') or \ + os.path.isfile(baseDir + '/fonts/custom.ttf'): + themesDropdown += \ + ' ' + \ + translate['Remove the custom font'] + '
' + themeName = getConfigParam(baseDir, 'theme') + themesDropdown = \ + themesDropdown.replace('
\n' + if adminNickname: if path.startswith('/users/' + adminNickname + '/'): # Instance details section @@ -1346,40 +1390,6 @@ def htmlEditProfile(cssCache: {}, translate: {}, baseDir: str, path: str, '
\n' - # Themes section - themes = getThemesList(baseDir) - themesDropdown += '

\n' - grayscaleFilename = \ - baseDir + '/accounts/.grayscale' - grayscale = '' - if os.path.isfile(grayscaleFilename): - grayscale = 'checked' - themesDropdown += \ - ' ' + translate['Grayscale'] + '
' - themesDropdown += '
' - if os.path.isfile(baseDir + '/fonts/custom.woff') or \ - os.path.isfile(baseDir + '/fonts/custom.woff2') or \ - os.path.isfile(baseDir + '/fonts/custom.otf') or \ - os.path.isfile(baseDir + '/fonts/custom.ttf'): - themesDropdown += \ - ' ' + \ - translate['Remove the custom font'] + '
' - themeName = getConfigParam(baseDir, 'theme') - themesDropdown = \ - themesDropdown.replace('