Commit 130928f16a15d8b918dc0a2af4113e8519e260b4

Authored by Gust
1 parent ceeb61d8

Add diazobase to proxy.utils

Signed-off-by: Gustavo Jaruga <darksshades@gmail.com>
colab/proxy/gitlab/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
... ...
colab/proxy/gitlab/views.py
1 1  
2   -from ..utils.views import ColabProxyView
3 2 from django.conf import settings
4 3  
  4 +from ..utils.views import ColabProxyView
5 5  
6 6 class GitlabProxyView(ColabProxyView):
7 7 app_label = 'gitlab'
... ...
colab/proxy/jenkins/views.py
1 1  
2 2 from django.conf import settings
3 3  
4   -from ..proxybase.views import ColabProxyView
  4 +from ..utils.views import ColabProxyView
5 5  
6 6  
7 7 class JenkinsProxyView(ColabProxyView):
... ...
colab/proxy/noosfero/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
... ...
colab/proxy/noosfero/views.py
1 1  
2 2 from django.conf import settings
3 3  
4   -from ..proxybase.views import ColabProxyView
  4 +from ..utils.views import ColabProxyView
5 5  
6 6  
7 7 class NoosferoProxyView(ColabProxyView):
... ...
colab/proxy/proxybase/__init__.py
colab/proxy/proxybase/apps.py
... ... @@ -1,4 +0,0 @@
1   -from django.apps import AppConfig
2   -
3   -class ColabProxiedAppConfig(AppConfig):
4   - colab_proxied_app = True
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
1 1  
2   -from ..proxybase.apps import ColabProxiedAppConfig
  2 +from ..utils.apps import ColabProxiedAppConfig
3 3  
4 4  
5 5 class ProxyRedmineAppConfig(ColabProxiedAppConfig):
... ...
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
1 1  
2 2 from django.conf import settings
3 3  
4   -from ..proxybase.views import ColabProxyView
  4 +from ..utils.views import ColabProxyView
5 5  
6 6  
7 7 class RedmineProxyView(ColabProxyView):
... ...
colab/proxy/trac/views.py
... ... @@ -3,7 +3,7 @@ from django.conf import settings
3 3  
4 4 from hitcounter.views import HitCounterViewMixin
5 5  
6   -from ..proxybase.views import ColabProxyView
  6 +from ..utils.views import ColabProxyView
7 7 from .models import Wiki, Ticket, Revision
8 8  
9 9  
... ...
colab/proxy/utils/__.init__.py 0 → 100644
colab/proxy/utils/apps.py 0 → 100644
... ... @@ -0,0 +1,4 @@
  1 +from django.apps import AppConfig
  2 +
  3 +class ColabProxiedAppConfig(AppConfig):
  4 + colab_proxied_app = True
... ...
colab/proxy/utils/diazobase.xml 0 → 100644
... ... @@ -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>
... ...
colab/proxy/utils/views.py 0 → 100644
... ... @@ -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)
... ...