Projet

Général

Profil

0001-distribute-theme-for-portail-agent-7294.patch

Frédéric Péters, 20 mai 2015 11:32

Télécharger (11 ko)

Voir les différences:

Subject: [PATCH] distribute theme for "portail agent" (#7294)

 MANIFEST.in                                        |  1 +
 data/themes/gadjo/static/css/agent-portal.css      |  5 ++
 data/themes/gadjo/static/js/publik.js              | 86 ++++++++++++++++++++++
 .../themes/gadjo/templates/combo/manager_base.html | 38 ++++++++++
 data/themes/gadjo/templates/combo/menu.html        | 14 ++++
 .../gadjo/templates/combo/page_template.html       | 38 ++++++++++
 .../templates/combo/page_template_sidebar.html     | 13 ++++
 data/themes/gadjo/templates/combo/placeholder.html |  8 ++
 setup.py                                           |  9 +++
 9 files changed, 212 insertions(+)
 create mode 100644 data/themes/gadjo/static/css/agent-portal.css
 create mode 100644 data/themes/gadjo/static/js/publik.js
 create mode 100644 data/themes/gadjo/templates/combo/manager_base.html
 create mode 100644 data/themes/gadjo/templates/combo/menu.html
 create mode 100644 data/themes/gadjo/templates/combo/page_template.html
 create mode 100644 data/themes/gadjo/templates/combo/page_template_sidebar.html
 create mode 100644 data/themes/gadjo/templates/combo/placeholder.html
MANIFEST.in
4 4
# static
5 5
recursive-include combo/manager/static *.css *.js *.ico *.gif *.png *.jpg
6 6
recursive-include combo/public/static *.css *.js *.ico *.gif *.png *.jpg
7
recursive-include data/themes *.css *.js  *.gif *.png *.jpg *.jpeg *.html
7 8

  
8 9
# templates
9 10
recursive-include combo/apps/wcs/templates *.html
data/themes/gadjo/static/css/agent-portal.css
1
div.welcome {
2
	border: 1px solid #e4e4e4;
3
	background: #fcfcfc;
4
	padding: 1ex;
5
}
data/themes/gadjo/static/js/publik.js
1
GADJO_DEFAULT_SIDEPAGE_STATUS = 'expanded';
2

  
3
$(function() {
4
  var all_done = false;
5

  
6
  function check_all_done() {
7
    var local_done = true;
8
    $(HOBO_ENVIRONMENT).each(function(index, service) {
9
      if (service.data === undefined) {
10
        local_done = false;
11
      }
12
    });
13
    all_done = local_done;
14
    if (all_done) {
15
      window.sessionStorage.hobo_environment = JSON.stringify(HOBO_ENVIRONMENT);
16
      window.sessionStorage.hobo_environment_timestamp = Date.now();
17
      create_menu_items();
18
    }
19
  }
20

  
21
  function create_menu_items() {
22
    $('#sidepage-menu').remove();
23
    var menu_links = $('<ul id="sidepage-menu">');
24
    var more_entries = Array();
25
    $(HOBO_ENVIRONMENT).each(function(index, service) {
26
      if (service.data === undefined || service.data.length == 0) {
27
         return;
28
      }
29
      if (service.service_id == 'wcs' && service.uniq === false) {
30
        /* as wcs comes with many menu entries, if it's not the only instance
31
         * in the environment, we only insert all the items if it's the
32
         * currently active site.
33
         */
34
        var that_hostname = $('<a>').attr('href', service.backoffice_menu_url)[0].hostname;
35
        var this_hostname = window.location.hostname;
36
        if (that_hostname != this_hostname) {
37
          more_entries.push({
38
                  title: service.title,
39
                  url: service.data[0].url});
40
          return;
41
        }
42
      }
43
      $(service.data).each(function(idx, element) {
44
        var li = $('<li><a href="#">' + element.label + '</a></li>').appendTo(menu_links);
45
        $(li).find('a').attr('href', element.url);
46
        if (element.icon !== undefined) {
47
          $(li).find('a').addClass('icon-' + element.icon);
48
        }
49
        if (window.location.href.indexOf(element.url) == 0) {
50
          $(li).addClass('active');
51
        }
52
      });
53
    });
54
    $(more_entries).each(function(index, entry) {
55
      var li = $('<li><a href="#">' + entry.title + '</a></li>').appendTo(menu_links);
56
      $(li).find('a').attr('href', entry.url);
57
    });
58
    menu_links.appendTo('#sidepage');
59
  }
60

  
61
  if (window.sessionStorage.hobo_environment &&
62
      parseInt(window.sessionStorage.hobo_environment_timestamp) > Date.now()-600000) {
63
    HOBO_ENVIRONMENT = JSON.parse(window.sessionStorage.hobo_environment);
64
    create_menu_items();
65
  } else {
66
    $(HOBO_ENVIRONMENT).each(function(index, element) {
67
      if (element.backoffice_menu_url === null) {
68
        element.data = Array();
69
        check_all_done();
70
        return;
71
      }
72
      $.ajax({url: element.backoffice_menu_url,
73
            xhrFields: { withCredentials: true },
74
            async: true,
75
            dataType: 'jsonp',
76
            crossDomain: true,
77
            success: function(data) { element.data = data; check_all_done(); },
78
            error: function(error) { console.log('bouh', error); element.data = Array(); check_all_done(); }
79
           }
80
       );
81
    });
82
  }
83

  
84
  var sidepage_button = $('#sidepage #applabel');
85
  sidepage_button.text('Publik ▼');
86
});
data/themes/gadjo/templates/combo/manager_base.html
1
{% extends "gadjo/base.html" %}
2
{% load staticfiles i18n %}
3

  
4
{% block css %}
5
<link rel="stylesheet" type="text/css" media="all" href="{{ STATIC_URL }}css/combo.manager.css"/>
6
{% endblock %}
7

  
8
{% block page-title %}Combo{% endblock %}
9
{% block site-title %}Combo{% endblock %}
10
{% block footer %}Combo — Copyright © Entr'ouvert{% endblock %}
11

  
12
{% block homepage-url %}
13
  {% url 'combo-manager-homepage' as default_homepage_url %}
14
  {% firstof manager_homepage_url default_homepage_url %}
15
{% endblock %}
16

  
17
{% block homepage-title %}
18
  {% trans 'Management' as default_homepage_title %}
19
  {% firstof manager_homepage_title default_homepage_url %}
20
{% endblock %}
21

  
22
{% block more-user-links %}
23
  {{ block.super }}
24
  {% if homepage_url %}
25
    <a href="{% url 'combo-manager-homepage' %}">{% trans 'Portal Management' %}</a>
26
  {% endif %}
27
{% endblock %}
28

  
29
{% block logout-url %}{% url 'auth_logout' %}{% endblock %}
30

  
31
{% block extrascripts %}
32
<script src="/__environment.js"></script>
33
<script src="{% static "js/publik.js" %}"></script>
34

  
35
<script src="{% static "ckeditor/ckeditor/ckeditor.js" %}"></script>
36
<script type="text/javascript" src="{% static "ckeditor/ckeditor-init.js" %}"></script>
37
<script src="{% static "js/combo.manager.js" %}"></script>
38
{% endblock %}
data/themes/gadjo/templates/combo/menu.html
1
{% load combo %}
2
{% if menuitems %}
3
<ul>
4
{% for menuitem in menuitems %}
5
<li class="menu-{{ menuitem.page.slug }} {% if menuitem.selected %}selected{% endif %}"><a
6
  href="{{ menuitem.page.get_online_url }}">{{ menuitem.page.title }}</a>
7
  {% if depth > 1 %}
8
    {% show_menu current_page=menuitem.page level=-1 depth=depth reduce_depth=True %}
9
  {% endif %}
10
</li>
11
</li>
12
{% endfor %}
13
</ul>
14
{% endif %}
data/themes/gadjo/templates/combo/page_template.html
1
{% extends "gadjo/base.html" %}
2
{% load combo gadjo static i18n %}
3

  
4
{% block css %}
5
<link rel="stylesheet" type="text/css" media="all" href="{{ STATIC_URL }}css/agent-portal.css"/>
6
{% endblock %}
7

  
8
{% block extrascripts %}
9
<script src="/__environment.js"></script>
10
<script src="{% static "js/publik.js" %}"></script>
11
{% endblock %}
12

  
13
{% block page-title %}{{ page.title }}{% endblock %}
14
{% block site-title %}Publik{% endblock %}
15
{% block footer %}Combo — Copyright © Entr'ouvert{% endblock %}
16
{% block logout-url %}{% url 'auth_logout' %}{% endblock %}
17

  
18
{% block content %}
19
{% block combo-content %}
20
{% placeholder "content" %}
21
{% endblock %}
22
{% endblock %}
23

  
24
{% block more-user-links %}
25
 <span id="breadcrumb">
26
 {% block breadcrumb %}
27
  {% if manager_homepage_url %}
28
    {% trans "Homepage" as default_manager_homepage_title %}
29
    <a class="icon-home-space" href="{{ manager_homepage_url }}">
30
      {% firstof manager_homepage_title default_manager_homepage_title %}
31
    </a>
32
    <a href="{% url 'homepage' %}">Passerelle</a>
33
  {% else %}
34
    <a href="" class="icon-home-space">{% trans 'Home' %}</a>
35
  {% endif %}
36
 {% endblock %}
37
 </span>
38
{% endblock %}
data/themes/gadjo/templates/combo/page_template_sidebar.html
1
{% extends "combo/page_template.html" %}
2
{% load combo %}
3

  
4
{% block combo-content %}
5
<div id="main-content">
6
{% placeholder "content" %}
7
</div>
8
<div id="sidebar">
9
<h2>Sidebar</h2>
10
{% show_menu 1 %}
11
{% placeholder "sidebar" %}
12
</div>
13
{% endblock %}
data/themes/gadjo/templates/combo/placeholder.html
1
{% load combo %}
2
{% for cell in cells %}
3
<div class="cell {{ cell.css_class_name }} {% if cell.slug %}{{cell.slug}}{% endif %}"
4
     {% if cell.ajax_refresh %}
5
     data-ajax-cell-url="{% url 'combo-public-ajax-page-cell' page_pk=page.id cell_reference=cell.get_reference %}"
6
     data-ajax-cell-refresh="{{ cell.ajax_refresh }}"
7
     {% endif %}><div>{% render_cell cell %}</div></div>
8
{% endfor %}
setup.py
39 39
            return version
40 40
    return '0'
41 41

  
42
def data_tree(destdir, sourcedir):
43
    extensions = ['.css', '.png', '.jpeg', '.jpg', '.gif', '.xml', '.html', '.js']
44
    r = []
45
    for root, dirs, files in os.walk(sourcedir):
46
        l = [os.path.join(root, x) for x in files if os.path.splitext(x)[1] in extensions]
47
        r.append((root.replace(sourcedir, destdir, 1), l))
48
    return r
49

  
42 50
class compile_translations(Command):
43 51
    description = 'compile message catalogs to MO files via django compilemessages'
44 52
    user_options = []
......
82 90
    packages=find_packages(),
83 91
    include_package_data=True,
84 92
    scripts=('manage.py',),
93
    data_files=data_tree('share/combo/themes/', 'data/themes/'),
85 94
    url='https://dev.entrouvert.org/projects/combo/',
86 95
    classifiers=[
87 96
        'Development Status :: 2 - Pre-Alpha',
88
-