Commit 130928f16a15d8b918dc0a2af4113e8519e260b4
1 parent
ceeb61d8
Exists in
proxy_base_template
Add diazobase to proxy.utils
Signed-off-by: Gustavo Jaruga <darksshades@gmail.com>
Showing
17 changed files
with
64 additions
and
64 deletions
Show diff stats
colab/proxy/gitlab/diazo.xml
colab/proxy/gitlab/views.py
colab/proxy/jenkins/views.py
colab/proxy/noosfero/diazo.xml
colab/proxy/noosfero/views.py
colab/proxy/proxybase/__init__.py
colab/proxy/proxybase/apps.py
colab/proxy/proxybase/diazobase.xml
... | ... | @@ -1,14 +0,0 @@ |
1 | -<!-- | |
2 | - This file will be included as a base rules for all diazo rules. | |
3 | - e.g.: The file proxy/noosfero/diazo.xml the first lines indicates this source file and this code will be replaced in &proxybase; | |
4 | ---> | |
5 | -<rules | |
6 | - xmlns="http://namespaces.plone.org/diazo" | |
7 | - xmlns:css="http://namespaces.plone.org/diazo/css" | |
8 | - xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> | |
9 | - | |
10 | - <before theme-children="/html/head" content-children="/html/head" /> | |
11 | - <before css:theme-children="#main-content" css:content-children="body" /> | |
12 | - | |
13 | - <merge attributes="class" css:theme="body" css:content="body" /> | |
14 | -</rules> |
colab/proxy/proxybase/views.py
... | ... | @@ -1,36 +0,0 @@ |
1 | -import json | |
2 | - | |
3 | -from django.conf import settings | |
4 | - | |
5 | -from revproxy.views import ProxyView | |
6 | - | |
7 | - | |
8 | -class ColabProxyView(ProxyView): | |
9 | - add_remote_user = settings.REVPROXY_ADD_REMOTE_USER | |
10 | - diazo_theme_template = 'base.html' | |
11 | - html5 = True | |
12 | - | |
13 | - @property | |
14 | - def upstream(self): | |
15 | - proxy_config = settings.PROXIED_APPS.get(self.app_label, {}) | |
16 | - return proxy_config.get('upstream') | |
17 | - | |
18 | - @property | |
19 | - def app_label(self): | |
20 | - raise NotImplementedError('app_label attribute must be set') | |
21 | - | |
22 | - def dispatch(self, request, *args, **kwargs): | |
23 | - | |
24 | - if request.user.is_authenticated(): | |
25 | - | |
26 | - remote_user_data = {} | |
27 | - | |
28 | - remote_user_data['email'] = request.user.email | |
29 | - remote_user_data['name'] = request.user.get_full_name() | |
30 | - | |
31 | - request.META['HTTP_REMOTE_USER_DATA'] = json.dumps( | |
32 | - remote_user_data, | |
33 | - sort_keys=True, | |
34 | - ) | |
35 | - | |
36 | - return super(ColabProxyView, self).dispatch(request, *args, **kwargs) |
colab/proxy/redmine/apps.py
colab/proxy/redmine/diazo.xml
1 | 1 | <?xml version="1.0" standalone="no" ?> |
2 | 2 | <!DOCTYPE rules [ |
3 | -<!ENTITY proxybase SYSTEM "../proxybase/diazobase.xml"> | |
3 | +<!ENTITY proxybase SYSTEM "../utils/diazobase.xml"> | |
4 | 4 | ]> |
5 | 5 | |
6 | 6 | <rules |
... | ... | @@ -8,7 +8,7 @@ |
8 | 8 | xmlns:css="http://namespaces.plone.org/diazo/css" |
9 | 9 | xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> |
10 | 10 | |
11 | - <!-- Includes base proxybase/diazobase.xml rules --> | |
11 | + <!-- Includes base utils/diazobase.xml rules --> | |
12 | 12 | &proxybase; |
13 | 13 | |
14 | 14 | <!-- Redmine specific rules --> | ... | ... |
colab/proxy/redmine/views.py
colab/proxy/trac/views.py
... | ... | @@ -0,0 +1,14 @@ |
1 | +<!-- | |
2 | + This file will be included as a base rules for all diazo rules. | |
3 | + e.g.: The file proxy/noosfero/diazo.xml the first lines indicates this source file and this code will be replaced in &proxybase; | |
4 | +--> | |
5 | +<rules | |
6 | + xmlns="http://namespaces.plone.org/diazo" | |
7 | + xmlns:css="http://namespaces.plone.org/diazo/css" | |
8 | + xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> | |
9 | + | |
10 | + <before theme-children="/html/head" content-children="/html/head" /> | |
11 | + <before css:theme-children="#main-content" css:content-children="body" /> | |
12 | + | |
13 | + <merge attributes="class" css:theme="body" css:content="body" /> | |
14 | +</rules> | ... | ... |
... | ... | @@ -0,0 +1,36 @@ |
1 | +import json | |
2 | + | |
3 | +from django.conf import settings | |
4 | + | |
5 | +from revproxy.views import ProxyView | |
6 | + | |
7 | + | |
8 | +class ColabProxyView(ProxyView): | |
9 | + add_remote_user = settings.REVPROXY_ADD_REMOTE_USER | |
10 | + diazo_theme_template = 'base.html' | |
11 | + html5 = True | |
12 | + | |
13 | + @property | |
14 | + def upstream(self): | |
15 | + proxy_config = settings.PROXIED_APPS.get(self.app_label, {}) | |
16 | + return proxy_config.get('upstream') | |
17 | + | |
18 | + @property | |
19 | + def app_label(self): | |
20 | + raise NotImplementedError('app_label attribute must be set') | |
21 | + | |
22 | + def dispatch(self, request, *args, **kwargs): | |
23 | + | |
24 | + if request.user.is_authenticated(): | |
25 | + | |
26 | + remote_user_data = {} | |
27 | + | |
28 | + remote_user_data['email'] = request.user.email | |
29 | + remote_user_data['name'] = request.user.get_full_name() | |
30 | + | |
31 | + request.META['HTTP_REMOTE_USER_DATA'] = json.dumps( | |
32 | + remote_user_data, | |
33 | + sort_keys=True, | |
34 | + ) | |
35 | + | |
36 | + return super(ColabProxyView, self).dispatch(request, *args, **kwargs) | ... | ... |