eg/tryhy: add version number
This commit is contained in:
parent
079e3002a7
commit
50ee81df13
@ -9,10 +9,6 @@ handlers:
|
|||||||
static_files: favicon.ico
|
static_files: favicon.ico
|
||||||
upload: favicon\.ico
|
upload: favicon\.ico
|
||||||
|
|
||||||
- url: /
|
|
||||||
static_files: index.html
|
|
||||||
upload: index\.html
|
|
||||||
|
|
||||||
- url: /js
|
- url: /js
|
||||||
static_dir: js
|
static_dir: js
|
||||||
|
|
||||||
|
@ -14,6 +14,9 @@ div.console div.jquery-console-message-value
|
|||||||
{ color:#1ad027; font-family:monospace;
|
{ color:#1ad027; font-family:monospace;
|
||||||
padding:0.1em; }
|
padding:0.1em; }
|
||||||
div.console div.jquery-console-message-type
|
div.console div.jquery-console-message-type
|
||||||
|
{ color:#52666f; font-family:monospace;
|
||||||
|
padding:0.1em; }
|
||||||
|
div.console div.jquery-console-welcome
|
||||||
{ color:#52666f; font-family:monospace;
|
{ color:#52666f; font-family:monospace;
|
||||||
padding:0.1em; }
|
padding:0.1em; }
|
||||||
div.console span.jquery-console-prompt-label { font-weight:bold }
|
div.console span.jquery-console-prompt-label { font-weight:bold }
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
$(document).ready(function(){
|
$(document).ready(function(){
|
||||||
var backlog = [];
|
var backlog = [];
|
||||||
$('#hy-console').console({
|
var console = $('#hy-console').console({
|
||||||
promptLabel: 'hy=> ',
|
promptLabel: '=> ',
|
||||||
commandValidate:function(line){
|
commandValidate:function(line){
|
||||||
if (line == '') return false;
|
if (line == '') return false;
|
||||||
else return true;
|
else return true;
|
||||||
@ -23,5 +23,20 @@ $(document).ready(function(){
|
|||||||
animateScroll:true,
|
animateScroll:true,
|
||||||
promptHistory:true,
|
promptHistory:true,
|
||||||
autofocus:true,
|
autofocus:true,
|
||||||
}).promptText('(+ 41 1)');
|
welcomeMessage: 'hy ({hy_version})'.supplant({hy_version: hy_version})
|
||||||
});
|
});
|
||||||
|
console.promptText('(+ 41 1)');
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
if (!String.prototype.supplant) {
|
||||||
|
String.prototype.supplant = function (o) {
|
||||||
|
return this.replace(
|
||||||
|
/\{([^{}]*)\}/g,
|
||||||
|
function (a, b) {
|
||||||
|
var r = o[b];
|
||||||
|
return typeof r === 'string' || typeof r === 'number' ? r : a;
|
||||||
|
}
|
||||||
|
);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
@ -1,8 +1,9 @@
|
|||||||
(import [hy.cmdline [HyREPL]]
|
(import [sys]
|
||||||
[sys]
|
|
||||||
[StringIO [StringIO]]
|
[StringIO [StringIO]]
|
||||||
[flask [Flask redirect request]]
|
[json]
|
||||||
[json])
|
[hy.cmdline [HyREPL]]
|
||||||
|
[hy]
|
||||||
|
[flask [Flask redirect request render_template]])
|
||||||
|
|
||||||
(defclass MyHyREPL [HyREPL]
|
(defclass MyHyREPL [HyREPL]
|
||||||
[[eval (fn [self code]
|
[[eval (fn [self code]
|
||||||
@ -19,6 +20,11 @@
|
|||||||
|
|
||||||
(def app (Flask __name__))
|
(def app (Flask __name__))
|
||||||
|
|
||||||
|
(with-decorator (kwapply (app.route "/") {"methods" ["GET"]})
|
||||||
|
(fn []
|
||||||
|
(kwapply (render_template "index.html") {"hy_version" hy.__version__})
|
||||||
|
))
|
||||||
|
|
||||||
(with-decorator (kwapply (app.route "/eval") {"methods" ["POST"]})
|
(with-decorator (kwapply (app.route "/eval") {"methods" ["POST"]})
|
||||||
(fn []
|
(fn []
|
||||||
(let [[repl (MyHyREPL)] [input (request.get_json)]]
|
(let [[repl (MyHyREPL)] [input (request.get_json)]]
|
||||||
@ -26,4 +32,3 @@
|
|||||||
(repl.eval expr))
|
(repl.eval expr))
|
||||||
(json.dumps (repl.eval (get input "code")))
|
(json.dumps (repl.eval (get input "code")))
|
||||||
)))
|
)))
|
||||||
|
|
||||||
|
@ -6,9 +6,13 @@
|
|||||||
<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
|
<script type="text/javascript" src="js/jquery-1.4.2.min.js"></script>
|
||||||
<script type="text/javascript" src="js/jquery.console.js"></script>
|
<script type="text/javascript" src="js/jquery.console.js"></script>
|
||||||
<script type="text/javascript" src="js/repl.js"></script>
|
<script type="text/javascript" src="js/repl.js"></script>
|
||||||
|
<script type="text/javascript">
|
||||||
|
var hy_version = '{{hy_version}}';
|
||||||
|
</script>
|
||||||
<link rel="stylesheet" type="text/css" href="css/style.css">
|
<link rel="stylesheet" type="text/css" href="css/style.css">
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<div id="hy-console" class="console"></div>
|
<div id="hy-console" class="console">
|
||||||
|
</div>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
Loading…
x
Reference in New Issue
Block a user