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 background path problem '../' #21

Closed
nikmauro opened this issue Jul 30, 2013 · 32 comments
Closed

CSS background path problem '../' #21

nikmauro opened this issue Jul 30, 2013 · 32 comments
Assignees
Labels

Comments

@nikmauro
Copy link

Hello the original css code is background-image: url('../img/logo.png'); and after Munee the css code chenge to background-image: url(/themes/default/img/logo.png); "WRONG PATH AND IMAGES NOT WORKING".

in the same CSS if the background path is 'images/demo.jpg' after Munee the code path remain the same and working.

The fixRelativeImagePaths have some issues.

@meenie
Copy link
Owner

meenie commented Jul 30, 2013

Hi @nikmauro,

The reason I have the fixRelativeImagePaths method is when you are concatenating multiple styles into one request. When doing that, the browser will use the relative path of the first CSS file in the comma separated list. So for for example, if you have a couple stylesheets included like this:

<link href="/css/style1.css,/css/sub-folder/style2.css" rel="stylesheet">

The relative paths inside of style2.css of something like ../../img/background.png will resolve to an unreachable image since the browser thinks that the path to the style2.css is just /css/style2.css.

Now, to fix your issue, you may have to define the correct WEBROOT in your munee.php dispatcher file. To do that, add the following code before you include the autoload.php file:

define('WEBROOT', __DIR__);

This should make sure Munee has the correct webroot.

If that doesn't work, please let me know what the correct path to the /themes/default/img/logo.png should be. Or better yet, try to give me a visualisation of what the directory structure is in your application is.

@meenie
Copy link
Owner

meenie commented Aug 6, 2013

Hi Again @nikmauro,

Just wondering if you had any luck with this?

Cheers,
cody

@ddtraceweb
Copy link

hello,

i have same problem with bootstrap image compress in multiple css files...

I have set define('WEBROOT', DIR); in munee.php but nothing...

@meenie
Copy link
Owner

meenie commented Aug 13, 2013

Hi @ddtraceweb,

Sorry, I was out of the state over the weekend and didn't get much of a chance to connect to the internet.

As for fixing your issues with bootstrap, I don't recall any images being distributed with bootstrap. They use Glyphicons (a font) instead.

As for putting in define('WEBROOT', __DIR__);, are you adding that before you include the autoload.php file? Or after? It needs to be before you include it, or it won't work.

Would you please provide the folder structure of your assets and what the <link> tag looks like in your index.html file?

Cheers,
cody

@ddtraceweb
Copy link

i have this :

#munee.php

define('WEBROOT', __DIR__);
define('MUNEE_CACHE', dirname(__FILE__).'/../init/cache');

// Include the composer autoload file
require dirname(__FILE__) . '/../vendor/autoload.php';
// Echo out the response
echo \Munee\Dispatcher::run(
    new \Munee\Request(array(
    ))
);

but the images un compile css file won't work, same with js compile.

@meenie
Copy link
Owner

meenie commented Aug 17, 2013

@ddtraceweb - That all looks right to me, as long as the init/cache folder is writeable by the server. Have you tried requesting a css/js/img file directly in your browser? In chrome you can type in the address to your assets directly and they will show their contents in the viewport. So if you had style.less located under /css/style.less, you can type into your browser http://example.com/css/style.less and you should see the compiled CSS version of that file. If the file is not compiled and still looks like LESS, then the issue is with your .htaccess file. Just to make sure, try typing in the url like this: http://example.com/munee.php?files=/css/style.less to see if that works.

That should give you a starting point as to why something isn't working.

@meenie
Copy link
Owner

meenie commented Aug 19, 2013

@ddtraceweb - Just wondering how it's going with this?

@ddtraceweb
Copy link

sorry for time of response, i have this :

<link rel="stylesheet" href="/munee.php?files=/assets/components/bootstrap/css/bootstrap.css,/assets/components/bootstrap/css/bootstrap-responsive.css,/assets/components/icons/css/font-awesome.css,/assets/components/jquery/css/ui-lightness/jquery-ui-1.9.0.custom.css,/assets/components/jqueryuibootstrap/css/custom-theme/jquery-ui-1.10.3.custom.css,/assets/components/google-code-prettify/src/prettify.css&minify=true">

compiling is ok, minify too, but he don't find images icons in bootstrap or other images.

i think the problem is for resolve : background-image: url("../img/glyphicons-halflings-white.png"); in .css

@meenie
Copy link
Owner

meenie commented Aug 24, 2013

Can you please paste the section of the css where Munee rewrites the URL's that link to the fonts and images? I just want to see what path is being written to see if something is going wrong.

@ddtraceweb
Copy link

i have found the problem :

@font-face {
    font-family: 'FontAwesome';
    src: url('../font/fontawesome-webfont.eot');
    src: url('../font/fontawesome-webfont.eot?#iefix') format('eot'), url('../font/fontawesome-webfont.woff') format('woff'), url('../font/fontawesome-webfont.ttf') format('truetype'), url('../font/fontawesome-webfont.svg#FontAwesome') format('svg');
    font-weight: normal;
    font-style: normal;
}

this url are not rewrite with the correct link... I think it's param "src" not interpreted.

@meenie
Copy link
Owner

meenie commented Aug 24, 2013

I'll have a look at this tomorrow. I believe the rewrite is a bit buggy at the moment.

@ghost ghost assigned meenie Aug 24, 2013
meenie added a commit that referenced this issue Oct 17, 2013
…correctly. This should fix issue #32.  I also implemented the feature requests in issue #24, issue #27, and issue #21.
@meenie
Copy link
Owner

meenie commented Oct 17, 2013

Hi @ddtraceweb,

I fixed this issue. Sorry it took so long.

@meenie meenie closed this as completed Oct 17, 2013
@geroyche
Copy link

for me the issue is not fixed.
WEBROOT is correct, but "../pics/test.jpg" in css background images becomes "/pics/test.jpg" when it should (probably) become "pics/test.jpg".
right now the images are not found.
this is beta server. the url is along the lines of beta.xxx.com/customers/customername/pics/test.jpg
and currently backgroud images 404 because the url munee generates is beta.xxx.com/pics/test.jpg

rewritebase is /customers/customername

edit: apparently it's a bit more complicated.
a simple
$filePath=substr($filePath,1);
leads to beta.xxx.com/customers/customername/css/pics/test.jpg
which also wrong, as pics is not a child of css, but a sibling,

@meenie
Copy link
Owner

meenie commented Oct 17, 2013

Hi @geroyche,

Where is your css file located? I'm guessing it's http://beta.xxx.com/customers/style.css. And if you had a background style in there of something like background: url(../pics/test.jpg); it will rewrite that to background: url(/pics/test.jpg); because it goes up one directory. Now if you move that style sheet to beta.xxx.com/customers/customername/css/style.css and kept the same rule, it would convert the url to background: url(/customers/customername/pics/test.jpg).

I hope this makes sense.

As for the rewritebase, Munee does not take that into account.

Cheers,
cody

@geroyche
Copy link

it makes sense as a deduction, but it's wrong in my case ;)

because the css file is already at
beta.xxx.com/customers/customername/css/style.css
and the rules are "background: url(../pics/test.jpg)"
as in "traverse up to beta.xxx.com/customers/customername/ and then down into /pics"...

and yet, as i said ... default munee behaviour results in "beta.xxx.com/pics/test.jpg"

@meenie
Copy link
Owner

meenie commented Oct 17, 2013

@geroyche which version of Munee do you have installed? If you run php composer.phar show -i, what version of Munee does it say that is installed?

@meenie meenie reopened this Oct 17, 2013
@geroyche
Copy link

@meenie i installed from the zip file. no composer.phar to run.
but i downloaded it this morning,
i just updated
\meenie\munee\src\Munee\Asset\Type\Css.php
to the very latest version (i had the one before, the one that had the bug fixed), and it's still not working.

@meenie
Copy link
Owner

meenie commented Oct 17, 2013

@geroyche I think you may need to delete your cache, if you haven't done so already. Inside meenie/munee/cache, delete the CSS folder and then refresh. When updating without Composer, it doesn't delete those files and it could be serving an older compiled version of the stylesheet.

If that doesn't work, does Munee think that your webroot is beta.xxx.com/customers/customername/? To find out, just after you include the autoload.php and before echo \Munee\Dispatcher::run(new \Munee\Request()); in your dispatcher, could you please do echo WEBROOT; exit; and let me know what it is?

