Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Repo info
Activity
    Damir Vandic
    @dvic
    Any idea why the 0.4.1-SNAPSHOT has been removed from the sonatype snapshots repo?
    Christian Kaps
    @akkie
    No idea. I've released 0.4.1 final a few days ago but I'm sure that I've not removed the snapshot version. Maybe the sbt-sonatype plugin removes it automatically after a release!?
    Damir Vandic
    @dvic
    Ahh, that’s probably it, I didn’t know 0.4.1 got published, thanks!
    André Schmidt
    @ASchmidt84
    @akkie I can not compress javascript and css inside the main.scala.html I am always getting an YUI Exception.
    Christian Kaps
    @akkie
    @IntelligyScience Please can you provide a test case?
    André Schmidt
    @ASchmidt84

    @akkie yes tomorrow i could show you also the exception. At this moment I am not in the office. But here
    */
    class MyHtmlCompressorFilter @Inject()(val configuration: Configuration,
    val environment: Environment,
    val mat: Materializer) extends HTMLCompressorFilter {

    override val compressor: HtmlCompressor = {
    val c = new HtmlCompressor()
    if (environment.mode == Mode.Dev) {
    c.setPreserveLineBreaks(true)
    }

    c.setCompressCss(true)
    c.setEnabled(true)
    c.setRemoveQuotes(true)
    c.setRemoveMultiSpaces(true)
    c.setRemoveScriptAttributes(true)
    c.setRemoveComments(true)
    c.setRemoveIntertagSpaces(true)
    c.setRemoveHttpProtocol(true)
    c.setRemoveHttpsProtocol(true)
    //c.setCompressJavaScript(true)
    
    c.setRemoveJavaScriptProtocol(true)
    c.setRemoveFormAttributes(true)
    c

    }

    }

    the outcomment line produce an exception. It is missing a javascript compressor.
    in sbt I added this "com.mohiva" %% "play-html-compressor" % "0.6.1", and also added libraryDependencies += "com.yahoo.platform.yui" % "yuicompressor" % "2.4.8" this
    Tomorrow I will show you the exception.
    André Schmidt
    @ASchmidt84

    @akkie The promiesed error:
    ! @70i16o194 - Internal server error, for (GET) [/] ->

    play.api.http.HttpErrorHandlerExceptions

    KaTeX parse error: Unexpected character: '$' at position 4: anon̲$1: Execution : anon$1: Execution exception[[StringIndexOutOfBoundsException: String index out of range: 436]]
        at play.api.http.HttpErrorHandlerExceptions$.throwableToUsefulException(HttpErrorHandler.scala:280)
        at play.api.http.DefaultHttpErrorHandler.onServerError(HttpErrorHandler.scala:206)
        at play.api.GlobalSettings$class.onError(GlobalSettings.scala:160)
        at play.api.DefaultGlobal$.onError(GlobalSettings.scala:188)
        at play.api.http.GlobalSettingsHttpErrorHandler.onServerError(HttpErrorHandler.scala:98)
        at play.core.server.netty.PlayRequestHandler
    anonfun$2
    KaTeX parse error: Unexpected character: '$' at position 7: anonfun̲$apply$1.apply: anonfun$apply$1.applyOrElse(PlayRequestHandler.scala:100)
        at play.core.server.netty.PlayRequestHandler
    anonfun$2
    KaTeX parse error: Unexpected character: '$' at position 7: anonfun̲$apply$1.apply: anonfun$apply$1.applyOrElse(PlayRequestHandler.scala:99)
        at scala.concurrent.Future
    anonfun$recoverWith$1.apply(Future.scala:346)
    at scala.concurrent.Future
    KaTeX parse error: Unexpected character: '$' at position 7: anonfun̲$recoverWith$1: anonfun$recoverWith$1.apply(Future.scala:345)
        at scala.concurrent.impl.CallbackRunnable.run(Promise.scala:32)
    Caused by: java.lang.StringIndexOutOfBoundsException: String index out of range: 436
        at java.lang.String.substring(String.java:1963)
        at com.yahoo.platform.yui.compressor.JavaScriptCompressor.printSourceString(JavaScriptCompressor.java:269)
        at com.yahoo.platform.yui.compressor.JavaScriptCompressor.parse(JavaScriptCompressor.java:333)
        at com.yahoo.platform.yui.compressor.JavaScriptCompressor.(JavaScriptCompressor.java:536)
        at com.googlecode.htmlcompressor.compressor.YuiJavaScriptCompressor.compress(YuiJavaScriptCompressor.java:53)
        at com.googlecode.htmlcompressor.compressor.HtmlCompressor.compressJavaScript(HtmlCompressor.java:946)
        at com.googlecode.htmlcompressor.compressor.HtmlCompressor.processScriptBlocks(HtmlCompressor.java:881)
        at com.googlecode.htmlcompressor.compressor.HtmlCompressor.processPreservedBlocks(HtmlCompressor.java:771)
        at com.googlecode.htmlcompressor.compressor.HtmlCompressor.compress(HtmlCompressor.java:220)
        at com.mohiva.play.compressor.CompressorFilter.com$mohiva$play$compressor$CompressorFilter
    compress$1(CompressorFilter.scala:87)

    the javascript inside the main.scala.html

    <script type="text/javascript">
    $(function() {
    $('a[href^="mailto:"]').each(function() {
    this.href = this.href.replace('(at)', '@@').replace(/(dot)/g, '.');
    // Remove this line if you don't want to set the email address as link text:
    this.innerHTML = this.href.replace('mailto:', '');
    });

    $.ajax({
    //url: "@routes.Articles.xCrossSelling(1,6).absoluteURL()",
    url: "@routes.Articles.articleHighlightOnPage( if(req.path.trim.isEmpty || req.path.trim == "/") "index" else req.path.trim ).url",
    //dataType:"text/html",
    method: "GET"//,
    //mimeType: "application/json"
    }).success(function(data,a,b){
    $('#article_highlight').append(data);
    $('#article_highlight_loading').hide();
    });

    });
    </script>

    Christian Kaps
    @akkie
    You should create a simple test case with an HTML file containing a Javascript part and this should be tried to compress with the standalone Google HTML compressor. If the same error occurred without the filter, then it's an issue of the Google HTML compressor and not of the filter. Maybe it's only a configuration issue.