Skip to content

Commit

Permalink
Merge branch '2651-rival-patch'
Browse files Browse the repository at this point in the history
  • Loading branch information
rossjones committed Jul 10, 2012
2 parents 096a414 + fea646f commit 16a6895
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 9 deletions.
5 changes: 0 additions & 5 deletions ckan/controllers/package.py
Expand Up @@ -772,11 +772,6 @@ def resource_read(self, id, resource_id):
c.datastore_api = h.url_for('datastore_read', id=c.resource.get('id'),
qualified=True)

c.resource_desc_formatted = ckan.misc.MarkdownFormat().to_html(
c.resource.get('description',''))
c.pkg_notes_formatted = ckan.misc.MarkdownFormat().to_html(
c.package.get('notes',''))

c.related_count = len(c.pkg.related)
return render('package/resource_read.html')

Expand Down
9 changes: 9 additions & 0 deletions ckan/lib/helpers.py
Expand Up @@ -886,6 +886,14 @@ def dashboard_activity_stream(user_id):
return logic.get_action('dashboard_activity_list_html')(context, {'id': user_id})


def render_markdown(data):
''' returns the data as rendered markdown '''
# cope with data == None
if not data:
return ''
return literal(ckan.misc.MarkdownFormat().to_html(data))


# these are the functions that will end up in `h` template helpers
# if config option restrict_template_vars is true
__allowed_functions__ = [
Expand Down Expand Up @@ -942,6 +950,7 @@ def dashboard_activity_stream(user_id):
'follow_button',
'follow_count',
'dashboard_activity_stream',
'render_markdown',
# imported into ckan.lib.helpers
'literal',
'link_to',
Expand Down
8 changes: 4 additions & 4 deletions ckan/templates/package/resource_read.html
Expand Up @@ -126,20 +126,20 @@
</dl>
</div>

<div class="notes" property="rdfs:label" py:if="c.resource_desc_formatted">
<div class="notes" property="rdfs:label" py:if="c.resource.get('description')">
<div id="notes-extract">
${Markup(c.resource_desc_formatted)}
${ h.render_markdown(c.resource.get('description')) }
</div>
</div>

<div py:if="not c.resource_desc_formatted and c.pkg_notes_formatted">
<div py:if="not c.resource.get('description') and c.package.get('notes')">
<div>
<strong i18n:msg="">
From the <a href="${h.url_for(controller='package', action='read', id=c.package['name'])}">Dataset</a>:
</strong>
</div>
<div class="notes">
<div id="notes-extract">${Markup(c.pkg_notes_formatted)}</div>
<div id="notes-extract">${h.render_markdown(c.package.get('notes')) }</div>
</div>
</div>

Expand Down

0 comments on commit 16a6895

Please sign in to comment.