Skip to content

Commit 2c88ddb

Browse files
authored
Merge pull request #73 from lemonsaurus/lint-on-push
Lint on push
2 parents 01e0f34 + f8a55e9 commit 2c88ddb

File tree

3 files changed

+131
-67
lines changed

3 files changed

+131
-67
lines changed

.github/workflows/lint.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
name: Lint with flake8
2-
on: [pull_request]
2+
on:
3+
push:
4+
branches: [main]
5+
pull_request:
6+
branches: [main]
37

48
jobs:
59
lint:

README.md

Lines changed: 125 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,31 @@
11
django-simple-bulma
22
===================
3-
`django-simple-bulma` is a Django application that makes [Bulma](https://bulma.io) and [Bulma-Extensions](https://wikiki.github.io/) available to use in your Django project with as little setup as possible. The goal of this project is to make it as easy as possible to use Bulma with Django.
3+
`django-simple-bulma` is a Django application that makes [Bulma](https://bulma.io)
4+
and [Bulma-Extensions](https://wikiki.github.io/) available to use in your Django project with as little setup as
5+
possible. The goal of this project is to make it as easy as possible to use Bulma with Django.
46

5-
This project currently uses **Bulma v0.9.2**, and is automatically updated with every new release. If a new version has come out with features you'd like to make use of, please [create an issue](https://github.com/python-discord/django-simple-bulma/issues), and we will be happy to make a release to update it.
7+
This project currently uses **Bulma v0.9.2**, and is automatically updated with every new release. If a new version has
8+
come out with features you'd like to make use of,
9+
please [create an issue](https://github.com/python-discord/django-simple-bulma/issues), and we will be happy to make a
10+
release to update it.
611

712
Installation
813
------------
914
To get `django-simple-bulma`, up and running for your Django project, follow these simple steps:
10-
- Install it from PyPI with `pip install django-simple-bulma` (or add it to your [Pipfile](https://pipenv.readthedocs.io/en/latest/))
15+
16+
- Install it from PyPI with `pip install django-simple-bulma` (or add it to
17+
your [Pipfile](https://pipenv.readthedocs.io/en/latest/))
1118
- In your Django projects `settings.py` file:
1219
- Add `django_simple_bulma` to your `INSTALLED_APPS`
1320
```python
1421
INSTALLED_APPS = [
15-
#...
22+
# ...
1623
'django_simple_bulma',
17-
#...
24+
# ...
1825
]
1926
```
20-
- Add `django_simple_bulma.finders.SimpleBulmaFinder` to your `STATICFILES_FINDERS`. This normally holds two default handlers that you will probably want to keep, so unless you have any other custom Finders, it should look like this:
27+
- Add `django_simple_bulma.finders.SimpleBulmaFinder` to your `STATICFILES_FINDERS`. This normally holds two default
28+
handlers that you will probably want to keep, so unless you have any other custom Finders, it should look like this:
2129
```python
2230
STATICFILES_FINDERS = [
2331
# First add the two default Finders, since this will overwrite the default.
@@ -28,58 +36,81 @@ To get `django-simple-bulma`, up and running for your Django project, follow the
2836
'django_simple_bulma.finders.SimpleBulmaFinder',
2937
]
3038
```
31-
- Run `python manage.py collectstatic` command in order to build Bulma and move it to your `staticfiles` folder. Please note that you will need to use this command every time you make a change to the configuration, as this is the only way to rebuild the Bulma css file. If you are not using `collectstatic`, [read up on it](https://stackoverflow.com/questions/34586114/whats-the-point-of-djangos-collectstatic) and [start using it](https://docs.djangoproject.com/en/2.1/ref/contrib/staticfiles/).
39+
- Run `python manage.py collectstatic` command in order to build Bulma and move it to your `staticfiles` folder. Please
40+
note that you will need to use this command every time you make a change to the configuration, as this is the only way
41+
to rebuild the Bulma css file. If you are not using `collectstatic`
42+
, [read up on it](https://stackoverflow.com/questions/34586114/whats-the-point-of-djangos-collectstatic)
43+
and [start using it](https://docs.djangoproject.com/en/2.1/ref/contrib/staticfiles/).
44+
45+
This app works fine with [Whitenoise](http://whitenoise.evans.io/en/stable/), which is a great way to serve static
46+
files without needing to mess with your webserver.
3247

33-
This app works fine with [Whitenoise](http://whitenoise.evans.io/en/stable/), which is a great way to serve static files without needing to mess with your webserver.
48+
`django-simple-bulma` should now be working! In order to import it into your template, first load the app
49+
with `{% load django_simple_bulma %}`, and then use the `{% bulma %}` template tag. If you're planning on using icons,
50+
you might also want to import FontAwesome by using `{% font_awesome %}`.
3451

35-
`django-simple-bulma` should now be working! In order to import it into your template, first load the app with `{% load django_simple_bulma %}`, and then use the `{% bulma %}` template tag. If you're planning on using icons, you might also want to import FontAwesome by using `{% font_awesome %}`.
3652
```html
37-
<head>
38-
<!-- ... -->
39-
{% load django_simple_bulma %}
40-
{% bulma %}
41-
{% font_awesome %}
42-
<!-- ... -->
43-
</head>
53+
<head>
54+
<!-- ... -->
55+
{% load django_simple_bulma %}
56+
{% bulma %}
57+
{% font_awesome %}
58+
<!-- ... -->
59+
</head>
4460
```
61+
4562
- You're all set! Any Bulma classes you apply should now be working!
4663

4764
Customization
4865
-------------
49-
Bulma looks nice by default, but most users will want to customize its look and feel. For this, we've provided a super simple way to change the [Bulma variables](https://bulma.io/documentation/customize/variables/) and to choose which [Bulma extensions](https://wikiki.github.io/) you want to load into your project.
66+
Bulma looks nice by default, but most users will want to customize its look and feel. For this, we've provided a super
67+
simple way to change the [Bulma variables](https://bulma.io/documentation/customize/variables/) and to choose
68+
which [Bulma extensions](https://wikiki.github.io/) you want to load into your project.
69+
70+
In order to do this, we'll simply create a dictionary inside your `settings.py` called `BULMA_SETTINGS`, and configure
71+
it there. Here's an example of what that looks like:
5072

51-
In order to do this, we'll simply create a dictionary inside your `settings.py` called `BULMA_SETTINGS`, and configure it there. Here's an example of what that looks like:
5273
```python
5374
# Custom settings for django-simple-bulma
5475
BULMA_SETTINGS = {
55-
"extensions": [
56-
"bulma-collapsible",
57-
"bulma-calendar",
58-
],
59-
"variables": {
60-
"primary": "#000000",
61-
"size-1": "6rem",
62-
},
63-
"alt_variables": {
64-
"primary": "#fff",
65-
"scheme-main": "#000",
66-
},
67-
"output_style": "compressed",
68-
"fontawesome_token": "e761a01be3",
76+
"extensions": [
77+
"bulma-collapsible",
78+
"bulma-calendar",
79+
],
80+
"variables": {
81+
"primary": "#000000",
82+
"size-1": "6rem",
83+
},
84+
"alt_variables": {
85+
"primary": "#fff",
86+
"scheme-main": "#000",
87+
},
88+
"output_style": "compressed",
89+
"fontawesome_token": "e761a01be3",
6990
}
7091
```
7192

72-
You may here define any variable found on the [Bulma variables](https://bulma.io/documentation/customize/variables/) page, and you may use any valid SASS or CSS as the value. For example, `hsl(217, 71%, 53%)` would be a valid value for a color variable, as would `#ffff00`. Please note that any syntactically incorrect values may prevent Bulma from building correctly, so be careful what you add here unless you know exactly what you're doing.
93+
You may here define any variable found on the [Bulma variables](https://bulma.io/documentation/customize/variables/)
94+
page, and you may use any valid SASS or CSS as the value. For example, `hsl(217, 71%, 53%)` would be a valid value for a
95+
color variable, as would `#ffff00`. Please note that any syntactically incorrect values may prevent Bulma from building
96+
correctly, so be careful what you add here unless you know exactly what you're doing.
7397

7498
#### Multiple themes
75-
If you want multiple different configurations of variables, then you should define them as separate themes. Define a new theme by providing a key that matches the regex `\w+_variables` (e.g. `alt_variables` or `dark_variables`), unique stylesheets will then be generated using the variables at that key.
7699

77-
To use these stylesheets in a template, pass the theme name to the `{% bulma %}` tag either as a string `{% bulma 'alt' %}` or as a template variable `{% bulma theme %}`.
100+
If you want multiple different configurations of variables, then you should define them as separate themes. Define a new
101+
theme by providing a key that matches the regex `\w+_variables` (e.g. `alt_variables` or `dark_variables`), unique
102+
stylesheets will then be generated using the variables at that key.
103+
104+
To use these stylesheets in a template, pass the theme name to the `{% bulma %}` tag either as a
105+
string `{% bulma 'alt' %}` or as a template variable `{% bulma theme %}`.
78106

79107
#### Extensions
80-
If the `extensions` key is not found, it will default to not loading any extensions. If you want all extensions, simply set it to the string `"all"`.
108+
109+
If the `extensions` key is not found, it will default to not loading any extensions. If you want all extensions, simply
110+
set it to the string `"all"`.
81111

82112
We currently support these extensions:
113+
83114
- bulma-badge
84115
- bulma-calendar
85116
- bulma-carousel
@@ -99,65 +130,94 @@ We currently support these extensions:
99130
- bulma-tooltip
100131
- bulma-coolcheckboxes (Cool-Checkboxes-for-Bulma.io)
101132

102-
If an extension you want to use is missing, feel free to [create an issue](https://github.com/python-discord/django-simple-bulma/issues) and we will be happy to add it. Alternatively, add it yourself and create a pull request (see [this pr](https://github.com/python-discord/django-simple-bulma/pull/55) for some context on how to go about doing that).
103-
133+
If an extension you want to use is missing, feel free
134+
to [create an issue](https://github.com/python-discord/django-simple-bulma/issues) and we will be happy to add it.
135+
Alternatively, add it yourself and create a pull request (
136+
see [this pr](https://github.com/python-discord/django-simple-bulma/pull/55) for some context on how to go about doing
137+
that).
104138

105139
#### CSS style
106-
The `output_style` parameter determines the style of the resulting CSS file. It can be any of `"nested"` (default), `"expanded"`, `"compact"`, and `"compressed"`. It is recommended to use `"compressed"` in production as to reduce the final file size.
140+
141+
The `output_style` parameter determines the style of the resulting CSS file. It can be any of `"nested"` (default)
142+
, `"expanded"`, `"compact"`, and `"compressed"`. It is recommended to use `"compressed"` in production as to reduce the
143+
final file size.
107144

108145
#### FontAwesome
109-
The optional `fontawesome_token` parameter allows you to specify your personal FontAwesome kit, which is necessary for FontAwesome v6 and up. This should be set to the identifier part of your FontAwesome kit script src parameter. For example, if your FontAwesome kit looks like this:
146+
147+
The optional `fontawesome_token` parameter allows you to specify your personal FontAwesome kit, which is necessary for
148+
FontAwesome v6 and up. This should be set to the identifier part of your FontAwesome kit script src parameter. For
149+
example, if your FontAwesome kit looks like this:
150+
110151
```html
111152
<script src="https://kit.fontawesome.com/e761a01be3.js" crossorigin="anonymous"></script>
112153
```
154+
113155
Then your `fontawesome_token` should be **e761a01be3**.
114156

115-
This is used by the `{% font_awesome %}` template tag to set up FontAwesome for you. If you don't specify a `fontawesome_token`, **the template tag will still work**, but will then use an older version of FontAwesome (v5.14.0).
157+
This is used by the `{% font_awesome %}` template tag to set up FontAwesome for you. If you don't specify
158+
a `fontawesome_token`, **the template tag will still work**, but will then use an older version of FontAwesome (v5.14.0)
159+
.
116160

117161
Additional scripts
118162
------------------
119-
For your convenience, we also give you the option to add other quality of life improvements to your Bulma app. You may want to add these as well if they sound useful to you.
120-
121-
* `bulma-fileupload` will handle displaying the filename in your [file upload inputs](https://bulma.io/documentation/form/file/).
122-
* `bulma-navbar-burger` will hook up your `navbar-burger`s and `navbar-menu`s automatically, to provide a toggle for mobile users. We use a slightly updated version of [the example from Bulma's documentation](https://bulma.io/documentation/components/navbar/#navbarJsExample) - simply add a `data-target` attribute to your `navbar-burger` that refers to the `id` of the `navbar-menu` that should be expanded and collapsed by the button.
123-
* `bulma-notifications` will allow you to close [notifications](https://bulma.io/documentation/elements/notification/) by clicking on the X button.
124-
* `bulma-dropdown` will open/close dropdowns using the `is-active` class. It mimics how the dropdowns function on the [documentation page](https://bulma.io/documentation/components/dropdown/#hoverable-or-toggable).
125-
* `bulma-modal` will handle opening and closing modals. Just assign the `modal-button` class to a `<button>`, and make sure it has a `data-target` attribute that matches the `id` of the modal that you want to open. See [the example code from Bulma's documentation](https://bulma.io/documentation/components/modal/) for modal element code.
163+
For your convenience, we also give you the option to add other quality of life improvements to your Bulma app. You may
164+
want to add these as well if they sound useful to you.
165+
166+
* `bulma-fileupload` will handle displaying the filename in
167+
your [file upload inputs](https://bulma.io/documentation/form/file/).
168+
* `bulma-navbar-burger` will hook up your `navbar-burger`s and `navbar-menu`s automatically, to provide a toggle for
169+
mobile users. We use a slightly updated version
170+
of [the example from Bulma's documentation](https://bulma.io/documentation/components/navbar/#navbarJsExample) -
171+
simply add a `data-target` attribute to your `navbar-burger` that refers to the `id` of the `navbar-menu` that should
172+
be expanded and collapsed by the button.
173+
* `bulma-notifications` will allow you to close [notifications](https://bulma.io/documentation/elements/notification/)
174+
by clicking on the X button.
175+
* `bulma-dropdown` will open/close dropdowns using the `is-active` class. It mimics how the dropdowns function on
176+
the [documentation page](https://bulma.io/documentation/components/dropdown/#hoverable-or-toggable).
177+
* `bulma-modal` will handle opening and closing modals. Just assign the `modal-button` class to a `<button>`, and make
178+
sure it has a `data-target` attribute that matches the `id` of the modal that you want to open.
179+
See [the example code from Bulma's documentation](https://bulma.io/documentation/components/modal/) for modal element
180+
code.
126181

127182
Compiling custom SCSS
128183
------------------------
129184

130-
If you're writing custom SCSS for your application, `django-simple-bulma` provides a mechanism for compiling
131-
it for you. This is provided mainly because `django-simple-bulma` may cause conflicts and issues with other tools
132-
to compile SCSS for you.
185+
If you're writing custom SCSS for your application, `django-simple-bulma` provides a mechanism for compiling it for you.
186+
This is provided mainly because `django-simple-bulma` may cause conflicts and issues with other tools to compile SCSS
187+
for you.
133188

134-
To use this feature, please specify the `custom_css` key when defining your `BULMA_SETTINGS`. This should be a list
135-
of strings, containing _relative paths_ to `.scss` files to be compiled.
189+
To use this feature, please specify the `custom_css` key when defining your `BULMA_SETTINGS`. This should be a list of
190+
strings, containing _relative paths_ to `.scss` files to be compiled.
136191

137192
```python
138193
BULMA_SETTINGS = {
139-
"custom_scss": [
140-
"css/base/base.scss", # This is okay
141-
"my_app/static/css/base/base.scss", # This also is okay
142-
"C:\Users\MainDawg\my_app\static\..." # Don't do this, though.
143-
],
194+
"custom_scss": [
195+
"css/base/base.scss", # This is okay
196+
"my_app/static/css/base/base.scss", # This also is okay
197+
"C:\Users\MainDawg\my_app\static\..." # Don't do this, though.
198+
],
144199
}
145200
```
146201

147-
The default Django behavior when collecting static files is to keep the containing file structure for
148-
them when they're copied over to the final staticfiles directory. We do the same thing, so all directories and
149-
subdirectories will still be intact in your staticfiles folder after they've been collected.
202+
The default Django behavior when collecting static files is to keep the containing file structure for them when they're
203+
copied over to the final staticfiles directory. We do the same thing, so all directories and subdirectories will still
204+
be intact in your staticfiles folder after they've been collected.
150205

151206
Here's the strategy the finder uses:
152-
* If your path contains `static/`, assume that the base path ends there and use the rest of the path as a relative
153-
path to the resource.
207+
208+
* If your path contains `static/`, assume that the base path ends there and use the rest of the path as a relative path
209+
to the resource.
154210
* Use whatever Finders you have enabled in your `settings.py` to search for the file using that relative path.
155211
* If the path is found using one of these Finders, compile it to css and collect it.
156212
* Otherwise, raise a `ValueException` asking you to double-check the filepath.
157213

158214
Troubleshooting
159215
---------------
160216

161-
- If you have the module `sass` installed, please note that it is incompatible with this project. There is a namespace conflict between `sass` and `libsass` which will make `django-simple-bulma` crash when you attempt to do a `collectstatic`. To solve this, just uninstall `sass` and use `libsass` instead.
217+
- If you have the module `sass` installed, please note that it is incompatible with this project. There is a namespace
218+
conflict between `sass` and `libsass` which will make `django-simple-bulma` crash when you attempt to do
219+
a `collectstatic`. To solve this, just uninstall `sass` and use `libsass` instead.
162220

163-
If you run into any other problems with this app, please [create an issue](https://github.com/python-discord/django-simple-bulma/issues), and I'll will be happy to help you with it. You can also find me at at https://discord.gg/python as `lemon#0001`.
221+
If you run into any other problems with this app,
222+
please [create an issue](https://github.com/python-discord/django-simple-bulma/issues), and I'll will be happy to help
223+
you with it. You can also find me at at https://discord.gg/python as `lemon#0001`.

django_simple_bulma/finders.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010

1111
import sass
1212
from django.conf import settings
13-
from django.contrib.staticfiles.finders import BaseFinder
13+
from django.contrib.staticfiles.finders import BaseFinder, get_finder
1414
from django.core.files.storage import FileSystemStorage
1515

1616
from .utils import (

0 commit comments

Comments
 (0)