Show description/content of posts/assets

This commit is contained in:
Pablo Vazquez 2016-11-24 19:03:43 +01:00
parent 5617f89c99
commit 1e1d9e57e7
3 changed files with 18 additions and 3 deletions

View File

@ -251,7 +251,7 @@ def render_project(project, api, extra_context=None, template_name=None):
project.picture_square = utils.get_file(project.picture_square, api=api)
project.picture_header = utils.get_file(project.picture_header, api=api)
def load_latest(list_of_ids):
def load_latest(list_of_ids, node_type=None):
"""Loads a list of IDs in reversed order."""
if not list_of_ids:
@ -263,6 +263,11 @@ def render_project(project, api, extra_context=None, template_name=None):
'picture': 1}
params = {'projection': projection, 'embedded': {'user': 1}}
if node_type == 'post':
projection['properties.content'] = 1
elif node_type == 'asset':
projection['description'] = 1
list_latest = []
for node_id in reversed(list_of_ids or ()):
try:
@ -278,8 +283,8 @@ def render_project(project, api, extra_context=None, template_name=None):
return list_latest
project.nodes_featured = load_latest(project.nodes_featured)
project.nodes_blog = load_latest(project.nodes_blog)
project.nodes_featured = load_latest(project.nodes_featured, node_type='asset')
project.nodes_blog = load_latest(project.nodes_blog, node_type='post')
# Merge featured assets and blog posts into one activity stream
def sort_key(item):

View File

@ -1615,6 +1615,10 @@ a.learn-more
flex-direction: column
justify-content: space-between
.description
font-size: .9em
padding-top: 5px
.title
display: block
word-break: break-word

View File

@ -97,6 +97,12 @@ script.
| {% endif %}
.info
a.title(href="{{ url_for_node(node=n) }}") {{ n.name }}
p.description(href="{{ url_for_node(node=n) }}")
| {% if n.node_type == 'post' %}
| {{ n.properties.content | striptags | truncate(125, end="... <small>read more</small>") | safe | hide_none }}
| {% else %}
| {{ n.description | striptags | truncate(125, end="... <small>read more</small>") | hide_none }}
| {% endif %}
span.details
span.what {% if n.properties.content_type %}{{ n.properties.content_type | undertitle }}{% else %}{{ n.node_type | undertitle }}{% endif %} ·
span.when {{ n._updated | pretty_date }} by