lemonsaurus / django-simple-bulma

Django application to add the Bulma CSS framework and its extensions
MIT License
137 stars 17 forks source link

Full path in js files #9

Closed wonkybream closed 5 years ago

wonkybream commented 5 years ago

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.

gdude2002 commented 5 years ago

Hey, thanks for your ticket.

Everyone's super busy right now with Christmas and other winter festivities, but I'll assign your ticket and we'll take a look then we can.

lemonsaurus commented 5 years ago

oh yeah I'll have a look at this in a couple of days, @wonkybream. It's probably just a bug, this hasn't been extensively tested yet. thanks for the thorough bug report, though.

lemonsaurus commented 5 years ago

Yeah @wonkybream, I had a quick look now and it looks like you're absolutely right about this being an oversight on my end. it should definitely be filename.name. I'm actually surprised I got it to work at all with the full file path being used. Perhaps the javascript was never working, I'm not sure it's been tested at all.

If you submit a pull request, I'd be happy to accept it. Otherwise, I can make this change and get a new version pushed to PyPI some day later this week when my house isn't full of visiting family members. :christmas_tree: :santa:

wonkybream commented 5 years ago

Glad to help, if I get some free time from all these relatives and eating fests I'll try to do pull requests.

Great holidays and thanks again for great project!

Edit: I had enough time to fix this and I'll test this during next 24 hours and then I'll create pull request.

lemonsaurus commented 5 years ago

@wonkybream that's great! Thanks so much for contributing to this, and I'm very happy that you're testing it as well.

If you want to join us over at the Python Discord server, I'd be happy to give you a Contributor role and access to our internal dev channels as thanks for making this contribution. Just poke me, my tag over there is lemon#0001.

wonkybream commented 5 years ago

I created pull request and hopefully it went okay, it's my first ever. https://github.com/python-discord/django-simple-bulma/pull/10

If there's anything to modify or fix I'm happy to do it again as a way you'd like it to be done.

gdude2002 commented 5 years ago

Looks good to me, but we require two approvals - I'm sure someone will be along presently

lemonsaurus commented 5 years ago

Solved in 1.0.4.