diff --git a/poetry.lock b/poetry.lock index 234f6bb1a..7d90e5bcf 100644 --- a/poetry.lock +++ b/poetry.lock @@ -296,6 +296,19 @@ category = "main" optional = false python-versions = "*" +[[package]] +name = "django-pattern-library" +version = "0.5.0" +description = "A module for Django that allows to build pattern libraries for your projects." +category = "main" +optional = false +python-versions = ">=3.6,<4.0" + +[package.dependencies] +Django = ">=2.2,<4.0" +Markdown = ">=3.1,<4.0" +PyYAML = ">=5.1,<6.0" + [[package]] name = "django-polymorphic" version = "3.0.0" @@ -826,7 +839,7 @@ python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*" parso = ">=0.7.0,<0.8.0" [package.extras] -qa = ["flake8 (==3.7.9)"] +qa = ["flake8 (3.7.9)"] testing = ["Django (<3.1)", "colorama", "docopt", "pytest (>=3.9.0,<5.0.0)"] [[package]] @@ -862,6 +875,17 @@ html5 = ["html5lib"] htmlsoup = ["beautifulsoup4"] source = ["Cython (>=0.29.7)"] +[[package]] +name = "markdown" +version = "3.3.5" +description = "Python implementation of Markdown." +category = "main" +optional = false +python-versions = ">=3.6" + +[package.extras] +testing = ["coverage", "pyyaml"] + [[package]] name = "mccabe" version = "0.6.1" @@ -1090,6 +1114,14 @@ category = "main" optional = false python-versions = "*" +[[package]] +name = "pyyaml" +version = "5.4.1" +description = "YAML parser and emitter for Python" +category = "main" +optional = false +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, !=3.5.*" + [[package]] name = "requests" version = "2.27.1" @@ -1105,7 +1137,7 @@ idna = {version = ">=2.5,<4", markers = "python_version >= \"3\""} urllib3 = ">=1.21.1,<1.27" [package.extras] -socks = ["PySocks (>=1.5.6,!=1.5.7)", "win-inet-pton"] +socks = ["PySocks (>=1.5.6,<1.5.7 || >1.5.7)", "win-inet-pton"] use_chardet_on_py3 = ["chardet (>=3.0.2,<5)"] [[package]] @@ -1212,7 +1244,7 @@ python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*, !=3.4.*, <4" [package.extras] brotli = ["brotlipy (>=0.6.0)"] secure = ["pyOpenSSL (>=0.14)", "cryptography (>=1.3.4)", "idna (>=2.0.0)", "certifi", "ipaddress"] -socks = ["PySocks (>=1.5.6,!=1.5.7,<2.0)"] +socks = ["PySocks (>=1.5.6,<1.5.7 || >1.5.7,<2.0)"] [[package]] name = "urlobject" @@ -1277,7 +1309,7 @@ testing = ["jaraco.itertools", "func-timeout"] [metadata] lock-version = "1.1" python-versions = "^3.7" -content-hash = "ede4ded5906287ebc533a39066285a4aa70377909a594c51f34fe0c8f72da0a6" +content-hash = "9295eadd5960cce1b03ba437a9bb2415858fab0ba465b568c797ebfc32319ad3" [metadata.files] aldryn-apphooks-config = [ @@ -1374,6 +1406,10 @@ django-mptt = [ django-parler = [ {file = "django-parler-2.2.tar.gz", hash = "sha256:51c33e7c0d3ca139d1f40ca4253894121a25d9df18076b8fafa573ab0d440010"}, ] +django-pattern-library = [ + {file = "django-pattern-library-0.5.0.tar.gz", hash = "sha256:25210194de8fe4c0c2a969e7ffbcea81efad19a7ac843bd67d28d39e26568545"}, + {file = "django_pattern_library-0.5.0-py3-none-any.whl", hash = "sha256:bd387f104652c26ce05e7d3cd884d134819c7757c0caa1107a3be3a05eda552d"}, +] django-polymorphic = [ {file = "django-polymorphic-3.0.0.tar.gz", hash = "sha256:9d886f19f031d26bb1391c055ed9be06fb226a04a4cec1842b372c58873b3caa"}, {file = "django_polymorphic-3.0.0-py2.py3-none-any.whl", hash = "sha256:73b75eb44ea302bd32820f8661e469509d245ce7f7ff09cd2ad149e5c42034ff"}, @@ -1623,6 +1659,10 @@ lxml = [ {file = "lxml-4.6.5-pp38-pypy38_pp73-manylinux_2_17_x86_64.manylinux2014_x86_64.manylinux_2_24_x86_64.whl", hash = "sha256:5d5254c815c186744c8f922e2ce861a2bdeabc06520b4b30b2f7d9767791ce6e"}, {file = "lxml-4.6.5.tar.gz", hash = "sha256:6e84edecc3a82f90d44ddee2ee2a2630d4994b8471816e226d2b771cda7ac4ca"}, ] +markdown = [ + {file = "Markdown-3.3.5-py3-none-any.whl", hash = "sha256:0d2d09f75cb8d1ffc6770c65c61770b23a61708101f47bda416a002a0edbc480"}, + {file = "Markdown-3.3.5.tar.gz", hash = "sha256:26e9546bfbcde5fcd072bd8f612c9c1b6e2677cb8aadbdf65206674f46dde069"}, +] mccabe = [ {file = "mccabe-0.6.1-py2.py3-none-any.whl", hash = "sha256:ab8a6258860da4b6677da4bd2fe5dc2c659cff31b3ee4f7f5d64e79735b80d42"}, {file = "mccabe-0.6.1.tar.gz", hash = "sha256:dd8d182285a0fe56bace7f45b5e7d1a6ebcbf524e8f3bd87eb0f125271b8831f"}, @@ -1803,6 +1843,37 @@ pytz = [ {file = "pytz-2020.1-py2.py3-none-any.whl", hash = "sha256:a494d53b6d39c3c6e44c3bec237336e14305e4f29bbf800b599253057fbb79ed"}, {file = "pytz-2020.1.tar.gz", hash = "sha256:c35965d010ce31b23eeb663ed3cc8c906275d6be1a34393a1d73a41febf4a048"}, ] +pyyaml = [ + {file = "PyYAML-5.4.1-cp27-cp27m-macosx_10_9_x86_64.whl", hash = "sha256:3b2b1824fe7112845700f815ff6a489360226a5609b96ec2190a45e62a9fc922"}, + {file = "PyYAML-5.4.1-cp27-cp27m-win32.whl", hash = "sha256:129def1b7c1bf22faffd67b8f3724645203b79d8f4cc81f674654d9902cb4393"}, + {file = "PyYAML-5.4.1-cp27-cp27m-win_amd64.whl", hash = "sha256:4465124ef1b18d9ace298060f4eccc64b0850899ac4ac53294547536533800c8"}, + {file = "PyYAML-5.4.1-cp27-cp27mu-manylinux1_x86_64.whl", hash = "sha256:bb4191dfc9306777bc594117aee052446b3fa88737cd13b7188d0e7aa8162185"}, + {file = "PyYAML-5.4.1-cp36-cp36m-macosx_10_9_x86_64.whl", hash = "sha256:6c78645d400265a062508ae399b60b8c167bf003db364ecb26dcab2bda048253"}, + {file = "PyYAML-5.4.1-cp36-cp36m-manylinux1_x86_64.whl", hash = "sha256:4e0583d24c881e14342eaf4ec5fbc97f934b999a6828693a99157fde912540cc"}, + {file = "PyYAML-5.4.1-cp36-cp36m-manylinux2014_aarch64.whl", hash = "sha256:72a01f726a9c7851ca9bfad6fd09ca4e090a023c00945ea05ba1638c09dc3347"}, + {file = "PyYAML-5.4.1-cp36-cp36m-manylinux2014_s390x.whl", hash = "sha256:895f61ef02e8fed38159bb70f7e100e00f471eae2bc838cd0f4ebb21e28f8541"}, + {file = "PyYAML-5.4.1-cp36-cp36m-win32.whl", hash = "sha256:3bd0e463264cf257d1ffd2e40223b197271046d09dadf73a0fe82b9c1fc385a5"}, + {file = "PyYAML-5.4.1-cp36-cp36m-win_amd64.whl", hash = "sha256:e4fac90784481d221a8e4b1162afa7c47ed953be40d31ab4629ae917510051df"}, + {file = "PyYAML-5.4.1-cp37-cp37m-macosx_10_9_x86_64.whl", hash = "sha256:5accb17103e43963b80e6f837831f38d314a0495500067cb25afab2e8d7a4018"}, + {file = "PyYAML-5.4.1-cp37-cp37m-manylinux1_x86_64.whl", hash = "sha256:e1d4970ea66be07ae37a3c2e48b5ec63f7ba6804bdddfdbd3cfd954d25a82e63"}, + {file = "PyYAML-5.4.1-cp37-cp37m-manylinux2014_aarch64.whl", hash = "sha256:cb333c16912324fd5f769fff6bc5de372e9e7a202247b48870bc251ed40239aa"}, + {file = "PyYAML-5.4.1-cp37-cp37m-manylinux2014_s390x.whl", hash = "sha256:fe69978f3f768926cfa37b867e3843918e012cf83f680806599ddce33c2c68b0"}, + {file = "PyYAML-5.4.1-cp37-cp37m-win32.whl", hash = "sha256:dd5de0646207f053eb0d6c74ae45ba98c3395a571a2891858e87df7c9b9bd51b"}, + {file = "PyYAML-5.4.1-cp37-cp37m-win_amd64.whl", hash = "sha256:08682f6b72c722394747bddaf0aa62277e02557c0fd1c42cb853016a38f8dedf"}, + {file = "PyYAML-5.4.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:d2d9808ea7b4af864f35ea216be506ecec180628aced0704e34aca0b040ffe46"}, + {file = "PyYAML-5.4.1-cp38-cp38-manylinux1_x86_64.whl", hash = "sha256:8c1be557ee92a20f184922c7b6424e8ab6691788e6d86137c5d93c1a6ec1b8fb"}, + {file = "PyYAML-5.4.1-cp38-cp38-manylinux2014_aarch64.whl", hash = "sha256:fd7f6999a8070df521b6384004ef42833b9bd62cfee11a09bda1079b4b704247"}, + {file = "PyYAML-5.4.1-cp38-cp38-manylinux2014_s390x.whl", hash = "sha256:bfb51918d4ff3d77c1c856a9699f8492c612cde32fd3bcd344af9be34999bfdc"}, + {file = "PyYAML-5.4.1-cp38-cp38-win32.whl", hash = "sha256:fa5ae20527d8e831e8230cbffd9f8fe952815b2b7dae6ffec25318803a7528fc"}, + {file = "PyYAML-5.4.1-cp38-cp38-win_amd64.whl", hash = "sha256:0f5f5786c0e09baddcd8b4b45f20a7b5d61a7e7e99846e3c799b05c7c53fa696"}, + {file = "PyYAML-5.4.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:294db365efa064d00b8d1ef65d8ea2c3426ac366c0c4368d930bf1c5fb497f77"}, + {file = "PyYAML-5.4.1-cp39-cp39-manylinux1_x86_64.whl", hash = "sha256:74c1485f7707cf707a7aef42ef6322b8f97921bd89be2ab6317fd782c2d53183"}, + {file = "PyYAML-5.4.1-cp39-cp39-manylinux2014_aarch64.whl", hash = "sha256:d483ad4e639292c90170eb6f7783ad19490e7a8defb3e46f97dfe4bacae89122"}, + {file = "PyYAML-5.4.1-cp39-cp39-manylinux2014_s390x.whl", hash = "sha256:fdc842473cd33f45ff6bce46aea678a54e3d21f1b61a7750ce3c498eedfe25d6"}, + {file = "PyYAML-5.4.1-cp39-cp39-win32.whl", hash = "sha256:49d4cdd9065b9b6e206d0595fee27a96b5dd22618e7520c33204a4a3239d5b10"}, + {file = "PyYAML-5.4.1-cp39-cp39-win_amd64.whl", hash = "sha256:c20cfa2d49991c8b4147af39859b167664f2ad4561704ee74c1de03318e898db"}, + {file = "PyYAML-5.4.1.tar.gz", hash = "sha256:607774cbba28732bfa802b54baa7484215f530991055bb562efbed5b2f20a45e"}, +] requests = [ {file = "requests-2.27.1-py2.py3-none-any.whl", hash = "sha256:f22fa1e554c9ddfd16e6e41ac79759e17be9e492b3587efa038054674760e72d"}, {file = "requests-2.27.1.tar.gz", hash = "sha256:68d7c56fd5a8999887728ef304a6d12edc7be74f1cfa47714fc8b414525c9a61"}, diff --git a/pyproject.toml b/pyproject.toml index ef73f889f..895e48e70 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -30,6 +30,7 @@ django-js-asset = "1.2.2" django-meta = "1.7.0" django-mptt = "0.11.0" django-parler = "2.2" +django-pattern-library = "0.5.0" django-polymorphic = "3.0.0" django-sekizai = "2.0.0" django-settings-export = "1.2.1" diff --git a/taccsite_cms/settings.py b/taccsite_cms/settings.py index 5ea7908ee..5c86dc912 100644 --- a/taccsite_cms/settings.py +++ b/taccsite_cms/settings.py @@ -180,6 +180,9 @@ def gettext(s): return s "img_file_src": "site_cms/img/favicons/favicon.ico" } +import importlib +_SETTINGS = importlib.import_module('taccsite_cms.settings') + ######################## # TACC: PORTAL ######################## @@ -473,6 +476,53 @@ def get_subdirs_as_module_names(path): 'h1', 'h2', 'h3', 'h4', 'h5', 'h6' ] +######################## +# PATTERN LIBRARY +######################## + +INSTALLED_APPS += [ + 'pattern_library' +] +# NOTE: To render the library, the following should be added to `urls.py` +""" +if apps.is_installed('pattern_library'): + urlpatterns += [ + path('pattern-library/', include("pattern_library.urls')), + ] +""" + +try: + TEMPLATES[0]['OPTIONS']['builtins'].append('pattern_library.loader_tags') +except KeyError: + TEMPLATES[0]['OPTIONS']['builtins'] = ['pattern_library.loader_tags'] + +# To see the detailed error pages generated by Django +# SEE: https://torchbox.github.io/django-pattern-library/getting-started/ +if _SETTINGS.DEBUG: + X_FRAME_OPTIONS = 'SAMEORIGIN' + +PATTERN_LIBRARY = { + # Groups of templates for the pattern library navigation. + # - The keys are group titles + # - The values are lists of template name prefixes + # (that will be searched to populate the groups) + 'SECTIONS': ( + ('components', ['patterns/components']), + ('pages', ['patterns/pages']), + ), + + # Configure which files to detect as templates. + 'TEMPLATE_SUFFIX': '.html', + + # Set the template inside of which components should be rendered + # (so they may use page-level component dependencies like CSS) + 'PATTERN_BASE_TEMPLATE_NAME': 'patterns/base.html', + + # Any template in BASE_TEMPLATE_NAMES (or any that extends one from there) + # is considered a "page" and will be rendered as-is (without being wrapped) + 'BASE_TEMPLATE_NAMES': ['patterns/base_page.html'], +} + ######################## # IMPORT & EXPORT ######################## @@ -495,6 +545,10 @@ def get_subdirs_as_module_names(path): None # do nothing +######################## +# EXPORT +######################## + SETTINGS_EXPORT = [ 'DEBUG', 'FEATURES', diff --git a/taccsite_cms/templates/patterns/base.html b/taccsite_cms/templates/patterns/base.html new file mode 100644 index 000000000..b117ccd5e --- /dev/null +++ b/taccsite_cms/templates/patterns/base.html @@ -0,0 +1,14 @@ + + + + + + Component Base + + + {% block content %} + {# pattern_library_rendered_pattern is where the pattern library will inject the rendered pattern. #} + {{ pattern_library_rendered_pattern }} + {% endblock %} + + diff --git a/taccsite_cms/templates/patterns/base_page.html b/taccsite_cms/templates/patterns/base_page.html new file mode 100644 index 000000000..52a1cfe59 --- /dev/null +++ b/taccsite_cms/templates/patterns/base_page.html @@ -0,0 +1,3 @@ +{% extends 'patterns/base.html' %} + +{% block title %}Page{% endblock %} diff --git a/taccsite_cms/templates/patterns/components/quote_block/quote_block.html b/taccsite_cms/templates/patterns/components/quote_block/quote_block.html new file mode 100644 index 000000000..b07c94629 --- /dev/null +++ b/taccsite_cms/templates/patterns/components/quote_block/quote_block.html @@ -0,0 +1,8 @@ +
+
+

{{ quote }}

+ {% if attribution %} +

{{ attribution }}

+ {% endif %} +
+
diff --git a/taccsite_cms/templates/patterns/components/quote_block/quote_block.yaml b/taccsite_cms/templates/patterns/components/quote_block/quote_block.yaml new file mode 100644 index 000000000..ab4a99605 --- /dev/null +++ b/taccsite_cms/templates/patterns/components/quote_block/quote_block.yaml @@ -0,0 +1,4 @@ +name: Quote Block (Sample) +context: + quote: What is love? + attribution: Haddaway diff --git a/taccsite_cms/templates/patterns/pages/test_page/test_page.html b/taccsite_cms/templates/patterns/pages/test_page/test_page.html new file mode 100644 index 000000000..5264f1008 --- /dev/null +++ b/taccsite_cms/templates/patterns/pages/test_page/test_page.html @@ -0,0 +1,3 @@ +{% extends 'patterns/base_page.html' %} + +{% block content %}{{ page.body }}{% endblock %} diff --git a/taccsite_cms/templates/patterns/pages/test_page/test_page.yaml b/taccsite_cms/templates/patterns/pages/test_page/test_page.yaml new file mode 100644 index 000000000..9b8ba8fae --- /dev/null +++ b/taccsite_cms/templates/patterns/pages/test_page/test_page.yaml @@ -0,0 +1,11 @@ +context: + page: + body: > +

+ Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod + tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, + quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo + consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse + cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat + non proident, sunt in culpa qui officia deserunt mollit anim id est laborum. +

diff --git a/taccsite_cms/urls.py b/taccsite_cms/urls.py index 85f9a4092..be672caf8 100755 --- a/taccsite_cms/urls.py +++ b/taccsite_cms/urls.py @@ -2,6 +2,7 @@ from __future__ import absolute_import, print_function, unicode_literals from cms.sitemaps import CMSSitemap +from django.apps import apps from django.conf import settings from django.conf.urls.static import static from django.conf.urls import include, url @@ -10,6 +11,7 @@ from django.contrib.sitemaps.views import sitemap from django.contrib.staticfiles.urls import staticfiles_urlpatterns from django.views.static import serve +from django.urls import path from taccsite_cms import remote_cms_auth as remote_cms_auth from django.http import request @@ -39,6 +41,11 @@ url(r'^', include('cms.urls')), ] +if apps.is_installed('pattern_library'): + urlpatterns.insert(0, + path('pattern-library/', include('pattern_library.urls')) + ) + # This is only needed when using runserver. if settings.DEBUG: urlpatterns += [