Browse files

initial commit

  • Loading branch information...
0 parents commit 5b5ffb76f900ed3a6239d6f344daee5df708f865 @ekoontz committed Jan 31, 2011
Showing with 123 additions and 0 deletions.
  1. +13 −0 README
  2. +95 −0 example.clj
  3. +8 −0 project.clj
  4. +1 −0 src/italianverbs/core.clj
  5. +6 −0 test/italianverbs/test/core.clj
13 README
@@ -0,0 +1,13 @@
+# italianverbs
+
+FIXME: write description
+
+## Usage
+
+FIXME: write
+
+## License
+
+Copyright (C) 2010 FIXME
+
+Distributed under the Eclipse Public License, the same as Clojure.
95 example.clj
@@ -0,0 +1,95 @@
+(ns slice.example
+ (:use slice.core
+ slice.compojure5 ; make slices render automatically
+ uteal.core ; defs FTW
+ compojure.core ; slice isn't tied to a web "framework"
+ ring.adapter.jetty
+ hiccup.form-helpers))
+
+;; when deploying use
+;; (slice-memoize! true)
+
+(defs
+ ;; strings
+ company-name* "Cool Company"
+ app-name* "Awesome App"
+
+ ;; colors
+ site-color* "blue"
+ important-color* "red"
+
+ ;; ids
+ logo-id* "#logo"
+ download-id* "#download"
+ subscribe-id* "#subscribe"
+
+ ;; classes
+ buttons* "button"
+
+ ;; mixins
+ rounded-corners* (list :-moz-border-radius :5px
+ :-webkit-border-radius :5px)
+ big-text* (list :font-size "300%")
+ special-button* (list rounded-corners* big-text*))
+
+(slice awesome-effect
+ jquery
+ (js (fn awesomeEffect [div]
+ (.fadeOut ($ div))
+ (.fadeIn ($ div)))))
+
+(slice mouse-effect [id]
+ awesome-effect
+ (dom (.mouseover ($ ~id) (fn [] (awesomeEffect ~id)))))
+
+(slice button [id text color]
+ (html (submit-button {:id (wo# id) :class buttons*} text))
+ (css [(wdot buttons*) rounded-corners* :color color]))
+
+(slice on-click-alert [id msg]
+ (dom (.click ($ ~id) (fn [] (alert ~msg)))))
+
+(slice download-button
+ (on-click-alert download-id* "Ain't slices cool?")
+ (css [download-id* special-button*])
+ (button download-id* "Download!" important-color*))
+
+(slice subscribe-button
+ jquery
+ (on-click-alert subscribe-id* (str "Subscribed to " company-name* " newsletter."))
+ (button subscribe-id* "Subscribe!" important-color*))
+
+(slice header [text & [id]]
+ (html [:h1 {:id (wo# id)} text]))
+
+(slice site-header
+ (mouse-effect logo-id*)
+ (header company-name* logo-id*)
+ (css [logo-id*
+ big-text*
+ :color site-color*]))
+
+;;; impure slices and slices that use impure slices aren't memoized
+(slice ^{:impure true} random-number
+ (html [:p (rand-int 100)]))
+
+(slice app-section
+ (header app-name*)
+ download-button)
+
+(slice main-page
+ (title company-name*)
+ site-header
+ subscribe-button
+ app-section
+ random-number)
+
+(defroutes app
+ (GET "/" _ (main-page))
+ (GET "/subscribe" _ (slices site-header subscribe-button))
+ (GET "/test" r (slices jquery
+ (dom (alert ~(:remote-addr r)))
+ (html [:h1 "Hi"])
+ (css [:h1 :color "blue"]))))
+
+(defonce server (run-jetty #'app {:port 8888 :join? false}))
8 project.clj
@@ -0,0 +1,8 @@
+(defproject italianverbs "1.0.0-SNAPSHOT"
+ :description "FIXME: write"
+ :dependencies [[org.clojure/clojure "1.2.0"]
+ [org.clojure/clojure-contrib "1.2.0"]
+ [slice "0.4.0-SNAPSHOT"]
+ [org.apache.lucene/lucene-core "3.0.2"]
+ [org.clojure/clojure "1.2.0"]
+ [org.clojure/clojure-contrib "1.2.0"]])
1 src/italianverbs/core.clj
@@ -0,0 +1 @@
+(ns italianverbs.core)
6 test/italianverbs/test/core.clj
@@ -0,0 +1,6 @@
+(ns italianverbs.test.core
+ (:use [italianverbs.core] :reload)
+ (:use [clojure.test]))
+
+(deftest replace-me ;; FIXME: write
+ (is false "No tests have been written."))

0 comments on commit 5b5ffb7

Please sign in to comment.