I have a Grails 2.4.3 project. It is using angular and a good amount of external js libraries. Whenever, I try to create a war, it times out when attempting to minimized the js. I assumed it was because there are way too many libraries so I extended the timeout in GGTS, but it still timeout. I tried also exclude some the assets but it gave me null pointer exception at the beginning of the asset compilation. For now, I'm skipping the minify by setting it to false. Here are my questions:
Is there a problem having minimized js libraries already in the manifest?
Can I added the required libraries outside the manifest and get added to the war? like in web-app/js ?
I believe I could add the CDN in the html rather than having the libraries in the manifest and copied to my project, but sometimes, I worked without internet access. Is there a way to configure asset pipeline that for production to use CDN for certain assets?
The documentation covers all if not most of your questions.
config section
This section cover cdn and control of minimization
For instance
grails.assets.url = "http://cdn.example.com/"
Will set a cdn URL
Related
I am working on ui bloodhound changes. I have to remove logo of apache bloodhound and header tabs in the dashboard. I made the changes in bloodhound_theme-> bhtheme-> templates-> bloodhound_theme.html, this location file but no changes have been made in ui. after running the server. I checked in the google i didnt get any material regarding it. If anyone knows the way to make a changes in bloodhound ui manually please guide me.
Thanks.
Bloodhound is built on Trac, so most of the Trac documentation applies.
You can modify aspects of the header using configuration options, so modifying a template may not be necessary. See also this documentation.
To modify templates you should follow the instructions TracInterfaceCustomization. In short, you should put a copy of the template in the Environment templates directory.
Keep in mind for any modifications to js and css files, particularly if you followed the installation instructions to install Bloodhound: you'll need to re-run the deploy command to extract static assets to the location from which they are served.
$ trac-admin /opt/bloodhound/environments/main/ deploy /opt/bloodhound/environments/main/site
I have installed the spring security core plugin. I need to modify the login page to look like my existing website. I have searched the entire project and cannot find it. I am running grails 2.4 and spring-security-core:2.0-RC5. Where can this pesky little file be? Can someone who is not a complete greenhorn help a fellow out?
As #Abs points out, the file is at target/work/plugins/spring-security-core-2.0-RC5/grails-app/views/login/auth.gsp but you shouldn't edit plugin files. Other developers on your team won't have access to the modified files and if you delete the target directory you'll lose your changes since the target directory is only a temporary work location.
Instead, copy the file to the same relative location in your application and make changes there. Create grails-app/views/login and copy the file there and make whatever changes you want.
This technique works for most plugin files, not just GSPs. The compilation order and classpath are configured such that application files and classes override plugin files if they're in the same location/package.
You can find the default login page here
targt->work->plugins->spring-security-core-2.0-RC5->grails-app->views->login>auth.gsp
I am building a Dart application. It needs to load code from a third-party package, which is only known at runtime. My application needs to:
auto-discover the dependency
load a library from that dependency
interact with the dependency
Ideally, I do not want to require that my users specify the third-party dependency. The application should auto-discover the dependency.
For example, a workflow could be something like this:
User installs my app (pub global activate my_app)
User installs a "plugin" (pub global activate plugin_for_my_app)
User runs my app (my_app)
The app auto-discovers that plugin_for_my_app exists.
The app loads the plugin (via spawnUri perhaps?)
The app calls into the plugin
Requirements:
Must run from the command-line.
Must work on Windows, Mac, Linux.
Should (but doesn't have to) run when compiled to JavaScript.
pub run support is optional (pub run makes it tricky, because it rewrites your import URIs, so it's not a requirement)
What's the best way to do this?
This package https://pub.dartlang.org/packages/plugins seems to do exactly what you want (haven't used it myself yet though) by loading plugins into isolates.
This is not directly answering the question (CL tools as requested), but I use plugins in the browser and wanted to share my "pattern".
My web application imports includes.dart which is a dynamically generated file that imports all .dart files found in a specified directory. The file gets (re-)generated at app startup by the backend, just before serving the files to the browser. The found .dart files implement a public api (eg. init() and run()) so that the main application can call their code. The plugin code are not loaded into separate isolates but are executed in the same isolate as the main app which gives the benefit of plugins sharing the same heap and you're able to access the plugin code directly. This solution also assumes the plugins resolve their own dependencies.
This setup works fairly well for my use case. However, as there's no real dynamic code reloading in Dart (yet, I hope. see https://code.google.com/p/dart/issues/detail?id=10530), there's always a refresh step needed to load the new code.
In the plugins package, currently, there is no way to resolve dependencies through pub. When I originally designed the API it was assumed that the dependencies were already retrieved through pub get. With that said, plugin discovery on the file system is simple.
As you can see in the example in the README, loading plugins was as simple as new PluginManager().loadAll(String directory) which would automatically discover all plugins inside the directory and load them. This solution is ideal if all plugins are to be in one folder.
It is possible to do individual plugin directory loading as well, provided it follows the plugin directory structure. Using a PluginLoader you can load in a directory that contains the necessary files for a plugin to run properly. It is not necessary to call load() since the PluginManager will take care of calling in load for you.
A simplified way of loading a plugin
Instantiate the PluginManager.
PluginManager pm = new PluginManager();
Determine the plugin you want loaded. The plugins library will automatically
determine the pub cache directory. As per the documentation of pub, the PUB_CACHE environment variable is also supported.
Load in the plugin. A Future is returned with a Plugin object that provides basic information about the plugin. The plugin requires a pubspec.yaml with a name, a packages directory, and a bin/main.dart source file. However we are loading from the pub cache, so we do not need to worry about the setup of the plugin, the only requirement is the package from the pub cache supports the plugins package.
pm.loadFromCache("test-1.0.0").then((Plugin plugin) {
print("Plugin loaded!");
handle();
});
After all the plugins you desire to be loaded are initialized, the manager can now listen for requests properly. Simply use the listener to 'see' the incoming data.
The plugin side
The plugin simply uses a receiver as provided by the plugins API.
void main(List<String> args, SendPort port) {
Receiver rec = new Receiver(port);
rec.listen((Map<dynamic, dynamic> data) {
print("Received data: $data");
});
}
I wrapped the plugins package with a bit of sugar to provide some extra things like declarative RPC. It's very flexible, and samrg472 (the author of plugins.dart) is a good friend, so I have asked him to comment as well.
https://github.com/PolymorphicBot/PolymorphicBot/blob/master/lib/src/core/plugins/handler.dart
Everything looks fine on the site, but those two errors are showing up in the console. If I hit the url the font downloads. Been trying to track this down for a while, but I am getting two errors in the console:
Failed to load resource resource:/font/fontawesome-webfont.woff?v=3.0.1
Failed to load resource resource:/font/fontawesome-webfont.ttf?v=3.0.1
How can I get rid of this error?
I recently encountered and solved this problem. The solution is to add the 'font' directory, and any other directories you want resources to be processed to your adhoc includes, so it ends up looking something like this in config.groovy (add directories as needed if you have resources elsewhere).
grails.resources.adhoc.includes = ['/images/**', '/css/**', '/js/**', '/font/**']
More detail here:
URLs within CSS files broken with Grails resources plugin 1.2.7
The resource: prefix is an intermediary step in the grails resource plugin's css rewriting process. You appear to be tripping over a bug in either the ad-hoc resource processor or in the css rewriter.
I made an example application (grails 2.1.1, font-awesome 3.0.2, grails-resources 1.1.6) which upon initial load shows no errors. After modifying the font-awesome.css with the application running, the rewriter then throws errors and leaves the broken resource: urls in place.
If I perform the same request with ?_debugResources=true the errors then disappear again.
In my sample's case, leaving the font-awesome files alone after deployment OR using the font-awesome-resources plugin prevented the errors from showing up.
I had the same issue.
Try using-
src:url(asset-path('fontawesome-webfont.eot?v=3.2.1', font));
instead of a direct static path.
It worked for me on clearing up those specific errors.
This is problem of ?v=3.0.1 change your file name and refrence as well. it will work fine. use only fontawesome-webfont.woff & fontawesome-webfont.ttf file name
I am developing a grails application. I want the browser page to refresh the changes/edits in code on the fly without manually hitting the refresh button everytime. I tried LiveReload but couldn't get it working with the grails server. Is there any other application for this purpose? I use Intellij Idea IDE for coding.
What does Grails do:
Grails automatically recompiles changes made to Java & Groovy source code. It can, by using the correct plugins, also automatically recompile Less, Sass, … files.
What does LiveReload do:
LiveReload monitors files & folders on your file system and signals a browser to refresh when one of the monitored files change.
How to combine both:
Configure LiveReload to monitor different sub folders of your Grails project. Add the different Grails resources (views, web-app/js, web-app/css, src/groovy, … ) as separate monitored folders. You also do not want liveReload to compile Less, Sass, CoffeeScript, … resources since Grails handles the recompilation.
Recompilation of resources by Grails can take some time, so we want to configure the waiting time for each resource in LiveReload accordingly. Otherwise the browser would refresh before the changed resources are made available by Grails.
For example for my folder with Less files the waiting time is set to 4 seconds, since recompiling most Less files takes at least a few seconds. The waiting time for my folder with js files is set to 1 second. It takes some experimentation to find the optimal settings for your project and system.