Commit f3189cf8 authored by Valéry Febvre's avatar Valéry Febvre
Browse files

Code cleanup

parent 463b08aa
......@@ -93,8 +93,8 @@ def main(global_config, **settings):
config.add_route('acces_donnees', '/acces_donnees') #Apache directory listing
config.add_route('organismes', '/organismes/{name}/{id}')
config.add_route('territoires', '/territoires/{territoires_type}/{id}')
config.add_route('organisms', '/organismes/{name}/{id}')
config.add_route('territories', '/territoires/{type}/{name}')
config.scan('passim.views')
return config.make_wsgi_app()
/*
Autocompleur des territoires
Available territories kinds:
Territoires disponible:
// CommuneOfFrance
// ArrondissementOfCommuneOfFrance
// ArrondissementOfFrance
// AssociatedCommuneOfFrance
// CantonOfFrance
// CantonalFractionOfCommuneOfFrance
// CommuneOfFrance
// Country
// DepartmentOfFrance
// IntercommunalityOfFrance
// InternationalOrganization
// MetropoleOfCountry
// Mountain
// OverseasCollectivityOfFrance
// PaysOfFrance
// RegionOfFrance
// RegionalNatureParkOfFrance
// Special
// UrbanAreaOfFrance
// UrbanTransportsPerimeterOfFrance
CommuneOfFrance
ArrondissementOfCommuneOfFrance
ArrondissementOfFrance
AssociatedCommuneOfFrance
CantonOfFrance
CantonalFractionOfCommuneOfFrance
CommuneOfFrance
Country
DepartmentOfFrance
IntercommunalityOfFrance
InternationalOrganization
MetropoleOfCountry
Mountain
OverseasCollectivityOfFrance
PaysOfFrance
RegionOfFrance
RegionalNatureParkOfFrance
Special
UrbanAreaOfFrance
UrbanTransportsPerimeterOfFrance
*/
......@@ -33,10 +32,10 @@ $("#term").select2({
url: territoria_api +
"autocomplete-territory?" +
"kind=CommuneOfFrance&" +
// "kind=ArrondissementOfCommuneOfFrance&" +
// "kind=AssociatedCommuneOfFrance&" +
//"kind=ArrondissementOfCommuneOfFrance&" +
//"kind=AssociatedCommuneOfFrance&" +
"kind=DepartmentOfFrance&" +
// "kind=IntercommunalityOfFrance&" +
//"kind=IntercommunalityOfFrance&" +
"kind=RegionOfFrance&" +
"jsonp=?",
dataType: 'jsonp',
......
## -*- coding: utf-8 -*-
<%!
import markdown
%>
<%inherit file="/site.mako"/>
<%def name="head()">
${parent.head()}
<link rel="stylesheet" href="http://cdn.comarquage.fr/leaflet/latest/leaflet.css">
<link rel="stylesheet" href="${request.static_path('passim:static/css/maps.css')}">
<link rel="stylesheet" href="http://cdn.comarquage.fr/leaflet/latest/leaflet.css">
<link rel="stylesheet" href="${request.static_path('passim:static/css/maps.css')}">
</%def>
${parent.page_header()}
......@@ -52,8 +48,8 @@ $(function () {
var osmUrl="http://{s}.tile2.opencyclemap.org/transport/{z}/{x}/{y}.png";
var osmAttrib=[
'Données cartographiques CC-By-SA ',
'<a href="http://openstreetmap.org/" rel="external">OpenStreetMap<\/a>, ',
'Tuiles fournies par <a href="http://www.opencyclemap.org/" rel="external">Andy Allan<\/a>'
'<a href="http://openstreetmap.org/" target="_blank">OpenStreetMap<\/a>, ',
'Tuiles fournies par <a href="http://www.opencyclemap.org/" target="_blank">Andy Allan<\/a>'
].join('');
var osmLayer = new L.TileLayer(osmUrl, {minZoom: 2, maxZoom: 16, attribution: osmAttrib});
......
## -*- coding: utf-8 -*-
<%!
import markdown
%>
<%inherit file="/site.mako"/>
<%def name="head()">
${parent.head()}
<link rel="stylesheet" href="http://cdn.comarquage.fr/leaflet/latest/leaflet.css">
<link rel="stylesheet" href="${request.static_path('passim:static/css/maps.css')}">
<link rel="stylesheet" href="http://cdn.comarquage.fr/leaflet/latest/leaflet.css">
<link rel="stylesheet" href="${request.static_path('passim:static/css/maps.css')}">
</%def>
${parent.page_header()}
......@@ -41,8 +38,8 @@ $(function () {
var osmUrl="http://{s}.tile2.opencyclemap.org/transport/{z}/{x}/{y}.png";
var osmAttrib=[
'Données cartographiques CC-By-SA ',
'<a href="http://openstreetmap.org/" rel="external">OpenStreetMap<\/a>, ',
'Tuiles fournies par <a href="http://www.opencyclemap.org/" rel="external">Andy Allan<\/a>'
'<a href="http://openstreetmap.org/" target="_blank">OpenStreetMap<\/a>, ',
'Tuiles fournies par <a href="http://www.opencyclemap.org/" target="_blank">Andy Allan<\/a>'
].join('');
var osmLayer = new L.TileLayer(osmUrl, {minZoom: 2, maxZoom: 16, attribution: osmAttrib});
......
## -*- coding: utf-8 -*-
<%!
import markdown
%>
<%inherit file="/site.mako"/>
<%def name="head()">
${parent.head()}
<link rel="stylesheet" href="http://cdn.comarquage.fr/leaflet/latest/leaflet.css">
<link rel="stylesheet" href="${request.static_path('passim:static/css/maps.css')}">
<link rel="stylesheet" href="http://cdn.comarquage.fr/leaflet/latest/leaflet.css">
<link rel="stylesheet" href="${request.static_path('passim:static/css/maps.css')}">
</%def>
${parent.page_header()}
......@@ -51,8 +47,8 @@ $(function () {
var osmUrl="http://{s}.tile2.opencyclemap.org/transport/{z}/{x}/{y}.png";
var osmAttrib=[
'Données cartographiques CC-By-SA ',
'<a href="http://openstreetmap.org/" rel="external">OpenStreetMap<\/a>, ',
'Tuiles fournies par <a href="http://www.opencyclemap.org/" rel="external">Andy Allan<\/a>'
'<a href="http://openstreetmap.org/" target="_blank">OpenStreetMap<\/a>, ',
'Tuiles fournies par <a href="http://www.opencyclemap.org/" target="_blank">Andy Allan<\/a>'
].join('');
var osmLayer = new L.TileLayer(osmUrl, {minZoom: 2, maxZoom: 16, attribution: osmAttrib});
......
## -*- coding: utf-8 -*-
<%!
import markdown
%>
<%inherit file="/site.mako"/>
<%def name="head()">
${parent.head()}
<link rel="stylesheet" href="http://cdn.comarquage.fr/leaflet/latest/leaflet.css">
<link rel="stylesheet" href="${request.static_path('passim:static/css/maps.css')}">
<link rel="stylesheet" href="http://cdn.comarquage.fr/leaflet/latest/leaflet.css">
<link rel="stylesheet" href="${request.static_path('passim:static/css/maps.css')}">
</%def>
${parent.page_header()}
......@@ -38,8 +35,8 @@ $(function () {
var osmUrl="http://{s}.tile2.opencyclemap.org/transport/{z}/{x}/{y}.png";
var osmAttrib=[
'Données cartographiques CC-By-SA ',
'<a href="http://openstreetmap.org/" rel="external">OpenStreetMap<\/a>, ',
'Tuiles fournies par <a href="http://www.opencyclemap.org/" rel="external">Andy Allan<\/a>'
'<a href="http://openstreetmap.org/" target="_blank">OpenStreetMap<\/a>, ',
'Tuiles fournies par <a href="http://www.opencyclemap.org/" target="_blank">Andy Allan<\/a>'
].join('');
var osmLayer = new L.TileLayer(osmUrl, {minZoom: 2, maxZoom: 16, attribution: osmAttrib});
......
......@@ -4,49 +4,53 @@ from passim.resources import UsersResource
%>\
<%def name="head()">
</%def>\
\
<%def name="france_button()">
<a class="btn btn-default btn-sm" href="${request.route_path('territoires', territoires_type='pays', id='france')}" rel="tooltip" title="${_('Search services for whole France')}">France</a>
<a class="btn btn-default btn-sm" href="${request.route_path('territories', type='pays', name='france')}" rel="tooltip" title="${_('Search services for whole France')}">France</a>
</%def>\
\
<%def name="csv_rss_button()">
<a class="btn btn-primary btn-sm" href="/acces_donnees" rel="tooltip" title="${_('Download PASSIM data in CSV format')}">CSV Data</a>
<a class="btn btn-warning btn-sm" href="${request.route_path('feed')}" target="_blank" title="${_('RSS feed')}"><i class="fa fa-rss"></i></a>
<a class="btn btn-primary btn-sm" href="/acces_donnees" rel="tooltip" title="${_('Download PASSIM data in CSV format')}">CSV Data</a>
<a class="btn btn-warning btn-sm" href="${request.route_path('feed')}" target="_blank" title="${_('Atom feed')}"><i class="fa fa-rss"></i></a>
</%def>\
\
<%def name="search_bar()">
<div>
<form class="form-inline">
<span class="form-group" style="width:100%;">
<label for="term">${_(u"Find the mobility info services available for a territory :")}</label><br>
<a class="btn btn-primary btn-sm" href="#" id="btn-geolocation" rel="tooltip" title="Votre position">
<i class="fa fa-globe icon-white"></i>
</a>
<select style="width:50%;" class="form-control" id="term" rel="tooltip" name="term" title="${_(u"Type a French city/department/region name")}"></select>
<span id="label-state-geolocalisation"></span>
</span>
</form>
<div>
<form class="form-inline">
<span class="form-group" style="width:100%;">
<label for="term">${_(u"Find the mobility info services available for a territory:")}</label>
<br>
<a class="btn btn-primary btn-sm" href="#" id="btn-geolocation" rel="tooltip" title="${_(u'Your position')}">
<i class="fa fa-globe icon-white"></i>
</a>
<select style="width:50%;" class="form-control" id="term" rel="tooltip" name="term" title="${_(u'Type a French city/department/region name')}"></select>
<span id="label-state-geolocalisation"></span>
</span>
</form>
</div>
</%def>\
\
<%def name="page_title(titre)">
<title>${titre} - Passim </title>
<%def name="page_title(title)">
<title>${title} - PASSIM</title>
</%def>\
\
<%def name="page_header()">
<div class="page-header" id="about-header">
<img src="${request.static_path('passim:static/img/logo-ministere.png')}" class="pull-left">
<h1>PASSIM <span class="pull-right">${csv_rss_button()}</span> </h1>
<h2>${_('Directory of Traveler Information Services in France')}</h2>
( Beta )
<img src="${request.static_path('passim:static/img/logo-ministere.png')}" class="pull-left">
<h1>PASSIM <span class="pull-right">${csv_rss_button()}</span></h1>
<h2>${_('Directory of Traveler Information Services in France')}</h2>
( Beta )
</div>
</%def>\
<% route_name = request.matched_route.name if request.matched_route else u'' %>\
<!DOCTYPE html>
<html>
<head>
%if title:
${page_title(title)}
%else:
${page_title("Accueil")}
%endif
%if title:
${page_title(title)}
%else:
${page_title(_("Accueil"))}
%endif
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
......@@ -66,87 +70,86 @@ from passim.resources import UsersResource
<link href="${request.static_path('passim:static/css/responsive.css')}" rel="stylesheet" />
<script src="${request.static_path('passim:static/js/passim.js')}"></script>
<!-- Global variables -->
<!-- Global variables -->
<script>
var territoria_api = '${request.registry.settings['territoria_api']}';
var petitpois_api = '${request.registry.settings['petitpois_api']}';
var territoria_api = '${request.registry.settings['territoria_api']}';
var petitpois_api = '${request.registry.settings['petitpois_api']}';
</script>
${self.head()}
</head>
<body>
<div class="navbar navbar-default navbar-fixed-top">
<div class="container">
<div class="navbar-header">
<a href="${request.route_path('accueil')}" class="navbar-brand"><h1>PASSIM</h1></a>
<button class="navbar-toggle" type="button" data-toggle="collapse" data-target="#navbar-main">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="navbar-collapse collapse" id="navbar-main">
<ul class="nav navbar-nav">
<li class="${u'active' if route_name == 'about' else u''}">
<a href="${request.route_path('about')}">${_('About')}</a>
</li>
<li class="${u'active' if route_name == 'contact' else u''}">
<a href="${request.route_path('contact')}">${_('Contact')}</a>
</li>
<li class="${u'active' if route_name == 'contribute' else u''}">
<a href="${request.route_path('contribute')}">${_('Contribute')}</a>
</li>
<li class="${u'active' if route_name == 'data' else u''}">
<a href="${request.route_path('data')}">${_('Reuse')}</a>
</li>
<li class="${u'active' if route_name == 'help' else u''}">
<a href="${request.route_path('help')}">${_('Help')}</a>
</li>
<li class="dropdown${u' active' if route_name.startswith('maps') else u''}">
<a href="#" class="dropdown-toggle" id="maps-menu" data-toggle="dropdown">
${_('Maps')} <span class="caret"></span>
</a>
<ul class="dropdown-menu" aria-labelledby="maps-menu">
<li class="${u'active' if route_name == 'maps.sim' else u''}">
<a href="${request.route_path('maps.sim')}">${_('Multimodal Information Services')}</a>
</li>
<li class="${u'active' if route_name == 'maps.reg' else u''}">
<a href="${request.route_path('maps.reg')}">${_('Indicators by Regions')}</a>
</li>
<li class="${u'active' if route_name == 'maps.dep' else u''}">
<a href="${request.route_path('maps.dep')}">${_('Indicators by Departments')}</a>
</li>
<li class="divider"></li>
<li class="${u'active' if route_name == 'maps.offers' else u''}">
<a href="${request.route_path('maps.offers')}">${_('Transport Offers')}</a>
</li>
</ul>
</li>
</ul>
<div class="container">
<div class="navbar-header">
<a href="${request.route_path('accueil')}" class="navbar-brand"><h1>PASSIM</h1></a>
<button class="navbar-toggle" type="button" data-toggle="collapse" data-target="#navbar-main">
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
</div>
<div class="navbar-collapse collapse" id="navbar-main">
<ul class="nav navbar-nav">
<li class="${u'active' if route_name == 'about' else u''}">
<a href="${request.route_path('about')}">${_('About')}</a>
</li>
<li class="${u'active' if route_name == 'contact' else u''}">
<a href="${request.route_path('contact')}">${_('Contact')}</a>
</li>
<li class="${u'active' if route_name == 'contribute' else u''}">
<a href="${request.route_path('contribute')}">${_('Contribute')}</a>
</li>
<li class="${u'active' if route_name == 'data' else u''}">
<a href="${request.route_path('data')}">${_('Reuse')}</a>
</li>
<li class="${u'active' if route_name == 'help' else u''}">
<a href="${request.route_path('help')}">${_('Help')}</a>
</li>
<li class="dropdown${u' active' if route_name.startswith('maps') else u''}">
<a href="#" class="dropdown-toggle" id="maps-menu" data-toggle="dropdown">
${_('Maps')} <span class="caret"></span>
</a>
<ul class="dropdown-menu" aria-labelledby="maps-menu">
<li class="${u'active' if route_name == 'maps.sim' else u''}">
<a href="${request.route_path('maps.sim')}">${_('Multimodal Information Services')}</a>
</li>
<li class="${u'active' if route_name == 'maps.reg' else u''}">
<a href="${request.route_path('maps.reg')}">${_('Indicators by Regions')}</a>
</li>
<li class="${u'active' if route_name == 'maps.dep' else u''}">
<a href="${request.route_path('maps.dep')}">${_('Indicators by Departments')}</a>
</li>
<li class="divider"></li>
<li class="${u'active' if route_name == 'maps.offers' else u''}">
<a href="${request.route_path('maps.offers')}">${_('Transport Offers')}</a>
</li>
</ul>
</li>
</ul>
</div>
</div>
</div>
</div>
<div class="container">
${self.body()}
${self.body()}
<hr>
<footer class="footer">
<a href="${request.route_path('about')}">${_(u'About')}</a>
% if route_name.startswith('organisme'):
<%include file="contribute-form.mako" args="subject=subject, body=body"/>
<p class="pull-right contribute-text">
<a class="label label-info modal-trigger" href="#contribute-modal">${_(u"Contribute")}</a>
% if isinstance(id,unicode):
<a href="${request.registry.settings['petitpois_url']}/poi/view/${id}" rel="external">
% else:
<a href="${request.registry.settings['petitpois_url']}" rel="external">
% endif
${_(u"Back-office access")}
</a>
</p>
% endif
</footer>
<hr>
<footer class="footer">
<a href="${request.route_path('about')}">${_(u'About')}</a>
% if route_name.startswith('organisms'):
<%include file="contribute-form.mako" args="subject=subject, body=body"/>
<p class="pull-right contribute-text">
<a class="label label-info modal-trigger" href="#contribute-modal">${_(u"Contribute")}</a>
% if isinstance(id, unicode):
<a href="${request.registry.settings['petitpois_url']}/poi/view/${id}" target="_blank">
% else:
<a href="${request.registry.settings['petitpois_url']}" target="_blank">
% endif
${_(u"Back-office access")}
</a>
</p>
% endif
</footer>
</div>
</body>
</html>
## -*- coding: utf-8 -*-
<%!
import markdown
%>
<%inherit file="/site.mako"/>
<%def name="head()">
${parent.head()}
<link href="${request.static_path('passim:static/lib/select2-4.0.0-rc.1/dist/css/select2.min.css')}" rel="stylesheet" />
<script defer src="${request.static_path('passim:static/lib/select2-4.0.0-rc.1/dist/js/select2.min.js')}"></script>
<script defer src="${request.static_path('passim:static/lib/select2-4.0.0-rc.1/dist/js/i18n/fr.js')}"></script>
<script defer src="${request.static_path('passim:static/js/search.js')}"></script>
</%def>
${parent.page_header()}
${parent.search_bar()}
<div class="search-navbar">
<h3>
% if error:
${error}
% else:
${_(u'Traveler Info Services List For')} « ${full_name} »
% endif
<span class="pull-right">
<a class="btn btn-default btn-sm" href="${request.route_path('territoires', territoires_type='pays', id='france')}" rel="tooltip" title="${_('Search services for whole France')}">France</a>
</span>
</h3>
</div>
<br>
% if result:
% if len(result["multimodal"]) > 0 and show_multimodales:
<table class="table table-bordered table-condensed table-hover table-responsive">
<colgroup>
<col class="col-md-1">
<col class="col-md-8">
<col class="col-md-3">
</colgroup>
<thead>
<tr>
<th>${_("Web Site")}</th>
<th>${_("Name")}</th>
<th>${_("Transport Type")}</th>
</tr>
</thead>
<tbody>
<h4>${_("Multimodal Information Services")}</h4>
% for multimodal in result["multimodal"]:
<tr>
<td>
<a class="btn btn-primary" rel="tooltip" target="_blank" title="" href="${multimodal["url"]}" data-original-title="Site web d'info transport">www</a>
</td>
<td>
<a href="${multimodal["internal"]}">${multimodal["name"]}</a>
</td>
<td>
% for offre in multimodal["type_transport"]:
<a href="#" rel="tooltip" title="${offre}" data-original-title="${offre}"><img alt="${offre}" src="${request.static_path('passim:static/img/types-de-transports/' + offre + '.png')}"></a>
% endfor
</td>
</tr>
% endfor
</tbody>
</table>
% endif
% if len(result["local"]) > 0 and type_name == u"Commune":
<table class="table table-bordered table-condensed table-hover table-responsive">
<colgroup>
<col class="col-md-1">
<col class="col-md-8">
<col class="col-md-3">
</colgroup>
<thead>
<tr>
<th>${_("Web Site")}</th>
<th>${_("Name")}</th>
<th>${_("Transport Type")}</th>
</tr>
</thead>
<tbody>
<h4>${_("Local Interest Traveler Info Services")}</h4>
% for local in result["local"]:
<tr>
% if local["niveau"] == u"Local":
<td>
<a class="btn btn-primary internal" rel="tooltip" target="_blank" title="" href="${local["url"]}" data-original-title="Site web d'info transport">www</a>
</td>
<td>
<a href="${local["internal"]}">${local["name"]}</a>
</td>
<td>
% for offre in local["type_transport"]:
<a href="#" rel="tooltip" title="${offre}" data-original-title="${offre}"><img alt="${offre}" src="${request.static_path('passim:static/img/types-de-transports/' + offre + '.png')}"></a>
% endfor
</td>
% endif
</tr>
% endfor
</tbody>
</table>
% endif
% if len(result["departemental"]) > 0 and (type_name == u"Région" or type_name == u"Département" or type_name == u"Commune"):
<table class="table table-bordered table-condensed table-hover table-responsive">
<colgroup>
<col class="col-md-1">
<col class="col-md-8">
<col class="col-md-3">
</colgroup>
<thead>
<tr>
<th>${_("Web Site")}</th>
<th>${_("Name")}</th>
<th>${_("Transport Type")}</th>
</tr>
</thead>
<tbody>
<h4>${_("Departmental Interest Traveler Info Services")}</h4>
% for departemental in result["departemental"]:
<tr>
% if departemental["niveau"] == u"Départemental":
<td>
<a class="btn btn-primary internal" rel="tooltip" target="_blank" title="" href="${departemental["url"]}" data-original-title="Site web d'info transport">www</a>
</td>
<td>
<a href="${departemental["internal"]}">${departemental["name"]}</a>
</td>
<td>
% for offre in departemental["type_transport"]:
<a href="#" rel="tooltip" title="${offre}" data-original-title="${offre}"><img alt="${offre}" src="${request.static_path('passim:static/img/types-de-transports/' + offre + '.png')}"></a>
% endfor
</td>
% endif
</tr>
% endfor
</tbody>
</table>
% endif
% if len(result["regional"]) > 0 and (type_name == u"Région" or type_name == u"Département" or type_name == u"Commune"):
<table class="table table-bordered table-condensed table-hover table-responsive">
<colgroup>
<col class="col-md-1">
<col class="col-md-8">
<col class="col-md-3">
</colgroup>
<thead>
<tr>
<th>${_("Web Site")}</th>
<th>${_("Name")}</th>
<th>${_("Transport Type")}</th>
</tr>
</thead>
<tbody>
<h4>${_("Regional Interest Traveler Info Services")}</h4>
% for regional in result["regional"]:
<tr>
% if regional["niveau"] == u"Régional":
<td>
<a class="btn btn-primary internal" rel="tooltip" target="_blank" title="" href="${regional["url"]}" data-original-title="Site web d'info transport">www</a>
</td>
<td>
<a href="${regional["internal"]}">${regional["name"]}</a>
</td>
<td>
% for offre in regional["type_transport"]:
<a href="#" rel="tooltip" title="${offre}" data-original-title="${offre}"><img alt="${offre}" src="${request.static_path('passim:static/img/types-de-transports/' + offre + '.png')}"></a>
% endfor
</td>
% endif
</tr>
% endfor
</tbody>
</table>
% endif
% if len(result["national"]) > 0 :
<table class="table table-bordered table-condensed table-hover table-responsive">
<colgroup>
<col class="col-md-1">
<col class="col-md-8">
<col class="col-md-3">
</colgroup>
<thead>
<tr>
<th>${_("Web Site")}</th>
<th>${_("Name")}</th>
<th>${_("Transport Type")}</th>
</tr>
</thead>
<tbody>
<h4>${_("National Information")}</h4>
% for national in result["national"]:
% if national["niveau"] == u"National":
% if len(national["territories"]) > 0 or full_name=="France":
<tr>
<td>
<a class="btn btn-primary internal" rel="tooltip" target="_blank" title="" href="${national["url"]}" data-original-title="Site web d'info transport">www</a>
</td>
<td>
<a class="internal" href="${national["internal"]}">${national["name"]}</a>
</td>
<td>
% for offre in national["type_transport"]:
<a href="#" rel="tooltip" title="${offre}" data-original-title="${offre}"><img alt="${offre}" src="${request.static_path('passim:static/img/types-de-transports/' + offre + '.png')}"></a>