i need to compress my css as part of my ant build. i noticed that csstidy does this, but it would not be easy to include this in my ant build because i would need to use a different binary on different platforms.
so, is there a java css compressor that people use?
Check out the Yahoo YUI compressor.
It compresses CSS as well as Javascript, and it's written in Java.
Edit: You should be using some sort of HTTP compression as well, like mod_deflate or mod_gzip.
I recently released CSS Compressor. It's a code fork of YUI Compressor, but adds more compression enhancements that make it more similar to csstidy, particularly with regards to grouping selectors that share the same rules. Obviously it's Java, and can be called via the command-line or used as a library within your own Java app.
Related
Coming from Node.js and now working with Java I'm wondering about how to achieve with Java what I did with Node.js, more specifically: How to compile my templates into JS functions.
What I did before was using EJS templates, then they were compiled into a single JS file that exposed functions to call from JS with parameters, these functions returned a HTML string that I could use as it to update my view.
The great thing about this is that I could write my templates in separated files, (EJS) then dynamically Grunt/EJS (I guess, that's from Sails.js internal logic) was converting the template into a function, merged all of them and finally generating a single file usable in my app, I just had to call a function, provide arguments and that's it: I get a view dynamically generated.
I want to achieve the same in a Java environment, using Ant, maybe maven, but I don't know how to do it neither where to look for since I'm a Java novice.
Edit:
I'm talking about client-side templating, I just want to avoid the -ugly-traditionnal way to write HTML code inside JS strings and split them in separated files so I can maintain them easier. I only need to use them from JS, not from Java, but I need to "compile" them from a Java environment, using Ant.
This is somewhat similar to this post, and this one, so you may have a look there to see if there are other useful answers.
A consensus seems to be that Mustache, which has a Java-implemented compiler (among other flavors) could be executed as an Ant target. It's a logic-less template, so you may want to find another solution.
Because it is possible to call Node.js scripts from Ant, it seems like an artificial restriction to not have Node.js. You will have much more choice and flexibility in template choice if you can persuade your team to allow Node.js.
Node.js is not in an either-or relationship with Java tools. There is plenty of room for both on a project, and I've worked on C# projects that use Node.js, just as I've worked on projects that use JRuby, Java, and Rails. None of those technologies excludes the others.
Note that I'm not recommending that you try to persuade people to switch to Node.js as an environment, migrate existing code, or use Grunt, but if it's a useful tool that you're familiar with, I can't think of a single good reason why you should be denied its use.
Another solution is to use this library I discovered yesterday. I've tried it and it seems to work well, some features are also quite useful for development mode, like the watcher on the templates.
http://jcruncher.org/
I think I'll go with it, just wondering about the author and his implication, and hope to see a Handlebars 3.0.0 compatible version soon, as well as the source code on GitHub.
P.S: You can find the handlebars compiler on the CDN (select the 2.0.0 version):
http://cdnjs.com/libraries/handlebars.js/
https://cdnjs.cloudflare.com/ajax/libs/handlebars.js/2.0.0/handlebars.runtime.min.js
Currently i am working on speed optimization of J2EE Application. The performance of the application is currently(in my case server is running pretty fast) more depended on the amount of time that it takes to download the associated files like js, css etc.
My Question:
Is there any way to compress these files(js, css,
images etc..) and send it to client machine?
I have came through some technologies which compress the js into a single line, but its causing some problems with the current syntax.
I like to know some way to compress and sent the files, if possible, for best client-side performance.
There is basically Two way to achive this functionality are as below
1) minify your css and js with minfy tool which avilable online.
I use Google Closure Tools, it uses Rhino to interpret your code while modifying it to enusre that it still works after minification. Many free tools exists: YUI Compressor, UglifyJS, etc.
UglifyJS is also good as well, try it here http://marijnhaverbeke.nl/uglifyjs
Google Closure Tools: https://developers.google.com/closure/
2) Gzip your css and js.Do server specific configuration to use Gzip
here i have link from where you can learn how GZip work
http://betterexplained.com/articles/how-to-optimize-your-site-with-gzip-compression/
Most browsers allow extensions for them. But, as I understand, there separate extensions needed for different browsers.
Is there any way to write one extension for all browsers? Can such thing be created Java, .NET, or Python?
In my opinion you can use Crossrider, with Crossrider you will write one JavaScript code, that will produce an Chrome,Firefox and Internet Explorer compatible extension.
Crossrider have a powerful API that hide all complexity while writing cross-browser code.
Try to give it a shot in: http://www.crossrider.com
Disclaimer: I worked at Crossrider
It depends what your extension does. Theoretically if your extension is quite simple (e.g. it doesn't require any special APIs like http, or filesystem access and it doesn't modify browser layout), than theoretically you can reuse the same code between browsers (but since each browser has its own extension format, you must create descriptors/browser specific code for each extension). Writing extensions in language other than javascript is possible by using some Name our language to JS compiler. For example SpeedTracer for Chrome is partially written in GWT (Java to JavaScript compiler).
So in short, you can reuse the same code between extensions for different browsers and you can use languages other than javascript to create browser extensions.
What are some ways to create PDF reports in a Java server environment without having to use Java code to do so. Or maybe minimal Java code?
We have used iText and various htmltopdf solutions. Those work, but they take a lot of Java code create the documents and you have to code the positioning of all the elements?
Is there a solution that has a a designer tool? You design a report template with the designer and then deploy the template on a server?
We could pay for an enterprise solution.
You might be interested in JasperReports and iReport (which is sort of a designer IDE for JasperReports).
You can use JCopist to generate PDFs using FreeMarker templates rather than writing Java code. Another option that is mostly suitable to JSF-based projects, is to use JBoss Seam's iText-based template-based PDF generation tools: http://docs.jboss.org/seam/1.1.1.GA/reference/en/html/itext.html
You don't say if you're prepared to pay for an enterprise solution. If you are, then Thunderhead may be an option. It provides the means for templates (as you've specified) and can generate documents off the back of these in a variety of formats. You can interface to it via a variety of means (JMS / WebService / COM - not sure about the COM, on reflection). It has ActiveX controls to allow users to edit templates (with appropriate and fine-grained permissioning) and the template editing resembles a Word-based editor. It's very powerful indeed.
You should look at Docmosis. It uses standard word or openoffice documents as templates - so you design your document in a normal word processor. Depending on what you want to do in your templates this can be an ideal way to build reports since most developers (and users) already know how to work with word processors. You can then have Docmosis manipulate the document, merge in data and produce various formats. Have a look at the demo on the website.
As you know there is a Syntax highlighter for PHP called GeSHi which supports a great number of Programming Languages or Code formats.
However, I couldn't find such a library for Java which supports programming languages that I need (ADA, ASP, BNF, Bash, Brainfuck, C, C++, C#, CSS, Cobol, ColdFusion, D, Fortran, Haskell, HTML, INI (Config), Java, JavaScript, Lisp, Make, Objective C, PASCAL, Perl, PHP, PLSQL, Prolog, Python, Ruby, Scheme, SQL, VB.NET, Verilog, VHDL, Visual Basic, XML.)
Do you know one or should I prefer inefficient way which is retrieving the highlighted code from a remote PHP server via http transaction? Any ideas?
Thanks.
Two related questions:
What code highlighting libs are there for Java?
Where can I find a syntax highlighting library for Java?
And one library I found: http://colorer.sourceforge.net/
Have a look at JHighlighter or jEdit Syntax Package. All mentioned languages aren't supported out of the box. However, you have the sources, so I guess it should be possible to add language support.
Not a direct answer but, if client-side syntax highlighting is an option, the SyntaxHighlighter library from Alex Gorbatchev is an awesome javascript library, supports lots of languages and is highly extensible.
You could use Pygments through Jython. Won't be as fast as a Java solution, but much faster than interacting with a remote server.
Barring that, you could run Geshi locally and pipe source code through it, that would also beat an HTTP round trip.
It seems that it is possible to run GeSHi from Java: GeSHi4J it seems to be a wrapper that run the PHP library on the JVM.
There is a port of prettify.js for Java: java-prettify.
It can be used to produce HTML (computed in Java), as I discussed here:
Use the java-prettify parser to create HTML
jedit is a text editor with syntax highlighting support for some 170+ languages via "modes". It also allows you to specify your own syntaxes. You can use the StandaloneTextArea component in your own application as follows:
Extract source (eg: jedit4.3source.tar.bz2 to d:\source\jedit)
Use ant to copy all the textarea files to ..\textarea eg:
D:\Source\jedit\jEdit> ant prepare-textArea
However, it misses the file BufferUndoListener.java. Copy this manually by executing
D:\Source\jedit\jEdit> copy org\gjt\sp\jedit\buffer\BufferUndoListener.java ..\textarea\src\org\gjt\sp\jedit\buffer\
In Eclipse create a Java Project from existing source in the directory D:\Source\jedit\textarea
Navigate to org.gjt.sp.jedit.textarea.StandaloneTextArea.java
Change the line
mode.setProperty("file","modes/xml.xml");
to
mode.setProperty("file","src/modes/xml.xml");
Run. Copy and paste an XML into the editor and see the syntax highlighting is working.