Skip to content

Commit 5562561

Browse files
authored
feat: tup-706 news on other sites (#868)
* refactor: CMD-97 breadcrumbs for news via 1 template * idea: TUP-706 4.a.i change RSS feed render ⚠️ NOT WORKING! Fails with: > NoReverseMatch at /feed/ > '' is not a registered namespace * refactor: TUP-706 rename and document blog block * feat: TUP-706 render page with only (*_)content * fix: TUP-706 disable failed djangocms_blog_c… url * idea!: TUP-706 render blog base via custom app Fails, because it renders nothing. * feat!: TUP-706 render remote url content Load `/blog/remote`. BREAKING CHANGE: Changed `/blog` to `/blog/local` * chore: TUP-706 move an import higher in file * feat: TUP-706 render remote url via setting * fix: TUP-706 render blog customizations * fix: TUP-706 render feed ⚠️ ⚠️ Does NOT render feed items. * docs: TUP-706 describe each URL's problem * docs: TUP-706 describe each URL goal and status * feat: TUP-706 A.1+3.c remote markup via template * feat: TUP-706 A.1.a. support BLOG_MULTISITE * fix: TUP-706 A.1.a. cannot login to site 2 * Revert "fix: TUP-706 A.1.a. cannot login to site 2" This reverts commit 6bece39. This did not fix anything. `SESSION_COOKIE_SECURE=False` is still required locally. * docs: TUP-706 feed status (ineffectual) * docs: tup-706 urls for local and remote * feat(poc): TUP-706 get news from remote url Messy but functional! * chore: remove test print statements from feeds * core: clean up views * core: clean up views more * refactor: switch order of methods in view class * feat: TUP-706 edit links via get_client_markup() * fix: TUP-706 broken links - ✓ fix links to articles - ✓ fix pagination links * chore: remove SITE_ID middleware I do not think it is a useful solution for TUP-706. The code/feature is archived in #873: #873 * chore: delete cruft from messy merge * refactor: djangocms_blog_custom… → remote_content This changes remote blog load to be remote anything load. This removes the failed custom feed (archived in #874): #874 * fix: load raw markup from remote site * fix: load raw markup from remote site * style: move parameter * feat!: change mage source not article link BREAKING CHANGE: images will not load, cuz of CORS. Solve via headers. * fix: links to articles should open on source * docs: how to test PR #868 * docs: fix how to test PR #868 * feat: (TEMPORARY) dynamic site id * docs: polish how to test PR #868 * fix: use settings for paths * feat: configurable template * refactor!: define template in URL not settings * refactor!: fix rel href paths, lose template param Gotta add back in support for tempalte param, and other CMS params. Working on it after this. * fix: tempalte param (and other cms params) KNOWN ISSUE: Frightening regex HTML manipulation. * docs: known issues * refactor: use beautiful soup not regex * docs: no major known issues * refactor: rename a function * chore; remove dumb comments * fix: support cms params in all href values * fix: do not try to load link rel=stylesheets * refactor: simplify href/src replacements * docs: comments * docs: how to convert (temp file) * feat!: use repo Core-CMS-Plugin-Remote-Content https://github.com/wesleyboar/Core-CMS-Plugin-Remote-Content BREAKING CHANGE: Repo has bug (see its issue #1) * refactor: replace internal app with external app * refactor: remove middleware * feat: update plugin * chore: delete outdated code Plugin handles this stuff now, and differently. * chore: update plugin (get improvements) * chore: update plugin (get better admin ui) * chore: update plugin (get better, refactored code) * test: djangocms_tacc_remote_content * chore: djangocms_tacc_remote_content via release * fix: remove extraneous dependency * fix: absolute urls for links by default * fix: keep relative urls via new settings * feat: do not passthrough cms query params * chore: v0.2.0 * refactor!: rename raw.html to bare.html Only pages testing this TUP-706 feature used `raw.html`. BREAKING CHANGE: Any pages using `raw.html` must switch to `bare.html` * chore: rename raw.html to bare.html in plugin * chore: rename bare.html to plain.html in plugin * chore: v0.3.0 * chore: TACC/Core-CMS-Plugin-Remote-Content * fix: rename bare.html file to plain.html * chore: v0.3.1 * chore: v0.3.2 * chore: v0.3.3 * feat: let admin change how to open external news
1 parent 99286c2 commit 5562561

File tree

6 files changed

+124
-4
lines changed

6 files changed

+124
-4
lines changed

poetry.lock

Lines changed: 59 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ djangocms-picture = "3.0.0"
5959
djangocms-snippet = "3.0.0"
6060
djangocms-style = "3.0.0"
6161
djangocms-tacc-image-gallery = {git = "https://github.com/TACC/Core-CMS-Plugin-Image-Gallery.git", rev = "v0.1.4"}
62+
djangocms-tacc-remote-content = {git = "https://github.com/TACC/Core-CMS-Plugin-Remote-Content.git", rev = "v0.3.3"}
6263
djangocms-tacc-system-monitor = {git = "https://github.com/TACC/Core-CMS-Plugin-System-Monitor.git", rev = "v0.3.0"}
6364
djangocms-text-ckeditor = "^5.1"
6465
djangocms-transfer = "1.0.1"

taccsite_cms/settings_custom.example.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@
3333
('standard.html', 'Standard'),
3434
('fullwidth.html', 'Full Width'),
3535

36-
# WARNING: Not intuitive to unset, so only enable as needed e.g. serve Blog such that it can be injected into another CMS
37-
# ('raw.html', 'Raw'),
36+
# WARNING: Unintuitive, so only enable as needed e.g. TACC/Core-CMS#868
37+
# ('plain.html', 'Plain'),
3838
)
3939

