Created
March 20, 2011 14:49
-
-
Save rkh/878357 to your computer and use it in GitHub Desktop.
Sinatra app to test what verbs your browser supports for forms, it's probably just POST and GET, though... :(
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'sinatra' | |
require 'coffee-script' | |
require 'slim' | |
require 'sass' | |
enable :sessions | |
helpers do | |
def verbs(&block) | |
verbs.each(&block) if block | |
%w[get post put delete options patch foo] | |
end | |
end | |
before do | |
session[:requests] ||= {} | |
end | |
before '/submit' do | |
next unless method = params[:method_was] | |
session[:requests][method] = request.request_method | |
session[:last_request] = method | |
redirect to('/') | |
end | |
get('/') { slim :html } | |
get('/js') { coffee :js } | |
get('/css') { sass :css } | |
__END__ | |
@@ html | |
doctype html | |
html | |
head | |
title Browser support for HTTP verbs | |
script src='http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js' | |
script src=url('/js') | |
link rel='stylesheet' href=url('/css') | |
body | |
form#test_form method="get" style="display: none" action=url("/submit") | |
input#method_was name="method_was" value="get" | |
input type="submit" | |
table | |
- verbs do |verb| | |
tr | |
th= verb | |
td= session[:requests][verb] || "-" | |
td | |
button onclick="testVerb(#{verb.inspect})" | |
| try | |
@@ js | |
window.testVerb = (verb) -> | |
$('#test_form').attr 'method', verb | |
$('#method_was').attr 'value', verb | |
$('#test_form').submit() | |
@@ css | |
th, td | |
font: | |
family: Verdana, Geneva, 'sans serif' | |
size: 80% | |
th | |
text-align: right |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment