Gwt static resource from subfolders not found - gwt

I have a problem with path to javascript in my GWT html.
I get: WARNING: No file found for: /smartajax/libs/historyjs/history.html4.js and more like this
File exists in my war/html1 dir.
It happens only if script like this above is called not from my Html1.html, but from other script that is in public (its not declared in html by <script type="text/javascript" ...>
- public_res
- smartajax
- libs
- historyjs
- war
- html1
- smartajax
- libs
- historyjs
<script type="text/javascript" src="html1/smartajax/load.smartajax.js"></script>
How to solve this?

You should ideally place all your third party scripts in same relative folder.
1) All in public/thirdparty
2) All in war/thirdparty

Your gwt public resource folder is compiled into your module's folder, and not war base directory. It will be compiled into war/module_name/html1/smartajax/... So, instead of using relative uris, how about absolute uris?
GWT.getHostPageBaseURL() -> Base url for html page, http://x.y/
GWT.getModuleBaseURL() -> Base url for gwt module, http://x.y/module_name/

Related

doxygen using absolute file path instead of symlinked(original) path

When doxygen is generating a File List it will be using the absolute path of the included files instead of the symlinked (original) path and the generated output file list is a bit ugly because of the absolute path of the files.
I have tried to use FULL_PATH_NAMES and STRIP_FROM_PATH but I would need something like REPLACE_PATH_NAMES
I have a project with following structure:
/home/user/workspace/myproject
- src
- inc
- usercode
- src
- inc
- mylibs
- my_awsome_external_lib1 --> /home/user/workspace/somecoollib
- my_awsome_external_lib2 --> /home/user/workspace/wherever/lib2
- my_awsome_external_lib3 --> /home/user/wherever3/lib3
So for example a file in one of the libs:
/home/user/workspace/myproject/mylibs/my_awsome_external_lib1/src/source.c --> /home/user/workspace/somecoollib/src/source.c
Will be included as
somecoollib/src/source.c
instead of
my_awsome_external_lib1/src/source.c
I don't really want to refactor my directory structure or use hard links.
Anyone has any idea how can I solve this issue?
Thanks

Is there a Sprockets method that returns the relative path of the asset?

This is a Sinatra app using a Sprockets Rack endpoint. When I reference a JavaScript file from an HTML page, I'd like to use a relative path to point to its location instead of just including the script file into the HTML. Doing so would enhance debugging, at the very least.
The Sprockets Rack definition in config.ru is:
map '/assets' do
SPROCKETS = Sprockets::Environment.new
SPROCKETS.append_path File.join(SPROCKETS.root, '/public/assets/js')
SPROCKETS.append_path File.join(SPROCKETS.root, '/public/assets/css')
SPROCKETS.append_path File.join(SPROCKETS.root, '/public/assets/fonts')
SPROCKETS.append_path File.join(SPROCKETS.root, '/public/assets')
SPROCKETS.paths.each{|path| puts path;}
SPROCKETS.js_compressor = :uglify
SPROCKETS.css_compressor = :scss
run SPROCKETS
end
To reference a JavaScript file in HTML, I define it within a script tag that effectively includes the source as a string as follows: (this works)
<script><%= SPROCKETS["frontend.js.erb"].to_s %></script>
What I would like to do is reference the file as an independent source as follows:
<script type="text/javascript" src="<%= SPROCKETS["frontend.js.erb"].filename %>"></script>
That option returns the following message:
Not allowed to load local resource: file:///C:/Bitnami/rubystack-2.2.5-3/projects/myapp/public/assets/js/frontend.js.erb
Obviously, this occurs because the Sprockets "filename" method returns the full path and the page cannot access the local file system. What I need is a method that returns the server's relative path.
Alright, just another head-slap moment...
Should have been using the standard assets path defined right there in the config.ru that I entered, as follows:
<script type="text/javascript" src="assets/frontend.js.erb"></script>
Works great.
have you tried using sprockets-helpers gem? this works with latest sprockets version. That gem allows you to use helper method to generate exactly what you need. If you are using SASS you can also check sprockets-sass gem. Works great with Sprockets 2.x and 3.x.

What is the physical path of Odoo webserver?

I'm building a custom odoo module that will be using several Javascript libraries.
I need to add references to those libraries (local references) but I don't know exactly where to place those libraries and how to refer to their location.
What I tried:
- I created the new module and placed the libraries inside the module directory but it didn't work.
- I also placed the libraries in the home directory of odoo.
As I understand, the problem would be solved if I could get the default directory of the webserver that odoo runs on.
If module is using js files, then you must put these files inside your module. And still if you cant reach these files from your module its your technical error and you have to fix it yourself, also note that odoo has its js libraries already
I found this page: how to add css and js files in Openerp 7 / Odoo module maybe can help you.
Below is the content.
Store files correctly:
CSS and JS files should be reside under 'static' directory in the module(the rest of subdirectory tree under 'static' is an optional convention):
static/src/css/your_file.css
static/src/js/your_file.js
Add files in manifest (v7.0) or in XML(v8.0)
Openerp v7.0 way is to add following entries in manifest (in openerp.py):
...
'css': ['static/src/css/your_file.css'],
'js': [static/src/js/your_file.js'],
...
Odoo v8.0 way is to add corresponding record in the XML:
Add XML to the manifest (openerp.py):
...
'data': [ 'your_file.xml'],
...
Then add following record in 'your_file.xml':
<data>
<template id="assets_backend" name="your_module_name assets" inherit_id="web.assets_backend">
<xpath expr="." position="inside">
<link rel='stylesheet' href="/your_module_name/static/src/css/your_file.css"/>
<script type="text/javascript" src="/your_module_name/static/src/js/your_file.js"></script>
</xpath>
</template>
....
....
</data>

Scala/Play/Nginx: static resource routing

I've got my Play app running:
http://localhost:9000
Nginx is proxy passing it to this url:
http://localhost/Demo/
I have a problem with static assets though. For instance, this asset in html template
<link rel="stylesheet" media="screen" href="#routes.Assets.at("stylesheets/main.css")">
is going to
http://localhost/assets/stylesheets/main.css
and obviously results in not being found. If I change it to this (add /Demo in front of the url):
<link rel="stylesheet" media="screen" href="/Demo#routes.Assets.at("stylesheets/main.css")">
it will now correctly go to this url:
http://localhost/Demo/assets/stylesheets/main.css
My question is: how can I add this /Demo to all my static assets without hard codding it into my templates? I prefer to solve this using Play's routing and limit changes done to nginx conf.
I've tried adding a url prefix into application.conf like this
application.context="/Demo"
but that affected all urls not only the static ones, so not a solution. Any thoughts?
My stack:
Play Framework 2.2.1 /
Scala 2.10.3 /
Java 8 64bit /
Nginx 1.4.3 /
Ubuntu 13.10 64bit
UPDATE: SOLUTION Thanks to #biesior for providing the Java version, I've converted it to scala:
package core
import controllers.routes
object Assets {
def at(path: String): String = {
"/Demo" + routes.Assets.at(path)
}
}
Just overwite the path using own implementation of assets (ie. in utils package):
package utils;
import controllers.routes;
public class MyAssets {
public static String at(String path){
return "/Demo"+ routes.Assets.at(path).toString();
}
}
in templates:
<img src='#utils.MyAssets.at("images/logo.png")' alt="">
On the quite other hand, will target project also work in subdirectory ? If not it's just easier to use subdomains, it's possible also with localhost, just configure your nginx for that project to use ie.: http://demo.loc instead od http://localhost/Demo and add this 'domain' to your hosts file

AWS Java S3-Upload Error while Runing Applet in HTML

I solved the problem upto certain extent by using the following command
$applettviewer -J-Djava.security.policy=java.policy.applet MyApplet.html
it does not show any error like before.
I came to know that my Applet has to be signed even im running in my Local System.
This is my test.html
File Name : test.HTML
<html>
<applet code="*MyApplet.class*" archive="aws-java-sdk-1.2.12.jar,commons-codec-1.3.jar,commons-logging-1.1.1.jar,httpclient-4.1.1.jar,httpcore-4.1.jar,jackson-core-asl-1.4.3.jar,mail-1.4.3.jar,stax-1.2.0.jar,stax-api-1.0.1.jar" width="500" height="500"></applet>
</html>
my Folder structure is as follows:
bin/
|----------------- MyApplet.class
|----------------- AwsCredentials.properties
|----------------- mime.types
|----------------- required Jar Files
|----------------- java.policy.applet
|----------------- test.html ( HTML file to Load the Applet)
I dont know how to sign the Class file.
Please guide me.
Regards,
Ananthavel
I dont know how to sign the Class file.
See Steps for the Code Signer in the Java tutorial.
You need to build your project as jar file. Then using keytool and jarsigner located in bin folder of jdk you need to sign your applet
and change your html as
<applet code="MyApplet.class" archive="MyApplet.jar,aws-java-sdk-1.2.12.jar,commons-codec-1.3.jar,commons-logging-1.1.1.jar,httpclient-4.1.1.jar,httpcore-4.1.jar,jackson-core-asl-1.4.3.jar,mail-1.4.3.jar,stax-1.2.0.jar,stax-api-1.0.1.jar" width="500" height="500"></applet>