Skip to content

Commit

Permalink
Merge branch '2375-demo-theme-development' into 2618-nested-resources
Browse files Browse the repository at this point in the history
Conflicts:
	ckan/templates/snippets/scripts.html

    both add new content
  • Loading branch information
tobes committed Aug 20, 2012
2 parents 650ca21 + a72ec6e commit b006a85
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 36 deletions.
30 changes: 0 additions & 30 deletions ckan/templates/snippets/internal-tracking.html

This file was deleted.

24 changes: 24 additions & 0 deletions ckan/templates/snippets/internal_tracking.html
@@ -0,0 +1,24 @@
<script type="text/javascript">
$(function (){
// Tracking
var url = location.pathname;
// remove any site root from url
console.log($('body').data('site-root'));
url = url.substring($('body').data('locale-root'), url.length);
// trim any trailing /
url = url.replace(/\/*$/, '');
$.ajax({url : $('body').data('site-root') + '_tracking',
type : 'POST',
data : {url:url, type:'page'},
timeout : 300 });
$('a.resource-url-analytics').click(function (e){
var url = $(e.target).closest('a').attr('href');
$.ajax({url : $('body').data('site-root') + '_tracking',
data : {url:url, type:'resource'},
type : 'POST',
complete : function () {location.href = url;},
timeout : 30});
e.preventDefault();
});
});
</script>
3 changes: 3 additions & 0 deletions ckan/templates/snippets/scripts.html
Expand Up @@ -35,3 +35,6 @@
<script src="{% url_for_static '/base/javascript/modules/related-item.js' %}"></script>
#}
{% resource 'base/main' %}
{% if config.get('ckan.tracking_enabled', 'false') %}
{% snippet 'snippets/internal_tracking.html' %}
{% endif %}
4 changes: 2 additions & 2 deletions ckan/templates/user/read.html
Expand Up @@ -28,8 +28,8 @@
<span class="media-image">{{ h.linked_gravatar(user.email_hash, 150) }}</span>
<div class="description">
<h1 class="heading">{{ user.fullname or _('No full name provided') }}</h1>
{% if user.about_formatted %}
{{ user.about_formatted }}
{% if c.about_formatted %}
{{ c.about_formatted }}
{% else %}
<p class="empty">
{% if c.is_myself %}
Expand Down
18 changes: 14 additions & 4 deletions doc/templating.rst
Expand Up @@ -127,6 +127,9 @@ language.
Includes
~~~~~~~~

.. Note::
Includes should be avoided as they are not portable use {% snippet %} tags whenever possible.

Snippets of text that are included using ``{% include %}`` should be
kept in a directory called _snippets_. This should be kept in the same
directory as the code that uses it.
Expand All @@ -138,6 +141,9 @@ case the usage should be clearly documented.
Snippets
~~~~~~~~

.. Note::
{% snippet %} tags should be used in favour of h.snippet()

Snippets are essentially middle ground between includes and macros in
that they are includes that allow a specific context to be provided
(includes just receive the parent context).
Expand Down Expand Up @@ -210,14 +216,17 @@ portion that we wish to change. In this case the ``breadcrumb`` block.

::

{% ckan_extends "user/read.html" %}
{% ckan_extends %}

{# Remove the breadcrumb #}
{% block breadcrumb %}{% endblock %}

This function works recursively and so is ideal for extensions that wish to
add a small snippet of functionality to the page.

.. Note::
{% ckan_extend %} only extends templates of the same name.

snippet
~~~~~~~

Expand Down Expand Up @@ -474,9 +483,10 @@ Builds a form from the supplied form_info list/tuple.

::

form_info - A list of dicts describing the form field to build.
data - The form data object.
errors - The form errors object.
form_info - A list of dicts describing the form field to build.
data - The form data object.
errors - The form errors object.
error_summary - The form errors object.

Example

Expand Down

0 comments on commit b006a85

Please sign in to comment.