[ckan-changes] [okfn/ckan] a245bf: [2302] Added support for editing about page, and a...
GitHub
noreply at github.com
Tue Apr 24 15:02:26 UTC 2012
Branch: refs/heads/feature-2302-simple-theming
Home: https://github.com/okfn/ckan
Commit: a245bf2b260c04a94c9ff9b202e59e02ec19943a
https://github.com/okfn/ckan/commit/a245bf2b260c04a94c9ff9b202e59e02ec19943a
Author: Ross Jones <rossdjones at gmail.com>
Date: 2012-04-24 (Tue, 24 Apr 2012)
Changed paths:
M ckan/controllers/home.py
M ckan/controllers/settings.py
M ckan/controllers/user.py
M ckan/logic/schema.py
M ckan/public/css/custom.css.template
M ckan/templates/home/about.html
M ckan/templates/settings/index.html
M ckan/templates/user/layout.html
M ckan/templates/user/read.html
Log Message:
-----------
[2302] Added support for editing about page, and also changing the href color
diff --git a/ckan/controllers/home.py b/ckan/controllers/home.py
index a675826..8be8552 100644
--- a/ckan/controllers/home.py
+++ b/ckan/controllers/home.py
@@ -1,4 +1,5 @@
import random
+import genshi
from pylons.i18n import set_lang
import sqlalchemy.exc
@@ -31,7 +32,7 @@ def __before__(self, action, **env):
# TODO: send an email to the admin person (#1285)
else:
raise
-
+
def index(self):
try:
@@ -88,7 +89,16 @@ def license(self):
return render('home/license.html')
def about(self):
- return render('home/about.html')
+
+ extra = dict(model.Setting.get_values(['about']))
+ if extra.get('about'):
+ try:
+ formatted = ckan.misc.MarkdownFormat().to_html(extra.get('about',''))
+ extra['about'] = genshi.HTML(formatted)
+ except Exception, e:
+ error_msg = "<span class='inline-warning'>%s</span>" % _("Cannot render about page")
+ extra['about'] = genshi.HTML(error_msg)
+ return render('home/about.html', extra_vars=extra)
def cache(self, id):
'''Manual way to clear the caches'''
diff --git a/ckan/controllers/settings.py b/ckan/controllers/settings.py
index b72c605..48b60c1 100644
--- a/ckan/controllers/settings.py
+++ b/ckan/controllers/settings.py
@@ -52,7 +52,8 @@ def index(self):
'user': c.user or c.author }
fields = ['name', 'image_url',
'tagline', 'css_header',
- 'css_footer', 'css_background']
+ 'css_footer', 'css_background',
+ 'css_linkcolor','about']
success = False
if request.method == 'POST':
diff --git a/ckan/controllers/user.py b/ckan/controllers/user.py
index 0a26d59..d946910 100644
--- a/ckan/controllers/user.py
+++ b/ckan/controllers/user.py
@@ -96,6 +96,7 @@ def read(self, id=None):
except NotFound:
h.redirect_to(controller='user', action='login', id=None)
+ c.is_sysadmin = Authorizer().is_sysadmin(c.user)
c.user_dict = user_dict
c.is_myself = user_dict['name'] == c.user
c.about_formatted = self._format_about(user_dict['about'])
diff --git a/ckan/logic/schema.py b/ckan/logic/schema.py
index 5b3c7d3..3f39f75 100644
--- a/ckan/logic/schema.py
+++ b/ckan/logic/schema.py
@@ -287,6 +287,8 @@ def default_settings_schema(hex_func):
"css_header" : [ignore_missing, unicode, hex_func],
"css_background": [ignore_missing, unicode, hex_func],
"css_footer" : [ignore_missing, unicode, hex_func],
+ "css_linkcolor" : [ignore_missing, unicode, hex_func],
+ "about" : [ignore_missing, unicode],
}
diff --git a/ckan/public/css/custom.css.template b/ckan/public/css/custom.css.template
index e7ca410..fa2ac73 100644
--- a/ckan/public/css/custom.css.template
+++ b/ckan/public/css/custom.css.template
@@ -1,3 +1,7 @@
+a, a:visited {
+ color: #${ css_linkcolor };
+ text-decoration: none;
+}
.header.outer {
background-color: #${ css_header } !important;
background-image: none;
diff --git a/ckan/templates/home/about.html b/ckan/templates/home/about.html
index 1df2995..c0e617a 100644
--- a/ckan/templates/home/about.html
+++ b/ckan/templates/home/about.html
@@ -2,12 +2,16 @@
xmlns:i18n="http://genshi.edgewall.org/i18n"
xmlns:xi="http://www.w3.org/2001/XInclude"
py:strip="">
-
+
<py:def function="page_title">About</py:def>
<div py:match="content">
+ <py:if test="about">
+ ${about}
+ </py:if>
+ <py:if test="not about">
<h2>About ${g.site_title}</h2>
-
+
<py:choose>
<py:when test="not g.site_about">
@@ -33,6 +37,7 @@
<p i18n:msg="">The <a href="http://okfn.org">Open Knowledge Foundation</a> is a non-profit organisation <a href="http://okfn.org/about/vision/">promoting</a> open knowledge: writing and improving CKAN is one of the ways we do that. If you want to get involved with its design or code, join the discussion or development <a href="http://ckan.org/contact/">mailing lists</a>, or take a look at the <a href="http://okfn.org">OKFN</a> site to find out about our other projects.</p>
+ </py:if>
</div>
<xi:include href="layout.html" />
diff --git a/ckan/templates/settings/index.html b/ckan/templates/settings/index.html
index bc83e7c..7c31cbb 100644
--- a/ckan/templates/settings/index.html
+++ b/ckan/templates/settings/index.html
@@ -37,7 +37,7 @@
<label class="control-label" for="input01">Logo url</label>
<div class="controls">
<input type="text" class="input-xlarge" id="image_url" name="image_url" value="${data.get('image_url', g.site_url + '/img/logo.png' )}"/>
- <p class="help-block">The image loaded from this URL should be 145x120 px</p>
+ <p class="help-block">The image loaded from this URL should be 145 x 120px</p>
<span class="help-inline" py:if="errors.get('image_url')">${errors['image_url']}</span>
</div>
</div>
@@ -71,6 +71,17 @@
</div>
</div>
+ <div class="control-group ${ 'error' if errors.get('css_linkcolor', '') else '' }">
+ <label class="control-label" for="input01">Link color</label>
+ <div class="controls">
+ <div class="input-prepend">
+ <span class='add-on'>#</span><input type="text" class="input-xlarge" id="css_linkcolor" name="css_linkcolor" value="${data.get('css_linkcolor','b22')}"/>
+ </div>
+ <span class="help-inline" py:if="not errors.get('css_linkcolor')">Hexadecimal value for the link color</span>
+ <span class="help-inline" py:if="errors.get('css_linkcolor')">${errors['css_linkcolor']}</span>
+ </div>
+ </div>
+
<div class="control-group ${ 'error' if errors.get('css_background', '') else '' }">
<label class="control-label" for="input01">Background</label>
<div class="controls">
@@ -94,6 +105,15 @@
</div>
</fieldset>
+ <fieldset>
+ <legend>About Page</legend>
+ <div class="control-group description-field">
+ <label class="control-label" for="notes">Text</label>
+ <div class="controls">
+ ${markdown_editor('about', data.get('about'), 'about', _('Enter some text for your about page ...'))}
+ </div>
+ </div>
+ </fieldset>
<div class="form-actions">
<button type="submit" class="btn btn-primary">Save changes</button>
<button class="btn">Cancel</button>
diff --git a/ckan/templates/user/layout.html b/ckan/templates/user/layout.html
index cf4d02c..f755c01 100644
--- a/ckan/templates/user/layout.html
+++ b/ckan/templates/user/layout.html
@@ -10,6 +10,9 @@
<py:when test="True">
<li class="${'active' if c.action=='read' else ''}"><a href="${h.url_for(controller='user', action='me')}">My Profile</a></li>
<li class="${'active' if c.action=='edit' else ''}"><a href="${h.url_for(controller='user', action='edit')}">Edit Profile</a></li>
+ <li py:if="c.is_sysadmin">
+ <a href="${ h.url_for(controller='settings', action='index')}">Edit Site Settings</a>
+ </li>
<li><a href="${h.url_for('/user/logout')}">Log out</a></li>
</py:when>
<py:otherwise>
@@ -23,7 +26,7 @@
</py:otherwise>
</ul>
</py:match>
-
+
<xi:include href="../layout.html" />
</html>
diff --git a/ckan/templates/user/read.html b/ckan/templates/user/read.html
index 681f0db..13d5f4f 100644
--- a/ckan/templates/user/read.html
+++ b/ckan/templates/user/read.html
@@ -1,7 +1,7 @@
<html xmlns:py="http://genshi.edgewall.org/"
xmlns:xi="http://www.w3.org/2001/XInclude"
py:strip="">
-
+
<py:def function="page_title">${c.user_dict['display_name']} - User</py:def>
<py:def function="page_heading">
${h.linked_gravatar(c.user_dict['email_hash'],48)}
@@ -14,7 +14,7 @@
</span>
</py:if>
</py:def>
-
+
<div py:match="content" py:strip="">
<div class="summary">
<div class="row">
@@ -62,6 +62,7 @@
</div>
</div><!-- /row -->
</div><!-- /summary -->
+
<div class="rule"></div>
<div class="listing">
@@ -82,6 +83,8 @@
</div>
</div><!-- /row -->
</div><!-- /listing -->
+
+
</div>
<xi:include href="layout.html" />
================================================================
Commit: a01c20f173eae3385d1d1c5923293bcdaffded19
https://github.com/okfn/ckan/commit/a01c20f173eae3385d1d1c5923293bcdaffded19
Author: Ross Jones <rossdjones at gmail.com>
Date: 2012-04-24 (Tue, 24 Apr 2012)
Changed paths:
M ckan/controllers/home.py
Log Message:
-----------
[2302] Fix to Home controller for testing the about page
diff --git a/ckan/controllers/home.py b/ckan/controllers/home.py
index 8be8552..bd6094f 100644
--- a/ckan/controllers/home.py
+++ b/ckan/controllers/home.py
@@ -98,6 +98,8 @@ def about(self):
except Exception, e:
error_msg = "<span class='inline-warning'>%s</span>" % _("Cannot render about page")
extra['about'] = genshi.HTML(error_msg)
+ else:
+ extra['about'] = None
return render('home/about.html', extra_vars=extra)
def cache(self, id):
================================================================
Compare: https://github.com/okfn/ckan/compare/89c2fcd...a01c20f
More information about the ckan-changes
mailing list