Link to exported theme

main
Bob Mottram 2021-05-28 22:39:34 +01:00
parent acd8aaa50f
commit b168fde295
3 changed files with 33 additions and 1 deletions

View File

@ -256,6 +256,7 @@ from cache import checkForChangedActor
from cache import storePersonInCache from cache import storePersonInCache
from cache import getPersonFromCache from cache import getPersonFromCache
from httpsig import verifyPostHeaders from httpsig import verifyPostHeaders
from theme import exportTheme
from theme import isNewsThemeName from theme import isNewsThemeName
from theme import getTextModeBanner from theme import getTextModeBanner
from theme import setNewsAvatar from theme import setNewsAvatar
@ -4147,6 +4148,18 @@ class PubServer(BaseHTTPRequestHandler):
print('WARN: profile update, no text ' + print('WARN: profile update, no text ' +
'fields could be extracted from POST') 'fields could be extracted from POST')
if fields.get('submitExportTheme'):
print('submitExportTheme')
themeDownloadPath = actorStr
if exportTheme(self.server.baseDir,
self.server.themeName):
themeDownloadPath += \
'/exports/' + self.server.themeName + '.zip'
self._redirect_headers(themeDownloadPath,
cookie, callingDomain)
self.server.POSTbusy = False
return
# load the json for the actor for this user # load the json for the actor for this user
actorFilename = \ actorFilename = \
baseDir + '/accounts/' + \ baseDir + '/accounts/' + \

View File

@ -11,9 +11,28 @@ from utils import loadJson
from utils import saveJson from utils import saveJson
from utils import getImageExtensions from utils import getImageExtensions
from shutil import copyfile from shutil import copyfile
from shutil import make_archive
from content import dangerousCSS from content import dangerousCSS
def exportTheme(baseDir: str, theme: str) -> bool:
"""Exports a theme as a zip file
"""
themeDir = baseDir + '/theme/' + theme
if not os.path.isdir(themeDir):
return False
if not os.path.isdir(baseDir + '/exports'):
os.mkdir(baseDir + '/exports')
exportFilename = baseDir + '/exports/' + theme + '.zip'
if os.path.isfile(exportFilename):
os.remove(exportFilename)
try:
make_archive(exportFilename, 'zip', themeDir)
except BaseException:
pass
return os.path.isfile(exportFilename)
def _getThemeFiles() -> []: def _getThemeFiles() -> []:
"""Gets the list of theme style sheets """Gets the list of theme style sheets
""" """

View File

@ -1347,7 +1347,7 @@ def htmlEditProfile(cssCache: {}, translate: {}, baseDir: str, path: str,
translate['Export Theme'] + '</label><br>\n' translate['Export Theme'] + '</label><br>\n'
graphicsStr += \ graphicsStr += \
' <button type="submit" class="button" ' + \ ' <button type="submit" class="button" ' + \
'name="exportTheme">➤</button>\n' 'name="submitExportTheme">➤</button>\n'
graphicsStr += ' </div></details>\n' graphicsStr += ' </div></details>\n'