summaryrefslogtreecommitdiff
path: root/service/pixelated
diff options
context:
space:
mode:
authorsw00 <sett.wai@gmail.com>2015-10-25 18:18:23 -0200
committersw00 <sett.wai@gmail.com>2015-11-09 20:57:19 -0200
commitb230d58eaa32a7f115881cffbf5637d98d1e8299 (patch)
tree062c6c8a80ef2f2d50e1499e1e745468b6d32a07 /service/pixelated
parentf2f5473ead184032d1de6208bc2530dfb88455fc (diff)
template user's email address into title
this should solve https://github.com/pixelated/pixelated-user-agent/issues/246 needed to inject leap_session into root resource to access user email on request.
Diffstat (limited to 'service/pixelated')
-rw-r--r--service/pixelated/application.py1
-rw-r--r--service/pixelated/resources/root_resource.py10
2 files changed, 9 insertions, 2 deletions
diff --git a/service/pixelated/application.py b/service/pixelated/application.py
index bca4d5e5..3505f884 100644
--- a/service/pixelated/application.py
+++ b/service/pixelated/application.py
@@ -47,6 +47,7 @@ def start_user_agent(root_resource, leap_home, leap_session):
yield add_welcome_mail(leap_session.mail_store)
root_resource.initialize(
+ leap_session,
services.keymanager,
services.search_engine,
services.mail_service,
diff --git a/service/pixelated/resources/root_resource.py b/service/pixelated/resources/root_resource.py
index e6046eae..fd3c4f92 100644
--- a/service/pixelated/resources/root_resource.py
+++ b/service/pixelated/resources/root_resource.py
@@ -1,5 +1,6 @@
import os
import requests
+from string import Template
from pixelated.resources.attachments_resource import AttachmentsResource
from pixelated.resources.contacts_resource import ContactsResource
from pixelated.resources.features_resource import FeaturesResource
@@ -22,6 +23,7 @@ class RootResource(Resource):
Resource.__init__(self)
self._startup_assets_folder = self._get_startup_folder()
self._static_folder = self._get_static_folder()
+ self._html_template = open(os.path.join(self._static_folder, 'index.html')).read()
self._startup_mode()
def _startup_mode(self):
@@ -33,7 +35,9 @@ class RootResource(Resource):
return self
return Resource.getChild(self, path, request)
- def initialize(self, keymanager, search_engine, mail_service, draft_service, feedback_service):
+ def initialize(self, leap_session, keymanager, search_engine, mail_service, draft_service, feedback_service):
+ self._leap_session = leap_session
+
self.putChild('assets', File(self._static_folder))
self.putChild('keys', KeysResource(keymanager))
self.putChild('attachment', AttachmentsResource(mail_service))
@@ -67,4 +71,6 @@ class RootResource(Resource):
if self._is_starting():
return open(os.path.join(self._startup_assets_folder, 'Interstitial.html')).read()
else:
- return open(os.path.join(self._static_folder, 'index.html')).read()
+ email = self._leap_session.account_email()
+ response = Template(self._html_template).safe_substitute(account_email=email)
+ return str(response)