Grails 2.3 Changes CSS Font-Face Url to "Resource:/..."

Grails 2.3 changes css font-face url to resource:/...

The solution was to disable CSS processing in Config.groovy:

grails.resources.rewrite.css = false

I found the tip how to do that on the Grails mailing list.

Grails Asset Pipeline @font-face src url

The issue for me was caused by a bug in the version of the Asset plugin that was bundled with Grails 2.4.2. This error will only show up for people using Windows PC's

Illegal character in path at index 0: \/../

Once I went from asset-pipeline:1.9.4 to asset-pipeline:1.9.6 the error went away

The error is discussed here:

URLs within CSS files broken with Grails resources plugin 1.2.7

According to my comment earlier, this wasn't an issue for me because by default all resources under /images, /css and /js are served as adhoc resources in Grails and I was testing with a .png file from images.

I came across this issue again from my colleague which made me think twice. :) In his case, he was trying to access fonts from /fonts which is provided by a plugin used in the app.

Before trying the below answer, I tried to disable css rewriting by adding the below configuration:

//Not required
//grails.resources.rewrite.css = false

but it made no sense for me as I was dealing with a font resource.

Ultimately, adding this as part of Config.groovy for fonts made the trick. For your case, you would need to do like below:

grails.resources.adhoc.includes = ['/img/**']
//If resource served from a plugin
//grails.resources.adhoc.includes = ['/plugins/**', '/img/**']

If you already have this configuration, it would look something like:

grails.resources.adhoc.includes = [
'/images/**', '/css/**', '/js/**', '/img/**'
]

But as I said you might not need adding adhoc includes for existing resources in a grails app.

Go ahead with

  • grails clean (to be on the safer side)
  • grails run-app.
  • Clean browser cache (I would prefer an incognito mode in Chrome, if Chrome used)
  • Hit app url

It should not complain about the resource any more.

Grails 3 - Add font resource folder

I am assuming you are used to using the resources plugin and not the asset pipeline which is what Grails 3 uses by default. From the upgrade guide:

Step 7 - Migrate Static Assets not handled by Asset Pipeline If you
have static assets in your web-app directory of your Grails 2.x
application such as HTML files, TLDs etc. these need to be moved. For
public assets such as static HTML pages and so on these should go in
src/main/resources/public.

TLD descriptors and non public assets should go in
src/main/resources/WEB-INF.

As noted earlier, src/main/webapp folder can also be used for this
purpose but it is not recommended.

This means you will need to pass your static resources through the asset pipeline plugin, installed by default in Grails 3. What is the asset pipeline?

The Grails Asset-Pipeline is a plugin used for managing and processing
static assets in Grails applications. Asset-Pipeline functions include
processing and minification of both CSS and JavaScript files. It is
also capable of being extended to compile custom static assets, such
as CoffeeScript or LESS.

Create a folder in your project at the following location:

grails-app/assets/fonts

Read the documentation on linking to assets and plugins.

Plugins
Plugins also can have the same "grails-app/assets" folder and
their URL mapping is also the same. This means it can be more
important to ensure unique naming / path mapping between plugins. This
is also powerful in the sense that a plugin can add helper manifests
to be used within your apps like jquery, bootstrap, font-awesome, and
more.

These plugins also differ in the fact that the assets within their
web-app directory also become available under a similar structure

If you follow those directions you should be able to require the font-awesome resource in your GSP pages. You will need to spend a little time learning the asset pipeline. There is another option, you could also use the font awesome plugin.

How to link to an image from a CSS file when using the resource plugin 1.2.14

Looks like adding grails.resources.rewrite.css = false can solve my problem. Found here.

Using CSS3 @font-face in Grails web application

If you're using a font embedding service like Google's free web fonts api (http://www.google.com/webfonts) then you don't need to put fonts in your app. You just grab the generated JS includes and the generated CSS, plonk it in and use it. Easy.

Can I force the browser to use CSS @font-face instead of font installed on system?

From the edit in my question:

This seems to resolve the issue:

  1. Ensure the CSS @font-face specification uses a different string for font-family than what is installed on the system.

  2. When referencing the font elsewhere in CSS, use:

    font-family: System Installed Font Name, 'Imported Font Name', Fallback Font;

Grails resources not working with cache-busting CKEditor release (4.5.5+)

The eventual solution (recommended by a colleague) is to exclude the specific CSS file(s) from being processed by grails resources:

resource url:"thirdparty/ckeditor/skins/moono/editor.css", exclude: "*"

This avoids affecting other files that were either unaffected by the upgraded CKEditor, or benefited from the processing done by grails resources.

MMORPG protocol encryption

@Samuel & coxymla:

That's not entirely true. If the protocol uses asynchronous encryption where the server's private key is unknown to the client, then the bot cannot decrypt the client's egress. This means that to modify the outgoing data, the bot actually has to hook the game process and intercept the data before it's encrypted.

It's simple enough in theory, but it can be technically challenging. At least you're raising the bar for attackers.

@Zombies:
Beyond initial key exchange, most encryption schemes do not require extra data transfer. Further, while there is extra work to be done when encryption is used, the data transfer will most certainly be limited by the network and not the processor.

Put plainly, encryption does not lead to slower/more data transfer.

Cautionary note: This Wikipedia page contains a story about a common encryption mistake made by the developers of Phantasy Star Online. It's worth a read.



Related Topics



Leave a reply



Submit