Giter VIP home page Giter VIP logo

django-simple-bulma's Introduction

django-simple-bulma's People

Contributors

den4200 avatar edrik avatar gdude2002 avatar gdwr avatar jb3 avatar jchristgit avatar jonasuj avatar ks129 avatar lemonsaurus avatar markkoz avatar max1666 avatar oguzhanogreden avatar pydis-bot avatar sco1 avatar scragly avatar talperetz avatar wonkybream avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

django-simple-bulma's Issues

Dropdown JS

From python-discord/site#202

(function() {
    window.dropdowns = {};

    let elements = document.getElementsByClassName("dropdown");

    for (let element of elements) {
        let menu_element = element.getElementsByClassName("dropdown-menu")[0];

        function show() {
            $(element).addClass("is-active");
        }

        function hide() {
            $(element).removeClass("is-active");
        }

        function handle_event(e) {
            show();

            $(document.body).on("click." + menu_element.id, function() {
                hide();

                $(document.body).off("click." + menu_element.id);
            });

            e.stopPropagation();
        }

        $(element).click(handle_event);
        $(element).hover(handle_event);
        $(element).mouseleave(hide);

        window.dropdowns[menu_element.id] = element;
    }
})();

Support for FontAwesome Pro

The app should be able to support FontAwesome Pro.

This is very easy to implement, since all the validation happens on the FA side. Simple add a boolean to the configuration which, if set to True, switches the CDN URL that the template tag returns from use.fontawesome.com... to pro.fontawesome.com...

A GitHub Action workflow to update submodules

As I recently learned, submodules are not kept up to date automatically. We have to update them by running git submodule update --recursive --remote and then committing the result - but that doesn't mean we can't automate this. Let's create a workflow to do the submodule update, and include it in the release workflow. That way, we will automatically update Bulma every time we do a release.

Not able to run collectstatic

Hi,

When I followed all the steps and I need to run the following command: python manage.py collectstatic

I get this error message:

Traceback (most recent call last): File "manage.py", line 22, in <module> main() File "manage.py", line 18, in main execute_from_command_line(sys.argv) File "/home/joshua/Documents/Code/SHOP/saulgadgets/env/lib/python3.7/site-packages/django/core/management/__init__.py", line 401, in execute_from_command_line utility.execute() File "/home/joshua/Documents/Code/SHOP/saulgadgets/env/lib/python3.7/site-packages/django/core/management/__init__.py", line 395, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/home/joshua/Documents/Code/SHOP/saulgadgets/env/lib/python3.7/site-packages/django/core/management/base.py", line 330, in run_from_argv self.execute(*args, **cmd_options) File "/home/joshua/Documents/Code/SHOP/saulgadgets/env/lib/python3.7/site-packages/django/core/management/base.py", line 371, in execute output = self.handle(*args, **options) File "/home/joshua/Documents/Code/SHOP/saulgadgets/env/lib/python3.7/site-packages/django/contrib/staticfiles/management/commands/collectstatic.py", line 155, in handle self.check(tags=[Tags.staticfiles]) File "/home/joshua/Documents/Code/SHOP/saulgadgets/env/lib/python3.7/site-packages/django/core/management/base.py", line 396, in check databases=databases, File "/home/joshua/Documents/Code/SHOP/saulgadgets/env/lib/python3.7/site-packages/django/core/checks/registry.py", line 70, in run_checks new_errors = check(app_configs=app_configs, databases=databases) File "/home/joshua/Documents/Code/SHOP/saulgadgets/env/lib/python3.7/site-packages/django/contrib/staticfiles/checks.py", line 7, in check_finders for finder in get_finders(): File "/home/joshua/Documents/Code/SHOP/saulgadgets/env/lib/python3.7/site-packages/django/contrib/staticfiles/finders.py", line 282, in get_finders yield get_finder(finder_path) File "/home/joshua/Documents/Code/SHOP/saulgadgets/env/lib/python3.7/site-packages/django/contrib/staticfiles/finders.py", line 291, in get_finder Finder = import_string(import_path) File "/home/joshua/Documents/Code/SHOP/saulgadgets/env/lib/python3.7/site-packages/django/utils/module_loading.py", line 17, in import_string module = import_module(module_path) File "/home/joshua/.pyenv/versions/3.7.2/lib/python3.7/importlib/__init__.py", line 127, in import_module return _bootstrap._gcd_import(name[level:], package, level) File "<frozen importlib._bootstrap>", line 1006, in _gcd_import File "<frozen importlib._bootstrap>", line 983, in _find_and_load File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked File "<frozen importlib._bootstrap>", line 677, in _load_unlocked File "<frozen importlib._bootstrap_external>", line 724, in exec_module File "<frozen importlib._bootstrap_external>", line 860, in get_code File "<frozen importlib._bootstrap_external>", line 791, in source_to_code File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed File "/home/joshua/Documents/Code/SHOP/saulgadgets/env/lib/python3.7/site-packages/django_simple_bulma/finders.py", line 166 if absolute_path := finder.find(relative_path): ^ SyntaxError: invalid syntax

Could somebody help me with this please.

Thank you!

Kind regards,

Joshua

Upgrade to Django 3.*

Looks like a least one change is needed to be make to django-simple-bulma work with for Django 3.*

If I get a few free cycles I'll look at working up a fix, and see if there are any other changes that need to be made.

Scripts using window.onload

Currently, we have multiple scripts making use of window.onload. This presents some issues, mainly that you can only have one function assigned to window.onload by default.

I propose that we make use of the newer DomContentLoaded event. This will be fired once the DOM has been loaded up, but before assets like images have fully loaded - which is generally what we want.

It's simple enough:

window.addEventListener('DOMContentLoaded', (event) => {
    console.log('DOM fully loaded and parsed');
});

Versioning

While I think it's a good idea to ship Bulma's assets (and that of its extensions) with the PyPi release, it would be nice to be able to specify the specific versions wanted of those for users that do have the option to download those dependencies in their environment.

We'd need to cache them somewhere, of course.

Submodule bulma instead of keeping a copy.

Right now, we've got copies of specific versions of Bulma and Bulma-Extensions in this repo, which is license permissable but adds maintenance in that we have to manually update these files to in order to "update" to a new version.

Perhaps we could include bulma and bulma-extensions as submodules to ensure these stayed up to date, and that we did not need to manage these files ourselves?

Overall design

Django uses a feature it calls collectstatic to locate all the static files for all your apps inside the django project and collect them all in a single location so that your web server can serve them from there. The way this actually works is that you have a class called something like StaticFilesStorage which is initialized when the command is used. That class will then check a setting variable called STATICFILES_FINDERS from your settings.py, which contains a list of Finder classes.

For example, AppDirectoriesFinder will look in every app you have in INSTALLED_APPS, and then find all the files located in the static folders in these.

For django-simple-bulma, we could probably create a custom Finder.

The user would add our custom finder to his list of finders (along with the two default ones), then the user would run collectstatic, and then they could simply do {% static "bulma.css" %} in their template. Then if they wanted to override any Bulma variables, they'd make a dict in settings.py called BULMA_VARIABLES and then fill that with whatever they wanna set variables to.

BULMA_VARIABLES = {
    "size-2": "4rem",
    "weight-normal": "700",
    "primary": "#7289da"
}

Our SimpleBulmaFinder would take this dict, parse it to an SCSS file, and then import Bulma at the end of that SCSS file. Then it would use libsass to turn this into a css file, and then just return the filepath to the StaticFilesStorage so this file could be added to the staticfiles folder.

Bulma-Calendar sass import fails with django-simple-bulma-2.5.0

Updated to django-simple-bulma-2.5.0 and get the following error.

(metron) bpepple@frodo ~/git/metron (deps) $ python3 manage.py check
Traceback (most recent call last):
  File "manage.py", line 15, in <module>
    execute_from_command_line(sys.argv)
  File "/home/bpepple/.local/share/virtualenvs/metron-UZX73b7p/lib/python3.8/site-packages/django/core/management/__init__.py", line 425, in execute_from_command_line
    utility.execute()
  File "/home/bpepple/.local/share/virtualenvs/metron-UZX73b7p/lib/python3.8/site-packages/django/core/management/__init__.py", line 419, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/bpepple/.local/share/virtualenvs/metron-UZX73b7p/lib/python3.8/site-packages/django/core/management/base.py", line 373, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/bpepple/.local/share/virtualenvs/metron-UZX73b7p/lib/python3.8/site-packages/django/core/management/base.py", line 417, in execute
    output = self.handle(*args, **options)
  File "/home/bpepple/.local/share/virtualenvs/metron-UZX73b7p/lib/python3.8/site-packages/django/core/management/commands/check.py", line 63, in handle
    self.check(
  File "/home/bpepple/.local/share/virtualenvs/metron-UZX73b7p/lib/python3.8/site-packages/django/core/management/base.py", line 438, in check
    all_issues = checks.run_checks(
  File "/home/bpepple/.local/share/virtualenvs/metron-UZX73b7p/lib/python3.8/site-packages/django/core/checks/registry.py", line 77, in run_checks
    new_errors = check(app_configs=app_configs, databases=databases)
  File "/home/bpepple/.local/share/virtualenvs/metron-UZX73b7p/lib/python3.8/site-packages/debug_toolbar/apps.py", line 108, in check_panel_configs
    for check_message in panel_class.run_checks():
  File "/home/bpepple/.local/share/virtualenvs/metron-UZX73b7p/lib/python3.8/site-packages/debug_toolbar/panels/staticfiles.py", line 193, in run_checks
    for path, finder_storage in finder.list([]):
  File "/home/bpepple/.local/share/virtualenvs/metron-UZX73b7p/lib/python3.8/site-packages/django_simple_bulma/finders.py", line 215, in list
    files = self._get_bulma_css()
  File "/home/bpepple/.local/share/virtualenvs/metron-UZX73b7p/lib/python3.8/site-packages/django_simple_bulma/finders.py", line 143, in _get_bulma_css
    css_string = sass.compile(string=scss_string,
  File "/home/bpepple/.local/share/virtualenvs/metron-UZX73b7p/lib64/python3.8/site-packages/sass.py", line 738, in compile
    raise CompileError(v)
sass.CompileError: Error: File to import not found or unreadable: ~bulma/sass/utilities/functions.sass.
        on line 1:1 of ../../.local/share/virtualenvs/metron-UZX73b7p/lib/python3.8/site-packages/django_simple_bulma/extensions/bulma-calendar/src/sass/index.sass
        from line 12:1 of stdin
>> @import "~bulma/sass/utilities/functions.sass";

AttributeError: 'Settings' object has no attribute 'BULMA_SETTINGS'

It seems the case where BULMA_SETTINGS is not defined is not handled well.

Perhaps consider:

  • Updateing Readme.md to make it clear that this is needed even if it's empty,
  • Catch the AttributeError and consider it empty.

Otherwise, the app enabled me to set up Bulma with great ease, thanks! ๐ŸŽ‰

Add pep8-naming to the linting toolchain

We've decided to use this plugin in our linting toolchain, which allows us to test things like variable name casing (no camelCase please!) and whether classes and methods use cls and self.

Implementation

Here are the errors it can catch:

code sample message
N801 class names should use CapWords convention
N802 function name should be lowercase
N803 argument name should be lowercase
N804 first argument of a classmethod should be named 'cls'
N805 first argument of a method should be named 'self'
N806 variable in function should be lowercase
N807 function name should not start and end with '__'
ย  ย 
N811 constant imported as non constant
N812 lowercase imported as non lowercase
N813 camelcase imported as lowercase
N814 camelcase imported as constant
N815 mixedCase variable in class scope
N816 mixedCase variable in global scope

We have not decided exactly which of these we should ignore, so it will be up to the person who handles this issue to discuss this with the core devs and come to a consensus on whether we should ignore some of these. It will probably be easier to see which ones here are not necessary after actually running a lint with this plugin on our current codebase.

The person implementing this will also need to fix all the linting errors that occur once this has been added to the toolchain.

Steps

  • Add the plugin to the toolchain
  • Run it and look through the errors that are created. Are any of them out of touch with our style guidelines, and should we ignore some of these rules? Discuss with the core developers if you think so.
  • Fix all the linting problems.

Full path in js files

I have following problems with JS files loaded into template.

Your loader uses full path which in my case means that path contains site-packages and all that stuff
/lib/python3.6/site-packages/django_simple_bulma/js/bulma-tagsinput.js

Loading css works fine because it's done like this css = static("css/bulma.css") instead of using full path.

By modifying following code to use filename.name to construct path seems to work in my case.

@register.simple_tag
def bulma():
    """
    Build and return all the HTML required to
    import bulma and the javascript for all
    active extensions.
    """
    # Build the html to include the stylesheet
    css = static("css/bulma.css")
    html = [f'<link rel="stylesheet" href="{css}">']

    # Build html to include all the js files required.
    for filename in js_folder.iterdir():
        js_file = static(f"js/{filename.name}")
        extension_name = filename.stem

        if extension_name in extensions or extensions == "_all":
            html.append(f'{" " * 8}<script type="text/javascript" src="{js_file}"></script>')

    return mark_safe("\n".join(html))  # noqa

Now to my actual question.
Is there something wrong on my end or is there actually small bug in code?

Thank you very much for your work with this and if there's anything I can do to help further just say a word.

Failure in prod with Whitenoise and disabled bulma addons

I'm not releasing to prod yet, but I figured I'd check what happens when I attempt to run my site in production. It turns out that django-simple-bulma appears to be trying to insert <script> tags for modules I don't actually have enabled, which results in a 500 error from Whitenoise.

In my settings.py:

STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'

# ...

BULMA_SETTINGS = {
    "extensions": [
        # Layout extensions
        "bulma-divider",

        # Form extensions
        "bulma-checkradio",
        "bulma-iconpicker",
        "bulma-slider",
        "bulma-switch",
        "bulma-tagsinput",

        # Element extensions
        "bulma-badge",
        "bulma-tooltip",

        # Component extensions
        "bulma-steps",

        # Bundled extensions
        "bulma-fileupload",
        "bulma-navbar-burger",
        "bulma-notifications",
    ],

    "variables": {
        "primary": "#7289DA",
        "link": "$primary",
    }
}

This results in a 500 error when DEBUG is False, and the following traceback in the debug log:

Internal Server Error: /
Traceback (most recent call last):
  File "/home/gdude/PycharmProjects/gserv.me/.venv/lib/python3.7/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/home/gdude/PycharmProjects/gserv.me/.venv/lib/python3.7/site-packages/django/core/handlers/base.py", line 156, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/home/gdude/PycharmProjects/gserv.me/.venv/lib/python3.7/site-packages/django/core/handlers/base.py", line 154, in _get_response
    response = response.render()
  File "/home/gdude/PycharmProjects/gserv.me/.venv/lib/python3.7/site-packages/django/template/response.py", line 106, in render
    self.content = self.rendered_content
  File "/home/gdude/PycharmProjects/gserv.me/.venv/lib/python3.7/site-packages/django/template/response.py", line 83, in rendered_content
    content = template.render(context, self._request)
  File "/home/gdude/PycharmProjects/gserv.me/.venv/lib/python3.7/site-packages/django/template/backends/django.py", line 61, in render
    return self.template.render(context)
  File "/home/gdude/PycharmProjects/gserv.me/.venv/lib/python3.7/site-packages/django/template/base.py", line 171, in render
    return self._render(context)
  File "/home/gdude/PycharmProjects/gserv.me/.venv/lib/python3.7/site-packages/django/template/base.py", line 163, in _render
    return self.nodelist.render(context)
  File "/home/gdude/PycharmProjects/gserv.me/.venv/lib/python3.7/site-packages/django/template/base.py", line 937, in render
    bit = node.render_annotated(context)
  File "/home/gdude/PycharmProjects/gserv.me/.venv/lib/python3.7/site-packages/django/template/base.py", line 904, in render_annotated
    return self.render(context)
  File "/home/gdude/PycharmProjects/gserv.me/.venv/lib/python3.7/site-packages/django/template/loader_tags.py", line 150, in render
    return compiled_parent._render(context)
  File "/home/gdude/PycharmProjects/gserv.me/.venv/lib/python3.7/site-packages/django/template/base.py", line 163, in _render
    return self.nodelist.render(context)
  File "/home/gdude/PycharmProjects/gserv.me/.venv/lib/python3.7/site-packages/django/template/base.py", line 937, in render
    bit = node.render_annotated(context)
  File "/home/gdude/PycharmProjects/gserv.me/.venv/lib/python3.7/site-packages/django/template/base.py", line 904, in render_annotated
    return self.render(context)
  File "/home/gdude/PycharmProjects/gserv.me/.venv/lib/python3.7/site-packages/django/template/library.py", line 192, in render
    output = self.func(*resolved_args, **resolved_kwargs)
  File "/home/gdude/PycharmProjects/gserv.me/.venv/lib/python3.7/site-packages/django_simple_bulma/templatetags/django_simple_bulma.py", line 41, in bulma
    js_file = static(f"js/{filename.name}")
  File "/home/gdude/PycharmProjects/gserv.me/.venv/lib/python3.7/site-packages/django/contrib/staticfiles/templatetags/staticfiles.py", line 19, in static
    return _static(path)
  File "/home/gdude/PycharmProjects/gserv.me/.venv/lib/python3.7/site-packages/django/templatetags/static.py", line 167, in static
    return StaticNode.handle_simple(path)
  File "/home/gdude/PycharmProjects/gserv.me/.venv/lib/python3.7/site-packages/django/templatetags/static.py", line 118, in handle_simple
    return staticfiles_storage.url(path)
  File "/home/gdude/PycharmProjects/gserv.me/.venv/lib/python3.7/site-packages/django/contrib/staticfiles/storage.py", line 152, in url
    return self._url(self.stored_name, name, force)
  File "/home/gdude/PycharmProjects/gserv.me/.venv/lib/python3.7/site-packages/django/contrib/staticfiles/storage.py", line 131, in _url
    hashed_name = hashed_name_func(*args)
  File "/home/gdude/PycharmProjects/gserv.me/.venv/lib/python3.7/site-packages/django/contrib/staticfiles/storage.py", line 419, in stored_name
    raise ValueError("Missing staticfiles manifest entry for '%s'" % clean_name)
ValueError: Missing staticfiles manifest entry for 'js/bulma-accordion.js'
"GET / HTTP/1.1" 500 27

As you can see, I don't actually have bulma-accordion enabled, so it is indeed not in that manifest. The question is why django-simple-bulma is still attempting to make use of it.

I don't have time right at this moment to investigate it myself, but I'll attempt to dig around and fix it if I have time to later on.

Intermittent "circular import" when starting Django app

Hi,

Thanks for a nice Python/Django package. It works fine, but sometimes I get this error on startup with this Django app installed (as described in the installation details):

pipenv run ./manage.py runserver
Watching for file changes with StatReloader
2021-04-20 13:37:09,008 INFO [django.utils.autoreload] Watching for file changes with StatReloader
Performing system checks...

Traceback (most recent call last):
  File "/home/per/.virtualenvs/centraln-czG2gyNf/lib/python3.9/site-packages/django/template/utils.py", line 66, in __getitem__
    return self._engines[alias]
KeyError: 'django'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/home/per/.virtualenvs/centraln-czG2gyNf/lib/python3.9/site-packages/django/template/backends/django.py", line 121, in get_package_libraries
    module = import_module(entry[1])
  File "/usr/lib/python3.9/importlib/__init__.py", line 127, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 1030, in _gcd_import
  File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
  File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 790, in exec_module
  File "<frozen importlib._bootstrap>", line 228, in _call_with_frames_removed
  File "/home/per/.virtualenvs/centraln-czG2gyNf/lib/python3.9/site-packages/django_simple_bulma/templatetags/django_simple_bulma.py", line 11, in <module>
    from ..utils import (
ImportError: cannot import name 'fontawesome_token' from partially initialized module 'django_simple_bulma.utils' (most likely due to a circular import) (/home/per/.virtualenvs/centraln-czG2gyNf/lib/python3.9/site-packages/django_simple_bulma/utils.py)

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "/home/per/git/centraln/./manage.py", line 22, in <module>
    main()
  File "/home/per/git/centraln/./manage.py", line 18, in main
    execute_from_command_line(sys.argv)
  File "/home/per/.virtualenvs/centraln-czG2gyNf/lib/python3.9/site-packages/django/core/management/__init__.py", line 419, in execute_from_command_line
    utility.execute()
  File "/home/per/.virtualenvs/centraln-czG2gyNf/lib/python3.9/site-packages/django/core/management/__init__.py", line 413, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/per/.virtualenvs/centraln-czG2gyNf/lib/python3.9/site-packages/django/core/management/base.py", line 354, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/per/.virtualenvs/centraln-czG2gyNf/lib/python3.9/site-packages/django/core/management/commands/runserver.py", line 61, in execute
    super().execute(*args, **options)
  File "/home/per/.virtualenvs/centraln-czG2gyNf/lib/python3.9/site-packages/django/core/management/base.py", line 398, in execute
    output = self.handle(*args, **options)
  File "/home/per/.virtualenvs/centraln-czG2gyNf/lib/python3.9/site-packages/django/core/management/commands/runserver.py", line 96, in handle
    self.run(**options)
  File "/home/per/.virtualenvs/centraln-czG2gyNf/lib/python3.9/site-packages/django/core/management/commands/runserver.py", line 103, in run
    autoreload.run_with_reloader(self.inner_run, **options)
  File "/home/per/.virtualenvs/centraln-czG2gyNf/lib/python3.9/site-packages/django/utils/autoreload.py", line 637, in run_with_reloader
    start_django(reloader, main_func, *args, **kwargs)
  File "/home/per/.virtualenvs/centraln-czG2gyNf/lib/python3.9/site-packages/django/utils/autoreload.py", line 622, in start_django
    reloader.run(django_main_thread)
  File "/home/per/.virtualenvs/centraln-czG2gyNf/lib/python3.9/site-packages/django/utils/autoreload.py", line 327, in run
    autoreload_started.send(sender=self)
  File "/home/per/.virtualenvs/centraln-czG2gyNf/lib/python3.9/site-packages/django/dispatch/dispatcher.py", line 180, in send
    return [
  File "/home/per/.virtualenvs/centraln-czG2gyNf/lib/python3.9/site-packages/django/dispatch/dispatcher.py", line 181, in <listcomp>
    (receiver, receiver(signal=self, sender=sender, **named))
  File "/home/per/.virtualenvs/centraln-czG2gyNf/lib/python3.9/site-packages/django/template/autoreload.py", line 41, in watch_for_template_changes
    for directory in get_template_directories():
  File "/home/per/.virtualenvs/centraln-czG2gyNf/lib/python3.9/site-packages/django/template/autoreload.py", line 14, in get_template_directories
    for backend in engines.all():
  File "/home/per/.virtualenvs/centraln-czG2gyNf/lib/python3.9/site-packages/django/template/utils.py", line 90, in all
    return [self[alias] for alias in self]
  File "/home/per/.virtualenvs/centraln-czG2gyNf/lib/python3.9/site-packages/django/template/utils.py", line 90, in <listcomp>
    return [self[alias] for alias in self]
  File "/home/per/.virtualenvs/centraln-czG2gyNf/lib/python3.9/site-packages/django/template/utils.py", line 81, in __getitem__
    engine = engine_cls(params)
  File "/home/per/.virtualenvs/centraln-czG2gyNf/lib/python3.9/site-packages/django/template/backends/django.py", line 25, in __init__
    options['libraries'] = self.get_templatetag_libraries(libraries)
  File "/home/per/.virtualenvs/centraln-czG2gyNf/lib/python3.9/site-packages/django/template/backends/django.py", line 43, in get_templatetag_libraries
    libraries = get_installed_libraries()
  File "/home/per/.virtualenvs/centraln-czG2gyNf/lib/python3.9/site-packages/django/template/backends/django.py", line 108, in get_installed_libraries
    for name in get_package_libraries(pkg):
  File "/home/per/.virtualenvs/centraln-czG2gyNf/lib/python3.9/site-packages/django/template/backends/django.py", line 123, in get_package_libraries
    raise InvalidTemplateLibrary(
django.template.library.InvalidTemplateLibrary: Invalid template library specified. ImportError raised when trying to load 'django_simple_bulma.templatetags.django_simple_bulma': cannot import name 'fontawesome_token' from partially initialized module 'django_simple_bulma.utils' (most likely due to a circular import) (/home/per/.virtualenvs/centraln-czG2gyNf/lib/python3.9/site-packages/django_simple_bulma/utils.py)
make: *** [Makefile:24: serve] Error 1

Note that this only happens sometimes, which is both puzzling and annoying. It can also happen when making a change to any .py file in the project, i.e. when the apps are reloaded. Any ideas? Thanks in advance.

Latest release seems to be overriding the Bulma default is-link color

Noticed that django-simple-bulma has changed the default "is-link" modifier color. The default used to be light blue, but with version 2.4.0, it has changed to a light purple (which is what I believe you use on your Python Dischord site). Haven't dug into the code yet, but I'm guessing maybe your site's css scheme might have been shipped.

Moving to Poetry for dependency management

To simplify the process of packaging and distribution to PyPI, we'd like to switch to Poetry for our dependency management. While this doesn't have priority at the moment, this is something we're planning for the near future.

AttributeError: module 'sass' has no attribute 'compile'

Hi,

You attend to one issue so quickly, you get one more... :-)

If sass is installed next to libsass, this error is raised in finders.py line 57 (also see). This is clearly not your fault and a I can imagine a reliable solution in the app being cumbersome.

Maybe a note in the Readme file would do it? This would help those of use who are not very well versed in web technologies.

Thanks,
Oguzhan

New release: 1.2.0

For 1.2.0, we should add support for Django 2.2, Django 3.0 and Python 3.8.

  • We've already merged #38, which should allow us to support Django 3.0.
  • This app probably already supports Python 3.8, but this needs to be tested.

So here's what needs to be done before we release the 1.2.0:

  • Test django-simple-bulma inside a Django 3.0 app running Python 3.8, and verify that it still works as expected.
  • Make a pull request to the setup.py file and add Django 2.2, Django 3.0, Python 3.8 to the list of classifiers.
  • Also in the same pull request in setup.py, bump the version of django-simple-bulma to 1.2.0

Once this has been done, we can do a release to PyPI.

Missing files in v2.0.0 release files

Updating to v2.0.0, and it looks like the submodules you're using now aren't included in the tarball. Since I get the following error when attempting to run django.

FileNotFoundError: [Errno 2] No such file or directory: '/home/bpepple/.local/share/virtualenvs/metron-UZX73b7p/lib/python3.6/site-packages/django_simple_bulma/bulma/sass'

Pulled the tarball down from the release page, and verified the bulma folder is empty.

Bulma Calendar widget shows incorrect value

Using the Bulma Calendar widget and notice that it's showing the incorrect date on a form.

Below screenshot shows the values it should be:
Screenshot from 2022-03-05 15-39-13

When updating the object the Bulma-Calendar widget shows the following:
Screenshot from 2022-03-05 15-39-25

It appears to be showing a day earlier than the value of the input:
Screenshot from 2022-03-05 15-44-46

Did a quick look at upstreams bugs and didn't see any for this bug, but when I get some free time I'll give a more thorough search.

Use async to defer loading of js, preload CSS.

When we add the bulma-related JS scripts and the CSS stylesheets into the , we don't enable any kind of deferment or preloading.

This means that sites using django-simple-bulma are taking a performance hit, because these are render-blocking resources.

To fix this, these should be inserted with async and preloading parameters so that they will not block the loading of the page itself.

Alternative variables dict in BULMA_SETTINGS

In some cases, a website will want to have two themes, e.g. a dark theme and a light theme. To do this while using this plugin is tricky because all the scss variables are compiled at startup. But here's what we can do:

  • If an alt_variables dict is present in BULMA_SETTINGS, we compile two css files, bulma.css and bulma_alt.css
  • We create a template tag for adding this other css file as well, something like {% bulma_alt %}

Now the client can simply add this second dict of variables and define the dark theme that way, and then add some client logic to allow switching between them by switching which template tag is called in the templates.

CI: Release pipeline/docs

  • Finish up CI by setting up a release pipeline on Azure
  • Document our release process (On a wiki - perhaps the meta repo)

Using multiple themes

Currently, I attempting to use this project's multiple themes functionality to create a dark and light mode.

While trying to do this am I facing issues with sending duplicate .js files, as the tag has been used twice.
With this .js being served twice, it is creating two event handlers for the navbar burger menu on the page and is causing it to stop working.

Django template:

{% bulma %}
{% bulma 'dark' %}

Firefox network tab when loading the page:
image

I am unsure how Django extensions work, but having a way to ensure that only one .js file is served would allow me to implement the functionality I want.


This functionality for switching themes could be implemented into this package also, as it would be a nice to have for other users of django-simple-bulma

Carousel extension is not working

Hi,

I would like to use the carousel extension, but somehow I'm not able to load the carousel properly. I'm getting the images below each other. The following I have setup.

base.html

{% load static %}

{% load django_simple_bulma %} {% bulma theme %} {% font_awesome %} <title>{% block title %}{% endblock %}Pocketminerals</title> <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script> <script src="{% static 'js/scripts.js' %}"></script>
<body>

	<nav class="navbar is-dark" id="navbarapp">
		<div class="container is-fullhd">
		<div class="navbar-brand">
			<a class="navbar-item" href="{% url 'frontpage' %}">Saul Gadgets</a>

			<a @click="toggleMenu()" role="button" class="navbar-burger burger" aria-label="menu" aria-expanded="false" data-target="main-navbar">
				<span aria-hidden="true"></span>
				<span aria-hidden="true"></span>
				<span aria-hidden="true"></span>
			</a>
		</div>

		<div id="main-navbar" class="navbar-menu" :class="{ 'is-active': menuClass }">
			<div class="navbar-start">
				<div class="navbar-item">
					<form method="get" action="{% url 'search' %}">
						<div class="field has-addons">
							<div class="control">
								<input type="text" class="input" placeholder="Search..." name="query">
							</div>
							<div class="control">
								<button class="button is-success">Search</button>
							</div>
						</div>
					</form>
				</div>
			</div>
			<div class="navbar-end">
				{% for category in menu_categories %}
					{% if not category.children.all %}
                    	<a href="{% url 'category_detail' category.slug %}" class="navbar-item">{{ category.title }}</a>
					{% else %}
						<div class="navbar-item has-dropdown is-hoverable">
							<a href="{% url 'category_detail' category.slug %}" class="navbar-link">{{ category.title }}</a>

							<div class="navbar-dropdown">
								{% for subcategory in category.children.all %}
									<a href="{% url 'category_detail' subcategory.slug %}" class="navbar-item">{{ subcategory.title }}</a>
								{% endfor %}
							</div>
						</div>
					{% endif %}
				{% endfor %}

				<div class="navbar-item">
					<a href="{% url 'cart' %}" class="button is-primary">Cart ([[ numItems ]])</a>
				</div>

				{% if request.user.is_authenticated %}
					<div class="navbar-item">
						<a href="{% url 'myaccount' %}" class="button is-light">My account</a>
					</div>
				{% else %}
					<div class="navbar-item">
						<div class="buttons">
							<a href="{% url 'signup' %}" class="button is-primary"><strong>Sign up</strong></a>
							<a href="{% url 'login' %}" class="button is-light">Log in</a>
						</div>
					</div>
				{% endif %}
			</div>
		</div>
		</div>
	</nav>
{% block content %} {% endblock %}
	</div>

	{% include 'parts/newsletter.html' %}

	<footer class="footer">
		<div class="container is-fullhd">
		<div class="columns">
			<div class="column is-2">
				<h2 class="subtitle">Saul Gadgets</h2>
			</div>

			<div class="column is-8">
				<a href="{% url 'contact' %}" class="navbar-item">Contact</a>
				<a href="{% url 'about' %}" class="navbar-item">About</a>
			</div>
		</div>
		</div>
	</footer>


			<!-- <script src="{% static 'js/scripts.js' %}"></script> -->
	<script src="https://unpkg.com/[email protected]/dist/vuex.js"></script>
	<script>
		var store = new Vuex.Store({
			state: {
				numItems: {{ cart.get_total_length }},
				totalCost: {{ cart.get_total_cost }}
			},
			mutations: {
				increment(state, quantity) {
					state.numItems += quantity;
				},
				changeTotalCost(state, newCost) {
					state.totalCost += newCost
				}
			}
		});

		var navbarapp = new Vue({
			el: '#navbarapp',
			delimiters: ['[[', ']]'],
			store: store,
			data () {
				return {
					menuClass: false
				}
			},
			computed: {
				numItems: function() {
					return store.state.numItems
				}
			},
			methods: {
				toggleMenu() {
					console.log('toggleMenu');

					this.menuClass = !this.menuClass;
				}
			}
		});

	</script>

	{% block scripts %}
	{% endblock %}
</body>

=======================
scripts.js

bulmaCarousel.attach('#carousel-demo', {
slidesToScroll: 1,
slidesToShow: 3
});

=======================
settings.py

(.....)

Custom settings for django-simple-bulma

BULMA_SETTINGS = {
"extensions": [
"all"
],
"variables": {
"primary": "#000000",
"size-1": "6rem",
},
"alt_variables": {
"primary": "#fff",
"scheme-main": "#000",
},
"output_style": "compressed",
"fontawesome_token": "e761a01be3",
}

=======================

I hope someone can help me.

Thank you!

Kind regards,

Joshua

Tuple() typehint instead of Tuple[] in SimpleBulmaFinder.list

  File "C:\Users\maku\.virtualenvs\friendly-frogs-ICo_ojhS\lib\site-packages\django_simple_bulma\finders.py", line 17, in <module>
    class SimpleBulmaFinder(BaseFinder):
  File "C:\Users\maku\.virtualenvs\friendly-frogs-ICo_ojhS\lib\site-packages\django_simple_bulma\finders.py", line 171, in SimpleBulmaFinder
    def list(self, _: List[str]) -> Tuple(str, FileSystemStorage):
  File "c:\users\maku\appdata\local\programs\python\python38-32\lib\typing.py", line 724, in __call__
    raise TypeError(f"Type {self._name} cannot be instantiated; "
TypeError: Type Tuple cannot be instantiated; use tuple() instead

Getting this error when using py manage.py runserver.
Looks like the typehint for the return type with Tuple should be Tuple[str, FileSystemStorage] instead of using parentheses.

v2.0 release

We're almost ready for a v2.0 release. Since this will include major changes, we're bumping the major version for this release.

Changes

  • Bulma and all bulma extensions are now submodules, which means we no longer need to do manual upgrades of these in the future.
  • Some bulma extensions have been removed, others updated. The README now contains a complete list of which extensions are supported.
  • We will now use the minified JS for most extensions by default, to improve performance slightly.
  • JS will now be loaded with the defer option, another slight performance improvement.
  • Our linting toolchain has grown stricter, and now includes the pep8-naming plugin.
  • We now support FontAwesome 6 kits, both for Free and Pro versions! See our readme for instructions on how to set this up. If you don't set this up, FontAwesome v5.14.0 will be used by default.
  • We now provide the JS required to be able to have clickable dropdown elements in Bulma, so you don't need to write this yourself. Simply add the bulma-dropdown extension to your BULMA_SETTINGS.

Allow this app to load additional sass files

Some users may want to customize their site beyond what can be done by changing bulma variables. For this, we could offer the option of loading additional sass files. I'm not sure how best to do this, so I'm inviting anyone reading this to discuss it in this issue. Here are a couple of potential ways:

  • Take a new BULMA_SETTINGS configuration parameter called additional_sass, which is a list of PosixPaths pointing at additional sass files that django-simple-bulma should load along with bulma. This means it would add that css onto the already huge css file that bulma + extensions makes, so it's not a very optimized solution, but since most users probably won't be adding more than a couple of lines of their own sass anyway, that might be okay.

  • Tell the user to put their .sass files in a specific location ($root/static/sass/ or something) and then compile all the files in this folder to css files of the same name whenever collectstatic is run. Then the user would manually load these by just using {% static "css/mycoolfile.css" %}. Saves the user the hassle of dealing with libsass directly, but isn't as smooth as just loading it with that {% bulma %} tag.

  • Tell the user to put all their desired additional sass into a specific file in a specific location, like $project_root/static/bulma_additional.sass. Then just import that file at the end of the bulma.sass. This is pretty easy and less error prone, but might be messy if the user needs a lot of sass. Again, though, I think that's probably rare.

Incompatibility with django-sass-processor

When making use of django-sass-processor, the automatic compilation of sass files referred to in templates using their special template tags works flawlessly, regardless of whether django-simple-bulma is in use or not.

However, their python manage.py compilescss command breaks, with the following - fairly weird - error:

(frontend) [gdude@arch frontend]$ DEBUG=1 python manage.py compilescss
........................................................................................................................................................................Traceback (most recent call last):
  File "manage.py", line 23, in <module>
    main()
  File "manage.py", line 19, in main
    execute_from_command_line(sys.argv)
  File "/home/gdude/.virtualenvs/frontend-1cyhH2HW/lib/python3.7/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
    utility.execute()
  File "/home/gdude/.virtualenvs/frontend-1cyhH2HW/lib/python3.7/site-packages/django/core/management/__init__.py", line 375, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/home/gdude/.virtualenvs/frontend-1cyhH2HW/lib/python3.7/site-packages/django/core/management/base.py", line 323, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/home/gdude/.virtualenvs/frontend-1cyhH2HW/lib/python3.7/site-packages/django/core/management/base.py", line 364, in execute
    output = self.handle(*args, **options)
  File "/home/gdude/.virtualenvs/frontend-1cyhH2HW/lib/python3.7/site-packages/sass_processor/management/commands/compilescss.py", line 157, in handle
    self.parse_source(py_source)
  File "/home/gdude/.virtualenvs/frontend-1cyhH2HW/lib/python3.7/site-packages/sass_processor/management/commands/compilescss.py", line 214, in parse_source
    self.compile_sass(sass_filename, sass_fileurl)
  File "/home/gdude/.virtualenvs/frontend-1cyhH2HW/lib/python3.7/site-packages/sass_processor/management/commands/compilescss.py", line 292, in compile_sass
    content = sass.compile(**compile_kwargs)
  File "/home/gdude/.virtualenvs/frontend-1cyhH2HW/lib/python3.7/site-packages/sass.py", line 689, in compile
    raise IOError('{!r} seems not a file'.format(filename))
OSError: '/home/gdude/.local/share/virtualenvs/frontend-1cyhH2HW/lib/python3.7/site-packages/django_simple_bulma/path' seems not a file

The path file referenced at the end of the traceback doesn't actually exist.

I'm not sure if this is a problem with django-simple-bulma or django-sass-processor, so I'll be opening this issue on both repos.

jrief/django-sass-processor#120

Support for custom FontAwesome kits

With FontAwesome 6, CDN URLs are now personalized, which means that in order to support FontAwesome 6, we need users to input a token into BULMA_SETTINGS.

How does FontAwesome 6 work, then?

Well, it lets you create a kit on a page that looks like this:
image

And whether you are a Pro user or a Free user, the kit URL always looks the same:
<script src="https://kit.fontawesome.com/IDENTIFIER.js" crossorigin="anonymous"></script>

Where IDENTIFIER is some hex value.

Okay, so what do we do?

Here's what I'm thinking:

  • If the user provides a fontawesome_token, we create a CDN url like the one above.
  • If no token is provided, we just do what we're doing now - put a CDN to FontAwesome 5. This ensures backwards compatibility, and will work for users who don't need the latest icons and features.
  • We update the README with a guide for how to set up FontAwesome 6 Free and where to get this token. We also document that this is optional, and what will happen if you don't specify it.

CompileError() with Powershell

Hi,

I'm getting the following error with Powershell. This is likely because of platform insensitive paths in the finder code.

File "C:\Users\<username>\envs\djenv\lib\site-packages\sass.py", line 709, in compile
    raise CompileError(v)
       jango_simple_bulma/bulma.sass.ort not found or unreadable: C:Users<username>nvs
        on line 6 of stdin
>> @import "C:\Users\<username>\envs\djenv\Lib\site-packages\django_simple_bulma/bulm

Best,
Oguzhan

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.