Permalink
Browse files

Merge branch 'learning' into development

  • Loading branch information...
2 parents 186ffa5 + 3f08ac4 commit e1f5da3b3e18d2e17f3ad6ac20c4535b0167ff1d @ryanpitts ryanpitts committed Mar 12, 2013
View
@@ -23,6 +23,7 @@ class ArticleAdmin(AdminImageMixin, admin.ModelAdmin):
prepopulated_fields = {'slug': ('title',)}
filter_horizontal = ('authors', 'people', 'organizations', 'code',)
list_filter = ('is_live', 'article_type',)
+ list_display = ('title', 'pubdate', 'article_type', 'is_live')
search_fields = ('title', 'body', 'summary',)
date_hierarchy = 'pubdate'
fieldsets = (
View
@@ -2,7 +2,7 @@
import itertools
from django.db import models
-from django.template.defaultfilters import date as dj_date, linebreaks
+from django.template.defaultfilters import date as dj_date, linebreaks, removetags
from caching.base import CachingManager, CachingMixin
from sorl.thumbnail import ImageField
@@ -24,6 +24,73 @@
('learning', 'Learning'),
)
+# Current iteration does not use this in nav, but leaving dict
+# in place for feed, url imports until we make a permanent call
+SECTION_MAP = {
+ 'articles': {
+ 'name': 'Features',
+ 'slug': 'articles',
+ 'article_types': ['project', 'tool', 'how-to', 'interview', 'roundtable', 'roundup', 'event', 'update'],
+ 'gets_promo_items': False,
+ },
+ 'learning': {
+ 'name': 'Learning',
+ 'slug': 'learning',
+ 'article_types': ['learning',],
+ 'gets_promo_items': True,
+ },
+}
+
+# Current iteration only has *one* articles section, but this map is in place
+# in case we split out into multiple sections that need parent categories
+CATEGORY_MAP = {
+ 'project': {
+ 'name': 'Project',
+ 'parent_name': 'Features',
+ 'parent_slug': 'articles',
+ },
+ 'tool': {
+ 'name': 'Tool',
+ 'parent_name': 'Features',
+ 'parent_slug': 'articles',
+ },
+ 'how-to': {
+ 'name': 'How-to',
+ 'parent_name': 'Features',
+ 'parent_slug': 'articles',
+ },
+ 'interview': {
+ 'name': 'Interview',
+ 'parent_name': 'Features',
+ 'parent_slug': 'articles',
+ },
+ 'roundtable': {
+ 'name': 'Roundtable',
+ 'parent_name': 'Features',
+ 'parent_slug': 'articles',
+ },
+ 'roundup': {
+ 'name': 'Roundup',
+ 'parent_name': 'Features',
+ 'parent_slug': 'articles',
+ },
+ 'event': {
+ 'name': 'Event',
+ 'parent_name': 'Features',
+ 'parent_slug': 'articles',
+ },
+ 'update': {
+ 'name': 'Update',
+ 'parent_name': 'Features',
+ 'parent_slug': 'articles',
+ },
+ 'learning': {
+ 'name': 'Learning',
+ 'parent_name': 'Learning',
+ 'parent_slug': 'learning',
+ },
+}
+
class LiveArticleManager(CachingManager):
def get_query_set(self):
return super(LiveArticleManager, self).get_query_set().filter(is_live=True, pubdate__lte=datetime.now())
@@ -62,7 +129,17 @@ def __unicode__(self):
@models.permalink
def get_absolute_url(self):
return ('article_detail', (), {
- 'slug': self.slug })
+ 'section': self.section['slug'],
+ 'slug': self.slug
+ })
+
+ @property
+ def section(self):
+ '''determine whether article matches specific section'''
+ for section in SECTION_MAP:
+ if self.article_type in SECTION_MAP[section]['article_types']:
+ return SECTION_MAP[section]
+ return SECTION_MAP['articles']
@property
def pretty_pubdate(self):
@@ -87,6 +164,11 @@ def pretty_body_text(self):
# that already contains <p> tags
_body = linebreaks(_body)
return _body
+
+ @property
+ def safe_summary(self):
+ '''suitable for use in places that must avoid nested anchor tags'''
+ return removetags(self.summary, 'a')
@property
def merged_tag_list(self):

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
@@ -0,0 +1 @@
+<h1 class="maintopic"><a href="{{ url('article_list_by_section', section.slug) }}">{{ section.name }}</a>{% if category %} / <span class="category">{{ category }}</span>{% endif %}{% if tags %} / <span class="category">{% for tag in tags %}{{ tag.name }}{% if not loop.last %}, {% endif %}{% endfor %}</span>{% endif %}</h1>
@@ -1,3 +1,7 @@
{% extends "base.html" %}
-{% set active_nav = "features" %}
-{% block page_title %}Features{% if tags %} tagged: {% for tag in tags %}{{ tag.name }}{% if not loop.last %}, {% endif %}{% endfor %}{% endif %} - {{ super() }}{% endblock %}
+
+{% if section %}
+ {% set active_nav = section.slug %}
+{% endif %}
+
+{% block page_title %}{% if section %}{{ section.name }}{% else %}Features{% endif %}{% if tags %} tagged: {% for tag in tags %}{{ tag.name }}{% if not loop.last %}, {% endif %}{% endfor %}{% endif %} - {{ super() }}{% endblock %}
@@ -3,9 +3,21 @@
{% block page_title %} {{ article.title }} - {{ super() }}{% endblock %}
{% block site_js_extra %}
-<script src="{{ static('articles/js/jquery.syntaxhighlighter.min.js') }}"></script>
+{% compress js %}
+ {% if article.section.slug == "learning" %}
+ <script src="{{ static('articles/js/jquery.scrollTo.min.js') }}"></script>
+ <script src="{{ static('articles/js/jquery.localScroll.min.js') }}"></script>
+ {% endif %}
+ <script src="{{ static('articles/js/jquery.syntaxhighlighter.min.js') }}"></script>
+{% endcompress %}
<script type="text/javascript">
$.SyntaxHighlighter.init();
+ {% if article.section.slug == "learning" %}
+ $('.article-toc').localScroll({
+ offset: -80,
+ hash: true
+ });
+ {% endif %}
</script>
{% endblock %}
@@ -23,24 +35,24 @@
<aside>
<div class="byline">
+ {% if article.section.slug == "learning" %}
+ <div class="article-toc">
+ {% for article_block in article.articleblock_set.all() %}
+ {% if loop.first %}<h3 class="subhead list-header">In this case study</h3>
+ <ul class="toc">{% endif %}
+ <li><i class="icon-circle-arrow-right"></i> <a href="#{{ article_block.slug }}">{{ article_block.title }}</a></li>
+ {% if loop.last %}</ul>{% endif %}
+ {% endfor %}
+ </div>
+ {% endif %}
+
<h6 class="date">{{ article.pretty_pubdate }}</h6>
{% if article.get_live_author_set().exists() %}<h6 class="byline-name">{% with author_list = article.get_live_author_set() %}{% include "articles/_article_author_list.html" %}{% endwith %}</h6>{% endif %}
<ul class="link-list">
<li><i class="icon-comments"></i><a href="{{ HTTP_PROTOCOL }}://{{ request.get_host() }}{{ article.get_absolute_url() }}#disqus_thread" data-disqus-identifier="article_detail_{{ article.pk }}">Comments</a></li>
</ul>
</div>
- {% if article.article_type == "learning" %}
- <div class="article-toc">
- {% for article_block in article.articleblock_set.all() %}
- {% if loop.first %}<h3 class="subhead list-header">Contents</h3>
- <ul class="link-list">{% endif %}
- <li><i class="icon-circle-arrow-right"></i><a href="#{{ article_block.slug }}">{{ article_block.title }}</a></li>
- {% if loop.last %}</ul>{% endif %}
- {% endfor %}
- </div>
- {% endif %}
-
<div class="article-people">
{% with code_link_list = article.get_live_code_set() %}
{% include "code/_code_link_list.html" %}{% endwith %}
@@ -2,7 +2,7 @@
{% block content %}
{% if section %}
-<h1 class="maintopic"><a href="{{ url('article_list_by_section', section.slug) }}">{{ section.name }}</a>{% if category %} / <span class="category">{{ category }}</span>{% endif %}{% if tags %} / <span class="category">{% for tag in tags %}{{ tag.name }}{% if not loop.last %}, {% endif %}{% endfor %}</span>{% endif %}</h1>
+ {% include "articles/_article_list_section_overline.html" %}
{% endif %}
{% for article in page.object_list %}
@@ -0,0 +1,63 @@
+{% extends "articles/_base_articles.html" %}
+
+{% block article_class %}learning{% endblock %}
+
+{% block content %}
+{% if section %}
+ {% include "articles/_article_list_section_overline.html" %}
+{% endif %}
+
+<p class="intro">In-depth case studies by the best journalist-developers in the field. <span class="tinyhide">Get schooled on how journo-coders find and build web-native stories, what kinds of questions they ask of data, how choices in presenting the news affects how it’s interpreted, and the ethics they encounter along the way.</span></p>
+
+{% if lead_promo %}
+ {% with article=lead_promo %}
+ <a class="page-block lead promo" href="{{ article.get_absolute_url() }}">
+ {% if article.image %}<img src="{{ MEDIA_URL }}{{ thumbnail(article.image, "525x400", crop="center") }}" alt="{{ article.title }}">{% endif %}
+ <h2>
+ <span class="category">{% if article.article_type %}{{ article.get_article_type_display() }}{% endif %}{% if article.tags.all().exists() %} <span class="tags">/ {% for tag in article.tags.all() %}{{ tag }}{% if not loop.last %} {% endif %}{% endfor %}</span>{% endif %}</span>
+ {{ article.title }}
+ </h2>
+ <p>{{ article.safe_summary|safe }}</p>
+ </a>
+ {% endwith %}
+
+ <div class="secondary-promo-wrap">
+ {# two secondary promo items go in here #}
+ {% for article in secondary_promos %}
+ <a class="page-block promo secondary-promo{% if not loop.first %} second-promo{% endif %}" href="{{ article.get_absolute_url() }}">
+ {% if article.image %}<img src="{{ MEDIA_URL }}{{ thumbnail(article.image, "200x90", crop="center") }}" alt="{{ article.title }}">{% endif %}
+ <h2>
+ <span class="category">{% if article.article_type %}{{ article.get_article_type_display() }}{% endif %}{% if article.tags.all().exists() %} <span class="tags">/ {% for tag in article.tags.all() %}{{ tag }}{% if not loop.last %} {% endif %}{% endfor %}</span>{% endif %}</span>
+ {{ article.title }}
+ </h2>
+ <p>{{ article.safe_summary|safe }}</p>
+ </a>
+ {% endfor %}
+ </div>
+{% endif %}
+
+{% if lead_promo and page.object_list|length > 3 %}
+ <p class="intro"><b>More case studies:</b></p>
+{% endif %}
+
+{% for article in page.object_list %}
+ {# if we have promos on this page, don't include those articles in list #}
+ {% if article.pk not in articles_to_exclude_from_list %}
+ {% include "articles/_article_list_item.html" %}
+ {% endif %}
+{% endfor %}
+
+{% include "utils/_paginate.html" %}
+{% endblock content %}
+
+{% block site_js_extra %}
+<script type="text/javascript">
+var disqus_shortname = 'source-opennews';
+(function () {
+ var s = document.createElement('script'); s.async = true;
+ s.type = 'text/javascript';
+ s.src = '{{ HTTP_PROTOCOL }}://' + disqus_shortname + '.disqus.com/count.js';
+ (document.getElementsByTagName('HEAD')[0] || document.getElementsByTagName('BODY')[0]).appendChild(s);
+}());
+</script>
+{% endblock %}
View
@@ -2,7 +2,7 @@
from django.views.decorators.cache import cache_page
from django.views.generic.simple import redirect_to
-from .views import ArticleList, ArticleDetail
+from .views import ArticleList
from source.base.feeds import ArticleFeed
@@ -32,10 +32,4 @@
kwargs = {'url': '/articles/'},
name = 'article_list_tags',
),
- url(
- regex = '^(?P<slug>[-\w]+)/$',
- view = ArticleDetail.as_view(),
- kwargs = {},
- name = 'article_detail',
- ),
)
Oops, something went wrong.

0 comments on commit e1f5da3

Please sign in to comment.