Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

test ruby/sinatra application

  • Loading branch information...
commit 3c6224b652c5100be2f2525328a0a16d4e23bfaa 1 parent 26f1219
Sokolov Yura authored
Showing with 6,953 additions and 0 deletions.
  1. +3 −0  config.ru
  2. +1 −0  public/autoNumeric.js
  3. +6,883 −0 public/jquery-1.4.3.js
  4. +66 −0 test.rb
3  config.ru
View
@@ -0,0 +1,3 @@
+require File.dirname(__FILE__) + '/test.rb'
+
+run Sinatra::Application
1  public/autoNumeric.js
View
6,883 public/jquery-1.4.3.js
View
6,883 additions, 0 deletions not shown
66 test.rb
View
@@ -0,0 +1,66 @@
+# encoding: utf-8
+require 'rubygems'
+require 'haml'
+require 'sinatra'
+require "sinatra/reloader"
+
+template :index do
+<<-EOF
+!!!
+%html
+ %head
+ %script(type="text/javascript" src='jquery-1.4.3.js')
+ %script(type="text/javascript" src='autoNumeric.js')
+ :css
+ #number {text-align: right}
+ label {display: block}
+ :javascript
+ function log(str) {
+ $('#log').append('<span>'+str+'</span><br/>');
+ }
+ %body
+ %form(method="post")
+ %p
+ %label(for="meta") options for autoNumeric
+ %textarea#meta(name="meta" cols=60 rows=4)&= meta
+ %p
+ %label(for="js") execute javascript
+ %textarea#js(name="js" cols=60 rows=4)&= js
+ %p
+ %input#number(type="text" name="number" value=number)
+ %button#apply apply
+ %input(type="submit" value="reload")
+ #log
+
+ :javascript
+ function applyMeta(){
+ var meta = $('#meta').val();
+ meta = eval("("+meta+")");
+ $('#number').autoNumeric(meta);
+ eval($('#js').val());
+ }
+ $('#apply').click(function(){
+ var $number = $('#number');
+ var val = $number.val();
+ var hnumber = $number.parent().html();
+ $number.parent().html(hnumber);
+ $('#number').val(val)
+ applyMeta();
+ return false;
+ });
+ applyMeta();
+ -#end
+EOF
+end
+
+default_params = { :meta => "{aSep: ' ', aForm: true, mNum: 10, mDec: 0}", :number => 1000000, :js => '' }
+get '/' do
+ haml :index, :locals => default_params
+end
+
+post '/' do
+ locals = default_params
+ params.each{|k, v| locals[k.to_sym] = v}
+ haml :index, :locals => locals
+end
+
Please sign in to comment.
Something went wrong with that request. Please try again.