Browse files

Better UI, added control-panel

  • Loading branch information...
1 parent 5352458 commit 5f4814f275e8b8f92a7c4cd4fed1252889a6d597 Jacob Hansson committed Apr 23, 2010
View
83 public/index.html
@@ -1,41 +1,52 @@
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
- <head>
- <meta http-equiv="content-type" content="text/html; charset=UTF-8">
- <link rel="icon" type="image/vnd.microsoft.icon" href="/images/favicon.ico" />
+ <head>
+ <meta http-equiv="content-type" content="text/html; charset=UTF-8">
+ <link rel="icon" type="image/vnd.microsoft.icon" href="/images/favicon.ico" />
- <link type="text/css" rel="stylesheet" href="stylesheets/reset.css">
- <link type="text/css" rel="stylesheet" href="stylesheets/terminal.css">
- <link type="text/css" rel="stylesheet" href="javascripts/facebox/facebox.css">
+ <link type="text/css" rel="stylesheet" href="stylesheets/reset.css">
+ <link type="text/css" rel="stylesheet" href="stylesheets/terminal.css">
+ <link type="text/css" rel="stylesheet" href="javascripts/facebox/facebox.css">
- <script type="text/javascript" language="javascript" src="javascripts/jquery-1.3.2.min.js"></script>
- <script type="text/javascript" language="javascript" src="javascripts/facebox/facebox.js"></script>
- <script type="text/javascript" language="javascript" src="javascripts/html-helpers.js"></script>
- <script type="text/javascript" language="javascript" src="javascripts/tutorial.js"></script>
- <script type="text/javascript" language="javascript" src="javascripts/terminal.js"></script>
-
- <title>Gremlin Web Console</title>
- </head>
- <body>
- <div id="header">
- <p><a href="htpp://www.neo4j.org"><img src="images/neo4j.png" width="300"/></a> + <a href="http://gremlin.tinkerpop.com"><img src="images/gremlin-logo.png" width="200"/></a></p>
- <p>Try Graphs, Gremlin and Neo4j!</p>
- </div>
- <div id="terminal">
- <p>Gremlin 0.2</p>
- <p>type "tutorial" for help</p>
- </div>
- <div id="footer">
- <p>Layout based on Mongulator (http://github.com/banker/mongulator)</p>
- </div>
- <script type="text/javascript">
- var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
- document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
- </script>
- <script type="text/javascript">
- try {
- var pageTracker = _gat._getTracker("UA-1192232-14");
- pageTracker._trackPageview();
- } catch(err) {}</script>
- </body>
+ <script type="text/javascript" language="javascript" src="javascripts/jquery-1.3.2.min.js"></script>
+ <script type="text/javascript" language="javascript" src="javascripts/facebox/facebox.js"></script>
+ <script type="text/javascript" language="javascript" src="javascripts/html-helpers.js"></script>
+ <script type="text/javascript" language="javascript" src="javascripts/tutorial.js"></script>
+ <script type="text/javascript" language="javascript" src="javascripts/terminal.js"></script>
+ <script type="text/javascript" language="javascript" src="javascripts/controls.js"></script>
+
+ <title>Gremlin Web Console</title>
+ </head>
+ <body>
+ <div id="content">
+ <div id="header">
+ <h1><a title="Try Graphs, Gremlin and Neo4j!" href="/"><span>Gremlin Web Console</span></a></h1>
+ </div>
+ <ul id="controls">
+ <li><h3>Shortcuts</h3></li>
+ </ul>
+ <div id="terminal">
+ <div class="terminal-visual">
+ <div id="terminal-intro">
+ <img src="/images/gremlin-icon.png" id="gremlin-logo" />
+ <h1>Try Gremlin 0.2 and Neo4j</h1>
+ <div id="intro-buttons">
+ <a id="tutorial-button">Tutorial</a>
+ </div>
+ </div>
+ </div>
+ <!--p>Gremlin 0.2</p>
+ <p>type "tutorial" for help</p-->
+ </div>
+ <div class="break"></div>
+ <div id="footer">
+ <p>Layout based on Mongulator (http://github.com/banker/mongulator)</p>
+ </div>
+ </div>
+ <script type="text/javascript">
+ //var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
+ //document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
+ </script>
+ <script type="text/javascript"> try { var pageTracker = _gat._getTracker("UA-1192232-14"); pageTracker._trackPageview(); } catch(err) {}</script>
+ </body>
</html>
View
31 public/javascripts/terminal.js
@@ -12,14 +12,20 @@ http://creativecommons.org/licenses/by-sa/2.5/
var ReadLine = function(options) {
this.options = options || {};
this.htmlForInput = this.options.htmlForInput;
- this.inputHandler = function(h, v) {
+ this.inputHandler = function(h, v, callback) {
+
+ callback = callback || function() {};
+
if(/^tutorial/.test(v) || /^next/.test(v) || /^prev/.test(v)) {
h.insertResponse(h.tutorial.handle(v));
h.newPromptLine();
// saving help history
h.history.push(v);
+ // Tell the caller that the execution is complete
+ callback();
+
return null;
}
@@ -37,14 +43,18 @@ var ReadLine = function(options) {
h.history.push(v);
h.newPromptLine();
-
+
+ // Tell the caller that the execution is complete
+ callback();
+
return null;
}
$.post('/exec', { code : v }, function(value) {
if(/gr-statement/.test(value) == false) {
h.insertResponse(value.replace(/\n/g, "<br />"));
}
+
// Save to the command history...
if((lineValue = $.trim(v)) !== "") {
h.history.push(lineValue);
@@ -53,6 +63,9 @@ var ReadLine = function(options) {
h.scopeHistory = [];
h.newPromptLine(h.depth);
+
+ // Tell the caller that the execution is complete
+ callback();
});
};
this.terminal = $(this.options.terminalId || "#terminal");
@@ -133,7 +146,10 @@ ReadLine.prototype = {
},
// Return the handler's response.
- processInput: function(value) {
+ processInput: function(value, callback) {
+
+ callback = callback || function() {};
+
if($.trim(value) == '') {
this.newPromptLine();
return null;
@@ -152,7 +168,7 @@ ReadLine.prototype = {
}
this.scopeHistory.push(value);
- this.inputHandler(this, value);
+ this.inputHandler(this, value, callback);
},
insertResponse: function(response) {
@@ -191,4 +207,11 @@ var ReservedWords = ['repeat', 'while', 'if', 'foreach', 'func ', 'path'];
$(document).ready(function() {
var terminal = new ReadLine({htmlForInput: DefaultInputHtml});
+
+ var controls = new Webling.Controls($, $('#controls'), terminal, Webling.shortcuts);
+
+ // Add next/previous buttons to UI and uncomment these to enable that functionality.
+ $("#tutorial-button").click( controls.createCallback( [ 'tutorial' ] ));
+ //$("#previous-button").click( controls.createCallback( [ 'previous' ] ));
+
});
View
71 public/stylesheets/terminal.css
@@ -1,53 +1,76 @@
-body {
- font-family: Monaco, serif;
- font-size: 20px;
- background-color: #f3f4eb;
-}
+html, body { margin:0; padding:0; font-family: "Lucida Sans", "Trebuchet MS", sans-serif; }
+body { background: url(/images/bg.gif) repeat-x; }
-#header {
- width: 960px;
- margin:50px auto 50px auto;
- color: #402817;
- font-family: 'Baskerville','Palatino Linotype','Times New Roman',serif;
+li {
+ padding-top: 7px;
+ padding-left: 4px;
}
+
+.break { clear:both; }
+
+/* Content */
+#content { width: 960px; margin:0 auto;}
+
+/* Controls */
+
+#controls { float:left; width: 140px; height: 400px; background: url(/images/nav_bg.gif) repeat-x; margin-left:10px; font-size: 80%; }
+#controls .control-headline { padding-left:0; }
+#controls a { background: none; border: none; cursor:pointer; font-size: 0.8em; font-family: Helvetica, Arial, sans-serif; }
+
+.submenu { font-size: 90%; padding-left: 5px; }
+
+/* Footer */
+
#footer {
width: 960px;
- margin:50px auto 50px auto;
+ margin:20px 8px 0;
color: #402817;
font-family: 'Baskerville','Palatino Linotype','Times New Roman',serif;
}
+
+/* Header */
+#header h1 { margin:0; padding: 30px 0 0 10px; display:block; background: url(/images/logo.gif) 10px 30px no-repeat; width:217px; height:58px; }
+#header h1 a { display:block; width: 217px; height: 58px; }
+#header h1 a span { position:absolute; top:-1000px; }
+
+#header { width: 960px; height:104px; background:url(/images/header.png) no-repeat; }
+
+/* Terminal */
+#terminal h1 { color: #eee; margin: 4px 0; }
+#terminal a { cursor:pointer; }
+#intro-buttons a { border: none; background: none; color: #ddd; font-size: 1.2em; }
+#intro-buttons a:hover { color: #aaa; }
+
#terminal {
- width: 960px;
- margin:50px auto 50px auto;
- border: 1px solid black;
- height: 500px;
+ float:left;
+ width: 800px;
+ height: 400px;
background: black;
overflow: scroll;
+ font-family: monospace;
}
#terminal div.line {
- width: 940px;
+ width: 780px;
margin-bottom: 5px;
}
#terminal input {
- width: 800px;
+ width: 700px;
margin: 1px 0 1px 10px;
border: none;
display: inline;
padding: 2px;
background: black;
color: #45FF17;
- font-size: 18px;
- font-family: Monaco, monospace;
+ font-size: 14px;
}
#terminal p, #terminal pre {
margin: 2px;
color: #45FF17;
- font-size: 18px;
- font-family: Monaco, serif;
+ font-size: 14px;
}
#terminal a {
@@ -60,7 +83,5 @@ body {
margin-left: 2px;
}
-li {
- padding-top: 7px;
- padding-left: 4px;
-}
+.terminal-visual { width:800px; margin: 10px 0; }
+#terminal-intro { width: 200px; text-align: center; margin: 0 auto; }
View
11 src/main/java/com/tinkerpop/webling/GremlinWorker.java
@@ -80,10 +80,17 @@ public static void main(String[] args) throws IOException {
// evaluating gremlin statements
try {
List result = gremlin.evaluate(line);
+
// logging last use time
lastEvaluationTime = System.currentTimeMillis();
- // return evaluation result to client
- out.println(((result.size() == 1) ? result.get(0) : result));
+
+ // return evaluation result to client, maintaining line-breaks
+ for( Object resultLine : result) {
+ logger.info(resultLine);
+ out.println(resultLine);
+ }
+ //out.println(((result.size() == 1) ? result.get(0) : result));
+
} catch(NullPointerException e) {
out.println("gr-statement");
} catch(Exception e) {
View
5 src/main/java/com/tinkerpop/webling/servlets/EvaluatorServlet.java
@@ -56,11 +56,12 @@ public void doPost(HttpServletRequest request, HttpServletResponse response)
for(int i = 0; i < resultBuffer.size(); i++) {
String line = resultBuffer.get(i);
- if (lastIndex == i) {
+ /*if (lastIndex == i) {
out.println("==> " + line);
} else {
out.println(line);
- }
+ }*/
+ out.println("==> " + line);
}
} catch(Exception e) {
out.println(e.getMessage());

0 comments on commit 5f4814f

Please sign in to comment.