markwatkinson / luminous

Accurate and powerful syntax highlighting library
http://luminous.asgaard.co.uk
GNU Lesser General Public License v2.1
50 stars 5 forks source link

Laravel / Packagist CSS/JS References #29

Open PWA-GouldA opened 11 years ago

PWA-GouldA commented 11 years ago

Issue

When using luminous within Laravel 4, the Luminous CSS and JavaScript references use filesystem absolute references. This causes issues in that the Laravel application will manipulate them to be part of a URI rather than a filesystem reference.

eg: -- /home/XYZ/html_home/luminous/client/luminous.js and -- /home/XYZ/html_home/luminous/style/luminous.js becomes: -- http://example.com/home/XYZ/html_home/luminous/client/luminous.js and -- http://example.com/home/XYZ/html_home/luminous/style/luminous.js

rather than: -- http://example.com/js/luminous.js and -- http://example.com/css/luminous/luminous.js

markwatkinson commented 11 years ago

I'm assuming you are referring to the output of the head_html() function. I'm not familiar with Laravel so if I've misunderstood something please let me know...

From what I remember, the head_html() function is a bit of a hack and won't necessarily always work. It's designed for the simple case that Luminous is inside the document root and you want to serve the CSS files straight out of it. If your problem is that it's not correctly figuring out the path relative to the document root, you can use the relative root setting to explicitly set the path.

e.g. (from memory)

<?php 
luminous::set('relative-root', '/luminous/'); 
echo luminous::head_html();
?>

Should spit out something like:

<link rel='stylesheet' type='text/css' href='/luminous/style/luminous.css'>

But that's still got the /style/ part of the path hard coded, because it expects you to still be using Luminous's directory structure.

Looking at your desired paths above, I don't THINK this is your problem (correct me if I'm wrong) and I don't think you want Luminous under the document root? It looks like you are trying to serve the CSS out of a different directory. In this case it's best if you just write the HTML tags yourself pointing at wherever the correct path is, and don't rely on head_html, it's not that smart :)

PWA-GouldA commented 10 years ago

What I did was to copy the styles etc to the Laravel public folder and worked from there by adding the styles "manually".

I think I ended up not using the luminous::head_html call as it was not the best solution for how Laravel and myself are working together.

Anyhow, if composer is being used to bring packages into the Laravel structure, then they are placed into a vendor location. Within that the package and its structure exists. I'm not fully familiar with how packages are supposed to refer to their internal files, such as css and js, but would think that they would need to expose them in a common method.

The work around hack of copying the styles and then referring to them using Larvel's methods (blade templating or such) is working fine.

Again, once I have learned a bit more about packages I would hope to be able to contribute something of a better packagist based package wrapper/modification that would allow for automagical configuration of shared file locations for css, js etc.