Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/okfn/ckan
Browse files Browse the repository at this point in the history
  • Loading branch information
rossjones committed Mar 20, 2012
2 parents ee40a61 + a9385df commit 1ca51d1
Show file tree
Hide file tree
Showing 8 changed files with 135 additions and 712 deletions.
14 changes: 11 additions & 3 deletions ckan/config/middleware.py
Original file line number Diff line number Diff line change
Expand Up @@ -204,12 +204,18 @@ def _start_response(status, response_headers, exc_info=None):
return start_response(status, response_headers, exc_info)

# Only use cache for GET requests
# If there is a cookie we avoid the cache.
# REMOTE_USER is used by some tests.
if environ['REQUEST_METHOD'] != 'GET' or environ.get('HTTP_COOKIE') or \
environ.get('REMOTE_USER'):
if environ['REQUEST_METHOD'] != 'GET' or environ.get('REMOTE_USER'):
return self.app(environ, start_response)

# If there is a ckan cookie (or auth_tkt) we avoid the cache.
# We want to allow other cookies like google analytics ones :(
cookie_string = environ.get('HTTP_COOKIE')
if cookie_string:
for cookie in cookie_string.split(';'):
if cookie.startswith('ckan') or cookie.startswith('auth_tkt'):
return self.app(environ, start_response)

# Make our cache key
key = 'page:%s?%s' % (environ['PATH_INFO'], environ['QUERY_STRING'])

Expand All @@ -220,6 +226,8 @@ def _start_response(status, response_headers, exc_info=None):
self.redis_connection = self.redis.StrictRedis()
self.redis_connection.flushdb()
except self.redis_exception:
# Connection may have failed at flush so clear it.
self.redis_connection = None
return self.app(environ, start_response)

# If cached return cached result
Expand Down
15 changes: 11 additions & 4 deletions ckan/lib/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,17 +180,24 @@ def __call__(self, environ, start_response):
# the request is routed to. This routing information is
# available in environ['pylons.routes_dict']

# clean out any old cookies as they may contain api keys etc
# Clean out any old cookies as they may contain api keys etc
# This also improves the cachability of our pages as cookies
# prevent proxy servers from caching content unless they have
# been configured to ignore them.
for cookie in request.cookies:
if cookie.startswith('ckan') and cookie not in ['ckan', 'ckan_killtopbar']:
if cookie.startswith('ckan') and cookie not in ['ckan']:
response.delete_cookie(cookie)

if cookie == 'ckan' and not c.user and not h.are_there_flash_messages():
# Remove the ckan session cookie if not used e.g. logged out
elif cookie == 'ckan' and not c.user and not h.are_there_flash_messages():
if session.id:
if not session.get('lang'):
session.delete()
else:
response.delete_cookie(cookie)
# Remove auth_tkt repoze.who cookie if user not logged in.
elif cookie == 'auth_tkt' and not session.id:
response.delete_cookie(cookie)

try:
return WSGIController.__call__(self, environ, start_response)
finally:
Expand Down
2 changes: 2 additions & 0 deletions ckan/templates/admin/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ <h3>Current Sysadmins</h3>
${h.linked_user(user)}
</li>
</ul>

<span class="insert-comment-recent"></span>
</div>

<xi:include href="layout.html" />
Expand Down
2 changes: 2 additions & 0 deletions ckan/templates/package/read.html
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ <h3>Related Datasets</h3>
</py:if>

<xi:include href="read_core.html" />

<span class="insert-comment-thread"></span>
</div>

<py:def function="optional_head">
Expand Down
2 changes: 2 additions & 0 deletions ckan/templates/package/resource_read.html
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,8 @@ <h3>Additional Information</h3>
</tbody>
</table>
</div>

<span class="insert-comment-thread"></span>
</div>

<py:def function="optional_footer">
Expand Down
23 changes: 23 additions & 0 deletions doc/commenting.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
=======================
Comments and Commenting
=======================

In a default CKAN install commenting is disabled. To enable it you have to
install and enable the disqus (commenting) extension:

https://github.com/okfn/ckanext-disqus/

Please read and follow the instructions there (as well as the standard
:doc:`extensions` documentation).

Important Note
--------------

Once installed and enabled, the presence of comments on a given page is
configured by your theme (see the documentation in the disqus extension for
details).

In the default CKAN theme (as of v1.6.1), comments will be shown only on dataset
and resource pages (and recent comments only on the
:doc:`administrative-dashboard`).

1 change: 1 addition & 0 deletions doc/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ Customizing and Extending
:maxdepth: 2

theming
commenting
extensions
writing-extensions
forms
Expand Down

0 comments on commit 1ca51d1

Please sign in to comment.