-
Notifications
You must be signed in to change notification settings - Fork 1
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
feat: tup 706 conditionally serve raw markup #872
Conversation
NOT WORKING! Fails with: > NoReverseMatch at /feed/ > '' is not a registered namespace
Fails, because it renders nothing.
Load `/blog/remote`. BREAKING CHANGE: Changed `/blog` to `/blog/local`
⚠️ Does NOT render feed items.
This reverts commit 6bece39. This did not fix anything. `SESSION_COOKIE_SECURE=False` is still required locally.
Messy but functional!
- ✓ fix links to articles - ✓ fix pagination links
This setting is from another branch.
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) | ||
TEMPLATE_DIR = os.path.join(BASE_DIR, 'templates') | ||
|
||
class CMSTemplateMiddleware(ToolbarMiddleware): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just checking: is this the most descriptive name for the middleware class name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't know. What I know:
- It allows one to explicitly swap to one of the
CMS_TEMPLATES
. - It supports shorthand for implicit swap i.e.
?raw
. - It seems typical to
prependappend the name of a Django class with the kind of class it is.
What about these names:
CMSTemplateSwapMiddleware
CMSTemplateChangeMiddleware
CMSTemplateOverrideMiddleware
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any of those proposed is great, thanks @wesleyboar
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Renamed… but PR closed, because the ?template=….html
feature already works by default. 😅
Important
Testing
Video of Test on Official Demoofficial.demo.test.template.query.param.movNo wonder I had such difficulty debugging when this middleware worked and didn't work… half of it was supported by default! |
Overview
Goal: Render TACC News outside of TACC (when we should not just link the user).
Important
?template=whatever.html
works without this middleware.Important
Supports requirement for LCCF website to show LCCF news from TACC.
Feature: Allow client to load raw page content markup (no header, no footer).
Use Case? Load news pages of one website (e.g. TACC) on other websites (e.g. LCCF, WeTeach CS). By having raw markup available at a URL, another website can load and inject that markup on its own page, thus borrowing news articles and lists rather than duplicating them.
Proof of Concept? In #868, I create and run an app that injects remote content. (I am still thinking how/when best to run the app.)
Bonus: Allow dev to render a page with any Core template (or one of their own).
Use Case? Test new templates for future custom CMS features without editing Core.
How to Use One of Their Own? Add (or override) a template into
taccsite_cms/templates
via Dockerfile, as is done in some Core-CMS-Custom projects (apcd_cms, ecep_cms) and TUP (tup-cms).Related
Changes
Testing
In
custom_app_settings.py
, add new middleware toCUSTOM_MIDDLEWARE
e.g.Load pages with recognized query parameters.
?raw
template=raw.html
Verify page loads with
raw.html
template.Load pages with ineffectual query parameters.
?rawng
template=raw
template=raw
Verify page loads with template that the page would normally use.