Remove lines from index.html after building with Ant task and regex - ant

I'm building an ExtJS application with Sencha Cmd and would like to remove some lines from the index.html file after it has been built.
I know that this can basically be done by placing Ant tasks inside the build.xml file. Those tasks can look something like this:
<target name="-after-build">
<replace file="index.html" token="some text" value="some new text"/>
</target>
Now I don't want to just replace some text but want to remove some complete lines that are recognized by regex. I also managed to replace multiple lines by regex with the replaceregexp task but don't now how to completely remove them. I only managed to replace them with a blank.
The lines I'd like to remove from my index.html file look something like this:
//<dev>
<script type="text/javascript" src="dev-files.js"></script>
...
//</dev>
Thanks & best regards

Related

Grails 3 how to include font-awesome fonts

this post has half the process for using font awesome in a project. The steps are:
download font-awesome zip and extract into grails-app/assets/fonts dir.
modify build.gradle to add includes = ["fonts/*"] under assets
?
Use the font in your code, e.g.
< i class="fa fa-camera-retro fa-4x"> fa-4x
The question is, what is step 3? I assume there are two options:
put something like < link rel="stylesheet" href="path/to/font-awesome/css/font-awesome.min.css"> at the top of your gsp page, but what is the path? I tried guessing, e.g. href="/assets/fonts/css/font-awesome.min.css" but this does not work even after restart.
Put something in application.css. I have no idea what this could be, as it currently only refers to files in its own directory. I even read the manual, but could not figure it out. The manual mentions "*= require font-awesome" but presumably this requires more code somewhere as it doesn't work.
Any suggestions? Grails certainly makes some very hard things easy, but it also makes some easy things hard.
You may have to change the directory references inside the fontawesome.css file. Try for a replace of all the references to ../fonts/fontawesome for fontawesome and check if it works.
This assumes having the font-awesome.css file inside the assets/stylesheets directory and the fonts inside the fonts directory. Then, in build.gradle you should have something like:
assets {
minifyJs = true
minifyCss = true
includes = ["fonts/*"]
}
In your layout GSP file's (main.gsp) <head> you should have something like:
<asset:stylesheet src="application.css"/>
Finally, in your application.css you should have something like:
*= require font-awesome
The require should have the same name as the CSS file without the .css extension. So, if you have the minified version of font-awesome it should look like this instead:
*= require font-awesome.min
Note that by doing that you don't need to add the CSS include to GSP pages.
Alternatively you can just generate an embedding code on the website of fontawesome (http://fontawesome.io/get-started/) and add it to your main.gsp file
<script src="https://use.fontawesome.com/xxxxxxxxxx.js"></script>
I got the answer to step number 3 from here:
The answer is to add the following to application.css
"*= require css/font-awesome"
Surprisingly, this will pull on font-awesome.min.css from the fonts/css/ dir where the files are exploded from the zip distribution.
Jordi and klocker also supplied valid solutions, but the above one is what I was looking for.
How to reference the assets directly via a link is still a mystery.

How to create and access packages containing html polymer custom element

I am trying to follow the example at this link enter link description here
My library structure is such:
epimss-polymer
-lib
-src
-registration
-personnel
+credentials-form.html
I have tried many variations of
<link rel="import" href="packages/epimss-polymer/registration/personnel/credentials-form.html">
but none works.
What is the correct way to access these .html files? For .dart files, my application works fine.
Thanks
You shouldn't use - for package names.
You forgot the src directory.
Only the lib part can be omitted.
<link rel="import" href="packages/epimss_polymer/registration/src/personnel/credentials-form.html">
(I changed the - to _)
I guess nobody saw you question earlier because you haven't added the dart tag.

Using AutoFileName with Sublime Text 2

I have installed the package 'AutoFileName' but when I try to define an img source I recieve only tag options and not images. Does anyone know if I have to define the folder where my images are or where AutoFileName looks for images?
AutoFileName lists files based on the html file you edit. For example, if test1.img, test2.img and test.html are in the same folder, it will list test1.img and test2.img if you are trying to add <img src=""> in test.html.

grails app root context

I have a test grails app setup with a context of "/testapp". When I add a link in my gsp that references / it does not go to the root of my grails.app.context, but to the root of my grails.serverURL property.
For example given a link with href "/css/main.css"
I would expect that this link would actually look in localhost:8080/testapp/css/main.css instead of localhost:8080/css/main.css
Is there a way that I can get references to / to start at my grails.app.context vs the grails.serverURL?
use the request contextPath value on the page
${request.contextPath}
and then prepend the additional host information if necessary to construct the complete url
the question is how do you add your links into your gsps?
We do things like
<link rel="stylesheet" href="${resource(dir: 'css', file: 'stylesheet1.css')}"/>
and
<g:javascript library="prototype"/>
by using the g:javascript and resource tags and methods, you tell grails to set the path for you...
I suspect you are just putting standard tags in...
goto
http://grails.org/doc/latest/
and, under tags in the left hand nav, look for resource and/or javascript to get an idea (its difficult to link directly in to the docs...:()
I had a similar issue to OP - how to have grails form links that start at the context root and NOT server root?
You can do so using the "uri" attribute for g:link and g:createLink tags. For example:
<g:link uri="/login">login</g:link>
will prefix any context if applicable, and produce the following
login if your app is at the http://server/
login if your app is at http://server/testapp/
Not sure why it's an undocumented attribute in the reference docs, but I found it in the Javadocs - ApplicationTagLib
You should probably be using the resource tag into your grails CSS directory, like mentioned above. However, you can also use the resource method to find the root context of you web application using the same tag:
${resource(uri:'/')}
then just use that string wherever.
And when it comes to elements like stylesheets I'd recommend creating a simple tag that'll do the trick, something along those lines:
class StylesTagLib {
static namespace = "g"
def stylesheet = { args, body ->
out << """<link rel="stylesheet" href="${resource(dir: 'css', file: args.href)}"/>"""
}
}
and later on in your code use it like this:
<g:stylesheet href="main.css"/>
Obviously you can fiddle with the conventions (should I use a predefined folder? should I add the .css extension automatically? stuff like that) but the general idea is to hide the ugliness behind a nicely defined tag.

In Grails template namespace how do you use a template that is in another directory

Say I have a template called /sample/_mytemplate.gsp.
If I want to call this template from the same directory I can use
However, what if I am in another directory. Then what do I do?
Say I'm in the view /sample2/mypage.gsp how do I call it?
In Grails 1.3.7 the following syntax
<tmpl:/sample/mytemplate />
works.
<g:render template="/sample/mytemplate" />
should do it.

Resources