Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: tup 706 conditionally serve raw markup #872

Open
wants to merge 46 commits into
base: main
Choose a base branch
from
Open
Changes from 1 commit
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
17640a4
refactor: CMD-97 breadcrumbs for news via 1 template
wesleyboar Jul 16, 2024
55dc431
idea: TUP-706 4.a.i change RSS feed render ⚠️
wesleyboar Jul 19, 2024
de81256
refactor: TUP-706 rename and document blog block
wesleyboar Jul 22, 2024
463871f
feat: TUP-706 render page with only (*_)content
wesleyboar Jul 22, 2024
8038de7
fix: TUP-706 disable failed djangocms_blog_c… url
wesleyboar Jul 22, 2024
89a160c
idea!: TUP-706 render blog base via custom app
wesleyboar Jul 22, 2024
db234df
feat!: TUP-706 render remote url content
wesleyboar Jul 22, 2024
d7f10ae
chore: TUP-706 move an import higher in file
wesleyboar Jul 22, 2024
ec10c85
feat: TUP-706 render remote url via setting
wesleyboar Jul 22, 2024
223b72a
fix: TUP-706 render blog customizations
wesleyboar Jul 22, 2024
aaa971e
Merge branch 'main' into feat/tup-706-news-on-other-sites
wesleyboar Jul 22, 2024
646b26d
fix: TUP-706 render feed ⚠️
wesleyboar Jul 22, 2024
aa709fd
docs: TUP-706 describe each URL's problem
wesleyboar Jul 22, 2024
26a9412
docs: TUP-706 describe each URL goal and status
wesleyboar Jul 22, 2024
4e78038
feat: TUP-706 A.1+3.c remote markup via template
wesleyboar Jul 22, 2024
17380fb
Merge branch 'main' into feat/tup-706-news-on-other-sites
wesleyboar Jul 23, 2024
a461693
feat: TUP-706 A.1.a. support BLOG_MULTISITE
wesleyboar Jul 23, 2024
6bece39
fix: TUP-706 A.1.a. cannot login to site 2
wesleyboar Jul 23, 2024
e6bdbbf
Revert "fix: TUP-706 A.1.a. cannot login to site 2"
wesleyboar Jul 23, 2024
4f9888b
Merge branch 'main' into feat/tup-706-news-on-other-sites
wesleyboar Sep 10, 2024
104fe71
docs: TUP-706 feed status (ineffectual)
wesleyboar Sep 10, 2024
dfc9fa4
docs: tup-706 urls for local and remote
wesleyboar Sep 10, 2024
cd59bf9
feat(poc): TUP-706 get news from remote url
wesleyboar Sep 11, 2024
6995c44
chore: remove test print statements from feeds
wesleyboar Sep 11, 2024
db79397
core: clean up views
wesleyboar Sep 11, 2024
a6d8551
core: clean up views more
wesleyboar Sep 11, 2024
82027fe
refactor: switch order of methods in view class
wesleyboar Sep 11, 2024
0c94401
feat: TUP-706 edit links via get_client_markup()
wesleyboar Sep 11, 2024
49edd04
fix: TUP-706 broken links
wesleyboar Sep 12, 2024
70e5111
feat: isolate breadcrumbs from content and news
wesleyboar Sep 12, 2024
4f7b761
chore: remove unnecessary app
wesleyboar Sep 12, 2024
c346a88
chore: remove unnecessary middleware
wesleyboar Sep 12, 2024
e5dae76
fix: do not load missing app and middleware
wesleyboar Sep 12, 2024
ca7a1c6
fix: remove unnecessary setting
wesleyboar Sep 12, 2024
d1680ee
fix: use correct name for app_content
wesleyboar Sep 12, 2024
c756e03
style: new line
wesleyboar Sep 12, 2024
59f7053
Merge branch 'main' into feat/tup-706-serve-raw-blog-content
wesleyboar Sep 13, 2024
53beba4
fix: raw template logic outdated
wesleyboar Sep 13, 2024
c7a4c96
fix: bad merge resolution
wesleyboar Sep 13, 2024
299d51b
fix: bad merge resolution
wesleyboar Sep 13, 2024
ba50574
docs: how to serve raw content
wesleyboar Sep 13, 2024
12c02ea
feat: tup-706 conditionally serve raw content
wesleyboar Sep 13, 2024
a4536cd
Merge branch 'main' into feat/tup-706-serve-raw-blog-content-conditio…
wesleyboar Sep 13, 2024
9e68a76
reactor: rename middlewar
wesleyboar Sep 13, 2024
d108352
Merge branch 'main' into feat/tup-706-serve-raw-blog-content-conditio…
wesleyboar Sep 13, 2024
af833ec
Merge branch 'main' into feat/tup-706-serve-raw-blog-content-conditio…
wesleyboar Dec 4, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: TUP-706 edit links via get_client_markup()
wesleyboar committed Sep 11, 2024

Unverified

This user has not yet uploaded their public signing key.
commit 0c9440160ef381a8dcfc82ebfd81bf14180f3693
34 changes: 20 additions & 14 deletions apps/djangocms_blog_customizations/views.py
Original file line number Diff line number Diff line change
@@ -13,29 +13,35 @@ class BlogRemoteView(TemplateView):

def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
remote_url = self.get_remote_url()
remote_content = self.get_remote_content(remote_url)
source_url = self.get_source_url()
source_markup = self.get_source_markup(source_url)
client_markup = self.get_client_markup(source_markup)

context['markup'] = remote_content
context['markup'] = client_markup

return context

def get_remote_url(self):
path = self.request.path.replace(
settings.PORTAL_BLOG_REMOTE_CLIENT_PATH,
''
)
url = (
settings.PORTAL_BLOG_REMOTE_SOURCE_ROOT
+ path
)
def get_source_url(self):
client_path = settings.PORTAL_BLOG_REMOTE_CLIENT_PATH
source_host = settings.PORTAL_BLOG_REMOTE_SOURCE_ROOT
source_path = self.request.path.replace(client_path, '')

return url
return source_host + source_path

def get_remote_content(self, url):
def get_source_markup(self, url):
response = requests.get(url)

if response.status_code == 200:
return response.text
else:
return None

# CAVEAT: Causes request to PORTAL_BLOG_REMOTE_CLIENT_PATH for every 'href'
def get_client_markup(self, source_markup):
client_path_prefix = settings.PORTAL_BLOG_REMOTE_CLIENT_PATH

# FAQ: No markup for bad URL or a resource specific to source wesbite
if source_markup:
return source_markup.replace('href="', 'href="' + client_path_prefix)
else:
return None