commit c944d4c5e9c398b1ddb5720625ed2a8a187e1fff Author: j Date: Sun Jul 14 14:55:58 2019 +0100 inital commit diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..0d20b64 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.pyc diff --git a/README.md b/README.md new file mode 100644 index 0000000..5c8390a --- /dev/null +++ b/README.md @@ -0,0 +1,26 @@ +# pan.do/ra site config overlay + +fork this repo into pandora_ and add your pan.do/ra customizations + +place your config as config.jsonc, add custom files to static/js, poster scripts to scripts + +custom files should be in the form ..js + +i.e. js overlay: + + static/js/home..js + +png overly the same i.e. + + static/png/icon..png + +poster/icon script without : + script/item_icon.py + script/list_icon.py + script/potser.py + +if you need a custom django module, touch __init__.py and install.py will take care of that too. + +to use js pages from other sites, add them to overwrite in install.py + +to deploy, checkout your fork into /srv/pandora/pandora/ and run ./install.py diff --git a/install.py b/install.py new file mode 100755 index 0000000..53257ac --- /dev/null +++ b/install.py @@ -0,0 +1,85 @@ +#!/usr/bin/python3 + +import os +from os.path import join, abspath, basename, dirname + +# change this +name = 'placeholder' +overwrite = ( + #('home', 'indiancinema'), + #('infoView', 'indiancinema'), +) + +base = abspath(dirname(__file__)) +os.chdir(base) + +for root, folders, files in os.walk(join(base, 'static')): + for f in files: + src = join(root, f) + target = src.replace(base, '/srv/pandora') + rel_src = os.path.relpath(src, dirname(target)) + if os.path.exists(target): + os.unlink(target) + os.symlink(rel_src, target) + +if overwrite: + os.chdir('/srv/pandora/static/js') + for filename, sitename in overwrite: + src = '%s.%s.js' % (filename, sitename) + target = '%s.%s.js' % (filename, name) + if os.path.exists(target): + os.unlink(target) + os.symlink(src, target) + +os.chdir(base) +src = join(base, 'config.jsonc') +target = '/srv/pandora/pandora/config.%s.jsonc' % name +rel_src = os.path.relpath(src, dirname(target)) +if os.path.exists(target): + os.unlink(target) +os.symlink(rel_src, target) +t = '/srv/pandora/pandora/config.jsonc' +if os.path.exists(t): + os.unlink(t) +os.symlink(basename(target), t) + +for root, folders, files in os.walk(join(base, 'scripts')): + for f in files: + src = join(root, f) + target = src.replace(base, '/srv/pandora') + rel_src = os.path.relpath(src, dirname(target)) + if os.path.exists(target): + os.unlink(target) + os.symlink(rel_src, target) + if f == 'poster.%s.py' % name: + t = os.path.join(dirname(target), 'poster.py') + if os.path.exists(t): + os.unlink(t) + os.symlink(f, os.path.join(dirname(target), t)) + + +if os.path.exists('__init__.py'): + # make module available to pandora + target = os.path.join('/srv/pandora/pandora/', name) + rel_src = os.path.relpath(base, dirname(target)) + if os.path.exists(target): + os.unlink(target) + os.symlink(rel_src, target) + + # include module in local settings + local_settings_py = '/srv/pandora/pandora/local_settings.py' + with open(local_settings_py) as fd: + local_settings_changed = False + local_settings = fd.read() + if 'LOCAL_APPS' not in local_settings: + local_settings += '\nLOCAL_APPS = ["%s"]\n' % name + local_settings_changed = True + else: + apps = re.compile('(LOCAL_APPS.*?)\]', re.DOTALL).findall(local_settings)[0] + if name not in apps: + new_apps = apps.strip() + ',\n"%s"\n' % name + local_settings = local_settings.replace(apps, new_apps) + local_settings_changed = True + if local_settings_changed: + with open(local_settings_py, 'w') as fd: + fd.write(local_settings)