wcs: share theme with combo

This commit is contained in:
Frédéric Péters 2015-06-20 20:52:46 +02:00
parent eca214d040
commit 1987cb862f
3 changed files with 105 additions and 378 deletions

View File

@ -1,144 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8"><!-- ☭ -->
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" />
<title>[page_title]</title>
<link rel="shortcut icon" href="/themes/auquotidien/favicon.png" />
<link rel="alternate" type="application/atom+xml" title="[site_name]" href="[root_url]announces/atom"/>
<script type="text/javascript" src="/qo/js/jquery.js"></script>
[script]
<link rel="stylesheet" type="text/css" href="[css]"/>
["<!--[if lt IE 10]>"]<style>
div#services > ul > li { width: 48%; float: left; height: 18em; }
div#centre { padding-top: 45px; margin-top: 0px; }
</style>["<![endif]-->"]
<link href='https://fonts.googleapis.com/css?family=Lato:400,700,700italic,400italic|Carme|Arvo' rel='stylesheet' type='text/css'>
<script type="text/javascript" src="[theme_url]/dataview.js"></script>
</head>
<body[if-any onload] onload="[onload]"[end]>
<div id="page">
<div id="header">
<div id="top">
[if-any user]
<a href="[siteagglo]simplesamlphp/module.php/core/as_login.php?ReturnTo=/&AuthId=default-sp" accesskey="1"><img src="[root_url]themes/montpellier2/logo.png" alt="[site_name]" /></a>
[else]
<a href="[siteagglo]" accesskey="1"><img src="[root_url]themes/montpellier2/logo.png" alt="[site_name]" /></a>
[end]
<div id="toplinks">
[if-any user]
<span><a class="logout" href="[root_url]logout">Me d&eacute;connecter</a>
[is session_user_admin_access "True"]
<a class="restricted" href="[root_url]admin/">Administration</a>
[else]
[is session_user_backoffice_access "True"]
<a class="restricted" href="[root_url]backoffice/">Back office</a>
[end]
[end]
</span>
[else]
<span class="login"><a href="[root_url]login/">Connexion</a> / <a href="[root_url]register/">Inscription</a></span>
[end]
</div>
[if-any user]
<div id="username">[session_user_display_name]</div>
[end]
</div>
</div> <!-- header -->
<div id="main-content-wrapper">
<div id="agglolinks">
[if-any user]
<a class="agglo-accueil" href="[siteagglo]simplesamlphp/module.php/core/as_login.php?ReturnTo=/&AuthId=default-sp">Ma métropole</a>
<a class="agglo-connaitre" href="[siteagglo]simplesamlphp/module.php/core/as_login.php?ReturnTo=/widgets/connaitre&AuthId=default-sp">Connaître</a>
<a class="agglo-vivre" href="[siteagglo]simplesamlphp/module.php/core/as_login.php?ReturnTo=/widgets/vivre&AuthId=default-sp">Vivre</a>
<a class="agglo-entreprendre" href="[siteagglo]simplesamlphp/module.php/core/as_login.php?ReturnTo=/widgets/entreprendre&AuthId=default-sp">Entreprendre</a>
[else]
<a class="agglo-accueil" href="[siteagglo]">Ma métropole</a>
<a class="agglo-connaitre" href="[siteagglo]widgets/connaitre">Connaître</a>
<a class="agglo-vivre" href="[siteagglo]widgets/vivre">Vivre</a>
<a class="agglo-entreprendre" href="[siteagglo]widgets/entreprendre">Entreprendre</a>
[end]
</div>
<div id="main-content">
[links]
<div id="content" [if-any is_index]class="large"[end]>
[if-any breadcrumb]<div id="breadcrumb">[breadcrumb]</div>[end]
[if-any gauche]
<div id="gauche">
[gauche]
</div>
[end]
[if-any bigdiv]<div id="[bigdiv]" [if-any breadcrumb]class="has-breadcrumb"[end]>[end]
[if-any title]<h2>[title]</h2>[end]
[body]
[if-any bigdiv]</div>[end]
</div> <!-- #content -->
<hr class="clear"/>
</div> <!-- #main-content -->
</div> <!-- #main-content-wrapper -->
<div id="footer">
<div id="agglo-little-links">
<ul>
[if-any user]
<li><a href="[siteagglo]simplesamlphp/module.php/core/as_login.php?ReturnTo=/vivre/transport&AuthId=default-sp">Je me déplace</a></li>
<li><a href="[siteagglo]simplesamlphp/module.php/core/as_login.php?ReturnTo=/vivre/environnement&AuthId=default-sp">Je préserve</a></li>
<li><a href="[siteagglo]simplesamlphp/module.php/core/as_login.php?ReturnTo=/entreprendre&AuthId=default-sp">Je travaille</a></li>
<li><a href="[siteagglo]simplesamlphp/module.php/core/as_login.php?ReturnTo=/vivre/solidarit%C3%A9&AuthId=default-sp">Je partage</a></li>
<li><a href="[siteagglo]simplesamlphp/module.php/core/as_login.php?ReturnTo=/vivre/culture&AuthId=default-sp">Je me cultive</a></li>
<li><a href="[siteagglo]simplesamlphp/module.php/core/as_login.php?ReturnTo=/vivre/tourisme-traditions&AuthId=default-sp">Je découvre</a></li>
<li><a href="[siteagglo]simplesamlphp/module.php/core/as_login.php?ReturnTo=/vivre/sport&AuthId=default-sp">Je m'oxygène</a></li>
<li><a href="[siteagglo]simplesamlphp/module.php/core/as_login.php?ReturnTo=/conna%C3%AEtre-comp%C3%A9tences/logement&AuthId=default-sp">Je me loge</a></li>
[else]
<li><a href="[siteagglo]vivre/transport">Je me déplace</a></li>
<li><a href="[siteagglo]vivre/environnement">Je préserve</a></li>
<li><a href="[siteagglo]entreprendre">Je travaille</a></li>
<li><a href="[siteagglo]vivre/solidarit%C3%A9">Je partage</a></li>
<li><a href="[siteagglo]vivre/culture">Je me cultive</a></li>
<li><a href="[siteagglo]vivre/tourisme-traditions">Je découvre</a></li>
<li><a href="[siteagglo]vivre/sport">Je m'oxygène</a></li>
<li><a href="[siteagglo]conna%C3%AEtre-comp%C3%A9tences/logement">Je me loge</a></li>
[end]
</ul>
</div>
<p id="legal">© Montpellier Méditerranée Métropole — Réalisation :
<a href="https://publik.entrouvert.com">Publik</a> par
<a href="http://www.entrouvert.com">Entr'ouvert</a> —
cartographie ©<a href="http://openstreetmap.org">OpenStreetMap</a>,
fournie par <a href="http://www.mapquest.com/" target="_blank">MapQuest</a>.
</p>
</div>
</div>
[if-any piwik_id]
<!-- Piwik -->
<script type="text/javascript">
var _paq = _paq || [];
_paq.push(['trackPageView']);
_paq.push(['enableLinkTracking']);
(function() {
var u="//piwik.monitoring.entrouvert.org/";
_paq.push(['setTrackerUrl', u+'piwik.php']);
_paq.push(['setSiteId', [piwik_id]]);
var d=document, g=d.createElement('script'),
s=d.getElementsByTagName('script')[0];
g.type='text/javascript'; g.async=true; g.defer=true; g.src=u
+'piwik.js'; s.parentNode.insertBefore(g,s);
})();
</script>
<noscript><p><img src="//piwik.monitoring.entrouvert.org/piwik.php?idsite=[piwik_id]" style="border:0;" alt="" /></p></noscript>
<!-- End Piwik -->
[end]
</body>
</html>

