Grails 2.1
I've declared the following new resource module to support Google Map API in my views:
'google-map' {
resource url: 'http://maps.googleapis.com/maps/api/js?key=MyGoogleApiKeyGoesHere&sensor=false', attrs: [type: "js"], disposition: 'head'
}
Now when I include this module into some of my pages I get the following HTML code in result:
<script src="http://maps.googleapis.com/maps/api/js" type="text/javascript" ></script>
As you can see the parameters part of URL was removed by some reason which causes an error (Google says that sensor parameter is required when I try to open the page).
Does anybody know how to prevent Grails Resources plug-in from removing query parameters from URLs?
Related
Iam using spring-security-core 3.1.1 in my grails 3.2.7 application. I have added the following code in my application.yml
server:
contextPath: /LGP
port: 9090
So the appcode LGP will be appended to my URL. eg: http://localhost:9090/LGP/home
But the problem is when i'm using the Projects tag, the URL is becoming http://localhost:9090/home , the app code (LGP) getting skipped from the URL.
Why this is happening?
For the time being i update the tag as Projects but this gives the URL only as
lgp/projects
the http://localhost:9090/ section is getting missed.
Why this is like this?
If you're linking to a controller use:
<g:link controller="projects">Projects</g:link>
If you're linking to e.g. a static resource use:
<g:link uri="/projects">Projects</g:link>
I have a test page setup with several "oembed"-style links in different formats because I was trying to see what worked:
http://dev2.ohlone.edu/people/clambert/testoembed.html
None of them work. I have searched and searched Google and found nothing to indicate that I have to include a javascript file or anything else on the HTML page.
The server is running Apache on MS Windows Server. I do not manage the server and am unfamiliar with its setup.
This is a static web page - i.e., not generated using WordPress or any other CMS.
What am I missing?
Thank you,
-Cheryl Lambert
Web Designer, Ohlone College
You have added links to oembed provider links in your html. To unfurl it and make visible the content in your html all you have to do is
Invoke oEmbed api which you have added as a XML http request
you should do some thing like this
Then you could get response something like this
<oembed>
<type>photo</type>
<flickr_type>photo</flickr_type>
<title>Bacon Lollys</title>
<author_name>bees</author_name>
<author_url>https://www.flickr.com/photos/bees/</author_url>
<width>1024</width>
<height>768</height>
<url>
https://farm4.staticflickr.com/3040/2362225867_4a87ab8baf_b.jpg
</url>
<web_page>https://www.flickr.com/photos/bees/2362225867/</web_page>
<thumbnail_url>
https://farm4.staticflickr.com/3040/2362225867_4a87ab8baf_q.jpg
</thumbnail_url>
<thumbnail_width>150</thumbnail_width>
<thumbnail_height>150</thumbnail_height>
<web_page_short_url>https://flic.kr/p/4AK2sc</web_page_short_url>
<license>All Rights Reserved</license>
<license_id>0</license_id>
<html>
<a data-flickr-embed="true" href="https://www.flickr.com/photos/bees/2362225867/" title="Bacon Lollys by bees, on Flickr"><img src="https://farm4.staticflickr.com/3040/2362225867_4a87ab8baf_b.jpg" width="1024" height="768" alt="Bacon Lollys"></a><script async src="https://embedr.flickr.com/assets/client-code.js" charset="utf-8"></script>
</html>
<version>1.0</version>
<cache_age>3600</cache_age>
<provider_name>Flickr</provider_name>
<provider_url>https://www.flickr.com/</provider_url>
</oembed>
Parse the response content and construct a div content which could contain
File name
Author name
Provider name
Description or
Embed video content
And finally add the content to your HTML page.
I'm not clear on how to configure my applicationResources.groovy to use CDN for resources. My file looks like:
core {
dependsOn 'jquery'
// <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
resource url:'http://localhost/js/jquery.ui.touch-punch.min.js'
resource url:'http://netdna.bootstrapcdn.com/bootstrap/3.0.0/js/bootstrap.min.js'
resource url:'http://localhost/js/modernizr.js'
resource url:'http://localhost/js/bootbox.min.js'
resource url:'http://localhost/js/flatui-checkbox.js'
resource url:'http://localhost/js/flatui-radio.js'
resource url:'http://localhost/js/jquery.tagsinput.js'
resource url:'http://localhost/js/jquery.placeholder.js'
resource url:'http://localhost/js/util.js'
resource url:'http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css', disposition: 'head'
resource url:'http://localhost/css/flat-ui.css', disposition: 'head'
resource url:'http://localhost/css/base.css', disposition: 'head'
}
Is there a place I can set http:// localhost one time instead of listing it over and over for each resource? My dev environment uses localhost, but production will use a cdn.
Something like:
myCDN=http://amazons3.com
resource url:???/js/myfile01.js
resource url:???/js/myfile02.js
Sure you can, The config files are .groovy and should be processed just like any other code in the application.
To do so, just put in your config closure:
def myCDN='http://amazons3.com'
resource url: myCDN + '/js/myfile01.js'
resource url: myCDN + '/js/myfile02.js'
Good luck with it.
I've tried several things:
just using the url:
resource url: '//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css', disposition: 'head'
local url with linkOverride:
resource url: '/lib/bootstrap/css/bootstrap.min.css', linkOverride: '//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css', disposition: 'head'
using the baseurl mapper config:
grails.resources.mappers.baseurl.modules = [
core: "//netdna.bootstrapcdn.com/"
]
resource url: 'bootstrap/3.0.0/css/bootstrap.min.css', disposition: 'head'
None of these work. I always get some form of
Resource not found:
//netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css
Any help is appreciated.
Co-incidentally I am working on it right now as I see the question.
Looks like we have to explicitly use http for the CDN url.
resource url: 'http://netdna.bootstrapcdn.com/bootstrap/3.0.0/css/bootstrap.min.css'
Same goes with linkOverride.
I need some help with showing the favicon on my site while using ASP.NET MVC.
The problem in short is that whenever a request is made for
http://example.com/favicon.ico OR
http://example.com/Content/favicon.ico
the request never gets served. Firefox says :
Content Encoding Error - The page you
are trying to view cannot be shown
because it uses an invalid or
unsupported form of compression.
I have tried ignoring the route using the following ignore route strategies, obviously not all at the same time ;-)
routes.Add(new Route("favicon.ico", new StopRoutingHandler()));
routes.IgnoreRoute("{*favicon}", new { favicon = #"(.*/)?favicon.ico(/.*)?" });
routes.IgnoreRoute("Content/{file}", new { file = #".*" });
I can confirm that it is ignoring the route because I subclassed the controller factory and it does not call CreateController
The kicker is this, I also have a png version of the file and it does get served. I have also checked it with fiddler and whenever I try to request the ico directly through url I get a pop-up that says something like this:
The magic number in GZip header is not
correct. Make sure you are passing in
a GZip stream.
So it seems that somehow IIS is trying to send it back compressed?
How do I stop this behavior/make it work?
Any insights?
UPDATE:
I figured it out, the web.config had a custom httpmodule that dealt with serving physical files and it was trying to compress the file output. That doesn't work when you have image files. :-)
Why are you adding it as a route??
Just add this to your master page header:
<link rel="shortcut icon" media="all" type="image/x-icon" href="<%= Url.Content("~/favicon.ico") %>" />