Flags URL

48 views
Skip to first unread message

PhilR

unread,
Sep 12, 2023, 8:29:54 PM9/12/23
to gcd-tech
I did manage to get my dev env to work, on windows, still not quite sure what the magic formula is.  I dropped the database, did the migrate, skipped the loadusers, loaded the datadump and it seemed to work.  However I'm going to try it on a clean setup to see if I can figure out the magic sequence and then I'll update the setup docs as needed.  I'll also set up my Linux env and try it out there.

The windows env works well enough for me to start to poke around the system.

I did notice that the flags were not displaying in the UI.

Looking at the image path I can see that there is a double forward slash in the path.  On Linux this is ignored which is why I suspect no one has worried about this, however on Windows it causes an error and won't load.

For example the URL for the flag on a series page is:

<img src="https://files1.comics.org/static//img/gcd/flags/us.png" alt="United States" class="embedded_flag">

Which appears to be caused by this code:

gcd-django/templates/gcd/bits/series_issue_header.html

line 48:     <img src="{{ STATIC_URL }}/img/gcd/flags/{{ series.country.code|lower }}.png" alt="{{ country }}" class="embedded_flag">

The STATIC_URL is set in settings.py as far as I can see and does already end in a "/".  I see that other uses of the STATIC_URL in the templates and other code does not add an additional slash when constructing the path. 

Similar code with an extra "/" appears in a few other places, for example the countries.html template.


    <img src="{{ STATIC_URL }}/img/gcd/flags/{{ country.code|lower }}.png" alt=" " class="embedded_flag"> ({{ country.code|lower }}) {{ country }}<br/>

I didn't find any discussion of this in the groups, so just wanted to check in to see if this is a known issue and if there are any concerns with making this change.

Thanks
Phil

PhilR

unread,
Sep 12, 2023, 9:29:02 PM9/12/23
to gcd-tech
The code in gcd-django/apps/gcd/templatetags/credits.py
416:  def show_country_info_by_code(code, name):
417:    src = 'src="%s/img/gcd/flags/%s.png"' % (settings.STATIC_URL,
417:                                             code.lower())

also appears to insert an extra "/"

removing the / here fixed the flags display in a number of spots, search results, issue details etc

I still don't know enough about how the system works so this is definitely me just "hacking" at it but these changes seem to fix the issues on my setup.  However let me know if there would be any unintended side-effects of making these changes.

Phil

Jochen G.

unread,
Sep 17, 2023, 2:49:57 AM9/17/23
to gcd-...@googlegroups.com
I think that these are leftovers (I dimly remember STATIC_URL changed in
view of final /) and it can be changed.
> <https://files1.comics.org/static>//img/gcd/flags/us.png"
> alt="United States" class="embedded_flag">
>
> Which appears to be caused by this code:
>
> gcd-django/templates/gcd/bits/series_issue_header.html
>
> line 48:     <img src="{{ STATIC_URL }}/img/gcd/flags/{{
> series.country.code|lower }}.png" alt="{{ country }}"
> class="embedded_flag">
>
> The STATIC_URL is set in settings.py as far as I can see and does
> already end in a "/".  I see that other uses of the STATIC_URL in
> the templates and other code does not add an additional slash when
> constructing the path.
>
> Similar code with an extra "/" appears in a few other places, for
> example the countries.html template.
>
> https://github.com/GrandComicsDatabase/gcd-django/blob/beta/templates/gcd/admin/countries.html <https://github.com/GrandComicsDatabase/gcd-django/blob/beta/templates/gcd/admin/countries.html>
>
>     <img src="{{ STATIC_URL }}/img/gcd/flags/{{ country.code|lower
> }}.png" alt=" " class="embedded_flag"> ({{ country.code|lower }}) {{
> country }}<br/>
>
> I didn't find any discussion of this in the groups, so just wanted
> to check in to see if this is a known issue and if there are any
> concerns with making this change.
>
> Thanks
> Phil
>
> --
> You received this message because you are subscribed to the Google
> Groups "gcd-tech" group.
> To unsubscribe from this group and stop receiving emails from it, send
> an email to gcd-tech+u...@googlegroups.com
> <mailto:gcd-tech+u...@googlegroups.com>.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/gcd-tech/446c8787-8160-4a86-a0c2-41c3a72b0c02n%40googlegroups.com <https://groups.google.com/d/msgid/gcd-tech/446c8787-8160-4a86-a0c2-41c3a72b0c02n%40googlegroups.com?utm_medium=email&utm_source=footer>.

Richard

unread,
Sep 17, 2023, 3:46:23 PM9/17/23
to gcd-...@googlegroups.com
In article <446c8787-8160-4a86...@googlegroups.com> you write:
>The code in gcd-django/apps/gcd/templatetags/credits.py
>416: def show_country_info_by_code(code, name):
>417: src = 'src="%s/img/gcd/flags/%s.png"' % (settings.STATIC_URL,
>417: code.lower())
>
>also appears to insert an extra "/"
>
>removing the / here fixed the flags display in a number of spots, search
>results, issue details etc

I saw this same issue.

I had a patch for this locally but I haven't submitted a pull request
for it yet.

Feel free to submit your change as a pull request.
--
"The Direct3D Graphics Pipeline" free book <http://tinyurl.com/d3d-pipeline>
The Terminals Wiki <http://terminals-wiki.org>
The Computer Graphics Museum <http://computergraphicsmuseum.org>
Legalize Adulthood! (my blog) <http://legalizeadulthood.wordpress.com>

PhilR

unread,
Sep 18, 2023, 9:03:23 AM9/18/23
to gcd-tech
Thank you both for the feedback.  I'll prepare a pull request later today.

PhilR

unread,
Sep 18, 2023, 12:26:47 PM9/18/23
to gcd-tech
I created an issue (#616) and then a pull request (#617).

I didn't see how to assign the issue to myself in the issues workflow, is that a restricted operation?

Also this is my first usage of github so please let me know if there was anything else I should have done or done differently. 

Reply all
Reply to author
Forward
0 new messages