diff --git a/daemon.py b/daemon.py
index 6c4b31b3e..cb3b20435 100644
--- a/daemon.py
+++ b/daemon.py
@@ -256,6 +256,7 @@ from cache import checkForChangedActor
from cache import storePersonInCache
from cache import getPersonFromCache
from httpsig import verifyPostHeaders
+from theme import exportTheme
from theme import isNewsThemeName
from theme import getTextModeBanner
from theme import setNewsAvatar
@@ -4147,6 +4148,18 @@ class PubServer(BaseHTTPRequestHandler):
print('WARN: profile update, no text ' +
'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
actorFilename = \
baseDir + '/accounts/' + \
diff --git a/theme.py b/theme.py
index 4aec87b13..00e1b33a4 100644
--- a/theme.py
+++ b/theme.py
@@ -11,9 +11,28 @@ from utils import loadJson
from utils import saveJson
from utils import getImageExtensions
from shutil import copyfile
+from shutil import make_archive
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() -> []:
"""Gets the list of theme style sheets
"""
diff --git a/webapp_profile.py b/webapp_profile.py
index 4f4dac110..19d8ce03e 100644
--- a/webapp_profile.py
+++ b/webapp_profile.py
@@ -1347,7 +1347,7 @@ def htmlEditProfile(cssCache: {}, translate: {}, baseDir: str, path: str,
translate['Export Theme'] + '
\n'
graphicsStr += \
' \n'
+ 'name="submitExportTheme">➤\n'
graphicsStr += ' \n'