View File

@ -0,0 +1,90 @@
#! /usr/bin/env python
class RemoteTemplate(object):
def __init__(self, source):
self.source = source
from wcs.qommon.misc import simplify
import os, urlparse
self.cache_key = simplify(urlparse.urlunparse(urlparse.urlparse(self.source)[:3] + ('', '', '')))
self.cache_dirpath = os.path.join(publisher.app_dir, 'skeleton-cache')
self.cache_filepath = os.path.join(self.cache_dirpath, self.cache_key)
def get_template_content(self):
import time, os, threading
if request.response.page_template_key == 'mobile':
return open(os.path.join(os.path.dirname(__file__), 'template.mobile.ezt')).read()
CACHE_REFRESH_TIMEOUT = 300
try:
cache_filepath_mtime = os.stat(self.cache_filepath).st_mtime
except OSError: # missing file
return self.update_content()
else:
template_content = open(self.cache_filepath).read()
if time.time() > (cache_filepath_mtime + CACHE_REFRESH_TIMEOUT):
threading.Thread(target=self.update_content).start()
return template_content
def update_content(self):
import requests
theme_skeleton_url = publisher.get_site_option('theme_skeleton_url')
r = requests.get(theme_skeleton_url, params={'source': self.source, 'format': 'ezt'})
body = """
[if-any gauche]
<div id="gauche">
[gauche]
</div>
[end]
[if-any bigdiv]<div id="[bigdiv]" [if-any breadcrumb]class="has-breadcrumb"[end]>[end]
[if-any title]<h2>[title]</h2>[end]
[body]
[if-any bigdiv]</div>[end]
"""
extra_head = """
[script]
<script type="text/javascript" src="/themes/base/static/dataview.js"></script>
<link rel="stylesheet" type="text/css" href="[css]">
"""
extra_top_head = """
<link rel="stylesheet" type="text/css" href="/qo/css/qommon.css">
"""
user_info = """
[if-any user]
<div id="toplinks">
<span>
<a class="logout" href="[root_url]logout">D&eacute;connexion</a>
[is session_user_backoffice_access "True"]
<a class="restricted" href="[root_url]backoffice/">Back office</a>
[end]
</span>
</div>
<div id="username">[session_user_display_name]</div>
[else]
<div id="toplinks">
<span class="login"><a href="[root_url]login/">Connexion</a> / <a href="[root_url]register/">Inscription</a></span>
</div>
[end]
"""
template_content = r.text.encode('utf-8')
template_content = template_content.replace('[if-any content][content][end]', body)
template_content = template_content.replace('[if-any extra-top-head][extra-top-head][end]', extra_top_head)
template_content = template_content.replace('[if-any extra-head][extra-head][end]', extra_head)
template_content = template_content.replace('[if-any user-info][user-info][end]', user_info)
self.cache(template_content)
return template_content
def cache(self, template_body):
import os
from qommon.storage import atomic_write
if not os.path.exists(self.cache_dirpath):
os.mkdir(self.cache_dirpath)
atomic_write(self.cache_filepath, template_body)
template_content = RemoteTemplate(request.get_url()).get_template_content()