4040
########################
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/**
2+
* Get URL of external web article of which internal news article represents
3+
* @param {HTMLElement} article - The article within which to find external URL
4+
* @return {string|null} - The URL of the external article
5+
*/
6+
export function getArticleExternalURL(article) {
7+
if (!article) {
8+
console.warn('No article found', article);
9+
return;
10+
}
11+
12+
// The admin of news promises leads/abstracts will only have 1 external link
13+
const contentLink = article.querySelector('.blog-lead a[href^="http"]');
14+
const isExternalLink = contentLink.hostname !== window.location.hostname;
15+
const URL = isExternalLink ? contentLink.href : null;
16+
17+
return URL;
18+
}
19+
20+
/**
21+
* Modify article links to point to external URLs based on tag name
22+
* @param {string} [extTagName='external'] - A tag that has been set on articles to select
23+
*/
24+
export function changeHowExternalArticleOpens(extTagName = 'external') {
25+
const articles = document.querySelectorAll(
26+
`.blog-list article.has-blog-tag-${extTagName}`
27+
);
28+
29+
console.debug(`Found ${articles.length} article(s) with tag "${extTagName}"`, articles );
30+
31+
[ ...articles ].forEach( article => {
32+
const externalLinkUrl = getArticleExternalURL( article );
33+
34+
if ( externalLinkUrl ) {
35+
const links = article.querySelectorAll(':is(h3, footer) a');
36+
37+
// all links to the post should open external URL in new window
38+
[ ...links ].forEach( link => {
39+
console.debug(`Changed article link to "${externalLinkUrl}"`, link );
40+
41+
link.href = externalLinkUrl;
42+
link.setAttribute('target', '_blank');
43+
});
44+
}
45+
});
46+
}
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
{# To open external news article, instead of internal news article #}
2+
{% load static %}
3+
4+
<script id="blog-list-link-to-external-site" type="module">
5+
import { changeHowExternalArticleOpens } from '{% static "site_cms/js/modules/manageExternalArticles.js" %}';
6+
7+
// The `{{html}}` is whatever user entered into snippet "HTML:" field
8+
const parameter = '{{html}}';
9+
10+
// Only certain articles should support this feature, cuz
11+
// articles might include external links on internal article
12+
const extTagName = parameter ? parameter : `external`;
13+
14+
// Only care about articles with the given tag
15+
changeHowExternalArticleOpens(extTagName);
16+
</script>

0 commit comments

Comments
 (0)