Skip to content

@thomd /loading_notice.template.rb
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
loading_notice
#
# prove of concept application for loading_notice rails-plugin (http://github.com/thomd/loading_notice)
#
# usage:
# rails loading-notice-demo -m http://gist.github.com/156145.txt
#
# loading_notice plugin
plugin 'loading_notice', :git => 'git://github.com/thomd/loading_notice.git'
rake('loading_notice:install')
# generators
run "rm public/index.html"
generate :controller, 'time'
route "map.root :controller => 'time'"
# generate time controller
file "app/controllers/time_controller.rb", <<-HTML
class TimeController < ApplicationController
def index
end
def now
render :text => current_time
end
def now_delayed
sleep 2
render :text => current_time
end
private
def current_time
"<p>Time is <em>#{DateTime.now.to_s}</em> now.</p>"
end
end
HTML
# generate layout template
file "app/views/layouts/time.html.erb", <<-HTML
<!DOCTYPE html>
<html>
<head>
<title>Proof of Concept 'loading_notice'</title>
<%= javascript_include_tag :defaults, 'loading_notice' %>
<%= stylesheet_link_tag 'loading_notice' %>
</head>
<body>
<%= yield %>
</body>
</html>
HTML
# generate index view
file "app/views/time/index.html.erb", <<-HTML
<%= link_to_remote "get time", :update => "times", :url => {:controller => "time", :action => "now"}, :position => "after" %> |
<%= link_to_remote "get time 2 seconds delayed", :update => "times", :url => {:controller => "time", :action => "now_delayed"}, :position => "after" %>
<div id="times"></div>
HTML
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.