View File

@ -1,82 +1,5 @@
/* general stuff */
html, body { margin: 0; font-family: 'Carme',sans-serif; font-size: 13px; }
a { text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3 { margin-top: 0; }
h1, h2, h3, h4 { color: #2a2a2a;}
ul { list-style: circle; }
a {
-webkit-transition: color 200ms ease-out;
}
::selection {
background: #1f4791;
color: white;
}
/* layout */
body {
overflow-x: hidden;
background: url(bg-page.png) #ece6e0 repeat-x;
}
div#page {
width: 100%;
}
div#header {
background-color: #ffffff;
width: 100%;
margin: 0 0 0 0;
position: absolute;
top: 0px;
margin-left: -500px;
z-index: 0;
}
div#top {
background: url(header-agglo.jpg) 0% 0% no-repeat;
height: 456px;
width: 1500px;
margin: 0 auto 0 auto;
margin-left: 50%;
}
div#top h1 {
width: 10em;
text-align: center;
padding-top: 3em;
padding-left: 2em;
margin-left: 20px;
font-size: 120%;
font-weight: bold;
}
div#top h1 a {
color: white;
text-shadow: #6374AB 0px 0px 3px;
}
div#top a img {
border: 0;
}
div#main-content-wrapper {
position: relative;
z-index: 100;
width: 1000px;
margin: 199px auto 0px auto;
}
div#main-content {
margin: 0;
min-height: 400px;
}
div#single-title {
font-size: 130%;
@ -99,9 +22,8 @@ div#sidebox h3 {
div#gauche {
clear: both;
width: 185px;
width: 19%;
float: left;
margin-top: -22px;
}
div#member,
@ -114,25 +36,24 @@ div#rub_agenda,
div#rub_annonce,
div#profile,
div#rub_consultation,
div#rub_service,
div#gauche + div#rub_service,
div#centre {
width: 795px;
width: 80%;
float: right;
background: white;
margin-top: 22px;
margin-bottom: 1em;
}
div#breadcrumb,
div#centre,
div#rub_service,
div.large div#rub_service,
div.large div#centre {
width: 1000px;
width: 100%;
float: none;
clear: both;
}
div#droite {
width: 275px;
float: left;
display: none;
}
@ -141,11 +62,9 @@ div#breadcrumb {
padding: 3px 0px;
z-index: 10;
color: #888;
margin-top: 22px;
}
div#centre {
margin-top: 38px;
}
#content div#breadcrumb a {
@ -167,85 +86,6 @@ hr.clear {
border: none;
}
#toplinks {
background: #ffffff;
position: relative;
float: right;
width: 250px;
margin: 0px 500px 0px 0px;
padding: 5px 5px 5px 5px;
}
#toplinks span {
width: 100%;
display: block;
margin: 0;
padding: 0;
color: #888;
background: url(button_connexion.gif) left center no-repeat;
border: 1px solid #e9e9e9;
line-height: 20px;
height: 22px;
}
#toplinks span.login {
text-align: center;
}
#toplinks a {
color: #888;
border: 1px solid transparent;
}
#toplinks a.logout {
padding-left: 30px;
}
#toplinks a:hover {
text-decoration: none;
color: #222;
}
#toplinks a.restricted {
color: white;
float: right;
padding: 0 1ex;
border: 1px outset #888;
background: #ea5b0c;
}
div#username {
float: right;
padding: 5px 5px 5px 5px;
background: white;
line-height: 20px;
height: 22px;
border: 1px solid white;
}
div#footer {
clear: both;
position: relative;
background: white url(background_footer.png) no-repeat top left;
padding: 0px;
width: 1000px;
height: 160px;
margin: 10px auto 0 auto;
}
p#legal {
position: absolute;
font-size: small;
color: #444;
margin: 0;
bottom: 0px;
left: 40px;
}
p#legal a {
color: inherit;
}
/* content styling */
div#rub_consultation h2,
@ -521,11 +361,14 @@ div#steps h2 {
div#steps ol {
list-style: none;
margin: 0;
margin-top: 45px;
padding: 0;
text-align: center;
}
div#steps ol li:first-child {
margin-top: 0;
}
div#steps span.marker {
float:left;
font-size: 250%;
@ -917,40 +760,6 @@ div.TableWidget input {
width: 7em;
}
#agglolinks {
position: absolute;
right: 0;
top: -140px;
}
#agglolinks a {
display: inline-block;
margin-left: 10px;
width: 130px;
color: white;
background: blue;
text-transform: uppercase;
text-align: center;
padding: 5px 5px;
font-size: 16px;
}
#agglolinks a.agglo-accueil {
background: #ea5b0c;
}
#agglolinks a.agglo-connaitre {
background: #d90024;
}
#agglolinks a.agglo-vivre {
background: #1f4791;
}
#agglolinks a.agglo-entreprendre {
background: #a3d117;
}
.chapeau {
font-style: italic;
font-size: 110%;
@ -1003,38 +812,6 @@ div#home-page-intro {
padding: 1ex;
}
div#agglo-little-links {
width: 475px;
padding-top: 5px;
}
div#agglo-little-links ul {
margin: 15px 20px;
padding: 0;
}
div#agglo-little-links li {
margin: 0;
display: inline;
list-style: none;
padding-right: 20px;
padding-bottom: 20px;
float: left;
}
div#agglo-little-links li a {
display: block;
width: 125px;
height: 26px;
line-height: 26px;
background: #6A408E;
text-align: center;
text-transform: uppercase;
color: white;
text-decoration: none;
font-size: 14px;
}
.use-file-from-msp span {
display: block;
text-indent: -9999px;
@ -1047,3 +824,7 @@ div#agglo-little-links li a {
div.qommon-map {
height: 280px;
}
br.quixoteform {
clear: both;
}