Skip to content
This repository has been archived by the owner on Mar 5, 2021. It is now read-only.

Commit

Permalink
Make link plugins' templates respect uninformative items
Browse files Browse the repository at this point in the history
  • Loading branch information
evildmp committed Mar 31, 2015
1 parent 35a72a1 commit c13e01b
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 27 deletions.
22 changes: 11 additions & 11 deletions arkestra_utilities/plugin_modifiers.py
Expand Up @@ -28,14 +28,14 @@

class SimplePlaceholderWidthAdjuster(WidthAdjuster):
kind="placeholder_width"

def modify(self, context, placeholder_width):
# check for conditions that adjust the placeholder width
adjust_width = context.get("adjust_width", False)
# can be "percent", "relative", "absolute", "divider"
adjuster = context.get("width_adjuster", None)
adjuster = context.get("width_adjuster", None)
adjustment = float(context.get("width_adjustment", 0))

if adjust_width:
# print "need to adjust"
if adjuster == "divider":
Expand All @@ -56,7 +56,7 @@ def modify(self, context, placeholder_width):
class AutoSpaceFloat(WidthAdjuster):
"""
this truth table gives us clues about how to decide on width reductions.
The three conditions that make up the key are:
The three conditions that make up the key are:
auto
space [the space-on-left/right classes that we use]
floated
Expand All @@ -80,14 +80,14 @@ class AutoSpaceFloat(WidthAdjuster):
def modify(self, context, target, width, auto):
# check for attributes that use the reduce_key
grandparent = target.parent.parent
if grandparent:
if grandparent:
grandparent_class = grandparent.get("class", "")
self.space = "space-on" in grandparent_class
self.floated = "images-left" in grandparent_class or "images-right" in grandparent_class
reduce_key = (auto, self.space, self.floated)
width = width * self.reduce_by[reduce_key] / 100
return width

class ReduceForBackground(WidthAdjuster):
kind="image_width"
"""
Expand Down Expand Up @@ -133,11 +133,11 @@ class ColumnWidths(WidthAdjuster):
two_fifths: 37.73,
three_fifths: 58.4,
}

def modify(self, context, element, width):
# print "============ ColumnWidths "
element_class = element.get("class", "") # and its HTML class
# if this is a column whose parent is a row
# if this is a column whose parent is a row
if re.search(r"\column\b", element_class) and "columns" in element.parent.get("class", ""):
# columns is the number of columns, or 1 if not specified
columns = float(element.parent.get("class", "").split("columns")[1][0] or 1)
Expand All @@ -155,18 +155,18 @@ def modify(self, context, element, width):

class ImageBorders(WidthAdjuster):
kind="mark_and_modify"

def mark(self, context, element, markers):
image_border_class = context.get("image_border_class", "image-borders")
no_image_border_class = context.get("no_image_border_class", "no-image-borders")
element_class = element.get("class", "") # and its HTML class
if image_border_class in element_class:
# print "has borders"
markers["has_borders"] = True
if no_image_border_class in element_class:
if no_image_border_class in element_class:
markers["has_borders"] = False
return markers

def modify(self, context, markers, width):
if markers.get("has_borders"):
# print "-16 for borders"
Expand Down
20 changes: 10 additions & 10 deletions arkestra_utilities/templates/arkestra/generic_list_item.html
@@ -1,16 +1,16 @@
{% load thumbnail typogrify_tags humanize %}
{% load thumbnail typogrify_tags humanize %}
{% block list_item %}
{% block item_title %}
{% if "details" in lister.item_format and item.is_uninformative %}
<span class="title">{{ item|amp|smartypants|caps|initial_quotes }}</span>
{% if item.external_url %}
<a class="external title" href="{{ item.get_absolute_url }}">{{ item|amp|smartypants|caps|initial_quotes }}</a>
<span class="site-name"> {{ item.external_url.external_site|amp|smartypants|caps|initial_quotes }}</span>
{% else %}
{% if item.external_url %}
<a class="external title" href="{{ item.get_absolute_url }}">{{ item|amp|smartypants|caps|initial_quotes }}</a>
<span class="site-name"> {{ item.external_url.external_site|amp|smartypants|caps|initial_quotes }}</span>
{% else %}
<a class="title" href="{{ item.get_absolute_url }}">{{ item|amp|smartypants|caps|initial_quotes }}</a>
{% endif %}
{% endif %}
{% if not "details" in lister.item_format and not "details" in item.format or not item.is_uninformative %}
<a class="title" href="{{ item.get_absolute_url }}">{{ item|amp|smartypants|caps|initial_quotes }}</a>
{% else %}
<span class="title">{{ item|amp|smartypants|caps|initial_quotes }}</span>
{% endif %}
{% endif %}
{% endblock item_title %}

{% block item_image %}
Expand Down
13 changes: 7 additions & 6 deletions news_and_events/templates/news_and_events/event_list_item.html
Expand Up @@ -2,10 +2,10 @@
{% load typogrify_tags %}
{% spaceless %}
{% block item_title %}
{# this item is the child of a series that shows the parent's title #}
{# is this item the child of a series that shows the parent's title? #}
{% if "series" in item.show_parent_series %}

{# the series is informative, so link to it #}
{# is the series informative? #}
{% if not item.parent.is_uninformative %}
<a class="title" href="{{ item.parent.get_absolute_url }}">
{{ item.parent|amp|smartypants|caps|initial_quotes }}
Expand All @@ -14,7 +14,7 @@
<span class="title">{{ item.parent|amp|smartypants|caps|initial_quotes }}</span><br>
{% endif %}

{# it should show its own title too #}
{# should it show its own title too? #}
{% if "children" in item.show_parent_series %}

{% if "details" in lister.format and item.is_uninformative %}
Expand All @@ -30,17 +30,18 @@
{% endif %}
{% endif %}

{# either not a child of a series, or we don't display the parent's title #}
{# this item is not the child of a series #}
{% else %}
{% if item.external_url %}
<a class="external title" href="{{ item.get_absolute_url }}">{{ item|amp|smartypants|caps|initial_quotes }}</a>
<span class="site-name"> {{ item.external_url.external_site|amp|smartypants|caps|initial_quotes }}</span>
{% else %}
{# is this item the child of an informative series? #}
{% if item.parent.series and not item.parent.is_uninformative %}
<a class="title" href="{{ item.informative_url }}">{{ item|amp|smartypants|caps|initial_quotes }}</a>
{% else %}
{% if not "details" in lister.item_format or not item.is_uninformative %}
<a class="title" href="{{ item.informative_url }}">{{ item|amp|smartypants|caps|initial_quotes }}</a>
{# is this item informative, or not displaying details here? #}
{% if not "details" in lister.item_format and not "details" in item.format or not item.is_uninformative %}<a class="title" href="{{ item.informative_url }}">{{ item|amp|smartypants|caps|initial_quotes }}</a>
{% else %}
<span class="title">{{ item|amp|smartypants|caps|initial_quotes }}</span>
{% endif %}
Expand Down

0 comments on commit c13e01b

Please sign in to comment.