@geroyche
Copy link

@meenie

webroot is
/path1/path2/path3/beta/customers/customername
url is beta.xxx.com/customers/customername/

still the same issue, with cache deleted.
i.e. "../" becomes "/", which causes
beta.xxx.com/customers/customername/pics/test.jpg
to become
/beta.xxx.com/pics/test.jpg

@meenie
Copy link
Owner

meenie commented Oct 17, 2013

Can you try and add this code right before you include the autoload.php file?

define('WEBROOT', '/path1/path2/path3/beta');

Just replace /path1/path2/path3 with the actual path. After you do that, let me know if it starts working. Munee is expecting to run in the absolute webroot of your site. So if it's webroot is set to that, you shouldn't be having this issues. I'm suspecting that that rewritebase is actually affecting Munee's ability to determine the correct webroot :).

Make sure and delete the cache again after the update.

@geroyche
Copy link

it's not that...
in fact, when i change WEBROOT from
"/path1/path2/path3/beta/customers/customername" to "/path1/path2/path3/beta" then things turn worse, as munee is not even able to locate /css/styles.css (which makes sense).

i do think rewrite base is the issue, and i feel like it's easier for me to simple leave css|js out of the rewriterule while in development, and try and use these features once the project goes live. then rewritebase will be /, and I have a feeling the issue will resolve itself.

@meenie
Copy link
Owner

meenie commented Oct 17, 2013

@geroyche, okay, it looks like I need to figure out how to get Munee working for sites that are using Rewritebase to change the webroot of a site. As a suggestion to your development practices (not saying what you are doing is wrong) is make a sub-domain for each client you work on instead of putting all their files in a subfolder of the same sub-domain. That way you can make the webroot of each site: http://client1.xxx.com, http://client2.xxx.com.

Anyway, hopefully I can get this resolved :).

Thank you for all your input so far! I appreciate you sticking with this 👍.

@geroyche
Copy link

as for the subdomains: not up to me, but thanks :)

@meenie
Copy link
Owner

meenie commented Oct 17, 2013

@geroyche, where is your munee.php (dispatcher) file and .htaccess located, btw? Is that under /path1/path2/path3/beta/customers/customername or /path1/path2/path3/beta? If you could elaborate a bit more on the structure and where Munee comes in, I can use that same structure in my testing :).

@geroyche
Copy link

/path1/path2/path3/beta/customers/customername/.htacess
/path1/path2/path3/beta/customers/customername/mun.php (dispatcher)
/path1/path2/path3/beta/customers/customername/pics/
/path1/path2/path3/beta/customers/customername/js/
/path1/path2/path3/beta/customers/customername/css/
/path1/path2/path3/beta/customers/customername/inc/munee

@meenie
Copy link
Owner

meenie commented Oct 17, 2013

And the webroot for the site (set in apache or whatever server you are using) is at /path1/path2/path3/beta/ ?

Also inside the .htaccess you have RewriteBase /customers/customername?

@geroyche
Copy link

it's an apache, yes.

RewriteBase /customers/customername is correct.
i can't honestly tell you what apache document root is, apache's config is beyond my access rights (managed server).

@meenie
Copy link
Owner

meenie commented Oct 17, 2013

Alright, that only leaves out one variable to test with, so I should be good. Thanks again!

@meenie
Copy link
Owner

meenie commented Oct 18, 2013

@geroyche - Okay, I put up a new version of Munee (1.15.19). Please download the zip and overwrite what you have. Please also delete everything in the cache folder. You shouldn't need to define WEBROOT anymore and the URLs in the stylesheets should be fixed. crosses fingers

@meenie
Copy link
Owner

meenie commented Oct 18, 2013

I've updated Munee again (1.15.20), please re-download if you haven't already.

@geroyche
Copy link

@meenie
problem solved.
thank you very much :)

@meenie
Copy link
Owner

meenie commented Oct 18, 2013

Yeeeeeessssss! Finally :-).

Sent from my phone.
On 18/10/2013 8:29 PM, "geroyche" notifications@github.com wrote:

@meenie https://github.com/meenie
problem solved.
thank you very much :)


Reply to this email directly or view it on GitHubhttps://github.com//issues/21#issuecomment-26582664
.

@meenie meenie closed this as completed Oct 19, 2013
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

4 participants