diff --git a/change-theme.sh b/change-theme.sh new file mode 100644 index 0000000..59fce13 --- /dev/null +++ b/change-theme.sh @@ -0,0 +1,5 @@ +#!/bin/bash + +source ~/envs/publik-env-py3/bin/activate +hobo-manage tenant_command runscript ~/src/misc-tjund/hobo-change-theme.py -d hobo.dev.publik.love --theme $1 +deactivate diff --git a/hobo-change-theme.py b/hobo-change-theme.py new file mode 100644 index 0000000..f85fab1 --- /dev/null +++ b/hobo-change-theme.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +# +# Change Publik theme +# +# Usage: +# --theme THEME -- theme to shot (substring match) +# +# Example: +# hobo-manage tenant_command runscript hobo-change-theme.py -d hobo.dev.publik.love --theme new-theme-id +# + +from hobo.theme.utils import get_selected_theme, set_theme +from hobo.deploy.signals import notify_agents +import sys +import argparse + +parser = argparse.ArgumentParser() +parser.add_argument('--theme', dest='theme', type=str) +args = parser.parse_args() + +theme_id = args.theme +if get_selected_theme() != theme_id: + set_theme(theme_id) + notify_agents(None) +print(get_selected_theme()) diff --git a/package.json b/package.json index fd4fe2d..00e0841 100644 --- a/package.json +++ b/package.json @@ -17,12 +17,13 @@ "scripts": { "explore:css": "cd $npm_package_config_themefolder && postcss static/**/style.css --config postcss.config.js --dir /tmp/ > /tmp/explorecss.txt", "stop:memcache": "sudo systemctl stop memcached", + "change:theme": "bash misc-tjund/change-theme.sh $npm_package_config_theme", "build:css": "cd $npm_package_config_themefolder && make static/$npm_package_config_theme/style.css", "build:themes": "cd $npm_package_config_themefolder && make themes.json", "watch:scss": "cd $npm_package_config_themefolder && chokidar 'static/**/*.scss' -c 'npm run build:css'", "watch:config": "cd $npm_package_config_themefolder && chokidar 'static/**/config.json' -c 'npm run build:themes'", "serve": "node npm_serve.js", - "dev": "run-p watch:* & npm run serve" + "dev": "npm run change:theme && run-p watch:* & npm run serve" }, "devDependencies": { "browser-sync": "^2.26.7",