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

Ignore asset url query string or anchor when generating path #20

Closed
createdbypete opened this issue Mar 11, 2013 · 8 comments
Closed

Ignore asset url query string or anchor when generating path #20

createdbypete opened this issue Mar 11, 2013 · 8 comments

Comments

@createdbypete
Copy link

I encountered and error when trying to use Font Awesome, this is however a more general bug I believe relating to the asset_path method.

The following is the code I used, edited to take advantage of font-path(). This code fails because it is looking for a filename that includes the query string. Removing everything after the ? will not throw any errors.

@font-face {
  font-family: 'FontAwesome';
  src: url(font-path('fontawesome-webfont.eot?v=3.0.1'));
  src: url(font-path('fontawesome-webfont.eot?#iefix&v=3.0.1')) format("embedded-opentype"),
       url(font-path('fontawesome-webfont.woff?v=3.0.1')) format("woff"),
       url(font-path('fontawesome-webfont.ttf?v=3.0.1')) format("truetype");
  font-weight: normal;
  font-style: normal;
}

This is not a problem only for this plugin, I found this issue in the Rails repo that proposes a simple solution.


If there is a work around other than this update that I'm missing please let me know!

@ixti
Copy link
Contributor

ixti commented Mar 11, 2013

As a quick workaround you can use this (if your are using none cachebusting):

@font-face {
  font-family: 'FontAwesome';
  src: url(font-path('fontawesome-webfont.eot')?v=3.0.1);
  src: url(font-path('fontawesome-webfont.eot')?v=3.0.1#iefix) format("embedded-opentype"),
       url(font-path('fontawesome-webfont.woff')?v=3.0.1) format("woff"),
       url(font-path('fontawesome-webfont.ttf')?v=3.0.1) format("truetype");
  font-weight: normal;
  font-style: normal;
}

If you are using hard cachebusting (default) you don't need query part as md5 sum will be injected in the filename:

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

Meanwhile - I'll try to adapt Rails patch into Jekyll-Assets core.

@createdbypete
Copy link
Author

Thanks for the reply the above throws an exception unfortunately:
Liquid Exception: Invalid CSS after "...e-webfont.eot')": expected ")", was "#iefix) format(..."

I was taking a quick look through today on lunch to try and be helpful and send this as a pull request but I'm not that familiar with the way Jekyll puts thing together yet so I will be interested to learn from your solution.

@ixti
Copy link
Contributor

ixti commented Mar 11, 2013

I guess, that's because of Liquid pre-processor I've introduced in latest version. Can you, please, show me full source of the file that causes an exception?

@createdbypete
Copy link
Author

No problem: https://github.com/createdbypete/createdbypete.github.com/blob/develop/_assets/stylesheets/vendor/_font-awesome.scss

Also thanks for taking the time to make this it's really useful!

ixti added a commit that referenced this issue Apr 29, 2013
ixti added a commit that referenced this issue Apr 29, 2013
There was an issue with Liquid pre-processor reported as part of #20.
Updated assets to mimc same situation.
@ixti
Copy link
Contributor

ixti commented Apr 29, 2013

asset_path now plays nicely with query separator and anchors (same is true for all SCSS helpers that relates on asset_path, e.g. font-path and so on). Here's example of transformations:

# cachebust: none
app.js                    -> app.js
app.js?v=1&foo=bar        -> app.js?v=1&foo=bar
app.js?v=1&foo=bar#baz    -> app.js?v=1&foo=bar#baz
app.js#?v=1&foo=bar#baz   -> app.js#?v=1&foo=bar#baz

# cachebust: soft
app.js                    -> app.js?cb=4f41243847da693a4f356c0486114bc6
app.js?v=1&foo=bar        -> app.js?cb=4f41243847da693a4f356c0486114bc6&v=1&foo=bar
app.js?v=1&foo=bar#baz    -> app.js?cb=4f41243847da693a4f356c0486114bc6&v=1&foo=bar#baz
app.js#?v=1&foo=bar#baz   -> app.js?cb=4f41243847da693a4f356c0486114bc6#?v=1&foo=bar#baz

# cachebust: hard
app.js                    -> app-4f41243847da693a4f356c0486114bc6.js
app.js?v=1&foo=bar        -> app-4f41243847da693a4f356c0486114bc6.js?v=1&foo=bar
app.js?v=1&foo=bar#baz    -> app-4f41243847da693a4f356c0486114bc6.js?v=1&foo=bar#baz
app.js#?v=1&foo=bar#baz   -> app-4f41243847da693a4f356c0486114bc6.js#?v=1&foo=bar#baz

@ixti ixti closed this as completed Apr 29, 2013
@createdbypete
Copy link
Author

Nice work!

@chrishough
Copy link

Unfortunately I think this issue popped up again, however, I was able to get around it like so:

$font-weight: 'normal';
$font-style: 'normal';
$font-stretch: 'normal';
$font-family:'funkydori';

$font-filename-eot: asset_path('fontawesome-webfont.eot');
$font-filename-ttf: asset_path('fontawesome-webfont.ttf');
$font-filename-woff: asset_path('fontawesome-webfont.woff');

@font-face {
  font-family: '#{$font-family}';
  src: url('#{$font-filename-eot}');
  src: url('#{$font-filename-eot}?#iefix') format('embedded-opentype'),
  url('#{$font-filename-woff}') format('woff'),
  url('#{$font-filename-ttf}') format('truetype');
  font-weight: $font-weight;
  font-style: $font-style;
  font-stretch: $font-stretch;
}

@ixti
Copy link
Contributor

ixti commented Dec 9, 2013

For history, Chris' issue was caused by Jekyll itself due to improper configuration (see #64, #65)

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

No branches or pull requests

3 participants