Projet

Général

Profil

« Précédent | Suivant » 

Révision c1b3c044

Ajouté par Serghei Mihai il y a environ 9 ans

footer links localized (#6707)

Voir les différences:

ckanext/ozwillo_theme/plugin.py
1
import json
2
import os
3
import requests
4
import xml.etree.ElementTree as ET
5
from slugify import slugify
6

  
1 7
from pylons import config as pconfig
2 8

  
3 9
import ckan.plugins as plugins
4 10
import ckan.plugins.toolkit as toolkit
5 11
from ckan.lib.app_globals import set_global
6 12

  
13
def footer_links():
14
    url = 'https://www.ozwillo.com/footer.xml'
15
    langs = {}
16

  
17
    response = requests.get(url)
18
    menuset = ET.fromstring(response.text.encode('utf-8'))
19

  
20
    items = ('News', 'Discovering', 'Co-construct', 'Let\'s go', 'Contact',
21
             'Projects', 'Project team', 'Ozwillo', 'User guide', 'Developers',
22
             'Legal Notices', 'General terms of use')
23

  
24

  
25
    for menu in menuset.findall('menu'):
26
        locale = menu.find('locale').text
27
        c = 0
28
        langs[locale] = {}
29
        for item in menu.findall('item'):
30
            if 'href' in item.attrib:
31
                langs[locale][slugify(items[c])] = item.get('href')
32
                c += 1
33
    return langs
34

  
7 35

  
8 36
class OzwilloThemePlugin(plugins.SingletonPlugin):
9 37
    plugins.implements(plugins.IConfigurer)
......
14 42
        set_global('ckan.ozwillo_portal_url',
15 43
                   pconfig.get('%s.ozwillo_portal_url' % __name__))
16 44

  
45
        set_global('ckan.footer_links', footer_links())
46

  
17 47
        toolkit.add_template_directory(config_, 'templates')
18 48
        toolkit.add_public_directory(config_, 'public')
19 49
        toolkit.add_resource('fanstatic', 'theme')
ckanext/ozwillo_theme/templates/footer.html
17 17
				</div>
18 18
				<div class=" col-lg-2 col-md-2 col-sm-3 col-xs-4">
19 19
					<ul class="nav navbar-nav navbar-footer">
20
						<li><a href="{{ g.ozwillo_url }}/{{current_lang}}/oz/news">{% trans %}News{% endtrans %}</a></li>
21
						<li><a href="{{ g.ozwillo_url }}/{{current_lang}}/oz/discover">{% trans %}Discovering{% endtrans %}</a></li>
22
						<li><a href="{{ g.ozwillo_url }}/{{current_lang}}/oz/co-construct">{% trans %}Co-construct{% endtrans %}</a></li>
23
						<li><a href="{{ g.ozwillo_url }}/{{current_lang}}/oz/let-s-go">{% trans %}Let's go{% endtrans %}</a></li></ul>
20
						<li><a href="{{ g.ozwillo_url }}{{ g.footer_links[current_lang]['news'] }}">{% trans %}News{% endtrans %}</a></li>
21
						<li><a href="{{ g.ozwillo_url }}{{ g.footer_links[current_lang]['discovering'] }}">{% trans %}Discovering{% endtrans %}</a></li>
22
						<li><a href="{{ g.ozwillo_url }}{{ g.footer_links[current_lang]['co-construct'] }}">{% trans %}Co-construct{% endtrans %}</a></li>
23
						<li><a href="{{ g.ozwillo_url }}{{ g.footer_links[current_lang]['lets-go'] }}">{% trans %}Let's go{% endtrans %}</a></li></ul>
24 24
				</div>
25 25
				<div class=" col-lg-2 col-md-2 col-sm-3 col-xs-4">
26 26
					<ul class="nav navbar-nav navbar-footer">
27
						<li><a href="{{ g.ozwillo_url }}/{{current_lang}}/contact">{% trans %}Contact{% endtrans %}</a></li>
28
						<li><a href="{{ g.ozwillo_url }}/{{current_lang}}/l-equipe-projet-oasis">{% trans %}Project team{% endtrans %}</a></li>
29
						<li><a href="{{ g.ozwillo_url }}/{{current_lang}}/oz/projects">{% trans %}Projects{% endtrans %}</a></li>
27
						<li><a href="{{ g.ozwillo_url }}{{ g.footer_links[current_lang]['contact'] }}">{% trans %}Contact{% endtrans %}</a></li>
28
						<li><a href="{{ g.ozwillo_url }}{{ g.footer_links[current_lang]['project-team'] }}">{% trans %}Project team{% endtrans %}</a></li>
29
						<li><a href="{{ g.ozwillo_url }}{{ g.footer_links[current_lang]['projects'] }}">{% trans %}Projects{% endtrans %}</a></li>
30 30
						<li><a class="ext-twitter" href="https://twitter.com/ozwillo">@Ozwillo</a></li>
31 31
					</ul>
32 32
				</div>
33 33
				<div class=" col-lg-2 col-md-2 col-sm-3 col-xs-4">
34 34
					<ul class="nav navbar-nav navbar-footer">
35
						<li><a href="{{ g.ozwillo_url }}/{{current_lang}}/guide-utilisateur">{% trans %}User guide{% endtrans %}</a></li>
35
						<li><a href="{{ g.ozwillo_url }}{{ g.footer_links[current_lang]['user-guide'] }}">{% trans %}User guide{% endtrans %}</a></li>
36 36
						<li><a href="http://doc.ozwillo.com/">{% trans %}Developers{% endtrans %}</a></li>
37
						<li><a href="{{ g.ozwillo_url }}/{{current_lang}}/legal-notices">{% trans %}Legal Notices{% endtrans %}</a></li>
38
						<li><a href="{{ g.ozwillo_url }}/{{current_lang}}/terms">{% trans %}General terms of use{% endtrans %}</a></li>
37
						<li><a href="{{ g.ozwillo_url }}{{ g.footer_links[current_lang]['legal-notices'] }}">{% trans %}Legal Notices{% endtrans %}</a></li>
38
						<li><a href="{{ g.ozwillo_url }}{{ g.footer_links[current_lang]['general-terms-of-use'] }}">{% trans %}General terms of use{% endtrans %}</a></li>
39 39
					</ul>
40 40
				</div>
41 41
			</div>

Formats disponibles : Unified diff