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
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 1 addition & 1 deletion taccsite_cms/custom_app_settings.example.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@
'djangocms_blog',

]
CUSTOM_MIDDLEWARE = []
CUSTOM_MIDDLEWARE = ['taccsite_cms.middleware.cms_template.CMSTemplateMiddleware']
STATICFILES_DIRS = ()
49 changes: 49 additions & 0 deletions taccsite_cms/middleware/cms_template.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
"""Change CMS page template at runtime"""
import os

from cms.middleware.toolbar import ToolbarMiddleware
from cms.models.pagemodel import Page as CMS_Page

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
TEMPLATE_DIR = os.path.join(BASE_DIR, 'templates')

class CMSTemplateMiddleware(ToolbarMiddleware):
"""
Use a different CMS template than is set for the current page

Usage:
http://0.0.0.0:8000/news/?raw
http://0.0.0.0:8000/news/?template=raw.html
Applies `raw.html` template

http://0.0.0.0:8000/news/?template=fullwidth.html
Applies `fulwidth.html` template

http://0.0.0.0:8000/news/?template=misspelling.html
Raises `TemplateDoesNotExist` error

http://0.0.0.0:8000/news/?rawng
http://0.0.0.0:8000/news/?template
http://0.0.0.0:8000/news/?template=s
No effect
"""
def __init__(self, get_response):
self.get_response = get_response

def __call__(self, request):
if (
hasattr(request, 'current_page') and
isinstance(request.current_page, CMS_Page)
):
page = request.current_page
query_params = request.GET
query_template = query_params.get('template', '')

if 'raw' in query_params:
page.template = os.path.join(TEMPLATE_DIR, 'raw.html')
if query_template.endswith('.html'):
page.template = os.path.join(TEMPLATE_DIR, query_template)

response = self.get_response(request)

return response