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

Switch to entrypoint-based themes handling #829

Merged
merged 3 commits into from Mar 28, 2017
Merged

Switch to entrypoint-based themes handling #829

merged 3 commits into from Mar 28, 2017

Conversation

noirbizarre
Copy link
Contributor

@noirbizarre noirbizarre commented Mar 27, 2017

This PR switch to entrypoint-based themes handling as it offers many advantages:

  • all themes are loaded with the same loader
  • themes can now be packaged standalone, no need to be a uData plugin (easier to make a new theme, or a theme template)
  • theme is tied to it's distribution, no need anymore to trick to find the real version

There theming process has also been documented.

Copy link
Member

@davidbgk davidbgk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good move! (and docs 👍 )

- reuses without image (`reuse.png`)
- territory without logo or flag (`territory.png`)

Then your free to add any static assets reuired by your theme
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reQuired + point at the end

<link rel="shortcut icon" href="{{ theme_static('img/favicon.png') }}">
{% endblock %}
```
You can reference static assets from you theme with the `theme_static` global function.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

of your theme

You can reference static assets from you theme with the `theme_static` global function.

!!! note
Don't forget to call `{{ super() }}` to includes the original block.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

include without an S


### Hooks

You're theme can also customize some behavior be using hooks in you ``__init__.py``.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

YouR + behaviors + bY + youR => Your theme can also customize some behaviors by using hooks in your ``__init__.py``.

### Hooks

You're theme can also customize some behavior be using hooks in you ``__init__.py``.
Currently there is 2 available hooks:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there ARE

## Publish and use

Once your theme is ready, you can publish it on [PyPI][] to share it to the world
(and notify us so we can be glad of your work).
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and link to your theme from the documentation?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added a "Known themes" section with a note on contributions

CHANGELOG.md Outdated
@@ -8,6 +8,9 @@
[Flask-Security-Fork](https://pypi.python.org/pypi/Flask-Security-Fork)
[#813](https://github.com/opendatateam/udata/pull/813)
- Ensure URLs are stripped [#823](https://github.com/opendatateam/udata/pull/823)
- Themes are now entrypoint-based [#829](https://github.com/opendatateam/udata/pull/829).
This is now documented, see [the related documention](https://udata.readthedocs.io/en/stable/creating-theme/)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

now is used twice, I'd remove the second one.

### `setup.py`

The `setup.py` is a classic python `setup.py` file.
The only requirements is that you properly expose the udata theme packaging
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

requirement without an S


### Static assets

The `static` should contains at least 2 files:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

contain without an S

The `static` should contains at least 2 files:

- `theme.css` which is loaded automatically on every page
- `admin.css` which is loaded automatically on on the amdin page
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

admin (typo on second occurrence)

@noirbizarre
Copy link
Contributor Author

@davidbgk Good to merge ?

- reuses without image (`reuse.png`)
- territory without logo or flag (`territory.png`)

Then your free to add any static assets required by your theme.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you are

@noirbizarre noirbizarre merged commit 618cdfa into opendatateam:dev Mar 28, 2017
@noirbizarre noirbizarre deleted the new-theme-loader branch March 28, 2017 17:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants