How to inject a comment in javascript files using gulp - javascript

I try to add a header to every js-file in my project.
The current files are without comments in header.
I want a gulp-task to insert following header to the files:
/*
* New Comment from Gulp-Task
*/
Is there a plugin, already ?
Gulp-Inject is maybe the solution, but I donĀ“t know, how to use it for javascript injection.

This is not a straight answer to your question as it requires some translation to your case, but here is a post on how to update version numbers (in your case, something else) within javascript files.
How to Increment Version Number via Gulp Task?
The second part to this answer is where you'll find your clue.

I found the solution that work for me:
gulp.src(['./**/*.js'])
.pipe(insert.prepend(license))
.pipe(gulp.dest('./'));
It prepend a license head to every .js files in this directory and sub folders.

Related

ExtJS 5.0 - assistance with overrides

In an existing ExtJS 5.0 project, cannot change the original code. We are allowed to add code to an existing overrides/ directory.
I have an existing function generateTree in class Products.view.ProductsTreeViewController that I want to override.
The current function is in file PTVC.js under Useless/app/view/.
This is the code I'm using to override:
Ext.define('overrides.Products.view.ProductsTreeViewController', {
override :'Products.view.ProductsTreeViewController',
generateTree: function (data) {
if (this.isValid(data))
this.callOverridden(data);
else
this.callOverridden(this.getDefaultData());
}
};
First question, where should the code reside under overrides/? I've seen many different configurations suggested, e.g.
Everything in one file:
Useless/
overrides/
app.js
Same path as original file:
Useless/
overrides/
app/
view/
PTVC.js
Overridden class name:
Useless/
overrides/
Products/
view/
ProductsTreeViewController/
class.js
I've tried all of the above and many more approaches and confirmed through various means that the code does not get included!
So second question, how to make sure it is included?
The documentation makes it seem like it's so easy, which makes it all the more frustrating.
In the version I'm using there is no classpath variable in sencha.cfg, in any case I'd be changing an existing file, so likely can't do that, or add requires in Ext.application for the same reason.
So third question, in lieu of modifying existing files, is there a build command line switch I can use to specify an additional build directory?
I'm pulling my hair out trying to figure this out. Any advice, short of quitting my job, would be appreciated.
It's best to duplicate the directory structure, then you don't have to worry about file name collisions, but you can put the files anywhere under overrides/.
Are you running ExtJS 5.0.0? It has a regression bug whereby they forgot to include "overrides": "${app.dir}/overrides" in app.json. You can also modify a config file under .sencha but it's better to have it in app.json. You won't need requires. This is fixed in version 5.0.1.
Probably not, but it's a really small change to add that line in app.json and the only way to make overrides work in 5.0.0 (which I suspect you're using).

Where do I put .js files in Max/MSP?

Where do I put .js files in Max?
I am currently using help from this thread on the Cycling forum to link Philips Hue lighting with Max 7.
https://cycling74.com/forums/topic/controlling-philips-hue-using-jython-and-phue/ and currently trying to use this method. https://gist.github.com/tgck/11185861#file-huerequestbuilder-js
I have got the patch in my patcher window but I don't know where to put the .js (HueRequestBuidler.js) file that it needs to run. Where do I put this file for Max to be able to read it and link with the patch?
I'm sure this has been asked before but I searched and couldn't find any answers that helped me out.
You typically place js files in the same folder as your patch. There should be a [js HueRequestBuidler] object in the patch that uses it.
Add the folder containing your .js files to the Max search path in Options/File Preferences. You can find more documentation here.

Not able to load the ext-all.js file

i have a couple of questions:
first i want to describe the things i am using.
1) Dynamic project.
2) using tomcat - 7.
3) put the extjs folder in WebContent folder.
i am just learning the things ... so might be have some stupid questions .. sorry for that.
so i have confusion that ext-all.js not uploaded ...might be because of one of the reason...
1) Use of tomcat (instead i need to use apache) .... please give me some explanation on that.
2) i need to put extjs folder somewhere else ... (not sure about this).
Please help
May or may not be the answer.
Try putting ./ infront of the path
<script src="./extjs/ext-all.js" type="text/javascript"/>
You didn't include the location of your html file, so their is no way of knowing where you have to point the script tag to.
Hope this helps a little
Cheers,
Demetry

Vim Javascript Autocompletion + Suggestions?

I'm developing on top of OpenLayers.js. My project folder is structured as follows:
project /
|-- OpenLayers.js
|-- map.html
|-- map.js
\-- etc
As you can argue, when I start a new map project, I espect suggestions from Vim on how to complete the code, reading JS classes from all the libraries in the project folder (in this case, just OpenLayers.js).
E.g.:
map = new OpenLayers. --> <C-x><C-o>
map = new OpenLayers.Bounds
.Control
.Map
Selecting one of the suggested classes I should get a kind of autocompletion, like in Aptana. I've installed AutoComplPop and I get a nice automatic menu to select suggestions, but all of them are taken from the current JS file.
Anyway, I've correctly set up Tagbar + node.js + jsctags and I've generated tags file for my project, and added set tags=./tags,./../tags,./*/tags to my .vimrc.
In this case, also, Tagbar maps the current file JS structure but doesn't offer any mapping of the classes coming from other files.
Another probably relevant line in my .vimrc:
autocmd FileType javascript set omnifunc=javascriptcomplete#CompleteJS
I'm struggling to get class and subclass suggestions and now I'm getting a bit confused with all the plugins/piece of software available.
Any hint?
Thank you guys :)
Check out YouCompleteMe and tern_for_vim.
Here's an article about using them together.
Your expectations are a bit too high. Vim is not an IDE like Aptana and the mechanisms used to provide completion are crude.
Did you check that your tags file has OpenLayers.Bounds, OpenLayers.Control or OpenLayer.Map? I can't find OpenLayer.Map and, going through the OpenLayer.debug.js I can't find this function either.
TagBar only works with the current buffer. If you want to show tags for other windows/buffers you'll need another older plugin: TagList.
AutoComplPop doesn't support JS out of the box. How did you set it up? Here is how I did but it still uses <C-x><C-o> while completion from tags is done with <C-x><C-]>.

modrewrite for css / jss minified

I have a web site hosted in a CentOS 5-Plesk-Apache server. I have recently added a second site to the server for serve dynamic content. I have established rewrite rules for images (static content) that works pretty well. The module rewrites the URI in the static server to pointing to the the original file.
The problem is that the first site has the minify (http://code.google.com/p/minify/) script installed but i cannot realize how to write a modwrite rule that works, so if I have:
...
< style src='http://www.mystaticserver.com/min/f=style.css' >
...
somewhere, this becomes in the file with this URL
http://www.myserver.com/min/f=style.css
Any ideas? Thank you in advance
PS: I asked this question in serverfault but i don't get any answers
What are the redirect rules you are trying to use in the .htaccess file?
If you are sending the request to a different server, are you using redirectmatch?
Also, if you are including a query string you may need to apply the option [QSA] to the end to the rule to include it.
Thaks to the guys at serverfault.com... This is the answer:
https://serverfault.com/questions/64223/modrewrite-for-css-jss-minified/65843#65843

Categories