Initial revision

This commit is contained in:
Frédéric Péters 2006-08-14 21:17:17 +00:00
parent 1b87fe41bb
commit 05c98e5fe4
11 changed files with 523 additions and 0 deletions

1
README Normal file
View File

@ -0,0 +1 @@
Extra modules and customizations for w.c.s.

5
extra/auquotidien.py Normal file
View File

@ -0,0 +1,5 @@
import modules.root
import modules.admin
import modules.news
import modules.links

View File

9
extra/modules/admin.ptl Normal file
View File

@ -0,0 +1,9 @@
import wcs.admin.root
def admin_index [html] (self):
self.items[-1] = ('/', N_('Au Quotidien'))
from wcs.admin.menu import html_top
html_top('/')
'hello world'
wcs.admin.root.RootDirectory._q_index = admin_index

121
extra/modules/links.ptl Normal file
View File

@ -0,0 +1,121 @@
from quixote import get_request, get_response, get_session, redirect
from quixote.directory import Directory
import wcs
from wcs.formdef import FormDef
import wcs.admin.root
from wcs.admin.menu import *
from wcs.form import *
from wcs.forms.root import FormPage, PublicFormStatusPage
from wcs.forms.common import FormStatusPage
from wcs import errors
class LinksFormStatusPage(PublicFormStatusPage):
def __init__(self, component):
html_top('links', title = 'XX')
formdef = FormDef.get_by_urlname('liens')
try:
filled = formdef.data_class().get(component)
except KeyError:
raise errors.TraversalError()
PublicFormStatusPage.__init__(self, formdef, filled)
if not 'delete' in self._q_exports:
self._q_exports.append('delete')
def check_receiver(self):
return # FIXME: must not stay like this
def html_top(self, title = None):
return html_top('links', title)
def _q_index [html] (self):
return self.status()
def status(self):
return FormStatusPage.status(self)
def submit(self, form, comment_only = False):
t = PublicFormStatusPage.submit(self, form, comment_only = comment_only)
if t:
t = t.replace('/liens/', '/admin/links/')
return t
def delete [html] (self):
get_response().breadcrumb.append((str(self.filled.id), self.filled.get_field_value('Titre')))
form = Form(enctype='multipart/form-data')
form.widgets.append(HtmlWidget('<p>%s</p>' % _(
'You are about to irrevocably delete this link.')))
form.add_submit('submit', _('Submit'))
form.add_submit('cancel', _('Cancel'))
if form.get_widget('cancel').parse():
return redirect('..')
if not form.is_submitted() or form.has_errors():
get_response().breadcrumb.append(('delete', _('Delete')))
html_top('links', title = _('Delete Link'))
'<h2>%s %s</h2>' % (_('Deleting Link:'), self.filled.get_field_value('Titre'))
form.render()
else:
self.filled.remove_self()
return redirect('..')
edit = PublicFormStatusPage.wfedit
class LinksFormPage(FormPage):
def __init__(self):
FormPage.__init__(self, 'liens')
def _q_lookup(self, component):
filled = self.formdef.data_class().get(component)
return LinksFormStatusPage(self.formdef, filled)
class LinksDirectory(Directory):
_q_exports = ['', 'new', 'listing']
label = N_('Links')
def _q_index [html] (self):
html_top('links', _('Links'))
get_response().breadcrumb.append(('links', _('Links')))
'<p><a href="new">%s</a></p>' % _('New')
try:
links = FormDef.get_by_urlname('liens').data_class().select()
except:
links = []
'<ul class="biglist">'
for l in links:
link_id = l.id
'<li>'
'<strong class="label">%s</strong>' % l.get_field_value('Titre')
'<p class="details">'
l.get_field_value('URL')
'</p>'
'<p class="commands">'
command_icon('%s/' % link_id, 'view')
command_icon('%s/edit' % link_id, 'edit')
command_icon('%s/delete' % link_id, 'remove')
'</p></li>'
'</ul>'
def new(self):
html_top('links', title = 'XX')
s = LinksFormPage()._q_index()
# fixing up breadcrumb
for i, data in enumerate(get_response().breadcrumb):
if data[0] == 'liens/':
get_response().breadcrumb[i] = ('links', _('Links'))
break
return s
def _q_lookup(self, component):
html_top('links', title = 'XX')
get_response().breadcrumb.append(('links', _('Links')))
return LinksFormStatusPage(component)
def listing(self):
return redirect('.')
wcs.admin.root.register_admin_page('links', LinksDirectory())

