Search code examples
playframework-2.0favicon

Play Framework [2.4.x] calling a favicon.ico file from a submodule


This is follow on to this question: Play Framework [2.4.x] how to address public assets in a sub module's routing file

How does one address a favicon as it appears the browser needs to see it as a file in the ROOT directory of the site and you can;t present it as a typical link located in the image directory.

IF I try to add it as follows:

  <link rel="shortcut icon" href="@controllers.submodule.routes.Assets.versioned(file="lib/submodule/images/favicon.ico")">

Then things compile and the link is clickable (If I view source there IS a file located there) however the browser refuses to visually deploy the favicon

If however I follow other advise and try to modify the routes file:

GET     /favicon.ico  controllers.submodule.Assets.versioned(path="/public/images", file="favicon.ico")

I get this lovely error:

play.sbt.PlayExceptions$CompilationException: Compilation error[method versioned is defined twice

Or if I follow this advice: (can't find favicon.ico issue in play scala)

I get this compile error:

play.sbt.PlayExceptions$CompilationException: Compilation error[too many arguments for method versioned: (file: controllers.Assets.Asset)play.api.mvc.Call]

Just for shiggles and as a learning exercise how would one serve the following file:

http://mysexysite.com/favicon.ico

1 from: the MAIN module's assets

2 from: the SUBMODULE module assets

instead of rerouting to a lower directory.


Solution

  • IBM Error :)

    Apparently it does work like this:

      <link rel="shortcut icon" href="@controllers.submodule.routes.Assets.versioned(file="lib/submodule/images/favicon.ico")">
    

    According to https://groups.google.com/forum/#!topic/play-framework/_I3hrKo-28A

    However if your using Safari as your reference browser you rarely actually see the favicon (unless you click on the address bar) as it is not shown on the actual tabs.

    Duh :(