Git Product home page Git Product logo

press's People

Contributors

dirkmc avatar eamelink avatar judu avatar kojilin avatar morisauce avatar pyppe avatar sussegaduss avatar tomparle avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

press's Issues

rendering files before compression

Hi Dirk,

we need to render some files with the template engine before compressing them.
I implemented a patch for this purpose, which we want to use internally for our project.

In our version the script, single-script, stylesheet and single-stylsheet tag support an option "render".
If it is true, the file is rendered using TemplateLoader before adding the source to the compressed file.

When press is disabled ("press.enabled=false"), files that need rendering are linked as "/press/[js|css]/rendered/". The corresponding action just renders the file and outputs it uncompressed.

The improvement is of limited use because you can't pass additional parameters to the template, but it is fine for our use case.
If you wan't this option in future press versions, I'm glad to send you a pull request.

Btw. what is the licence of the press module? Is it fine for you that we use a modified version? All changes are published in my press git repository.

Thanks,

Florian

Be great to have namespaces for groups of files

Hi,

When my visitors hit my homepage they only need a subset of the css and javascript served to them - the rest can be served if they log into the application.

It would be great if you could say something like:

{press.script 'mootools-1.2.4.js' id='homepage'/}

{press.script 'mootools-1.2.4.4-more.js' id='homepage' /}

{press.compressed-script id='homepage'/}

and then once logged in include another set of directives with a different ID.

Bug in outputDir directive

I'm using press module 1.0.33 and is ignoring the outputDir directive in both cases, js and css. If I set it or not, is always the same, the compressed files are been created in my project root directory. I have this in my application.conf file:

press.enabled=true
press.cache=Change
press.cache.clearEnabled=false
press.inMemoryStorage=false
press.js.sourceDir=/public/javascripts/
press.css.sourceDir=/public/stylesheets/
press.js.outputDir=/public/compressed/
press.css.outputDir=/public/compressed/

And my file structure is this:

/my_project
/app
/public
/images
/javascripts
/stylesheets
*-compressed.css
*-compressed.js

I tried to previously create this directory or even the javascripts/press and stylesheets/press directories with no change.

The plugin isn't giving me any Exception, just saving the file in my project root.

I'm developing in OSX and my production server is Centos and in both environments the result is the same.

Is anything wrong with my configuration? Did I forget something?

Thank for time and effort cause this is a great Play! module.

press for scala

It would be great to have a version for Play-Scala template.

Invalid <link> tag being created

When outputting the compressed-stylesheet, the format is:

The closing tag is incorrect, as doesn't require a closing tag like <script> does. The tag should be omitted.

press overriding flash scope

Take the secure module for example.

  1. Add a controller annotated with @with(Secure.class)
  2. Override the secure login template.
  3. Use press to serve the css and javascript

If you go to http://yourhost:port/controller-path you should see a login page. After logging in the page will take you to http://yourhost:port/ instead of http://yourhost:port/controller-path. The secure module stores the continue url in the flash cookie which is deleted by the press request.
A flash.keep() while serving press files would probably solve this issue.

PressException

Getting this on some, but not all, pages in my app. Can't quite figure out what it is in the page that is causing this.

@645d5k7kc
Internal Server Error (500) for request GET /coach/clients

Oops: PressException
An unexpected error occured caused by exception PressException: Number of file compress requests found in response (0) not equal to number of files added to compression (10). Please report a bug.

play.exceptions.UnexpectedException: Unexpected Error
at play.Invoker$Invocation.onException(Invoker.java:153)
at play.Invoker$Invocation.run(Invoker.java:195)
at Invocation.HTTP Request(Play!)
Caused by: press.PressException: Number of file compress requests found in response (0) not equal to number of files added to compression (10). Please report a bug.
at press.Compressor.getFileListOrder(Compressor.java:224)
at press.Compressor.saveFileList(Compressor.java:201)
at press.Plugin.afterActionInvocation(Plugin.java:105)
at play.mvc.ActionInvoker.invoke(ActionInvoker.java:305)
... 1 more

Sass support: HTTP instead FileIO to access file's contents

Hey dirkmc,

Firstly, thanks for such a great plugin.

Last week, we've integrated press into our project and that all works fine for js and css files. Since we're also using a lot of SCSS we needed a way to get compile it before feeding press with it's contents.
In order to do that, I've sort of merged "press" with "play-sass" (https://github.com/guillaumebort/play-sass). It's a bit hacky but it all works fine.

After having it all work, I thought of something better: why doesn't press get the content of files via HTTP instead of FileIO. At least for less, coffee, sass and scss files. The Compressors should declare which file extensions they're interested in, but need to be read via HTTP. Reading those files with HTTP abstracts the knowlegde away from press, about how to compile those file into ordinary js/css. Instead another module could take care of that, as play-sass does really well.

Is there something I'm missing here?

Thanks in advance,

Kamil

Exception on file compression

Hi

I try to use press module 1.0.25 in play 1.2.4
For all js file I get the same exception

Oops: StringIndexOutOfBoundsException
An unexpected error occured caused by exception StringIndexOutOfBoundsException: String index out of range: 211

play.exceptions.UnexpectedException: Unexpected Error
at press.Compressor.writeCompressedFile(Compressor.java:352)
at press.Compressor.getCompressedFile(Compressor.java:323)
at press.Compressor.getCompressedFile(Compressor.java:291)
at press.JSCompressor.getCompressedFile(JSCompressor.java:32)
at controllers.press.Press.getCompressedJS(Press.java:25)
at play.mvc.ActionInvoker.invokeWithContinuation(ActionInvoker.java:548)
at play.mvc.ActionInvoker.invoke(ActionInvoker.java:502)
at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:478)
at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:473)
at play.mvc.ActionInvoker.invoke(ActionInvoker.java:161)
at Invocation.HTTP Request(Play!)
Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: 211
at java.lang.String.substring(String.java:1934)
at com.yahoo.platform.yui.compressor.JavaScriptCompressor.printSourceString(JavaScriptCompressor.java:267)
at com.yahoo.platform.yui.compressor.JavaScriptCompressor.parse(JavaScriptCompressor.java:330)
at com.yahoo.platform.yui.compressor.JavaScriptCompressor.(JavaScriptCompressor.java:533)
at press.JSCompressor$1.compress(JSCompressor.java:46)
at press.Compressor.compress(Compressor.java:407)
at press.Compressor.writeCompressedFile(Compressor.java:345)
... 10 more

After this an empty file is generate in the cache

Any ideas ?

Thanks

Robert

LESS support (latest version, for twitter bootstrap 2)

Hi dirkmc,

Until now, I worked with less 0.9.1.
I want to use press but I have conflicts with versions (less 0.9.1 links to rhino-1.7R3.jar).

Any idea when a new version that supports less, with the latest engine (lesscss-engine-1.3.0.jar) ?

Thanks,
Oren

Duplicate generations when press.allowDuplicates=true

That's a serious one, and I am sorry I didn't pick it earlier.

application.conf

press.allowDuplicates=true

HTML

<!-- press-css: ugot/forms.css[0] --> 
<input type="text" id="" name="" value="" class="ugot" tabindex="1" /> Comments<br/> 
  <!-- press-css: ugot/forms.css[1] --> 
 <input....>

CSS

the compressed CSS holds two copies of the same css file.

That's an serious issue, only one copy of the CSS file should be generate, the configuration flag press.allowDuplicate which only trigger the logic to through an exception or not.

Compatibility with the Scala module

The plugin (1.0.12) doesn't seem to be compatible with the latest Scala module (0.8). After enabling both modules, restarting and refreshing, I get:

Compilation error

The file {module:press-1.0.12}/app/press/PressFileFilter.java could not be compiled. Error raised is : illegal start of type declaration

In {module:press-1.0.12}/app/press/PressFileFilter.java (around line 22)

Ideas..?

Potential memory leak?

Hi Dirk

Firstly - thanks again for this excellent module. It's one of the few that we really could not live without.

I'm using the latest version of the module (1.0.36) and it seems that on line 84 of the PressWriter class, you create a new BufferedReader, but then never call .close() on it?

Perhaps adding a finally block will sort it out, something like this:

finally {
if (reader != null) {
try {
reader.close();
} catch (Exception e) {
// Log warning if necessary
}
}

False alarms about duplicate stylesheet inclusion

Hi,

I'm seeing exceptions about a stylesheet being added to compression twice. I'm sure that I'm including the .css only once. It seems this exception also randomly happens when there really is some other underlying problem such as a missing route or some other exception.

I don't know where to look for the problem. Can you give me a hint? And thanks for the plugin, btw.

Jakub

play.exceptions.JavaExecutionException: Attempt to add the same CSS file to compression twice: 'styleTH.css'
Check that you're not including the same file in two different #{press.stylesheet} tags.
at play.templates.BaseTemplate.throwException(BaseTemplate.java:90)
at play.templates.GroovyTemplate.internalRender(GroovyTemplate.java:257)
at play.templates.GroovyTemplate$ExecutableTemplate.invokeTag(GroovyTemplate.java:379)
at play.templates.GroovyTemplate.internalRender(GroovyTemplate.java:232)
at play.templates.GroovyTemplate.internalRender(GroovyTemplate.java:267)
at play.templates.Template.render(Template.java:26)
at play.templates.GroovyTemplate.render(GroovyTemplate.java:187)
at play.server.PlayHandler.serve404(PlayHandler.java:690)
at play.server.PlayHandler$NettyInvocation.init(PlayHandler.java:197)
at play.Invoker$Invocation.run(Invoker.java:276)
at play.server.PlayHandler$NettyInvocation.run(PlayHandler.java:235)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:303)
at java.util.concurrent.FutureTask.run(FutureTask.java:138)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:98)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:206)
at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
at java.lang.Thread.run(Thread.java:662)
Caused by: press.DuplicateFileException: Attempt to add the same CSS file to compression twice: 'styleTH.css'
Check that you're not including the same file in two different #{press.stylesheet} tags.
at press.Plugin.checkForDuplicates(Plugin.java:213)
at press.Plugin.checkForCSSDuplicates(Plugin.java:201)
at press.Plugin.addCSS(Plugin.java:111)
at press.Plugin$addCSS.call(Unknown Source)
at play.templates.GroovyTemplate.internalRender(GroovyTemplate.java:232)
... 17 more