118
extra/modules/news.ptl Normal file
View File

@ -0,0 +1,118 @@
from quixote import get_request, get_response, get_session, redirect
from quixote.directory import Directory
import wcs
from wcs.formdef import FormDef
import wcs.admin.root
from wcs.admin.menu import *
from wcs.form import *
from wcs.forms.root import FormPage, PublicFormStatusPage
from wcs.forms.common import FormStatusPage
from wcs import errors
class NewsFormStatusPage(PublicFormStatusPage):
def __init__(self, component):
html_top('news', title = 'XX')
formdef = FormDef.get_by_urlname('actualite')
try:
filled = formdef.data_class().get(component)
except KeyError:
raise errors.TraversalError()
PublicFormStatusPage.__init__(self, formdef, filled)
if not 'delete' in self._q_exports:
self._q_exports.append('delete')
def check_receiver(self):
return # FIXME: must not stay like this
def html_top(self, title = None):
return html_top('news', title)
def _q_index [html] (self):
return self.status()
def status(self):
return FormStatusPage.status(self)
def submit(self, form, comment_only = False):
t = PublicFormStatusPage.submit(self, form, comment_only = comment_only)
if t:
t = t.replace('/actualite/', '/admin/news/')
return t
def delete [html] (self):
get_response().breadcrumb.append((str(self.filled.id), self.filled.get_field_value('Titre')))
form = Form(enctype='multipart/form-data')
form.widgets.append(HtmlWidget('<p>%s</p>' % _(
'You are about to irrevocably delete this link.')))
form.add_submit('submit', _('Submit'))
form.add_submit('cancel', _('Cancel'))
if form.get_widget('cancel').parse():
return redirect('..')
if not form.is_submitted() or form.has_errors():
get_response().breadcrumb.append(('delete', _('Delete')))
html_top('news', title = _('Delete Link'))
'<h2>%s %s</h2>' % (_('Deleting Link:'), self.filled.get_field_value('Titre'))
form.render()
else:
self.filled.remove_self()
return redirect('..')
edit = PublicFormStatusPage.wfedit
class NewsFormPage(FormPage):
def __init__(self):
FormPage.__init__(self, 'actualite')
def _q_lookup(self, component):
filled = self.formdef.data_class().get(component)
return NewsFormStatusPage(self.formdef, filled)
class NewsDirectory(Directory):
_q_exports = ['', 'new', 'listing']
label = N_('News')
def _q_index [html] (self):
html_top('news', _('News'))
get_response().breadcrumb.append(('news', _('News')))
'<p><a href="new">%s</a></p>' % _('New')
try:
news = FormDef.get_by_urlname('actualite').data_class().select()
except:
news = []
'<ul class="biglist">'
for l in news:
link_id = l.id
'<li>'
'<strong class="label">%s</strong>' % l.get_field_value('Titre')
'<p class="commands">'
command_icon('%s/' % link_id, 'view')
command_icon('%s/edit' % link_id, 'edit')
command_icon('%s/delete' % link_id, 'remove')
'</p></li>'
'</ul>'
def new(self):
html_top('news', title = 'XX')
s = NewsFormPage()._q_index()
# fixing up breadcrumb
for i, data in enumerate(get_response().breadcrumb):
if data[0] == 'actualite/':
get_response().breadcrumb[i] = ('news', _('News'))
break
return s
def _q_lookup(self, component):
html_top('news', title = 'XX')
get_response().breadcrumb.append(('news', _('News')))
return NewsFormStatusPage(component)
def listing(self):
return redirect('.')
wcs.admin.root.register_admin_page('news', NewsDirectory())

102
extra/modules/root.ptl Normal file
View File

@ -0,0 +1,102 @@
import wcs
import wcs.root
from wcs import template
from wcs.categories import Category
from wcs.formdef import FormDef
OldRootDirectory = wcs.root.RootDirectory
class AlternateRootDirectory(OldRootDirectory):
_q_exports = ['', 'admin', 'backoffice', 'forms', 'login', 'logout', 'liberty', 'token', 'saml']
def _q_index [html] (self):
template.html_top(default_org = _('Ma ville au quotidien'))
'<div id="gauche">'
## Services
'<div id="services">'
'<h3>%s</h3>' % _('Services')
consultations_category = None
'<ul>'
for category in Category.select(order_by = 'name'):
if category.url_name == 'consultations':
consultations_category = category
continue
'<li>'
'<strong>'
'<a href="%s/">' % category.url_name
category.name
'</a></strong> : '
formdefs = FormDef.select(lambda x: (
x.category_id == category.id and not x.disabled),
order_by = 'name')
for formdef in formdefs:
'<a href="%s/">%s</a>' % (formdef.url_name, formdef.name)
if formdef != formdefs[-1]:
', '
'...'
'</li>'
'</ul>'
'</div>'
## Consultations
'<div id="consultations">'
'<h3>%s</h3>' % _('Consultations')
formdefs = FormDef.select(lambda x: (
x.category_id == consultations_category.id and not x.disabled),
order_by = 'name')
'<ul>'
for formdef in formdefs:
'<li>'
'<a href="%s/">%s</a>' % (formdef.url_name, formdef.name)
'</li>'
'</ul>'
'</div>'
'</div>'
'<div id="droite">'
## Links
try:
links = FormDef.get_by_urlname('liens').data_class().select()
except KeyError:
links = None
if links:
'<div id="links">'
'<h3>%s</h3>' % _('Useful links')
'<ul>'
for link in links:
url = link.get_field_value('URL')
name = link.get_field_value('Titre')
'<li><a href="%s">%s</a></li>' % (url, name)
'</ul>'
'</div>'
## News
try:
news = FormDef.get_by_urlname('actualite').data_class().select()
except KeyError:
news = None
if news:
'<div id="news">'
'<h3>%s</h3>' % _('News')
for item in news:
'<div class="newsitem">'
'<h4>'
item.get_field_value('Titre')
'</h4>'
'<p>'
item.get_field_value('Texte')
'</p>'
'</div>'
'</div>'
'</div>'
wcs.root.RootDirectory = AlternateRootDirectory

6
theme/desc.xml Normal file
View File

@ -0,0 +1,6 @@
<?xml version="1.0"?>
<theme name="auquotidien" version="1.0">
<label>Au Quotidien</label>
<desc>Theme for au-quotidien.fr</desc>
<author>Frederic Peters</author>
</theme>

BIN
theme/icon.png Normal file

Binary file not shown.

23
theme/template.ezt Normal file
View File

@ -0,0 +1,23 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>[page_title]</title>
<link rel="stylesheet" type="text/css" href="[css]"/>
[script]
</head>
<body[if-any onload] onload="[onload]"[end]>
<div id="page">
<div id="top"> <h1>[site_name]</h1> </div>
<div id="main-content">
[if-any title]<h2>[title]</h2>[end]
[prelude]
[body]
<hr />
</div>
<div id="footer">
<p>Truc CNIL, vous avez des droits.</p>
</div>
</div>
</body>
</html>

138
theme/wcs.css Normal file
View File

@ -0,0 +1,138 @@
@import url(/css/wcs-common.css);
h1 {
text-align: center;
}
#gauche {
float: left;
width: 45%;
margin: 0 2%;
}
#droite {
float: left;
width: 45%;
margin: 0 2%;
}
hr {
clear: both;
visibility: hidden;
}
div.liens {
text-align: right;
}
div.liens ul {
margin: 0;
padding: 0;
}
div.liens li {
display: inline;
padding-right: 1em;
}
div.nouvelles h2,
div.nouvelles h3 {
text-align: right;
}
div.nouvelles p {
text-align: justify;
}
div.liens,
div.services {
margin-bottom: 2em;
}
div#footer {
margin-top: 2em;
font-size: 70%;
color: gray;
text-align: center;
}
#steps {
height: 32px;
margin-bottom: 1em;
}
#steps ol {
list-style: none;
padding: 0 20px;
}
#steps li {
display: inline;
padding-right: 1em;
display: block;
float: left;
width: 30%;
list-style: none;
}
#steps ol ul {
border: 1px solid #ffa500;
margin-left: 2em;
background: #ffdb94;
margin-bottom: 1em;
padding: 0;
width: auto;
}
#steps li li {
display: block;
width: auto;
float: none;
text-align: left;
margin-left: 1em;
font-size: 90%;
}
#steps li li.current {
color: black;
}
#steps span.marker {
font-size: 26px;
padding: 2px 9px;
font-weight: bold;
color: white;
text-align: center;
background: #ddd;
border: 1px solid #ddd;
-moz-border-radius: 0.7ex;
}
#steps li.current span.marker {
background: #ffa500;
border: 1px solid #ffc400;
}
#steps span.label {
font-size: 90%;
}
#steps li.current span.label {
color: black;
}
#steps {
background: #f0f0f0;
color: #aaa;
}
#steps ol ul {
display: none;
}
#steps ol li.current ul {
display: block;
}