Externalizing Grails Datasource configuration

You can use a properties file specified in the grails.config.locations as a way to externalize the datasource configuration. Below is how I typically set up a Grails project: In my DataSource.groovy I specify this for the production environment: …. …. production { dataSource { dbCreate = “update” driverClassName = “com.myorg.jdbcDriverNotExists” url = “” username = … Read more

How to open/display documents(.pdf, .doc) without external app?

I think you should use custom library for getting that done .See this and this But there is a way for displaying PDF with out calling another application This is a way for showing PDF in android app that is embedding the PDF document to android webview using support from http://docs.google.com/viewer pseudo String doc=”<iframe src=”http://docs.google.com/viewer?url=+location … Read more

Twig variable in external JS file

There a two approaches when you need to pass a twig variable to an external javascript file Define the variables inside a script block in the twig template <!DOCTYPE html> <html> <head> <title></title> </head> <body> <script> var my_twig_var = {% if twig_var is defined %}'{{ twig_var }}'{% else %}null{% endif %} </script> <script src=”scripts/functions.js”></script> </body> … Read more

Can I load external stylesheets on request?

Yup: if you create a <link> tag linking to a stylesheet and add it to the <head> tag, the browser will load that stylesheet. E.g. $(‘head’).append(‘<link rel=”stylesheet” type=”text/css” href=”https://stackoverflow.com/questions/2126238/lightbox_stylesheet.css”>’); However, as per @peteorpeter’s comments, this doesn’t work in IE 8 or under — there, you need to either: append the <link> before setting its href; … Read more

Access PHP var from external javascript file

You don’t really access it, you insert it into the javascript code when you serve the page. However if your other javascript isn’t from an external source you can do something like: <?php $color = “Red”; ?> <script type=”text/javascript”>var color = “<?= $color ?>”;</script> <script type=”text/javascript” src=”https://stackoverflow.com/questions/2928827/file.js”></script> and then in the file.js use color like … Read more

How to style SVG with external CSS?

Your main.css file would only have an effect on the content of the SVG if the SVG file is included inline in the HTML: https://developer.mozilla.org/en/docs/SVG_In_HTML_Introduction <html> <body> <svg version=”1.1″ id=”Layer_1″ xmlns=”http://www.w3.org/2000/svg” xmlns:xlink=”http://www.w3.org/1999/xlink” viewBox=”0 0 56.69 56.69″> <g> <path d=”M28.44…….”/> </g> </svg> </html> If you want to keep your SVG in files, the CSS needs to … Read more