Escaping correctly carriage returns

I'm using a modified version of PlayLessPlugin for my needs on a project that is also using Press. Since I needed to be able to get the compiled output of a file as a String, I create a method in PlayLessEngine to do it, and name my class MyPlayLessEngine.

The problem that I'm having now is that after using MyPlayLessEngine on an HTML page, and going on a different Html page that is using the press plugin, then '\n' are inserted inside the pressed Less files, therefore causing the css output to be wrong and not taken into my page.

So I added a package named press in my code, with a PlayLessEngine within to override the default one, and instead of doing return css.replace("\\n", "\n"); on line 129 I do return css.replace("\\n", "").replace("\n", ""); and then I don't have the problem anymore. Has it been happening to anyone? would there be another way to correct this? thanks

An option to disable compressed files list comment on production

Hi dirk how are you?

More than an issue, this is a kind of improvement. Would be helpful to have an option in the module that let us disable the list comment that shows up above the final compressed js or css file (in the rendered html file) on production mode. Could this be possible?

Thanks in advance.

javialeon

html5 script tags and no-comment-replace options?

Hi,

I really like the simplicity of press - thanks for your work on it.

I don't know if you're still actively working on the module but if you are, do you think you could allow for a html5 option for the script tag. It would render a script tag like this:

<script src="/press/js/hash.js"></script>

Also it would be great if you could allow an option not to replace the individual script elements with a corresponding comment.

Thanks again.

Pete.

allow multiple chunks of compressed script?

I want to combine 2-3 different scripts into one file and the rest into another. Does not seem possible with press right now and I seem to end up with one monolithic js file.

Could not move to final path in Windows

There seems to be a problem with finalizing the file on Windows (Windows 7 Professional 64-bit). The move command fails. On Mac OSX the same code works fine.

Stack trace:

Internal Server Error (500) for request GET /press/js/ZsmbmSbZpEbptzVZoAAqYQJJ.js

Execution exception (In {module:press-1.0.23}/app/press/io/OnDiskCompressedFile.java around line 102)
PressException occured : Successfully wrote compressed file to temporary path C:\Projects\Sourcecode\WebApp\medi
th C:\Projects\Sourcecode\WebApp\media\press-cache\bVyCcFVMmZbLVrEEVkWXaQJJ.js

play.exceptions.JavaExecutionException: Successfully wrote compressed file to temporary path
C:\Projects\Sourcecode\WebApp\media\press-cache\bVyCcFVMmZbLVrEEVkWXaQJJ.js.tmp
But could not move it to final path
C:\Projects\Sourcecode\WebApp\media\press-cache\bVyCcFVMmZbLVrEEVkWXaQJJ.js
at play.mvc.ActionInvoker.invoke(ActionInvoker.java:229)
at Invocation.HTTP Request(Play!)
Caused by: press.PressException: Successfully wrote compressed file to temporary path
C:\Projects\Sourcecode\WebApp\media\press-cache\bVyCcFVMmZbLVrEEVkWXaQJJ.js.tmp
But could not move it to final path
C:\Projects\Sourcecode\WebApp\media\press-cache\bVyCcFVMmZbLVrEEVkWXaQJJ.js
at press.io.OnDiskCompressedFile.close(OnDiskCompressedFile.java:102)
at press.Compressor.writeCompressedFile(Compressor.java:354)
at press.Compressor.getCompressedFile(Compressor.java:323)
at press.Compressor.getCompressedFile(Compressor.java:291)
at press.JSCompressor.getCompressedFile(JSCompressor.java:32)
at controllers.press.Press.getCompressedJS(Press.java:25)
at play.mvc.ActionInvoker.invokeWithContinuation(ActionInvoker.java:546)
at play.mvc.ActionInvoker.invoke(ActionInvoker.java:500)
at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:476)
at play.mvc.ActionInvoker.invokeControllerMethod(ActionInvoker.java:471)
at play.mvc.ActionInvoker.invoke(ActionInvoker.java:159)
...

Relative image urls breaking the app

Hi,

I had to add:

GET /press/images/ staticDir:public/images

to the bottom of my routes file - I had images referenced in my CSS that was breaking the app. You should maybe add this to the gotchas along with the CSS and JS directives?

Add @NoTransaction to the Press controller

Hi!

If jpa/a database is configured, then for each request play! gets a connection from the connection pool and starts a transaction. You can read the detailed infos here:
http://www.playframework.com/documentation/1.2.5/jpa#transactions

So I was wondering if the controller handling the press requests (controllers.press.Press) also gets a connections and opens a transaction for each request?
If so I think it makes sense to simply add the @play.db.jpa.NoTransaction Annotation to this controller class, because press never uses any database connection and therefore would unnecessarily fetch and occupy a db connection from the pool. Which also would improve performance.

I'm I right?

Regards,

Matthias

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.