add labels for HTML output
- add translatable labels for HTML output (not used for JSON yet) - add oldpeople URL - modify the output template to use one table - add styles - rename action from handle_post to urllist to reflect its use - use a property to determine the order of url sections - use a list with a type to aggregate the urlbuilder results - use textilize to display labels
This commit is contained in:
parent
9c641cb79c
commit
709f2067cd
7 changed files with 163 additions and 41 deletions
|
@ -40,7 +40,7 @@ def make_map():
|
||||||
|
|
||||||
# CUSTOM ROUTES HERE
|
# CUSTOM ROUTES HERE
|
||||||
map.connect('', controller='ddportfolio', action='index')
|
map.connect('', controller='ddportfolio', action='index')
|
||||||
map.connect('result', controller='ddportfolio', action='handle_post')
|
map.connect('result', controller='ddportfolio', action='urllist')
|
||||||
map.connect(':controller/:action/:id')
|
map.connect(':controller/:action/:id')
|
||||||
map.connect('*url', controller='template', action='view')
|
map.connect('*url', controller='template', action='view')
|
||||||
|
|
||||||
|
|
|
@ -30,6 +30,82 @@ from ddportfolioservice.model.urlbuilder import *
|
||||||
log = logging.getLogger(__name__)
|
log = logging.getLogger(__name__)
|
||||||
|
|
||||||
class DdportfolioController(BaseController):
|
class DdportfolioController(BaseController):
|
||||||
|
_LABELS = {
|
||||||
|
'overview' : {
|
||||||
|
'label' : N_('Overview'),
|
||||||
|
'ddpo' : N_("Debian Developer's Package Overview"),
|
||||||
|
'alladdresses' : N_("""Debian Developer's Package Overview
|
||||||
|
... showing all email addresses"""),
|
||||||
|
},
|
||||||
|
'bugs' : {
|
||||||
|
'label' : N_('Bugs'),
|
||||||
|
'received' : N_('''bugs received
|
||||||
|
(note: co-maintainers not listed, see \
|
||||||
|
<a href="http://bugs.debian.org/cgi-bin/bugreport.cgi?\
|
||||||
|
bug=430986">#430986</a>)'''),
|
||||||
|
'reported' : N_('bugs reported'),
|
||||||
|
'bugstats' : N_('bugstats AKA <em>karma</em>'),
|
||||||
|
'usertags' : N_('user tags'),
|
||||||
|
'searchall' : N_('all messages (i.e., full text search for \
|
||||||
|
developer name on all bug logs)'),
|
||||||
|
'wnpp' : N_('<a href="http://wiki.debian.org/WNPP">WNPP</a>'),
|
||||||
|
},
|
||||||
|
'build' : {
|
||||||
|
'label' : N_('Build'),
|
||||||
|
'buildd' : N_('buildd.d.o (note: co-maintainers \
|
||||||
|
<em>not</em> listed)'),
|
||||||
|
'igloo' : N_('igloo'),
|
||||||
|
'svnbuildstat' : N_('svnbuildstat'),
|
||||||
|
},
|
||||||
|
'qa' : {
|
||||||
|
'label' : N_('Quality Assurance'),
|
||||||
|
'lintian' : N_('lintian reports'),
|
||||||
|
'lintianfull' : N_('full lintian reports (i.e. including \
|
||||||
|
"info"-level messages)'),
|
||||||
|
'dehs' : N_('DEHS (Debian External Health Status)'),
|
||||||
|
},
|
||||||
|
'upload' : {
|
||||||
|
'label' : N_('Upload'),
|
||||||
|
'keylog' : N_('''keylog (per-key upload list)
|
||||||
|
(note: uses key fingerprint)'''),
|
||||||
|
},
|
||||||
|
'lists' : {
|
||||||
|
'label' : N_('Mailing Lists'),
|
||||||
|
'dolists' : N_('lists.d.o'),
|
||||||
|
'adolists' : N_('lists.a.d.o'),
|
||||||
|
'gmane' : N_('gmane'),
|
||||||
|
},
|
||||||
|
'files' : {
|
||||||
|
'label' : N_('Files'),
|
||||||
|
'people' : N_('people.d.o'),
|
||||||
|
'oldpeople' : N_('oldpeople'),
|
||||||
|
'alioth' : N_('Alioth'),
|
||||||
|
},
|
||||||
|
'membership' : {
|
||||||
|
'label' : N_('Membership'),
|
||||||
|
'nm' : N_('NM'),
|
||||||
|
'db' : N_('DB'),
|
||||||
|
'alioth' : N_('Alioth'),
|
||||||
|
},
|
||||||
|
'miscellaneous' : {
|
||||||
|
'label' : N_('Miscellaneous'),
|
||||||
|
'debtags' : N_('debtags'),
|
||||||
|
'links' : N_('links'),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def _get_label(self, section, url=None):
|
||||||
|
if section in self._LABELS:
|
||||||
|
if url:
|
||||||
|
if url in self._LABELS[section]:
|
||||||
|
return self._LABELS[section][url]
|
||||||
|
elif 'label' in self._LABELS[section]:
|
||||||
|
return self._LABELS[section]['label']
|
||||||
|
if url:
|
||||||
|
return "%s.%s" % (section, url)
|
||||||
|
return section
|
||||||
|
|
||||||
|
|
||||||
def index(self):
|
def index(self):
|
||||||
# Return a rendered template
|
# Return a rendered template
|
||||||
|
@ -37,7 +113,8 @@ class DdportfolioController(BaseController):
|
||||||
# or, Return a response
|
# or, Return a response
|
||||||
return render('/showform.mako')
|
return render('/showform.mako')
|
||||||
|
|
||||||
def handle_post(self):
|
def urllist(self):
|
||||||
|
"""Handle the actual data."""
|
||||||
schema = DeveloperData()
|
schema = DeveloperData()
|
||||||
try:
|
try:
|
||||||
formencode.api.set_stdtranslation(
|
formencode.api.set_stdtranslation(
|
||||||
|
@ -50,6 +127,14 @@ class DdportfolioController(BaseController):
|
||||||
data = build_urls(form_result)
|
data = build_urls(form_result)
|
||||||
if 'mode' in request.params and request.params['mode'] == 'json':
|
if 'mode' in request.params and request.params['mode'] == 'json':
|
||||||
response.headers['Content-Type'] = 'text/json'
|
response.headers['Content-Type'] = 'text/json'
|
||||||
return simplejson.dumps(data['data'])
|
return simplejson.dumps(
|
||||||
|
dict([("%s.%s" % \
|
||||||
|
(entry[1], entry[2]), entry[3]) \
|
||||||
|
for entry in data if entry[0] == 'url']))
|
||||||
|
for entry in data:
|
||||||
|
if entry[0] in ('url', 'error'):
|
||||||
|
entry.append(_(self._get_label(entry[1], entry[2])))
|
||||||
|
elif entry[0] == 'section':
|
||||||
|
entry.append(_(self._get_label(entry[1])))
|
||||||
c.urldata = data
|
c.urldata = data
|
||||||
return render('/showurls.mako')
|
return render('/showurls.mako')
|
||||||
|
|
|
@ -1,4 +1,7 @@
|
||||||
#
|
#
|
||||||
|
# Configuration for DDPortfolio service
|
||||||
|
# Copyright (c) 2009 Jan Dittberner <jan@dittberner.info>
|
||||||
|
#
|
||||||
# This file is part of DDPortfolio service.
|
# This file is part of DDPortfolio service.
|
||||||
#
|
#
|
||||||
# DDPortfolio service is free software: you can redistribute it and/or
|
# DDPortfolio service is free software: you can redistribute it and/or
|
||||||
|
@ -17,6 +20,8 @@
|
||||||
#
|
#
|
||||||
[DEFAULT]
|
[DEFAULT]
|
||||||
keyring.dir=/usr/share/keyrings
|
keyring.dir=/usr/share/keyrings
|
||||||
|
urlbuilder.sections=overview,bugs,build,qa,upload,lists,files,membership,
|
||||||
|
miscellaneous
|
||||||
|
|
||||||
[overview]
|
[overview]
|
||||||
urls=ddpo,alladdresses
|
urls=ddpo,alladdresses
|
||||||
|
@ -55,8 +60,9 @@ adolists.pattern=http://www.google.com/search?q=site%%3Alists.alioth.debian.org+
|
||||||
gmane.pattern=http://search.gmane.org/?email=%(name)s&group=gmane.linux.debian.*
|
gmane.pattern=http://search.gmane.org/?email=%(name)s&group=gmane.linux.debian.*
|
||||||
|
|
||||||
[files]
|
[files]
|
||||||
urls=people,alioth
|
urls=people,oldpeople,alioth
|
||||||
people.pattern=http://people.debian.org/~%(username)s/
|
people.pattern=http://people.debian.org/~%(username)s/
|
||||||
|
oldpeople.pattern=http://oldpeople.debian.org/~%(username)s/
|
||||||
alioth.pattern=http://alioth.debian.org/~%(username)s/
|
alioth.pattern=http://alioth.debian.org/~%(username)s/
|
||||||
|
|
||||||
[membership]
|
[membership]
|
||||||
|
|
|
@ -31,6 +31,7 @@ import pkg_resources
|
||||||
from ddportfolioservice.model import keyfinder
|
from ddportfolioservice.model import keyfinder
|
||||||
from urllib import quote_plus
|
from urllib import quote_plus
|
||||||
|
|
||||||
|
|
||||||
my_config = ConfigParser.ConfigParser()
|
my_config = ConfigParser.ConfigParser()
|
||||||
my_config.readfp(pkg_resources.resource_stream(__name__, 'ddportfolio.ini'))
|
my_config.readfp(pkg_resources.resource_stream(__name__, 'ddportfolio.ini'))
|
||||||
|
|
||||||
|
@ -38,23 +39,24 @@ my_config.readfp(pkg_resources.resource_stream(__name__, 'ddportfolio.ini'))
|
||||||
def build_urls(fields):
|
def build_urls(fields):
|
||||||
"""Build personalized URLs using the developer information in
|
"""Build personalized URLs using the developer information in
|
||||||
fields."""
|
fields."""
|
||||||
data = {}
|
data = []
|
||||||
errors = {}
|
|
||||||
qfields = dict([(key, quote_plus(fields[key].encode('utf8'))) \
|
qfields = dict([(key, quote_plus(fields[key].encode('utf8'))) \
|
||||||
for key in fields])
|
for key in fields])
|
||||||
fpr = keyfinder.getFingerprintByEmail(fields['email'].encode('utf8'))
|
fpr = keyfinder.getFingerprintByEmail(fields['email'].encode('utf8'))
|
||||||
if fpr:
|
if fpr:
|
||||||
qfields['gpgfp'] = fpr[0]
|
qfields['gpgfp'] = fpr[0]
|
||||||
for section in my_config.sections():
|
for section in [section.strip() for section in \
|
||||||
|
my_config.get('DEFAULT',
|
||||||
|
'urlbuilder.sections').split(',')]:
|
||||||
|
data.append(['section', section])
|
||||||
if my_config.has_option(section, 'urls'):
|
if my_config.has_option(section, 'urls'):
|
||||||
for url in my_config.get(section, 'urls').split(','):
|
for url in my_config.get(section, 'urls').split(','):
|
||||||
if my_config.has_option(section, url + '.pattern'):
|
if my_config.has_option(section, url + '.pattern'):
|
||||||
try:
|
try:
|
||||||
data[section + '.' + url] = \
|
data.append(
|
||||||
|
['url', section, url,
|
||||||
my_config.get(section, url + '.pattern',
|
my_config.get(section, url + '.pattern',
|
||||||
False, qfields)
|
False, qfields)])
|
||||||
except Exception, e:
|
except Exception, e:
|
||||||
errors['%s.%s.pattern' % (section, url)] = \
|
data.append(['error', section, url, str(e)])
|
||||||
[my_config.get(section, '%s.pattern' % url,
|
return data
|
||||||
True), str(e)]
|
|
||||||
return {'data' : data, 'errors' : errors}
|
|
||||||
|
|
|
@ -1,3 +1,27 @@
|
||||||
|
html, body {
|
||||||
|
font-family:sans, Arial;
|
||||||
|
font-size:10pt;
|
||||||
|
}
|
||||||
|
|
||||||
|
table {
|
||||||
|
border-collapse:collapse;
|
||||||
|
width:100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
th, td {
|
||||||
|
border:1px solid grey;
|
||||||
|
}
|
||||||
|
|
||||||
|
td {
|
||||||
|
vertical-align:top;
|
||||||
|
padding:2px;
|
||||||
|
}
|
||||||
|
|
||||||
|
td p {
|
||||||
|
padding:0;
|
||||||
|
margin:0;
|
||||||
|
}
|
||||||
|
|
||||||
.errormsg {
|
.errormsg {
|
||||||
font-size:80%;
|
font-size:80%;
|
||||||
color:red;
|
color:red;
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||||
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||||
<%doc>
|
<%doc>
|
||||||
Template for the data input form.
|
Template for the data input form.
|
||||||
Copyright (c) 2009 Jan Dittberner <jan@dittberner.info>
|
Copyright (c) 2009 Jan Dittberner <jan@dittberner.info>
|
||||||
|
@ -18,16 +20,13 @@ You should have received a copy of the GNU Affero General Public
|
||||||
License along with this program. If not, see
|
License along with this program. If not, see
|
||||||
<http://www.gnu.org/licenses/>.
|
<http://www.gnu.org/licenses/>.
|
||||||
</%doc>
|
</%doc>
|
||||||
<!DOCTYPE html PUBLIC
|
|
||||||
"-//W3C//DTD XHTML 1.0 Strict//EN"
|
|
||||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>${_('Debian Developer Portfolio')}</title>
|
<title>${_('Debian Developer Portfolio')}</title>
|
||||||
${h.stylesheet_link_tag('style')}
|
${h.stylesheet_link_tag('style')}
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
${h.start_form(h.url_for(action='handle_post'), method='get')}
|
${h.start_form(h.url_for(action='urllist'), method='get')}
|
||||||
<fieldset id="ddportfolio">
|
<fieldset id="ddportfolio">
|
||||||
<legend>${_('Debian Developer Portfolio')}</legend>
|
<legend>${_('Debian Developer Portfolio')}</legend>
|
||||||
<label for="name">${_('Name:')}
|
<label for="name">${_('Name:')}
|
||||||
|
|
|
@ -1,3 +1,5 @@
|
||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
||||||
|
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||||
<%doc>
|
<%doc>
|
||||||
Template for the url output page.
|
Template for the url output page.
|
||||||
Copyright (c) 2009 Jan Dittberner <jan@dittberner.info>
|
Copyright (c) 2009 Jan Dittberner <jan@dittberner.info>
|
||||||
|
@ -18,35 +20,39 @@ You should have received a copy of the GNU Affero General Public
|
||||||
License along with this program. If not, see
|
License along with this program. If not, see
|
||||||
<http://www.gnu.org/licenses/>.
|
<http://www.gnu.org/licenses/>.
|
||||||
</%doc>
|
</%doc>
|
||||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
|
|
||||||
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
|
||||||
<html>
|
<html>
|
||||||
<head>
|
<head>
|
||||||
<title>${_('Debian Developer Portfolio')}</title>
|
<title>${_('Debian Developer Portfolio')}</title>
|
||||||
${h.stylesheet_link_tag('style')}
|
${h.stylesheet_link_tag('style')}
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
% if c.urldata['data']:
|
% if c.urldata:
|
||||||
<fieldset id="ddportfolio">
|
<fieldset id="ddportfolio">
|
||||||
<legend>${_('Debian Developer Portfolio')}</legend>
|
<legend>${_('Debian Developer Portfolio')}</legend>
|
||||||
<ul>
|
<table>
|
||||||
% for key in c.urldata['data']:
|
<thead>
|
||||||
<li>${key}<br />${h.link_to(h.truncate(
|
<tr><th>${_('Usage')}</th><th>${_('URL')}</th></tr>
|
||||||
c.urldata['data'][key], length=120), c.urldata['data'][key])}</li>
|
</thead>
|
||||||
% endfor
|
<tbody>
|
||||||
</ul>
|
% for row in c.urldata:
|
||||||
</fieldset>
|
% if row[0] == 'section':
|
||||||
|
<tr><th class="sectionlabel" colspan="2">${row[2]}</th></tr>
|
||||||
|
% elif row[0] == 'error':
|
||||||
|
<tr>
|
||||||
|
<td>${h.textilize(row[4])}</td>
|
||||||
|
<td>${_('Error during URL creation')}<br />
|
||||||
|
<span class="errormsg">${row[3].replace("\n",
|
||||||
|
'<br />')}</span></td>
|
||||||
|
</tr>
|
||||||
|
% else:
|
||||||
|
<tr>
|
||||||
|
<td>${h.textilize(row[4])}</td>
|
||||||
|
<td>${h.link_to(h.truncate(row[3], length=120), row[3])}</td>
|
||||||
|
</tr>
|
||||||
% endif
|
% endif
|
||||||
% if c.urldata['errors']:
|
|
||||||
<fieldset id="ddportfolioerrors">
|
|
||||||
<legend>${_('Errors during URL creation')}</legend>
|
|
||||||
<ul>
|
|
||||||
% for key in c.urldata['errors']:
|
|
||||||
<li>${key}<br />
|
|
||||||
<span class="errormsg">${c.urldata['errors'][key][0]}<br />
|
|
||||||
${c.urldata['errors'][key][1]}</span></li>
|
|
||||||
% endfor
|
% endfor
|
||||||
</ul>
|
</tbody>
|
||||||
|
</table>
|
||||||
</fieldset>
|
</fieldset>
|
||||||
% endif
|
% endif
|
||||||
<p>${h.link_to(_('Restart'), h.url_for(action='index'))}</p>
|
<p>${h.link_to(_('Restart'), h.url_for(action='index'))}</p>
|
||||||
|
|
Loading…
Reference in a new issue