Commits

Miki Tebeka  committed 09df5b6

Initial commit

  • Participants

Comments (0)

Files changed (6)

+syntax glob
+
+lib
+classes
+# dr-evil
+
+FIXME: write description
+
+## Usage
+
+FIXME: write
+
+## Installation
+
+FIXME: write
+
+## License
+
+Copyright (C) 2010 FIXME
+
+Distributed under the Eclipse Public License, the same as Clojure.
+(defproject dr-evil "1.0.0-SNAPSHOT"
+  :description "The evil web debugger"
+  :dependencies [[org.clojure/clojure "1.2.0"]
+                 [org.clojure/clojure-contrib "1.2.0"]
+                 [ring "0.3.2"]
+                 [compojure "0.4.1"]])

File src/dr_evil.clj

+(ns dr.evil)
+
+(defn input-page []
+  (slurp "src/index.html"))
+
+(defn eval-expr [expr]
+  (
+
+(defn evil [params]
+  (let [expr (params "expr")]
+    (
+
+(defroutes handler
+  (GET "/" [] (input-page))
+  (POST "/" {params :params} (evil params))
+  (ANY "/*" [path] (redirect "/"))

File src/index.html

+<html>
+    <head>
+        <title>Dr. Evil Web Debugger</title>
+        <style>
+            body {
+                margin: 50px;
+                font-family: Monospace;
+            }
+            #log {
+                border: 3px solid black;
+                width: 100%;
+                height: 500px;
+                overflow: auto;
+            }
+            #entry {
+                width: 80em;
+            }
+            div.error {
+                color: red;
+            }
+        </style>
+    </head>
+    <body>
+        <h1>Dr. Evil Web Debugger</h1>
+        <div id="log"></div>
+        <input id="entry" /> <button id="submit">Run</button>
+    </body>
+    <script
+        src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js">
+    </script>
+    <script
+        src="http://flesler-plugins.googlecode.com/files/jquery.scrollTo-1.4.2-min.js">
+    </script>
+    <script>
+        function on_run() {
+            var value = $.trim($('#entry').val());
+            if (value.length == 0) {
+                return;
+            }
+            var div = $('<div/>').text('=> ' + value);
+            $('#log').append(div);
+            $('#log').scrollTo(div);
+        }
+
+        function hook_enter_key(elem, handler) {
+            elem.keyup(function(e) {
+                if (e.keyCode == 13) {
+                    handler();
+                }
+            });
+        }
+
+        $(document).ready(function() {
+            $('#submit').click(on_run);
+            hook_enter_key($('#entry'), on_run);
+        });
+    </script>
+</html>

File test/dr_evil_test.clj

+(ns dr-evil-test
+  (:use [dr-evil] :reload-all)
+  (:use [clojure.test]))
+
+(deftest dr-evil-test
+  (is 1 1))