Skip to content
This repository has been archived by the owner on Jun 25, 2018. It is now read-only.

Commit

Permalink
adding a test index page
Browse files Browse the repository at this point in the history
  • Loading branch information
humanzz committed Feb 4, 2009
1 parent da5505f commit 9a1a918
Show file tree
Hide file tree
Showing 5 changed files with 549 additions and 4 deletions.
7 changes: 6 additions & 1 deletion app.rb
Expand Up @@ -41,5 +41,10 @@ def browser_headers
end

def wrap_response(json)
params[:callback].nil? ? json : "#{params[:callback]}(#{json})"
response['Content-Type'] = "application/json"
if params[:callback]
json = "#{params[:callback]}(#{json})"
response['Content-Type'] = "application/javascript"
end
json
end
8 changes: 5 additions & 3 deletions config/config.ru
@@ -1,11 +1,13 @@
require 'sinatra'


app_root = File.join(File.expand_path(File.dirname(__FILE__)),'..')
Sinatra::Application.set :environment, :production
Sinatra::Application.set :run, false
Sinatra::Application.set :public, File.join(app_root,'public')

#log = File.new("sinatra.log", "w")
#STDOUT.reopen(log)
#STDERR.reopen(log)

require 'app'
run Sinatra::application
require File.join(app_root,'app.rb')
run Sinatra::application
41 changes: 41 additions & 0 deletions public/index.html
@@ -0,0 +1,41 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Analyze This!</title>
<script type="text/javascript" src="/javascripts/jquery.js"></script>
<script type="text/javascript" src="/javascripts/json2.js"></script>
</head>

<body>
<h1>Analyze This!</h1>
<p>
Enter url<br />
<input type="text" id="url" style="width:600px;"/>
<input type="button" id="button" value="Go"/>
</p>

<h2>Analyze This</h2>
<textarea id="analyze_this" style="width:640px;height:200px;"></textarea>

<h2>oohEmbed</h2>
<textarea id="oohembed" style="width:640px;height:200px;"></textarea>

<script type="text/javascript">
var analyze_this = function(json){
$('#analyze_this').html(JSON.stringify(json));
};

var oohembed = function(json){
$('#oohembed').html(JSON.stringify(json));
};

$(document).ready(function(){
$('#button').click(function(){
var url = encodeURIComponent($('#url')[0].value);
$('<script>').attr('type','text/javascript').attr('src','/analyze_this?callback=analyze_this&url='+url).appendTo('body');
$('<script>').attr('type','text/javascript').attr('src','http://www.oohembed.com/oohembed?callback=oohembed&url='+url).appendTo('body');
});
});
</script>
</body>
19 changes: 19 additions & 0 deletions public/javascripts/jquery.js

Large diffs are not rendered by default.

0 comments on commit 9a1a918

Please sign in to comment.