Skip to content

Instantly share code, notes, and snippets.

@makimoto
Created November 28, 2010 07:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save makimoto/718697 to your computer and use it in GitHub Desktop.
Save makimoto/718697 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require 'rubygems'
require 'sinatra'
require 'haml'
require 'json'
get '/' do
@title = 'Presentation'
haml :index
end
post '/' do |urls|
@title = 'Presentation'
@urls = params[:urls].strip.split("\r\n").reverse.to_json
haml :index
end
get '/select' do
@urls = ''
haml :select, :locals => { :urls => '' }
end
get '/m/:msg' do |msg|
haml :m, :locals => { :msg => msg }
end
__END__
@@ layout
%html
%head
%title #{@title}
%script{:src=>'http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js', :type =>'text/javascript'}
%style
:plain
body {
background-color: black;
color: white;
}
%body
=yield
@@ index
#content
%a#prev{:href => 'javascript:void(0)'} 前へ
%a#post{:href => 'javascript:void(0)'} 後へ
%iframe#frame{:src => '/m/紫蘇のアレ', :style => 'width:100%; height:95%'}
%a#prev{:href => 'javascript:void(0)'} 前へ
%a#post{:href => 'javascript:void(0)'} 後へ
:javascript
jQuery(document).ready(function($){
var urls = '#{@urls}';
var u;
if(urls != ''){
u = eval(urls);
}
else {
u = [
'/select',
];
};
pos = 0;
$('title').text((pos+1) + " of " + u.length)
$('#frame').attr('src',u[0]);
$('#prev').click(function(){
if(0 < pos) {
pos--;
}
$('#frame').attr('src',u[pos]);
$('title').text((pos+1) + " of " + u.length)
});
$('#post').click(function(){
if(pos < u.length - 1) {
pos++;
}
$('#frame').attr('src',u[pos]);
$('title').text((pos+1) + " of " + u.length)
});
});
@@ select
%h2 Select URIs
%form#select{:method => 'POST', :target => '_parent', :action => '/'}
%textarea#urls{:style => 'width:600px;height:450px', :name => 'urls'}
%input{:type => 'submit', :value => '決定'}
@@ m
%div#msg{:style => 'font-size: 800%;text-align:center;font-weight:bold'}
= msg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment