Skip to content

Commit a009a85

Browse files
authored
feat: auto-manage external articles (#1033)
* feat: auto-manage external articles * fix: missing tag import * fix: move new scripts into `content_block` * chore: move attr in html * feat: def setting vals, "external" & "multimedia" * fix: do not assume `external`
1 parent 3ac4f28 commit a009a85

3 files changed

Lines changed: 31 additions & 4 deletions

File tree

taccsite_cms/settings.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -317,8 +317,8 @@ def gettext(s): return s
317317
PORTAL_BLOG_SHOW_CATEGORIES = True
318318
PORTAL_BLOG_SHOW_TAGS = True
319319
# To flag posts of certain category or tag, so template can take special action
320-
PORTAL_BLOG_CUSTOM_MEDIA_POST_CATEGORY = 'sample_value_e_g__mutlimedia__'
321-
PORTAL_BLOG_SHOW_ABSTRACT_TAG = 'sample_value_e_g__redirect__'
320+
PORTAL_BLOG_CUSTOM_MEDIA_POST_CATEGORY = 'mutlimedia'
321+
PORTAL_BLOG_SHOW_ABSTRACT_TAG = 'external'
322322

323323
PORTAL_BLOG_CATEGORY_ORDER = []
324324
# PORTAL_BLOG_CATEGORY_ORDER = ['press-release', 'feature-story', 'multimedia', 'podcast']

taccsite_cms/templates/djangocms_blog/post_detail.html

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
{# https://github.com/nephila/djangocms-blog/blob/1.2.3/djangocms_blog/templates/djangocms_blog/post_detail.html #}
22
{% extends "djangocms_blog/post_detail.html" %}
3-
{% load i18n easy_thumbnails_tags cms_tags blog_post_use_custom_media blog_post_is_show_abstract %}
3+
{# TACC (define whether this is a special post): #}
4+
{# TACC (redirect external articles): #}
5+
{% load i18n easy_thumbnails_tags cms_tags static sekizai_tags blog_post_use_custom_media blog_post_is_show_abstract %}
6+
{# /TACC #}
7+
{# /TACC #}
48

59
{% block content_blog %}{% spaceless %}
610

@@ -82,6 +86,17 @@ <h3>{% render_model post "subtitle" %}</h3>
8286
</section>
8387
{% endif %}
8488
</article>
89+
90+
{# TACC (redirect external articles): #}
91+
{% addtoblock "js" %}
92+
<script id="redirect-external-article" type="module">
93+
import { redirectExternalArticle } from '{% static "site_cms/js/modules/manageExternalArticles.js" %}';
94+
95+
redirectExternalArticle('{{ settings.PORTAL_BLOG_SHOW_ABSTRACT_TAG }}');
96+
</script>
97+
{% endaddtoblock %}
98+
{# /TACC #}
99+
85100
{# TACC (end wrap and end spaceless-ness later than source): #}
86101
{% endspaceless %}
87102
{# /TACC #}

taccsite_cms/templates/djangocms_blog/post_list.html

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
{# https://github.com/nephila/djangocms-blog/blob/1.2.3/djangocms_blog/templates/djangocms_blog/post_list.html #}
22
{% extends "djangocms_blog/base.html" %}
3-
{% load i18n easy_thumbnails_tags cms_tags %}{% spaceless %}
3+
{# TACC (change how to open external articles): #}
4+
{% load i18n easy_thumbnails_tags cms_tags static sekizai_tags %}{% spaceless %}
5+
{# /TACC #}
46

57
{% block canonical_url %}<link rel="canonical" href="{{ view.get_view_url }}"/>{% endblock canonical_url %}
68

@@ -78,5 +80,15 @@ <h2>
7880
{% endif %}
7981
</section>
8082

83+
{# TACC (change how to open external articles): #}
84+
{% addtoblock "js" %}
85+
<script type="module" id="change-how-to-open-external-articles">
86+
import { changeHowExternalArticleOpens } from '{% static "site_cms/js/modules/manageExternalArticles.js" %}';
87+
88+
changeHowExternalArticleOpens('{{ settings.PORTAL_BLOG_SHOW_ABSTRACT_TAG }}');
89+
</script>
90+
{% endaddtoblock %}
91+
{# /TACC #}
92+
8193
{% endblock %}
8294
{% endspaceless %}

0 commit comments

Comments
 (0)