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

Bugfix/fp 1652 template inheritance #142

Closed
wants to merge 12 commits into from
Closed
31 changes: 9 additions & 22 deletions _readme-cms/_templates/README.md
Original file line number Diff line number Diff line change
@@ -1,32 +1,19 @@
# TACC CMS Project - Example - Templates

Templates specific to this project __must__ be in this directory.
Otherwise, they will be unavailable to [Core CMS] loading this project.
You may overwrite Core CMS templates and 3rd-party apps/plugin templates.

The directory structure here __should__ mirror [Core CMS]:
[`/taccsite_cms/templates`][core-tpl-dir]
## Page Templates

This consistency lets us override templates in Django fashion.
To make new templates available as page templates for CMS editors, replace or add to `CMS_TEMPLATES` setting.

[Core CMS]: https://github.com/TACC/Core-CMS
[core-tpl-dir]: https://github.com/TACC/Core-CMS/blob/main/taccsite_cms/static/site_cms

## How to Write Template Path

Where `name-of-project` is a CMS projects with custom templates:

- `/name-of-project/templates/___.html`
## Overwrite Core

### How to Overwrite Core Templates

1. Create a template of the same name here.
2. Reference the template (where needed) with the correct path.

⚠️ A project __must not__ overwrite the Core CMS `base.html`.
1. Create a template of the same name as the [Core CMS template][core-tpl-dir] to overwrite.
2. Replace or extend the content of the overwritten template.

## Overwrite Apps or Plugins

You may overwrite apps [like Core][core-overwrite-doc].
But you msut do so relative to this directory.
Follow [Core CMS instructions][core-tpl-doc], but within _this_ directory instead.

[core-overwrite-doc]: https://github.com/TACC/Core-CMS/tree/main/taccsite_cms/templates/README.md#overwrite-apps-or-plugins
[core-tpl-dir]: https://github.com/TACC/Core-CMS/blob/main/taccsite_cms/static/site_cms
[core-tpl-doc]: https://github.com/TACC/Core-CMS/tree/main/taccsite_cms/templates
4 changes: 3 additions & 1 deletion _readme-cms/settings_custom.py.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
# TACC CMS Project - Example - `settings_custom.py`

Populate a `settings_custom.py` only with settings that overwrite the defaults.
Populate a `settings_custom.py` only with:
- settings that overwrite the defaults
- import attempt of `taccsite_cms.settings_local`

- default: [`settings.py`][default]
- example: [`settings_custom.example.py`][example]
Expand Down
22 changes: 20 additions & 2 deletions a2cps-cms/settings_custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,30 @@
# TACC WMA CMS SITE:
# *.A2CPS.TACC.UTEXAS.EDU

from taccsite_cms.settings import *

########################
# DJANGO CMS SETTINGS
########################

CMS_TEMPLATES = (
('a2cps-cms/templates/standard.html', 'Standard'),
('a2cps-cms/templates/fullwidth.html', 'Full Width'),
('standard.html', 'Standard'),
('fullwidth.html', 'Full Width'),

('guide.html', 'Guide'),
('guides/getting_started.html', 'Guide: Getting Started'),
('guides/data_transfer.html', 'Guide: Data Transfer'),
('guides/data_transfer.globus.html', 'Guide: Globus Data Transfer'),
('guides/portal_technology.html', 'Guide: Portal Technology Stack')
)

# Deprecated Templates
# TODO: FP-1645: Remove
CMS_TEMPLATES += [
('a2cps-cms/templates/standard.html', 'Standard'),
('a2cps-cms/templates/fullwidth.html', 'Full Width'),
]

########################
# TACC: LOGOS
########################
Expand All @@ -35,3 +44,12 @@
FAVICON = {
"img_file_src": "a2cps-cms/img/org_logos/favicon.ico"
}

########################
# IMPORT & EXPORT
########################

try:
from taccsite_cms.settings_local import *
except ModuleNotFoundError:
pass
8 changes: 8 additions & 0 deletions a2cps-cms/templates/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# TACC CMS Project - * - Templates

The root-level Core override templates are deprecated.

For standard Core override templates, see:

- `./taccsite_custom/*`
- `../settings_custom.py`
4 changes: 0 additions & 4 deletions a2cps-cms/templates/assets_custom.html

This file was deleted.

7 changes: 1 addition & 6 deletions a2cps-cms/templates/fullwidth.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
{% extends "fullwidth.html" %}
{% load cms_tags %}

{% block assets_custom %}
{{ block.super }}

{% include "./assets_custom.html" %}
{% endblock assets_custom %}
{# DEPRECATED TEMPLATE #}
7 changes: 1 addition & 6 deletions a2cps-cms/templates/standard.html
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
{% extends "standard.html" %}
{% load cms_tags %}

{% block assets_custom %}
{{ block.super }}

{% include "./assets_custom.html" %}
{% endblock assets_custom %}
{# DEPRECATED TEMPLATE #}
9 changes: 9 additions & 0 deletions a2cps-cms/templates/taccsite_cms/assets_custom.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{% extends "assets_custom.html" %}
{% load cms_tags static %}

{% block assets %}
{{ block.super }}

<!-- To style old CMS content on new CMS -->
<link rel="stylesheet" href="{% static 'a2cps-cms/css/build/migrate.v1_v2.css' %}">
{% endblock assets %}
10 changes: 10 additions & 0 deletions apcd-cms/settings_custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# TACC WMA CMS SITE:
# *.APCD.TACC.UTEXAS.EDU

from taccsite_cms.settings import *

########################
# DJANGO CMS SETTINGS
Expand Down Expand Up @@ -35,3 +36,12 @@
FAVICON = {
"img_file_src": "apcd-cms/img/org_logos/favicon.ico"
}

########################
# IMPORT & EXPORT
########################

try:
from taccsite_cms.settings_local import *
except ModuleNotFoundError:
pass
11 changes: 11 additions & 0 deletions brainmap-cms/settings_custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# TACC WMA CMS SITE:
# *.BRAINMAP.TACC.UTEXAS.EDU

from taccsite_cms.settings import *

########################
# DJANGO CMS SETTINGS
########################
Expand Down Expand Up @@ -87,3 +89,12 @@
FAVICON = {
"img_file_src": "brainmap-cms/img/org_logos/favicon.ico"
}

########################
# IMPORT & EXPORT
########################

try:
from taccsite_cms.settings_local import *
except ModuleNotFoundError:
pass
19 changes: 12 additions & 7 deletions ecep-cms/settings_custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
# TACC WMA CMS SITE:
# *.ECEP.TACC.UTEXAS.EDU

# FAQ: Some _VARIABLES are duplicated from settings.py (but prefixed with "_")
# because current infrastructure lacks ability to reference default values
from taccsite_cms.settings import *

########################
# DJANGO CMS SETTINGS
Expand Down Expand Up @@ -92,10 +91,7 @@
# NEWS / BLOG
########################

from taccsite_cms.settings import INSTALLED_APPS

tacc_app_index = INSTALLED_APPS.index('taccsite_cms')
INSTALLED_APPS[tacc_app_index:tacc_app_index] = [
INSTALLED_APPS += [
# 'filer', # already in Core
# 'easy_thumbnails', # already in Core
'parler',
Expand Down Expand Up @@ -137,4 +133,13 @@
# CLIENT BUILD SETTINGS
########################

ROOT_URLCONF = 'taccsite_custom.ecep-cms.urls'
ROOT_URLCONF = TACC_CUSTOM_ROOT + '.ecep-cms.urls'

########################
# IMPORT & EXPORT
########################

try:
from taccsite_cms.settings_local import *
except ModuleNotFoundError:
pass
11 changes: 11 additions & 0 deletions example-cms/settings_custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
# TACC WMA CMS SITE:
# *.PROJECT_DOMAIN.TACC.UTEXAS.EDU

from taccsite_cms.settings import *

########################
# DJANGO CMS SETTINGS
########################
Expand Down Expand Up @@ -61,3 +63,12 @@

# Should a user be able to see link to Portal? (default value: True)
# INCLUDES_CORE_PORTAL = False # True to show login link, False to hide login link

########################
# IMPORT & EXPORT
########################

try:
from taccsite_cms.settings_local import *
except ModuleNotFoundError:
pass
27 changes: 22 additions & 5 deletions frontera-cms/settings_custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@
# TACC WMA CMS SITE:
# *.FRONTERA-PORTAL.TACC.UTEXAS.EDU

# FAQ: Some _VARIABLES are duplicated from settings.py (but prefixed with "_")
# because current infrastructure lacks ability to reference default values
from taccsite_cms.settings import *

########################
# DJANGO CMS SETTINGS
########################

CMS_TEMPLATES = (
('frontera-cms/templates/standard.html', 'Standard'),
('frontera-cms/templates/fullwidth.html', 'Full Width'),
('frontera-cms/templates/home.html', 'Homepage'),
('standard.html', 'Standard'),
('fullwidth.html', 'Full Width'),

('home.html', 'Homepage'),

('guide.html', 'Guide'),
('guides/getting_started.html', 'Guide: Getting Started'),
Expand All @@ -21,6 +21,14 @@
('guides/portal_technology.html', 'Guide: Portal Technology Stack')
)

# Deprecated Templates
# TODO: FP-1645: Remove
CMS_TEMPLATES += (
('frontera-cms/templates/standard.html', 'DEPRECATED Standard'),
('frontera-cms/templates/fullwidth.html', 'DEPRECATED Full Width'),
('frontera-cms/templates/home.html', 'DEPRECATED Homepage'),
)

########################
# TACC: BRANDING
########################
Expand Down Expand Up @@ -78,3 +86,12 @@
FAVICON = {
"img_file_src": "frontera-cms/img/org_logos/favicon.ico"
}

########################
# IMPORT & EXPORT
########################

try:
from taccsite_cms.settings_local import *
except ModuleNotFoundError:
pass
8 changes: 8 additions & 0 deletions frontera-cms/templates/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# TACC CMS Project - * - Templates

The root-level Core override templates are deprecated.

For standard Core override templates, see:

- `./taccsite_custom/*`
- `../settings_custom.py`
2 changes: 2 additions & 0 deletions frontera-cms/templates/assets_custom.html
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
{% load static %}

{# DEPRECATED TEMPLATE #}

<link rel="stylesheet" href="{% static 'frontera-cms/css/build/site.css' %}">
2 changes: 2 additions & 0 deletions frontera-cms/templates/fullwidth.html
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
{% extends "fullwidth.html" %}
{% load cms_tags static %}

{# DEPRECATED TEMPLATE #}

{% block assets_custom %}
{{ block.super }}

Expand Down
4 changes: 1 addition & 3 deletions frontera-cms/templates/home.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,7 @@
{% load cms_tags static %}

{% block assets_custom %}
{{ block.super }}

{% include "./assets_custom.html" %}
{% include "./taccsite_cms/assets_custom.html" %}

<style>
/* To simplify calculation of `rem` values */
Expand Down
3 changes: 3 additions & 0 deletions frontera-cms/templates/standard.html
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
{% extends "standard.html" %}

{# DEPRECATED TEMPLATE #}

{% load cms_tags %}

{% block assets_custom %}
Expand Down
8 changes: 8 additions & 0 deletions frontera-cms/templates/taccsite_cms/assets_custom.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{% extends "assets_custom.html" %}
{% load cms_tags static %}

{% block assets %}
{{ block.super }}

<link rel="stylesheet" href="{% static 'frontera-cms/css/build/site.css' %}">
{% endblock assets %}
13 changes: 13 additions & 0 deletions frontera-cms/templates/taccsite_cms/fullwidth.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{% extends "fullwidth.html" %}
{% load cms_tags static %}

{% block assets_custom %}
{{ block.super }}

<!-- To style old CMS content on new CMS -->
<!-- NOTE: This should probably be loaded BEFORE "To customize styles …", but:
- Frontera was tested with this load order (so let it lie)
- Frontera is being redesigned (which will obviate this stylesheet)
-->
<link rel="stylesheet" href="{% static 'frontera-cms/css/build/migrate.v1_v2.css' %}">
{% endblock assets_custom %}
12 changes: 10 additions & 2 deletions lccf-tacc/settings_custom.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
# TACC WMA CMS SITE:
# *.LCCF.TACC.UTEXAS.EDU

# FAQ: Some _VARIABLES are duplicated from settings.py (but prefixed with "_")
# because current infrastructure lacks ability to reference default values
from taccsite_cms.settings import *

########################
# TACC: BRANDING
Expand Down Expand Up @@ -64,3 +63,12 @@
########################

INCLUDES_CORE_PORTAL = False

########################
# IMPORT & EXPORT
########################

try:
from taccsite_cms.settings_local import *
except ModuleNotFoundError:
pass
Loading