Closed ichik closed 8 years ago
I've created duplicating folder for now, so you won't get 404 I guess.
Ah actually i think this is something I've just fixed. Try adding css
to the list of fallback_types
in your system.yaml
. That should get you working until the next release.
Hm, nope, that didn't work.
For reference part of system.yaml:
pages:
theme: GrvSqncBrk
markdown_extra: true
process:
markdown: true
twig: true
redirect_default_route: true
fallback_types: [css,png,jpg,gif]
if you add that, then this url: http://sqncbrk.com/user/pages/metroidvanias/custom.css
should work. Basically before any file that was in a page route, would fallback and be downloaded/streamed by Grav. This was considered a bit of a security risk, so i created a fallback_types list to 'whitelist' the types.
However, this only had images in by default and kinda broke other types such as .css
, so... I changed it recently in the develop branch so any media type is considered a valid type to fallback to, and there is a new whitelist that will override that list if you want to restrict it even more.
In the meantime, adding css to your fallback types should definitely fix this. There was another issue reported (but for .pdf) and this did work.
This was the issue, basically the same problem. https://github.com/getgrav/grav/issues/452
BTW you might need to back out your folder fix.
Actually i am seeing someing weird.. your url should be: http://sqncbrk.com/metroidvanias/custom.css
hold on...
That is because I've specifically asked for /user/pages:
{% do assets.add('/user/pages' ~ page.url() ~ '/custom.css',10,false) %}
simple page.url didn't work so I've resorted to this some time ago.
Anyway, maybe fallback_types is dependant on some other settings?
No this should never of worked. /user/pages
is basically going directly to the file, which is fine.. however, page.url
is going to get the slug for the route, not the path.. these are not the same. Just trying to find a better solution. Stand by...
Checked if requesting http://sqncbrk.com/metroidvanias/custom.css works — it doesn't somehow. While say http://sqncbrk.com/bloodborne/custom.css works.
So it may have something to do with numeric prefix after all.
Requesting http://sqncbrk.com/02.metroidvanias/custom.css doesn't work either though.
where is the actual css file your trying to reach??? what 'should' work?
Ok this should work with numeric and non-numeric folders:
{% if page.header.customcss %}
{% set path = base_url ~ '/' ~ page.filePathClean|replace({('/'~page.name): ''}) %}
{% do assets.add(path ~ '/custom.css',10,false) %}
{% endif %}
BTW i've added this to Page object to make it a little easier going forward:
/**
* Returns the clean path to the page file
*/
public function relativePagePath()
{
$path = str_replace('/'.$this->name, '', $this->filePathClean());
return $path;
}
Basically does that replace bit automatically so after this is in Grav (next version) you can just do this:
{% if page.header.customcss %}
{% do assets.add(base_url ~ '/' ~ page.relativePagePath ~ '/custom.css',10,false) %}
{% endif %}
Actual CSS was is 02.metroidvanias. Thanks for your help
I use custom CSS loading for some pages like this:
It worked previously for pages with numbers in folder name previously, but now it returns 404.
e.g.: http://sqncbrk.com/user/pages/metroidvanias/custom.css but http://sqncbrk.com/user/pages/02.metroidvanias/custom.css
What gives? Is there a way to request page slug with number?