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

CSS not injected correctly in some ZIM files #230

Closed
mossroy opened this issue May 10, 2017 · 7 comments
Closed

CSS not injected correctly in some ZIM files #230

mossroy opened this issue May 10, 2017 · 7 comments
Assignees
Labels

Comments

@mossroy
Copy link
Contributor

mossroy commented May 10, 2017

As initially reported in #220 by @julianharty :

When I use the content I create (from github.com/julianharty/testing-heuristics) the CSS doesn't get applied. When we generate the content we use zimwriterfs --uniqueNamespace ... so that the CSS can be found (well sort of at the moment). However, it seems that might cause some knock-on complications as the mime-type is now reported by Google Chrome as text/html (see below for the message Chrome Developer Console shows). The bug may be in zimwriterfs I'll cross-link the relevant issue. openzim/libzim#15 I'll also zip the ZIM file and add it here (I can't attach it directly with a .zim extension).

Resource interpreted as Stylesheet but transferred with MIME type text/html: "chrome-extension://donaljnlmapmngakoipdmehbfcioahhk/www/A/style.css".

Here's the ZIM file I used. It's zipped so will need unzipping before using it.
th20170509.zim.zip

OK, a quick test using my kiwix-apache module (which logs the filename and mime-type in Apache Server's error.log) indicates that the mime-type is set correctly for ./A/style.css (at least as far as I can tell)

[Tue May 09 07:50:59.397995 2017] [kiwix:notice] [pid 19337:tid 140382893475584]  ZIM file including path: /home/julian/Downloads/th20170509.zim
[Tue May 09 07:50:59.398025 2017] [kiwix:notice] [pid 19337:tid 140382893475584] full url = /kiwix/A/style.css, kiwix url = A/style.css
[Tue May 09 07:50:59.398182 2017] [kiwix:notice] [pid 19337:tid 140382893475584] contentType:[text/css]

The CSS is being applied correctly e.g. if I visit http://localhost/kiwix/A/I%20SLICED%20UP%20FUN.html (which will only work for you if you've got kiwix-apache setup to use the above ZIM file).

@mossroy mossroy added the bug label May 10, 2017
@mossroy mossroy self-assigned this May 10, 2017
@mossroy mossroy added this to the v2.1 milestone May 10, 2017
@mossroy
Copy link
Contributor Author

mossroy commented May 10, 2017

I suspect the CSS is not detected properly by kiwix-html5 (in jQuery mode), and not injected at all.
It's certainly because it expects the stylesheets to be in a subdirectory of /-/ (like in wiki* ZIM files), instead of /A/
It's probably wrong to assume that.

@mossroy
Copy link
Contributor Author

mossroy commented May 11, 2017

When I read http://www.openzim.org/wiki/ZIM_file_format#Namespaces , I see that CSS should be in the - namespace instead of A
Maybe this ZIM file does not comply this spec? (and maybe libzim implementation is more tolerant than kiwix-html5)

@julianharty
Copy link
Contributor

(FYI I've extracted the following and repeated it from notes I made on one of my issues so you don't have to wander over there to follow the story julianharty/testing-heuristics#8)

Background context

A couple of years ago, partly to help us get the PhET simulations to work, Emmanuel either implemented or explained another approach where all the files would be put in the ./A/ namespace to enable to ZIM file to 'work' despite the complex implementation that heavily relied on JavaScript, etc. Note: there are other variations of ZIM files with absolute links. Some implementations (including kiwix-serve and kiwix-apache rewrite those links before serving content from these ZIM files (some of the non-Wikimedia materials e.g. Wikipedia for Schools uses this internal structure).

Emmanuel has opened a ticket to investigate further changes to the ZIM file format openzim/libzim#15

@mossroy
Copy link
Contributor Author

mossroy commented Jan 3, 2018

This needs to be tested again : it might have been fixed in version 2.2

@mossroy
Copy link
Contributor Author

mossroy commented Jan 4, 2018

This has not been fixed in 2.2.

@mossroy mossroy modified the milestones: v2.2, v2.4 Jan 4, 2018
@Jaifroid
Copy link
Member

Jaifroid commented Mar 4, 2020

I think we should close this and open a new issue relating to upcoming changes in openzim/libzim#15 (removal of namespaces). I think we will need to address the general issue of arbitrary content being placed in a 'flat' structure, even though I don't currently understand the advantage of doing this...

@mossroy
Copy link
Contributor Author

mossroy commented Mar 4, 2020

I agree.
And, as far as I know, this bug only occurs in jQuery mode, and only on this specific ZIM file, for which the CSS style is not in the right namespace.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants