Skip to content

Instantly share code, notes, and snippets.

@hexx
hexx / PlayAssetsCompiler.scala
Created June 22, 2012 06:39
A part of PlayAssetsCompiler.scala
// Name: name of the compiler
// files: the function to find files to compile from the assets directory
// naming: how to name the generated file from the original file and whether it should be minified or not
// compile: compile the file and return the compiled sources, the minified source (if relevant) and the list of dependencies
def AssetsCompiler(name: String,
watch: File => PathFinder,
filesSetting: sbt.SettingKey[PathFinder],
naming: (String, Boolean) => String,
compile: (File, Seq[String]) => (String, Option[String], Seq[File]),
optionsSettings: sbt.SettingKey[Seq[String]]) =
@hexx
hexx / JsxCompiler.scala
Created June 22, 2012 06:29
play-jsx JsxCompiler.scala
package com.github.hexx
import java.io.File
import scala.sys.process._
import scala.util.control.Exception._
import sbt.PlayExceptions.AssetCompilationException
import play.api._
import play.core.jscompile.JavascriptCompiler
object JsxCompiler {
@hexx
hexx / PlayJsxPlugin.scala
Created June 22, 2012 05:09
play-jsx PlayJsxPlugin.scala
package com.github.hexx
import sbt._
import sbt.Keys._
object PlayJsxPlugin extends Plugin {
val jsxEntryPoints = SettingKey[PathFinder]("play-jsx-entry-points")
val jsxOptions = SettingKey[Seq[String]]("play-jsx-options")
val JsxCompiler = PlayProject.AssetsCompiler("jsx",
@hexx
hexx / jsx.jsx
Created June 21, 2012 10:51
jQuery Sample in JSX
import "js.jsx";
native class jQuery {
function click(: function(): void) : void;
}
class _Main {
static function main() : void {
var jq = js.global["$"] as function (: string) : jQuery;
var alert = js.global["alert"] as function (: string) : void;
@hexx
hexx / coffee.coffee
Created June 21, 2012 10:42
jQuery Sample in CoffeeScript
$ ->
$("#coffee").click ->
alert "Hello CoffeeScript!"
@hexx
hexx / Haxe.hx
Created June 21, 2012 10:40
jQuery Sample in Haxe
class Haxe {
static function main() {
new js.JQuery(js.Lib.document).ready(function(evt) {
new js.JQuery("#haxe").click(function(evt) {
js.Lib.alert("Hello Haxe!");
});
});
}
}
@hexx
hexx / sample.js
Created June 21, 2012 10:10
jQuery Sample
$(function() {
$("#javascript").click(function() {
alert("Hello JavaScript!");
});
});
@hexx
hexx / build.sbt
Created June 21, 2012 05:59
play-jsx build.sbt
sbtPlugin := true
name := "play-jsx"
organization := "com.github.hexx"
version := "0.0.1"
scalacOptions := Seq("-deprecation", "-unchecked")
@hexx
hexx / default.properties
Created June 1, 2012 10:21
default.properties
description = This template generates a Google App Engine project using Gaeds, Unfiltered and Twirl.
gae_app_name = mygoogleappengineapp
gae_app_version = 1
org_id = com.example
gae_sessions_enabled = false
name = My Google App Engine Project
version = 0.1.0-SNAPSHOT
unfiltered_version = ls(unfiltered, unfiltered)
sbt_appengine_version = ls(sbt-appengine, sbt)
verbatim = *.js *.css
@hexx
hexx / index.scala.html
Created May 26, 2012 13:45
index.scala.html
@main("Message Board") {
@form()
@board()
}