Created
May 14, 2012 16:27
-
-
Save stephanos/2694910 to your computer and use it in GitHub Desktop.
play assets
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //~ INTERFACE ================================================================================= | |
| lazy val robots_yes = Assets.at("/public", "robots.txt") | |
| lazy val robots_no = Assets.at("/public", "robots.no.txt") | |
| lazy val robots = if (isProduction) robots_yes else robots_no | |
| def at(typeOf: String, file: String, ver: String = "") = { | |
| val path = typeOf match { | |
| case "js" => ("/public/javascripts", file) | |
| case "css" => ("/public/stylesheets", file) | |
| case "img" => ("/public/images", file) | |
| case "view" => ("/public/templates", file) | |
| case _ => ("/public", file) | |
| } | |
| Assets.at(path._1, path._2) | |
| } | |
| def urlOf(path: String) = { | |
| val uri = "/assets/" + build + path | |
| (httpDomain + uri, httpsDomain + uri) | |
| } | |
| def embed(secure: Boolean, urls: (String, String) *): String = | |
| urls.map(u => if (isLocal) (if(secure) u._2 else u._1) + "?" + new Date().getTime else u).mkString("','") | |
| //~ SHARED ==================================================================================== | |
| protected def cssUrl(path: String) = | |
| urlOf("/css" + (if (isProduction) path else path.replace(".min.css", ".css"))) | |
| protected def jsUrl(path: String) = | |
| urlOf("/js" + (if (isProduction) path else path.replace("script.min.js", "script.js"))) | |
| //~ INTERNALS ================================================================================= | |
| private lazy val baseDomain = if (isProduction) "static.crashnote.com" else "" | |
| private lazy val httpDomain = if (isProduction) "http://" + baseDomain else baseDomain | |
| private lazy val httpsDomain = if (isProduction) "https://" + baseDomain else baseDomain |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment