-
-
Notifications
You must be signed in to change notification settings - Fork 196
Provide the content for the Diazo theming part #1870
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
Merged
Merged
Changes from 27 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
e08c079
Update tips submodules/plone.api submodules/volto
stevepiercy 1f0a07b
Update tip submodules/volto
stevepiercy cc4288e
Fix broken references (#1868)
stevepiercy 4dd1406
Update tip submodules/plone.api
stevepiercy 710db4f
Update tip submodules/volto
stevepiercy 7e0abed
initial structure of Theming with Diazo
erral 676f204
more doc
erral 4892209
initial structure of Theming with Diazo
erral df34704
more doc
erral 98a42ea
Merge remote-tracking branch 'origin/erral-diazo-docs' into erral-dia…
stevepiercy 87b4981
- Add diazo to toctree
stevepiercy a08782e
Clean up grammar, one sentence per line, MyST syntax
stevepiercy cc749b3
Add language
stevepiercy 0341281
Move concepts and advice into a new Theme development advice section
stevepiercy bccd9ff
Minor tweaks
stevepiercy 7960810
Rename section to reflect its content
stevepiercy 8cb69c8
Adjust heading level
stevepiercy 273daee
Update diazo.md
erral 99f70f2
Update diazo.md
erral dee7d89
Update diazo.md
erral 126fa5d
- Make first mention of Diazo a term, already existing in the Glossary
stevepiercy d0bc7dd
Tweak markup
stevepiercy f092f6e
Merge branch 'classic-ui-theming-reorg-1645' into erral-diazo-docs
stevepiercy 580bc71
Merge branch 'classic-ui-theming-reorg-1645' into erral-diazo-docs
stevepiercy 5e65e3f
add tinymce templates docs
erral fd97ddf
Tidy up
stevepiercy a0779be
Add a label and important admonition about Template plugin removal in…
stevepiercy 2d47570
Remove important admonition about Template plugin
stevepiercy File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,178 @@ | ||
| --- | ||
| myst: | ||
| html_meta: | ||
| "description": "Plone Classic UI theming with Diazo" | ||
| "property=og:description": "Plone Classic UI theming with Diazo" | ||
| "property=og:title": "Plone Classic UI theming with Diazo" | ||
| "keywords": "Plone, Classic UI, theming, Diazo" | ||
| --- | ||
|
|
||
| (classic-ui-theming-diazo-label)= | ||
|
|
||
| # Classic UI theming with Diazo | ||
|
|
||
| {term}`Diazo` allows you to apply a theme contained in a static HTML web page to a dynamic website created using any server-side technology. | ||
| With Diazo, you can take an HTML wireframe created by a web designer, and turn it into a theme for your favourite CMS, redesign the user interface of a legacy web application without even having access to the original source code, or build a unified user experience across multiple disparate systems, all in a matter of hours, not weeks. | ||
|
|
||
| A Diazo theme consists of a static HTML page, referred to as the _theme_, and a rules file, conventionally called {file}`rules.xml`. | ||
|
|
||
| When using Diazo, you will work with syntax and concepts familiar from working with HTML and CSS. | ||
| And by allowing you to seamlessly integrate XSLT into your rules files, Diazo makes common cases simple, and complex requirements possible. | ||
|
|
||
|
|
||
| ## Create an add-on package | ||
|
|
||
| To create a Diazo theme, you need to create an add-on package with [`plonecli`](https://github.com/plone/plonecli). | ||
|
|
||
| You can run `plonecli` using [pipx](https://pipx.pypa.io/stable/), without needing to install `plonecli`, as follows. | ||
|
|
||
| ```shell | ||
| pipx run plonecli create addon diazo.theme | ||
| ``` | ||
|
|
||
| Answer all the questions. | ||
|
|
||
| Next, add a theme called `theme` to the add-on package using `plonecli`. | ||
|
|
||
| ```shell | ||
| cd diazo.theme | ||
| pipx run plonecli add theme | ||
| ``` | ||
|
|
||
| Answer the question of the theme name. | ||
|
|
||
|
|
||
| ### Theme structure | ||
|
|
||
| The previous step creates a {file}`theme` folder inside {file}`diazo.theme/src/diazo/theme`, with the following structure. | ||
|
|
||
| ```console | ||
| . | ||
| ├── index.html | ||
| ├── manifest.cfg | ||
| ├── package.json | ||
| ├── README.rst | ||
| ├── rules.xml | ||
| ├── styles | ||
| │ ├── theme.min.css | ||
| │ └── theme.scss | ||
| └── tinymce-templates | ||
| ├── bs-dark-hero.html | ||
| ├── bs-hero-left.html | ||
| └── bs-pricing.html | ||
erral marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| ``` | ||
|
|
||
| The purpose of each item is described as follows. | ||
|
|
||
| {file}`index.html` | ||
| : This is the theme file. | ||
| Plone populates it with its content, according to rules defined in {file}`rules.xml`. | ||
|
|
||
| {file}`manifest.cfg` | ||
| : This file contains the theme configuration, such as the theme name, the path to the rules file and some other configurations. | ||
|
|
||
| {file}`package.json` | ||
| : The theme folder is, by itself, a JavaScript package. | ||
| If you want to develop your theme here, you can declare the dependencies of your theme in this file. | ||
| For instance, you can add `bootstrap` or `tailwind` as dependencies, and manage those dependencies and the building of your final CSS from here. | ||
|
|
||
| {file}`README.rst` | ||
| : The file that explains how this theme is built and developed. | ||
|
|
||
| {file}`rules.xml` | ||
| : The file where you will write your rules to bring Plone content into the theme in the {file}`index.html` file. | ||
|
|
||
| {file}`styles` folder | ||
| : Where you can save your theme's CSS files. | ||
|
|
||
| {file}`tinymce-templates` | ||
| : Template files that can be loaded into the TinyMCE editor in Plone. | ||
| It requires additional configuration in the add-on's profile's {file}`registry.xml` file. | ||
stevepiercy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
|
|
||
| ## Integrate an external theme using Diazo | ||
|
|
||
| Begin with any theme from outside Plone. | ||
| It should be composed of the required HTML, CSS, and JavaScript files. | ||
|
|
||
| When you have all files of your theme, put them in the {file}`theme` folder, and organize the CSS and JavaScript folders as you received them from your designer. | ||
|
|
||
| You may want to remove the `plonecli` generated `styles` and `tinymce-templates` folders. | ||
|
|
||
|
|
||
| ## Adjust the theme manifest | ||
|
|
||
| Open the {file}`manifest.cfg` file. | ||
| You will see the following lines. | ||
|
|
||
| ```cfg | ||
| production-css = ++theme++my-shiny-theme/styles/theme.min.css | ||
| tinymce-content-css = ++theme++my-shiny-theme/styles/theme.min.css | ||
| ``` | ||
|
|
||
| Comment them out as shown. | ||
|
|
||
| ```cfg | ||
| # production-css = ++theme++my-shiny-theme/styles/theme.min.css | ||
| # tinymce-content-css = ++theme++my-shiny-theme/styles/theme.min.css | ||
| ``` | ||
|
|
||
| This way, you signal that you don't want either Plone or Diazo to manage the CSS files at all. | ||
| But it means that you will need to handle them in your design HTML files. | ||
|
|
||
|
|
||
| ## Theme development advice | ||
|
|
||
| This section describes common practices when developing a Diazo theme. | ||
|
|
||
|
|
||
| ### Avoid cache issues | ||
|
|
||
| CSS and JavaScript files should be properly versioned or hashed to avoid any caching problems whenever the theme is updated. | ||
|
|
||
| If the CSS file is called {file}`global.css`, and your designer updates the CSS without changing the file name, you will surely face caching issues. | ||
| Browsers, varnish, or other proxy servers might cache your files, and not serve them to the end users until the cache expires or gets flushed. | ||
|
|
||
| To avoid this issue, CSS bundling techniques that use npm tooling—such as Gulp, Grunt, or Webpack—create hashed or versioned filenames for CSS and JavaScript files. | ||
| The following HTML snippets show examples of versioned files. | ||
|
|
||
| ```html | ||
| <link id="frontend-css" rel="stylesheet" href="./css/app.css?v=14" /> | ||
| <script id="frontend-javascript" src="./js/app.js?v=3"></script> | ||
| ``` | ||
|
|
||
|
|
||
| ### HTML template structure | ||
|
|
||
| Your theme should be as simple as possible. | ||
| That will make your {file}`rules.xml` file also as simple as possible. | ||
|
|
||
| The {file}`rules.xml` file declares which parts of theme will be replaced by the HTML produced by Plone. | ||
|
|
||
| It is a good practice to have a `<div>` element called `content` in your theme, which will contain the maximum space of the content area of your site. | ||
| That way you can inject the HTML produced by Plone there using Plone's content section, too. | ||
|
|
||
| Add a stanza in your {file}`rules.xml` file. | ||
|
|
||
| ```xml | ||
| <replace | ||
| css:theme-children="#content" | ||
| css:content-children="article#content" | ||
| css:if-content="#content"/> | ||
| ``` | ||
|
|
||
|
|
||
| ### Minimize rules | ||
|
|
||
| You can start with the provided {file}`rules.xml` file. | ||
|
|
||
| You can read about how to write your rules and their syntax in the [official Diazo documentation](https://docs.diazo.org/en/latest/basic.html). | ||
|
|
||
| You will need to write your own rules to bring the dynamic content from Plone into the theme. | ||
stevepiercy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| Sometimes you will face difficult situations where you may find it hard to put items in the same place that Plone produces in very different places. | ||
|
|
||
| For instance, you may need to put together the main menu, the language change, and the search box. | ||
| Sometimes it is easier to override the corresponding template in Plone, build the new HTML structure there, and replace one thing in the {file}`rules.xml` file than trying to write complex Diazo rules or writing XSLT. | ||
|
|
||
| The size of the {file}`rules.xml` file and the number of rules it contains can negatively impact the performance of your site. | ||
stevepiercy marked this conversation as resolved.
Show resolved
Hide resolved
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -57,6 +57,7 @@ To summarize: | |
| settings-ttw | ||
| create-add-on | ||
| color-modes | ||
| diazo | ||
| ``` | ||
|
|
||
| ## Reference | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.