Grails ui-performance plugin page compression issue - grails

I am using Grails 2.0.1 in my website. Everything was fine until I installed grails ui-performance plugin into my website.
When I am deploying war with this new plugin the css files cannot be accessed. The web pages are rendered without the css and when I "view source" the page and try to access the generated url (versioned) of the css files I get the following error in firefox
"The page you are trying to view cannot be shown because it uses an invalid or unsupported form of compression."
After installing this plugin I have only changed the way I call the css to my page.
Like this:
<p:css name='main'/>
<p:css name='style'/>
Am I missing something. Please help

Uninstall one of them. Either don't use UI Performance, or remove resources by deleting the line in BuildConfig.groovy that declares the dependency. Note that there are plugins that work with resources and add in functionality like what UI Performance has, so one option is to keep resources and uninstall ui-performance, and add one or more of these to BuildConfig.groovy
runtime ":zipped-resources:1.0"
runtime ":cached-resources:1.0"
runtime ":yui-minify-resources:0.1.4"

Related

How can I easily customize the templates used for generation of Controller in Grails rest-api profile

I have a rest-api app I am working on. I run generate-controller on my domain, and a controller is generated, but in other profiles I have been able to "install" the templates that were used and customize them. This profile has no install templates command.
All attempts at doing this with the rest-api profile have been unsuccessful. I exported the templates that are used from the plugin jar and placed them in the file system, in a place grails could find them, but they are not used.
Should it be possible with this profile to customize the templates used for code generation - controller,service, view GSON? If so what does that project setup look like? I am working with a vanilla 4.0.0 rest-api profile project.
Section 10.5.3 in the documentation glosses over this, and contains a dead link to the scaffolding plugin, so it is of no help.
I tried to add the scaffolding plugin to my project build.gradle.
compile "org.grails.plugins:scaffolding"
but then the project won't even run.
org.springframework.beans.factory.NoSuchBeanDefinitionException: No bean named 'abstractViewResolver' available
It seems like it ought to be possible to customize the code generation templates in the rest-api profile, but I can't find a working configuration/setup to do it. Any pointers would be greatly appreciated.
When I generate the scaffolding after adding the scaffolding plugin, and run install-templates, it installs the templates for a web profile, rather than rest-api, so they are of little use. And even after doing so, they are not used in generation.
Should it be possible with this profile to customize the templates
used for code generation - controller,service, view gsps?
It probably should be but I don't think the templates are currently supported in the rest-api profile. I don't think install-templates even exists in that profile by default. You mention GSPs but I would not anticipate that install-templates would generate GSP templates in a rest-api app because by default, there is no GSP support in the rest-api profile.
If so what does that project setup look like?
If support is added for this I would expect the project setup to looks just like a typical rest-api app plus the templates installed below the src folder.
Feel free to submit feature requests at https://github.com/grails-profiles/rest-api/issues and/or pull requests at https://github.com/grails-profiles/rest-api/pulls.

Warning messages in GSP: "unknown tag"

I am having bunch of warning messages for "g:" | "asset:" etc, in my GSP files. Also, the content assist is not working in the editor. But if I manually type the code, the file executes properly while running in server. But it is very tedious to code without the content assist for the grails taglib elements and also warning messages are annoying.
Ex Warning in editor: "Unknown Tag (asset:image)"
My configuration is as below:
1. Grails 2.4.0
2. GGTS 3.6.2
I have the grails.tld, with all the grails tags mentioned in the tld, in webapp/web-inf/tld folder but seems GGTS is not able to recognize the tld. I read in various similar questions that we do not have to explicitly specify the taglibs at the top of each GSP page.
Need suggestions on what can be done to resolve the warnings and make the content assist work properly in the editor.

Customizing new Grails Spring Security Core Plugin login page

I installed Grails Spring Security Core Plugin and it works great, but I can't find the gsp file for the login page. I want to change the login page to match my web theme. Anyone knows how to find the file ? I tried generate-views and also generate-all followed by User, UserRole, and Role domain classes but I didn't see the actual files. Also I can't find the login and logout controllers for the spring security core plugin in my project directories. Any idea what's going on ?
They're in the plugin itself, so it depends on where your plugins get installed. In 2.3 they'll be under target/work/plugins, and in earlier versions they'll be in the .grails folder which is in your home directory, so it'll be something like $HOME/.grails/2.x.x/projects/<projectname>/plugins
I like to keep things simple by deleting the grails.project.class.dir, grails.project.test.class.dir, and grails.project.test.reports.dir settings from BuildConfig.groovy and adding just
grails.project.work.dir = 'target'
so everything is in one place.

What is a Grails Plugin? What does it mean to Install a Plugin?

I used Grails recently, and added Grails plugin for JQuery, but I don't think it did anything more than just copy some jQuery files over.
So far, I have seen info only on 'how to install and use' plugins...but I can't find anything that describes the concept of a plugin.
Can somebody please tell me, what is a Grails Plugin? And what does it mean to 'Install' a plugin?
A Grails plugin is (or should be) a self-contained bundle of functionality that can be installed into a Grails application. When a Grails plugin is installed, it can do any of the following:
define additional Spring beans
modify the generated web.xml
add new methods to the application's artefacts (controllers, domain classes, services, etc.)
provide new tag libraries
make additional resources and classes available to the application
provide new Grails commands
For example, when you install the JQuery plugin
the JQuery JavaScript files are added to the application
a new Grails tag <jq:jquery> is added to the application
a new Grails command grails install-plugin jquery is added to the application
When you install a Grails plugin, that plugin's functionality is made available to the installing application. However, the plugin itself is not actually copied into the application, only the plugin name and version is added to the application's application.properties file. The plugin itself is downloaded to $HOME/.grails and the application loads it from there.
The structure of a Grails plugin project is identical to that of a Grails application, with the exception of a configuration file (known as a plugin descriptor) that is included in a plugin's root directory.
Well, a Grails plugin is some piece of software that extends the frameworks funcionalities in some manner. Generally, installing a plugin in Grails means copying it to your Grails folder, so projects can refer to it and Grails will know where to find it.
Grails plugins have this folder structure:
grails-app
controllers
domain
taglib
service
etc
lib
src
java
groovy
web-app
js
css
So anything it has there will also be available to the application that uses it. For example, the Searchable plugin has a service class which you can use to perform advanced searchs in your own domain classes .
The jQuery plugin you mentioned has the jQuery .js file, and a tag to include that file.
For information on creating plugins, see http://grails.org/doc/latest/guide/12.%20Plug-ins.html
A plugin is just a set of functionality around a desired purpose. So the Spring Security plugin provides a way to lock down your app, assign roles to users, restrict access, whatever. The Searchable plugin allows you to integrate advanced searching into your app. There are lots of plugins
The point is to provide useful functionality so that you don't have to implement hard things yourself. Someone did something useful, and they wanted to contribute back to the community, so they organized their functionality and made it available.
A plugin is code and configuration, like any functionality you would implement yourself.
There is some documentation here: http://grails.org/doc/latest/ref/Plug-ins/Usage.html

Grails - Plugin view pages issue

I have a plugin with domain, controller and view pages. (Using grails 1.3.6)
I run the plugin as standalone, the views work fine. URL: http://localhost:8080/sample-plugin/gp/list. I am able to view the list page.
I installed the plugin into a main application i.e. plugin-test. Start as run-app within STS and browse to http://localhost:8080/plugin-test/gp/list. I am able to view the list page.
I bundle the application as war i.e. plugin-test.war and deploy to tomcat. When I browse to http://localhost:8181/plugin-test/gp/list I get a 404 error! I am not sure what I am doing wrong.
I have been trying to resolve it for quite sometime now and still no luck. The same main application works fine in STS but not in tomcat.
HTTP Status 404 - /plugin-test/WEB-INF/grails-app/views/gp/list.jsp
type Status report
message /plugin-test/WEB-INF/grails-app/views/gp/list.jsp
description The requested resource (/plugin-test/WEB-INF/grails-app/views/gp/list.jsp) is not available.
Please help.
Thank you.
Jay Chandran.
This sounds worryingly familiar, as I spent a while figuring out this (or a very similar) issue. I ended up raising this Grails bug report:
Plugin layout not found in war when installed from BuildConfig.groovy
Have you installed the plugin as using the new BuidConfig dependency technique? The JIRA documents my workaround.
Sharing some of my lessons learned after experiencing the same exact issue (1.3.7):
Double check your HTML source to make sure that your template really isn't being included. Mine was being included, but my CSS/image URLs were wrong (only while running as a war)...so I wrongly assumed that my template wasn't there.
Don't use the ui performance tags for referencing your static content...doesn't appear to work, even if the plugin attribute is specified.
Don't name your layout main.gsp. You're guaranteed to have conflicts.
Don't use absolute=true on your g:resource tags. This doesn't appear to append the pluginContextPath to the absolute url, even if you specify dir="${pluginContextPath}"
Don't use pluginContextPath, as it's no longer required: http://grails.org/doc/latest/guide/single.html#6.3%20Tag%20Libraries (search "Plugin Paths")
In your g:resource tags in your plugin layout, make sure you specify the plugin attribute. Set it to the name of your plugin.
Move your static images/css from your plugin to a web server. If each application using your plugin has its own copy, your users aren't going to benefit from caching when bouncing between apps.
Note that all of the above applies to the layout gsp in your plugin project, not your consuming application.

Resources