[ckan-changes] commit/ckan: 2 new changesets
Bitbucket
commits-noreply at bitbucket.org
Wed Oct 26 11:16:53 UTC 2011
2 new commits in ckan:
https://bitbucket.org/okfn/ckan/changeset/be189c649db9/
changeset: be189c649db9
branch: release-v1.5
user: zephod
date: 2011-10-26 13:02:14
summary: [template_head_end][s]: Added new config option for easy addition of CSS.
affected #: 5 files
diff -r 945e2a6ce74fc1aaed058346da5b9127162d6d89 -r be189c649db9f7f8d5ac7568994e7cb8326ccc92 ckan/config/deployment.ini_tmpl
--- a/ckan/config/deployment.ini_tmpl
+++ b/ckan/config/deployment.ini_tmpl
@@ -154,6 +154,11 @@
## Enable if the API is at a different domain
# ckan.api_url = http://www.ckan.net
+## html content to be inserted just before </head> tag (e.g. extra stylesheet)
+## NB: can use html e.g. <strong>blah</strong>
+## NB: can have multiline strings just indent following lines
+# ckan.template_head_end = <link rel="stylesheet" href="http://mysite.org/css/custom.css" type="text/css">
+
## html content to be inserted just before </body> tag (e.g. google analytics code)
## NB: can use html e.g. <strong>blah</strong>
## NB: can have multiline strings just indent following lines
diff -r 945e2a6ce74fc1aaed058346da5b9127162d6d89 -r be189c649db9f7f8d5ac7568994e7cb8326ccc92 ckan/lib/app_globals.py
--- a/ckan/lib/app_globals.py
+++ b/ckan/lib/app_globals.py
@@ -28,6 +28,7 @@
# has been setup in load_environment():
self.site_id = config.get('ckan.site_id')
+ self.template_head_end = config.get('ckan.template_head_end', '')
self.template_footer_end = config.get('ckan.template_footer_end', '')
# hide these extras fields on package read
diff -r 945e2a6ce74fc1aaed058346da5b9127162d6d89 -r be189c649db9f7f8d5ac7568994e7cb8326ccc92 ckan/templates/layout_base.html
--- a/ckan/templates/layout_base.html
+++ b/ckan/templates/layout_base.html
@@ -42,6 +42,7 @@
${optional_head()}
</py:if>
+ ${h.literal(getattr(g, 'template_head_end', ''))}
</head><body class="${request.environ.get('pylons.routes_dict', {}).get('action')}
diff -r 945e2a6ce74fc1aaed058346da5b9127162d6d89 -r be189c649db9f7f8d5ac7568994e7cb8326ccc92 ckan/tests/functional/test_home.py
--- a/ckan/tests/functional/test_home.py
+++ b/ckan/tests/functional/test_home.py
@@ -75,6 +75,11 @@
url = url_for('guide')
assert url == 'http://wiki.okfn.org/ckan/doc/'
+ def test_template_head_end(self):
+ offset = url_for('home')
+ res = self.app.get(offset)
+ assert 'ckan.template_head_end = <link rel="stylesheet" href="TEST_TEMPLATE_HEAD_END.css" type="text/css"> '
+
def test_template_footer_end(self):
offset = url_for('home')
res = self.app.get(offset)
diff -r 945e2a6ce74fc1aaed058346da5b9127162d6d89 -r be189c649db9f7f8d5ac7568994e7cb8326ccc92 test-core.ini
--- a/test-core.ini
+++ b/test-core.ini
@@ -47,6 +47,9 @@
# ckan.plugins = amqp_notifier
# use <strong> so we can check that html is *not* escaped
+ckan.template_head_end = <link rel="stylesheet" href="TEST_TEMPLATE_HEAD_END.css" type="text/css">
+
+# use <strong> so we can check that html is *not* escaped
ckan.template_footer_end = <strong>TEST TEMPLATE_FOOTER_END TEST</strong>
# mailer
https://bitbucket.org/okfn/ckan/changeset/189fbd62ae3e/
changeset: 189fbd62ae3e
branch: release-v1.5
user: zephod
date: 2011-10-26 13:16:49
summary: [merge,from-remote]:
affected #: 1 file
diff -r be189c649db9f7f8d5ac7568994e7cb8326ccc92 -r 189fbd62ae3ed0dd6d1d6ee45ec6cc6a91801dbc ckan/lib/munge.py
--- a/ckan/lib/munge.py
+++ b/ckan/lib/munge.py
@@ -19,6 +19,33 @@
name = re.sub('[^a-zA-Z0-9-_]', '', name).lower()
return name
+def munge_title_to_name(name):
+ '''Munge a title into a name.
+ '''
+ # remove foreign accents
+ if isinstance(name, unicode):
+ name = substitute_ascii_equivalents(name)
+ # convert spaces and separators
+ name = re.sub('[ .:/]', '-', name)
+ # take out not-allowed characters
+ name = re.sub('[^a-zA-Z0-9-_]', '', name).lower()
+ # remove doubles
+ name = re.sub('--', '-', name)
+ # remove leading or trailing hyphens
+ name = name.strip('-')
+ # if longer than max_length, keep last word if a year
+ max_length = model.PACKAGE_NAME_MAX_LENGTH - 5
+ # (make length less than max, in case we need a few for '_' chars
+ # to de-clash names.)
+ if len(name) > max_length:
+ year_match = re.match('.*?[_-]((?:\d{2,4}[-/])?\d{2,4})$', name)
+ if year_match:
+ year = year_match.groups()[0]
+ name = '%s-%s' % (name[:(max_length-len(year)-1)], year)
+ else:
+ name = name[:max_length]
+ return name
+
def substitute_ascii_equivalents(text_unicode):
# Method taken from: http://code.activestate.com/recipes/251871/
"""This takes a UNICODE string and replaces Latin-1 characters with
Repository URL: https://bitbucket.org/okfn/ckan/
--
This is a commit notification from bitbucket.org. You are receiving
this because you have the service enabled, addressing the recipient of
this email.
More information about the ckan-changes
mailing list