summaryrefslogtreecommitdiff
path: root/service/pixelated
diff options
context:
space:
mode:
authorRoald de Vries <rdevries@thoughtworks.com>2016-11-18 13:47:32 +0100
committerRoald de Vries <rdevries@thoughtworks.com>2016-11-18 13:52:14 +0100
commit6cdfb2110b0f96502eeaaf98f59a05704534cdff (patch)
tree5b90c24ab4e2501ccea8c1ddbf23e7c4837ed3c6 /service/pixelated
parent44112ced551f36972770704b2ee7ef61a455df83 (diff)
serve signup page through twisted
Diffstat (limited to 'service/pixelated')
-rw-r--r--service/pixelated/resources/login_resource.py13
-rw-r--r--service/pixelated/resources/root_resource.py14
2 files changed, 27 insertions, 0 deletions
diff --git a/service/pixelated/resources/login_resource.py b/service/pixelated/resources/login_resource.py
index d5555b90..905b872c 100644
--- a/service/pixelated/resources/login_resource.py
+++ b/service/pixelated/resources/login_resource.py
@@ -39,6 +39,17 @@ def _get_startup_folder():
return os.path.join(path, '..', 'assets')
+def _get_public_folder():
+ static_folder = os.path.abspath(os.path.join(os.path.abspath(__file__), "..", "..", "..", "web-ui", "public"))
+ # this is a workaround for packaging
+ if not os.path.exists(static_folder):
+ static_folder = os.path.abspath(
+ os.path.join(os.path.abspath(__file__), "..", "..", "..", "..", "web-ui", "public"))
+ if not os.path.exists(static_folder):
+ static_folder = os.path.join('/', 'usr', 'share', 'pixelated-user-agent')
+ return static_folder
+
+
def _get_static_folder():
static_folder = os.path.abspath(os.path.join(os.path.abspath(__file__), "..", "..", "..", "web-ui", "app"))
# this is a workaround for packaging
@@ -107,6 +118,7 @@ class LoginResource(BaseResource):
def __init__(self, services_factory, provider=None, disclaimer_banner=None, authenticator=None):
BaseResource.__init__(self, services_factory)
self._static_folder = _get_static_folder()
+ self._public_folder = _get_public_folder()
self._startup_folder = _get_startup_folder()
self._disclaimer_banner = disclaimer_banner
self._provider = provider
@@ -114,6 +126,7 @@ class LoginResource(BaseResource):
self._bootstrap_user_services = BootstrapUserServices(services_factory, provider)
self.putChild('startup-assets', File(self._startup_folder))
+ self.putChild('public-assets', File(self._public_folder))
with open(os.path.join(self._startup_folder, 'Interstitial.html')) as f:
self.interstitial = f.read()
diff --git a/service/pixelated/resources/root_resource.py b/service/pixelated/resources/root_resource.py
index 8df76c70..8fa80bb2 100644
--- a/service/pixelated/resources/root_resource.py
+++ b/service/pixelated/resources/root_resource.py
@@ -51,6 +51,7 @@ class RootResource(BaseResource):
def __init__(self, services_factory):
BaseResource.__init__(self, services_factory)
self._startup_assets_folder = self._get_startup_folder()
+ self._public_assets_folder = self._get_public_folder()
self._static_folder = self._get_static_folder()
self._html_template = open(os.path.join(self._static_folder, 'index.html')).read()
self._services_factory = services_factory
@@ -61,6 +62,7 @@ class RootResource(BaseResource):
def _startup_mode(self):
self.putChild('startup-assets', File(self._startup_assets_folder))
+ self.putChild('public-assets', File(self._public_assets_folder))
self._mode = MODE_STARTUP
def getChild(self, path, request):
@@ -106,10 +108,22 @@ class RootResource(BaseResource):
self._mode = MODE_RUNNING
+ # TODO: use the public folder for this
def _get_startup_folder(self):
path = os.path.dirname(os.path.abspath(__file__))
return os.path.join(path, '..', 'assets')
+ def _get_public_folder(self):
+ public_folder = os.path.abspath(os.path.join(os.path.abspath(__file__), "..", "..", "..", "web-ui", "public"))
+ # this is a workaround for packaging
+ if not os.path.exists(public_folder):
+ public_folder = os.path.abspath(
+ os.path.join(os.path.abspath(__file__), "..", "..", "..", "..", "web-ui", "public"))
+ if not os.path.exists(public_folder):
+ # TODO: how is this packaged?
+ public_folder = os.path.join('/', 'usr', 'share', 'pixelated-user-agent')
+ return public_folder
+
def _get_static_folder(self):
static_folder = os.path.abspath(os.path.join(os.path.abspath(__file__), "..", "..", "..", "web-ui", "app"))
# this is a workaround for packaging