diff --git a/assets/application.js b/assets/application.js index 07e801e..d124830 100644 --- a/assets/application.js +++ b/assets/application.js @@ -21,7 +21,6 @@ Attentive.Presentation = (function() { this.getCurrentSlide = __bind(this.getCurrentSlide, this); this.calculate = __bind(this.calculate, this); this.advanceTo = __bind(this.advanceTo, this); - this.isFile = __bind(this.isFile, this); this.advance = __bind(this.advance, this); this.handleKeyDown = __bind(this.handleKeyDown, this); this.handleClick = __bind(this.handleClick, this); @@ -50,9 +49,6 @@ Attentive.Presentation = (function() { Presentation.prototype.start = function() { var imageWait, _this = this; - if (!this.isFile()) { - window.addEventListener('popstate', this.handlePopState, false); - } this.timer.render(); document.addEventListener('click', this.handleClick, false); document.addEventListener('keydown', this.handleKeyDown, false); @@ -80,13 +76,11 @@ Attentive.Presentation = (function() { }; Presentation.prototype.slideFromLocation = function() { - var value; - value = this.isFile() ? location.hash : location.pathname; - return Number(value.substr(1)); + return Number(location.hash.substr(1)); }; Presentation.prototype.handlePopState = function(e) { - return this.advanceTo(e.state ? e.state.index : this.slideFromLocation()); + return this.advanceTo(this.slideFromLocation()); }; Presentation.prototype.handleClick = function(e) { @@ -98,9 +92,11 @@ Attentive.Presentation = (function() { case 72: return this.advanceTo(0); case 37: + case 33: return this.advance(-1); case 39: case 32: + case 34: return this.advance(); case 220: return this.timer.reset(); @@ -118,21 +114,11 @@ Attentive.Presentation = (function() { return this.advanceTo(Math.max(Math.min(this.currentSlide + offset, this.length - 1), 0)); }; - Presentation.prototype.isFile = function() { - return location.href.slice(0, 4) === 'file'; - }; - Presentation.prototype.advanceTo = function(index) { this.priorSlide = this.currentSlide; this.currentSlide = index || 0; this.calculate(); - if (this.isFile()) { - return location.hash = this.currentSlide; - } else { - return history.pushState({ - index: this.currentSlide - }, '', this.currentSlide); - } + return location.hash = this.currentSlide; }; Presentation.prototype.calculate = function() { diff --git a/index.html b/index.html index b29c00a..4a6d6c3 100644 --- a/index.html +++ b/index.html @@ -1,1580 +1,5211 @@ - +
-
+ layout.haml
evaluate_source
+
/Users/john/Projects/attentive/views/layout.haml
in
+ evaluate_source
+ !!!
+
%html
+
%head
+
%title= Attentive.title
+
%script{:type => 'text/javascript', :src => 'assets/application.js'}
+
%style{:type => 'text/css'}= Pygments.css
%link{:rel => 'stylesheet', :href => 'assets/application.css', :type => 'text/css'}/
+
= haml :"_header"
+
%body.loading
+
= yield
+
+
/Users/john/.rvm/gems/ruby-1.9.3-p125/gems/tilt-1.3.3/lib/tilt/template.rb
in
+ instance_eval
+ compile_template_method(locals_keys)
+
end
+
+
private
+
# Evaluate the template source in the context of the scope object.
+
def evaluate_source(scope, locals, &block)
+
source, offset = precompiled(locals)
+
scope.instance_eval(source, eval_file, line - offset)
end
+
+
# JRuby doesn't allow Object#instance_eval to yield to the block it's
+
# closed over. This is by design and (ostensibly) something that will
+
# change in MRI, though no current MRI version tested (1.8.6 - 1.9.2)
+
# exhibits the behavior. More info here:
+
#
+
/Users/john/.rvm/gems/ruby-1.9.3-p125/gems/tilt-1.3.3/lib/tilt/template.rb
in
+ evaluate_source
+ compile_template_method(locals_keys)
+
end
+
+
private
+
# Evaluate the template source in the context of the scope object.
+
def evaluate_source(scope, locals, &block)
+
source, offset = precompiled(locals)
+
scope.instance_eval(source, eval_file, line - offset)
end
+
+
# JRuby doesn't allow Object#instance_eval to yield to the block it's
+
# closed over. This is by design and (ostensibly) something that will
+
# change in MRI, though no current MRI version tested (1.8.6 - 1.9.2)
+
# exhibits the behavior. More info here:
+
#
+
/Users/john/.rvm/gems/ruby-1.9.3-p125/gems/tilt-1.3.3/lib/tilt/template.rb
in
+ cached_evaluate
+ # Redefine itself to use method compilation the next time:
+
def self.cached_evaluate(scope, locals, &block)
+
method = compiled_method(locals.keys)
+
method.bind(scope).call(locals, &block)
+
end
+
+
# Use instance_eval the first time:
+
evaluate_source(scope, locals, &block)
end
+
+
# Generates all template source by combining the preamble, template, and
+
# postamble and returns a two-tuple of the form: [source, offset], where
+
# source is the string containing (Ruby) source code for the template and
+
# offset is the integer line offset where line reporting should begin.
+
#
+
/Users/john/.rvm/gems/ruby-1.9.3-p125/gems/tilt-1.3.3/lib/tilt/template.rb
in
+ evaluate
+ compile!
+
else
+
raise NotImplementedError
+
end
+
end
+
+
def evaluate(scope, locals, &block)
+
cached_evaluate(scope, locals, &block)
end
+
+
# Process the template and return the result. The first time this
+
# method is called, the template source is evaluated with instance_eval.
+
# On the sequential method calls it will compile the template to an
+
# unbound method which will lead to better performance. In any case,
+
# template executation is guaranteed to be performed in the scope object
+
/Users/john/.rvm/gems/ruby-1.9.3-p125/gems/tilt-1.3.3/lib/tilt/haml.rb
in
+ evaluate
+ def prepare
+
options = @options.merge(:filename => eval_file, :line => line)
+
@engine = ::Haml::Engine.new(data, options)
+
end
+
+
def evaluate(scope, locals, &block)
+
if @engine.respond_to?(:precompiled_method_return_value, true)
+
super
else
+
@engine.render(scope, locals, &block)
+
end
+
end
+
+
# Precompiled Haml source. Taken from the precompiled_with_ambles
+
# method in Haml::Precompiler:
+
/Users/john/.rvm/gems/ruby-1.9.3-p125/gems/tilt-1.3.3/lib/tilt/template.rb
in
+ render
+ prepare
+
end
+
+
# Render the template in the given scope with the locals specified. If a
+
# block is given, it is typically available within the template via
+
# +yield+.
+
def render(scope=Object.new, locals={}, &block)
+
evaluate scope, locals || {}, &block
end
+
+
# The basename of the template file.
+
def basename(suffix='')
+
File.basename(file, suffix) if file
+
end
+
+
/Users/john/.rvm/gems/ruby-1.9.3-p125/gems/sinatra-1.3.2/lib/sinatra/base.rb
in
+ render
+ scope = options.delete(:scope) || self
+
+
# compile and render template
+
begin
+
layout_was = @default_layout
+
@default_layout = false
+
template = compile_template(engine, data, options, views)
+
output = template.render(scope, locals, &block)
ensure
+
@default_layout = layout_was
+
end
+
+
# render layout
+
if layout
+
options = options.merge(:views => views, :layout => false, :eat_errors => eat_errors, :scope => scope)
+
/Users/john/Projects/attentive/lib/attentive/server.rb
in
+ block in render
+
+
private
+
def render(engine, data, options = {}, locals = {}, &block)
+
settings.views.each do |view|
+
template = "#{data}.#{engine}"
+
+
if File.file?(File.join(view, template))
+
return super(engine, data, options.merge(:views => view), locals, &block)
end
+
end
+
end
+
end
+
end
+
+
/Users/john/Projects/attentive/lib/attentive/server.rb
in
+ each
+ haml :index, :ugly => true
+
end
+
+
set :views, [ File.join(Dir.pwd, 'views'), Attentive.root.join('views')]
+
+
private
+
def render(engine, data, options = {}, locals = {}, &block)
+
settings.views.each do |view|
template = "#{data}.#{engine}"
+
+
if File.file?(File.join(view, template))
+
return super(engine, data, options.merge(:views => view), locals, &block)
+
end
+
end
+
end
+
/Users/john/Projects/attentive/lib/attentive/server.rb
in
+ render
+ haml :index, :ugly => true
+
end
+
+
set :views, [ File.join(Dir.pwd, 'views'), Attentive.root.join('views')]
+
+
private
+
def render(engine, data, options = {}, locals = {}, &block)
+
settings.views.each do |view|
template = "#{data}.#{engine}"
+
+
if File.file?(File.join(view, template))
+
return super(engine, data, options.merge(:views => view), locals, &block)
+
end
+
end
+
end
+
/Users/john/.rvm/gems/ruby-1.9.3-p125/gems/sinatra-1.3.2/lib/sinatra/base.rb
in
+ block in render
+ ensure
+
@default_layout = layout_was
+
end
+
+
# render layout
+
if layout
+
options = options.merge(:views => views, :layout => false, :eat_errors => eat_errors, :scope => scope)
+
catch(:layout_missing) { return render(layout_engine, layout, options, locals) { output } }
end
+
+
output.extend(ContentTyped).content_type = content_type if content_type
+
output
+
end
+
+
def compile_template(engine, data, options, views)
+
/Users/john/.rvm/gems/ruby-1.9.3-p125/gems/sinatra-1.3.2/lib/sinatra/base.rb
in
+ catch
+ ensure
+
@default_layout = layout_was
+
end
+
+
# render layout
+
if layout
+
options = options.merge(:views => views, :layout => false, :eat_errors => eat_errors, :scope => scope)
+
catch(:layout_missing) { return render(layout_engine, layout, options, locals) { output } }
end
+
+
output.extend(ContentTyped).content_type = content_type if content_type
+
output
+
end
+
+
def compile_template(engine, data, options, views)
+
/Users/john/.rvm/gems/ruby-1.9.3-p125/gems/sinatra-1.3.2/lib/sinatra/base.rb
in
+ render
+ ensure
+
@default_layout = layout_was
+
end
+
+
# render layout
+
if layout
+
options = options.merge(:views => views, :layout => false, :eat_errors => eat_errors, :scope => scope)
+
catch(:layout_missing) { return render(layout_engine, layout, options, locals) { output } }
end
+
+
output.extend(ContentTyped).content_type = content_type if content_type
+
output
+
end
+
+
def compile_template(engine, data, options, views)
+
/Users/john/Projects/attentive/lib/attentive/server.rb
in
+ block in render
+
+
private
+
def render(engine, data, options = {}, locals = {}, &block)
+
settings.views.each do |view|
+
template = "#{data}.#{engine}"
+
+
if File.file?(File.join(view, template))
+
return super(engine, data, options.merge(:views => view), locals, &block)
end
+
end
+
end
+
end
+
end
+
+
/Users/john/Projects/attentive/lib/attentive/server.rb
in
+ each
+ haml :index, :ugly => true
+
end
+
+
set :views, [ File.join(Dir.pwd, 'views'), Attentive.root.join('views')]
+
+
private
+
def render(engine, data, options = {}, locals = {}, &block)
+
settings.views.each do |view|
template = "#{data}.#{engine}"
+
+
if File.file?(File.join(view, template))
+
return super(engine, data, options.merge(:views => view), locals, &block)
+
end
+
end
+
end
+
/Users/john/Projects/attentive/lib/attentive/server.rb
in
+ render
+ haml :index, :ugly => true
+
end
+
+
set :views, [ File.join(Dir.pwd, 'views'), Attentive.root.join('views')]
+
+
private
+
def render(engine, data, options = {}, locals = {}, &block)
+
settings.views.each do |view|
template = "#{data}.#{engine}"
+
+
if File.file?(File.join(view, template))
+
return super(engine, data, options.merge(:views => view), locals, &block)
+
end
+
end
+
end
+
/Users/john/.rvm/gems/ruby-1.9.3-p125/gems/sinatra-1.3.2/lib/sinatra/base.rb
in
+ haml
+ def erubis(template, options={}, locals={})
+
warn "Sinatra::Templates#erubis is deprecated and will be removed, use #erb instead.\n" \
+
"If you have Erubis installed, it will be used automatically."
+
render :erubis, template, options, locals
+
end
+
+
def haml(template, options={}, locals={})
+
render :haml, template, options, locals
end
+
+
def sass(template, options={}, locals={})
+
options.merge! :layout => false, :default_content_type => :css
+
render :sass, template, options, locals
+
end
+
+
/Users/john/Projects/attentive/lib/attentive/server.rb
in
+ block in <class:Sinatra>
+ end
+
+
slides.collect(&:to_html).join
+
end
+
end
+
+
get %r{/?\d*} do
+
haml :index, :ugly => true
end
+
+
set :views, [ File.join(Dir.pwd, 'views'), Attentive.root.join('views')]
+
+
private
+
def render(engine, data, options = {}, locals = {}, &block)
+
settings.views.each do |view|
+
/Users/john/.rvm/gems/ruby-1.9.3-p125/gems/sinatra-1.3.2/lib/sinatra/base.rb
in
+ call
+ method_name = "#{verb} #{path}"
+
unbound_method = generate_method(method_name, &block)
+
pattern, keys = compile path
+
conditions, @conditions = @conditions, []
+
+
[ pattern, keys, conditions, block.arity != 0 ?
+
proc { |a,p| unbound_method.bind(a).call(*p) } :
+
proc { |a,p| unbound_method.bind(a).call } ]
end
+
+
def compile(path)
+
keys = []
+
if path.respond_to? :to_str
+
pattern = path.to_str.gsub(/[^\?\%\\\/\:\*\w]/) { |c| encoded(c) }
+
pattern.gsub!(/((:\w+)|\*)/) do |match|
+
/Users/john/.rvm/gems/ruby-1.9.3-p125/gems/sinatra-1.3.2/lib/sinatra/base.rb
in
+ block in compile!
+ method_name = "#{verb} #{path}"
+
unbound_method = generate_method(method_name, &block)
+
pattern, keys = compile path
+
conditions, @conditions = @conditions, []
+
+
[ pattern, keys, conditions, block.arity != 0 ?
+
proc { |a,p| unbound_method.bind(a).call(*p) } :
+
proc { |a,p| unbound_method.bind(a).call } ]
end
+
+
def compile(path)
+
keys = []
+
if path.respond_to? :to_str
+
pattern = path.to_str.gsub(/[^\?\%\\\/\:\*\w]/) { |c| encoded(c) }
+
pattern.gsub!(/((:\w+)|\*)/) do |match|
+
/Users/john/.rvm/gems/ruby-1.9.3-p125/gems/sinatra-1.3.2/lib/sinatra/base.rb
in
+ []
+ end
+
+
# Run routes defined on the class and all superclasses.
+
def route!(base = settings, pass_block=nil)
+
if routes = base.routes[@request.request_method]
+
routes.each do |pattern, keys, conditions, block|
+
pass_block = process_route(pattern, keys, conditions) do |*args|
+
route_eval { block[*args] }
end
+
end
+
end
+
+
# Run routes defined in superclass.
+
if base.superclass.respond_to?(:routes)
+
return route!(base.superclass, pass_block)
+
/Users/john/.rvm/gems/ruby-1.9.3-p125/gems/sinatra-1.3.2/lib/sinatra/base.rb
in
+ block (3 levels) in route!
+ end
+
+
# Run routes defined on the class and all superclasses.
+
def route!(base = settings, pass_block=nil)
+
if routes = base.routes[@request.request_method]
+
routes.each do |pattern, keys, conditions, block|
+
pass_block = process_route(pattern, keys, conditions) do |*args|
+
route_eval { block[*args] }
end
+
end
+
end
+
+
# Run routes defined in superclass.
+
if base.superclass.respond_to?(:routes)
+
return route!(base.superclass, pass_block)
+
/Users/john/.rvm/gems/ruby-1.9.3-p125/gems/sinatra-1.3.2/lib/sinatra/base.rb
in
+ route_eval
+
+
route_eval(&pass_block) if pass_block
+
route_missing
+
end
+
+
# Run a route block and throw :halt with the result.
+
def route_eval
+
throw :halt, yield
end
+
+
# If the current request matches pattern and conditions, fill params
+
# with keys and call the given block.
+
# Revert params afterwards.
+
#
+
# Returns pass block.
+
/Users/john/.rvm/gems/ruby-1.9.3-p125/gems/sinatra-1.3.2/lib/sinatra/base.rb
in
+ block (2 levels) in route!
+ end
+
+
# Run routes defined on the class and all superclasses.
+
def route!(base = settings, pass_block=nil)
+
if routes = base.routes[@request.request_method]
+
routes.each do |pattern, keys, conditions, block|
+
pass_block = process_route(pattern, keys, conditions) do |*args|
+
route_eval { block[*args] }
end
+
end
+
end
+
+
# Run routes defined in superclass.
+
if base.superclass.respond_to?(:routes)
+
return route!(base.superclass, pass_block)
+
/Users/john/.rvm/gems/ruby-1.9.3-p125/gems/sinatra-1.3.2/lib/sinatra/base.rb
in
+ block in process_route
+ if values.any?
+
original, @params = params, params.merge('splat' => [], 'captures' => values)
+
keys.zip(values) { |k,v| (@params[k] ||= '') << v if v }
+
end
+
+
catch(:pass) do
+
conditions.each { |c| throw :pass if c.bind(self).call == false }
+
block ? block[self, values] : yield(self, values)
end
+
ensure
+
@params = original if original
+
end
+
+
# No matching route was found or all routes passed. The default
+
# implementation is to forward the request downstream when running
+
/Users/john/.rvm/gems/ruby-1.9.3-p125/gems/sinatra-1.3.2/lib/sinatra/base.rb
in
+ catch
+ values += match.captures.to_a.map { |v| force_encoding URI.decode(v) if v }
+
+
if values.any?
+
original, @params = params, params.merge('splat' => [], 'captures' => values)
+
keys.zip(values) { |k,v| (@params[k] ||= '') << v if v }
+
end
+
+
catch(:pass) do
conditions.each { |c| throw :pass if c.bind(self).call == false }
+
block ? block[self, values] : yield(self, values)
+
end
+
ensure
+
@params = original if original
+
end
+
+
/Users/john/.rvm/gems/ruby-1.9.3-p125/gems/sinatra-1.3.2/lib/sinatra/base.rb
in
+ process_route
+ values += match.captures.to_a.map { |v| force_encoding URI.decode(v) if v }
+
+
if values.any?
+
original, @params = params, params.merge('splat' => [], 'captures' => values)
+
keys.zip(values) { |k,v| (@params[k] ||= '') << v if v }
+
end
+
+
catch(:pass) do
conditions.each { |c| throw :pass if c.bind(self).call == false }
+
block ? block[self, values] : yield(self, values)
+
end
+
ensure
+
@params = original if original
+
end
+
+
/Users/john/.rvm/gems/ruby-1.9.3-p125/gems/sinatra-1.3.2/lib/sinatra/base.rb
in
+ block in route!
+ base.filters[type].each { |args| process_route(*args) }
+
end
+
+
# Run routes defined on the class and all superclasses.
+
def route!(base = settings, pass_block=nil)
+
if routes = base.routes[@request.request_method]
+
routes.each do |pattern, keys, conditions, block|
+
pass_block = process_route(pattern, keys, conditions) do |*args|
route_eval { block[*args] }
+
end
+
end
+
end
+
+
# Run routes defined in superclass.
+
if base.superclass.respond_to?(:routes)
+
/Users/john/.rvm/gems/ruby-1.9.3-p125/gems/sinatra-1.3.2/lib/sinatra/base.rb
in
+ each
+ filter! type, base.superclass if base.superclass.respond_to?(:filters)
+
base.filters[type].each { |args| process_route(*args) }
+
end
+
+
# Run routes defined on the class and all superclasses.
+
def route!(base = settings, pass_block=nil)
+
if routes = base.routes[@request.request_method]
+
routes.each do |pattern, keys, conditions, block|
pass_block = process_route(pattern, keys, conditions) do |*args|
+
route_eval { block[*args] }
+
end
+
end
+
end
+
+
# Run routes defined in superclass.
+
/Users/john/.rvm/gems/ruby-1.9.3-p125/gems/sinatra-1.3.2/lib/sinatra/base.rb
in
+ route!
+ filter! type, base.superclass if base.superclass.respond_to?(:filters)
+
base.filters[type].each { |args| process_route(*args) }
+
end
+
+
# Run routes defined on the class and all superclasses.
+
def route!(base = settings, pass_block=nil)
+
if routes = base.routes[@request.request_method]
+
routes.each do |pattern, keys, conditions, block|
pass_block = process_route(pattern, keys, conditions) do |*args|
+
route_eval { block[*args] }
+
end
+
end
+
end
+
+
# Run routes defined in superclass.
+
/Users/john/.rvm/gems/ruby-1.9.3-p125/gems/sinatra-1.3.2/lib/sinatra/base.rb
in
+ dispatch!
+ end
+
end
+
+
# Dispatch a request with error handling.
+
def dispatch!
+
static! if settings.static? && (request.get? || request.head?)
+
filter! :before
+
route!
rescue ::Exception => boom
+
handle_exception!(boom)
+
ensure
+
filter! :after unless env['sinatra.static_file']
+
end
+
+
# Error handling during requests.
+
/Users/john/.rvm/gems/ruby-1.9.3-p125/gems/sinatra-1.3.2/lib/sinatra/base.rb
in
+ block in call!
+ @request = Request.new(env)
+
@response = Response.new
+
@params = indifferent_params(@request.params)
+
template_cache.clear if settings.reload_templates
+
force_encoding(@params)
+
+
@response['Content-Type'] = nil
+
invoke { dispatch! }
invoke { error_block!(response.status) }
+
+
unless @response['Content-Type']
+
if Array === body and body[0].respond_to? :content_type
+
content_type body[0].content_type
+
else
+
content_type :html
+
/Users/john/.rvm/gems/ruby-1.9.3-p125/gems/sinatra-1.3.2/lib/sinatra/base.rb
in
+ block in invoke
+ # Creates a Hash with indifferent access.
+
def indifferent_hash
+
Hash.new {|hash,key| hash[key.to_s] if Symbol === key }
+
end
+
+
# Run the block with 'throw :halt' support and apply result to the response.
+
def invoke
+
res = catch(:halt) { yield }
res = [res] if Fixnum === res or String === res
+
if Array === res and Fixnum === res.first
+
status(res.shift)
+
body(res.pop)
+
headers(*res)
+
elsif res.respond_to? :each
+
body res
+
/Users/john/.rvm/gems/ruby-1.9.3-p125/gems/sinatra-1.3.2/lib/sinatra/base.rb
in
+ catch
+ # Creates a Hash with indifferent access.
+
def indifferent_hash
+
Hash.new {|hash,key| hash[key.to_s] if Symbol === key }
+
end
+
+
# Run the block with 'throw :halt' support and apply result to the response.
+
def invoke
+
res = catch(:halt) { yield }
res = [res] if Fixnum === res or String === res
+
if Array === res and Fixnum === res.first
+
status(res.shift)
+
body(res.pop)
+
headers(*res)
+
elsif res.respond_to? :each
+
body res
+
/Users/john/.rvm/gems/ruby-1.9.3-p125/gems/sinatra-1.3.2/lib/sinatra/base.rb
in
+ invoke
+ # Creates a Hash with indifferent access.
+
def indifferent_hash
+
Hash.new {|hash,key| hash[key.to_s] if Symbol === key }
+
end
+
+
# Run the block with 'throw :halt' support and apply result to the response.
+
def invoke
+
res = catch(:halt) { yield }
res = [res] if Fixnum === res or String === res
+
if Array === res and Fixnum === res.first
+
status(res.shift)
+
body(res.pop)
+
headers(*res)
+
elsif res.respond_to? :each
+
body res
+
/Users/john/.rvm/gems/ruby-1.9.3-p125/gems/sinatra-1.3.2/lib/sinatra/base.rb
in
+ call!
+ @request = Request.new(env)
+
@response = Response.new
+
@params = indifferent_params(@request.params)
+
template_cache.clear if settings.reload_templates
+
force_encoding(@params)
+
+
@response['Content-Type'] = nil
+
invoke { dispatch! }
invoke { error_block!(response.status) }
+
+
unless @response['Content-Type']
+
if Array === body and body[0].respond_to? :content_type
+
content_type body[0].content_type
+
else
+
content_type :html
+
/Users/john/.rvm/gems/ruby-1.9.3-p125/gems/sinatra-1.3.2/lib/sinatra/base.rb
in
+ call
+ @app = app
+
@template_cache = Tilt::Cache.new
+
yield self if block_given?
+
end
+
+
# Rack call interface.
+
def call(env)
+
dup.call!(env)
end
+
+
attr_accessor :env, :request, :response, :params
+
+
def call!(env) # :nodoc:
+
@env = env
+
@request = Request.new(env)
+
/Users/john/.rvm/gems/ruby-1.9.3-p125/gems/rack-protection-1.2.0/lib/rack/protection/xss_header.rb
in
+ call
+ default_options :xss_mode => :block
+
+
def header
+
{ 'X-XSS-Protection' => "1; mode=#{options[:xss_mode]}" }
+
end
+
+
def call(env)
+
status, headers, body = @app.call(env)
[status, header.merge(headers), body]
+
end
+
end
+
end
+
end
+
/Users/john/.rvm/gems/ruby-1.9.3-p125/gems/rack-protection-1.2.0/lib/rack/protection/path_traversal.rb
in
+ call
+ #
+
# Unescapes '/' and '.', expands +path_info+.
+
# Thus <tt>GET /foo/%2e%2e%2fbar</tt> becomes <tt>GET /bar</tt>.
+
class PathTraversal < Base
+
def call(env)
+
path_was = env["PATH_INFO"]
+
env["PATH_INFO"] = cleanup path_was if path_was
+
app.call env
ensure
+
env["PATH_INFO"] = path_was
+
end
+
+
def cleanup(path)
+
parts = []
+
unescaped = path.gsub('%2e', '.').gsub('%2f', '/')
+
/Users/john/.rvm/gems/ruby-1.9.3-p125/gems/rack-protection-1.2.0/lib/rack/protection/json_csrf.rb
in
+ call
+ # JSON GET APIs are vulnerable to being embedded as JavaScript while the
+
# Array prototype has been patched to track data. Checks the referrer
+
# even on GET requests if the content type is JSON.
+
class JsonCsrf < Base
+
default_reaction :deny
+
+
def call(env)
+
status, headers, body = app.call(env)
if headers['Content-Type'].to_s.split(';', 2).first =~ /^\s*application\/json\s*$/
+
if referrer(env) != Request.new(env).host
+
result = react(env)
+
warn env, "attack prevented by #{self.class}"
+
end
+
end
+
result or [status, headers, body]
+
/Users/john/.rvm/gems/ruby-1.9.3-p125/gems/rack-protection-1.2.0/lib/rack/protection/base.rb
in
+ call
+ end
+
+
def call(env)
+
unless accepts? env
+
warn env, "attack prevented by #{self.class}"
+
result = react env
+
end
+
result or app.call(env)
end
+
+
def react(env)
+
result = send(options[:reaction], env)
+
result if Array === result and result.size == 3
+
end
+
+
/Users/john/.rvm/gems/ruby-1.9.3-p125/gems/rack-protection-1.2.0/lib/rack/protection/xss_header.rb
in
+ call
+ default_options :xss_mode => :block
+
+
def header
+
{ 'X-XSS-Protection' => "1; mode=#{options[:xss_mode]}" }
+
end
+
+
def call(env)
+
status, headers, body = @app.call(env)
[status, header.merge(headers), body]
+
end
+
end
+
end
+
end
+
/Users/john/.rvm/gems/ruby-1.9.3-p125/gems/rack-1.4.1/lib/rack/logger.rb
in
+ call
+ end
+
+
def call(env)
+
logger = ::Logger.new(env['rack.errors'])
+
logger.level = @level
+
+
env['rack.logger'] = logger
+
@app.call(env)
end
+
end
+
end
+
/Users/john/.rvm/gems/ruby-1.9.3-p125/gems/rack-1.4.1/lib/rack/head.rb
in
+ call
+
+
class Head
+
def initialize(app)
+
@app = app
+
end
+
+
def call(env)
+
status, headers, body = @app.call(env)
+
if env["REQUEST_METHOD"] == "HEAD"
+
[status, headers, []]
+
else
+
[status, headers, body]
+
end
+
end
+
/Users/john/.rvm/gems/ruby-1.9.3-p125/gems/sinatra-1.3.2/lib/sinatra/showexceptions.rb
in
+ call
+
+
def initialize(app)
+
@app = app
+
@template = ERB.new(TEMPLATE)
+
end
+
+
def call(env)
+
@app.call(env)
rescue Exception => e
+
errors, env["rack.errors"] = env["rack.errors"], @@eats_errors
+
+
if respond_to?(:prefers_plain_text?) and prefers_plain_text?(env)
+
content_type = "text/plain"
+
body = [dump_exception(e)]
+
else
+
/Users/john/.rvm/gems/ruby-1.9.3-p125/gems/sinatra-1.3.2/lib/sinatra/base.rb
in
+ block in call
+ setup_default_middleware builder
+
setup_middleware builder
+
builder.run new!(*args, &bk)
+
builder
+
end
+
+
def call(env)
+
synchronize { prototype.call(env) }
end
+
+
private
+
def setup_default_middleware(builder)
+
builder.use ShowExceptions if show_exceptions?
+
builder.use Rack::MethodOverride if method_override?
+
builder.use Rack::Head
+
/Users/john/.rvm/gems/ruby-1.9.3-p125/gems/sinatra-1.3.2/lib/sinatra/base.rb
in
+ synchronize
+ end
+
+
@@mutex = Mutex.new
+
def synchronize(&block)
+
if lock?
+
@@mutex.synchronize(&block)
+
else
+
yield
end
+
end
+
+
public
+
CALLERS_TO_IGNORE = [ # :nodoc:
+
/\/sinatra(\/(base|main|showexceptions))?\.rb$/, # all sinatra code
+
/lib\/tilt.*\.rb$/, # all tilt code
+
/Users/john/.rvm/gems/ruby-1.9.3-p125/gems/sinatra-1.3.2/lib/sinatra/base.rb
in
+ call
+ setup_default_middleware builder
+
setup_middleware builder
+
builder.run new!(*args, &bk)
+
builder
+
end
+
+
def call(env)
+
synchronize { prototype.call(env) }
end
+
+
private
+
def setup_default_middleware(builder)
+
builder.use ShowExceptions if show_exceptions?
+
builder.use Rack::MethodOverride if method_override?
+
builder.use Rack::Head
+
/Users/john/.rvm/gems/ruby-1.9.3-p125/gems/rack-1.4.1/lib/rack/builder.rb
in
+ call
+ def to_app
+
app = @map ? generate_map(@run, @map) : @run
+
fail "missing run or map statement" unless app
+
@use.reverse.inject(app) { |a,e| e[a] }
+
end
+
+
def call(env)
+
to_app.call(env)
end
+
+
private
+
+
def generate_map(default_app, mapping)
+
mapped = default_app ? {'/' => default_app} : {}
+
mapping.each { |r,b| mapped[r] = self.class.new(default_app, &b) }
+
/Users/john/.rvm/gems/ruby-1.9.3-p125/gems/rack-1.4.1/lib/rack/urlmap.rb
in
+ block in call
+
+
rest = m[1]
+
next unless !rest || rest.empty? || rest[0] == ?/
+
+
env['SCRIPT_NAME'] = (script_name + location)
+
env['PATH_INFO'] = rest
+
+
return app.call(env)
end
+
+
[404, {"Content-Type" => "text/plain", "X-Cascade" => "pass"}, ["Not Found: #{path}"]]
+
+
ensure
+
env['PATH_INFO'] = path
+
env['SCRIPT_NAME'] = script_name
+
/Users/john/.rvm/gems/ruby-1.9.3-p125/gems/rack-1.4.1/lib/rack/urlmap.rb
in
+ each
+ def call(env)
+
path = env["PATH_INFO"]
+
script_name = env['SCRIPT_NAME']
+
hHost = env['HTTP_HOST']
+
sName = env['SERVER_NAME']
+
sPort = env['SERVER_PORT']
+
+
@mapping.each do |host, location, match, app|
unless hHost == host \
+
|| sName == host \
+
|| (!host && (hHost == sName || hHost == sName+':'+sPort))
+
next
+
end
+
+
next unless m = match.match(path.to_s)
+
/Users/john/.rvm/gems/ruby-1.9.3-p125/gems/rack-1.4.1/lib/rack/urlmap.rb
in
+ call
+ def call(env)
+
path = env["PATH_INFO"]
+
script_name = env['SCRIPT_NAME']
+
hHost = env['HTTP_HOST']
+
sName = env['SERVER_NAME']
+
sPort = env['SERVER_PORT']
+
+
@mapping.each do |host, location, match, app|
unless hHost == host \
+
|| sName == host \
+
|| (!host && (hHost == sName || hHost == sName+':'+sPort))
+
next
+
end
+
+
next unless m = match.match(path.to_s)
+
/Users/john/.rvm/gems/ruby-1.9.3-p125/gems/rack-1.4.1/lib/rack/builder.rb
in
+ call
+ def to_app
+
app = @map ? generate_map(@run, @map) : @run
+
fail "missing run or map statement" unless app
+
@use.reverse.inject(app) { |a,e| e[a] }
+
end
+
+
def call(env)
+
to_app.call(env)
end
+
+
private
+
+
def generate_map(default_app, mapping)
+
mapped = default_app ? {'/' => default_app} : {}
+
mapping.each { |r,b| mapped[r] = self.class.new(default_app, &b) }
+
/Users/john/Projects/attentive/lib/attentive/server.rb
in
+ call
+ use(*opts)
+
end
+
+
run Attentive::Sinatra
+
end
+
end
+
+
@app.call(env)
end
+
end
+
+
class Highlight
+
attr_reader :code, :lang
+
+
def self.run(*args)
+
/Users/john/Projects/attentive/bin/attentive
in
+ block in static
+
+
FileUtils.rm_rf target_dir
+
FileUtils.mkdir_p target_dir
+
+
Attentive.middleware.replace([])
+
+
urls.each do |url|
+
response = Attentive::Server.call(Rack::MockRequest.env_for(url))
+
target = "#{target_dir}#{url}"
+
target += "index.html" if target[-1..-1] == '/'
+
+
puts "Writing #{target}..."
+
+
FileUtils.mkdir_p(File.dirname(target))
+
/Users/john/Projects/attentive/bin/attentive
in
+ each
+ target_dir = "_site"
+
+
FileUtils.rm_rf target_dir
+
FileUtils.mkdir_p target_dir
+
+
Attentive.middleware.replace([])
+
+
urls.each do |url|
response = Attentive::Server.call(Rack::MockRequest.env_for(url))
+
+
target = "#{target_dir}#{url}"
+
target += "index.html" if target[-1..-1] == '/'
+
+
puts "Writing #{target}..."
+
+
/Users/john/Projects/attentive/bin/attentive
in
+ static
+ target_dir = "_site"
+
+
FileUtils.rm_rf target_dir
+
FileUtils.mkdir_p target_dir
+
+
Attentive.middleware.replace([])
+
+
urls.each do |url|
response = Attentive::Server.call(Rack::MockRequest.env_for(url))
+
+
target = "#{target_dir}#{url}"
+
target += "index.html" if target[-1..-1] == '/'
+
+
puts "Writing #{target}..."
+
+
/Users/john/Projects/attentive/bin/attentive
in
+ gh_pages
+ end
+
+
FileUtils.rm_rf '.sass-cache' if File.directory?('.sass-cache')
+
end
+
+
desc "gh-pages", "Commit the static site to the associated GitHub pages account"
+
def gh_pages
+
static
+
target = "/tmp/attentive-#{Time.now.to_i}"
+
+
system %{cp -Rpv _site #{target}}
+
+
system %{git checkout gh-pages}
+
if $?.exitstatus == 1
+
/Users/john/.rvm/gems/ruby-1.9.3-p125/gems/thor-0.14.6/lib/thor/task.rb
in
+ run
+ false
+
end
+
+
# By default, a task invokes a method in the thor class. You can change this
+
# implementation to create custom tasks.
+
def run(instance, args=[])
+
public_method?(instance) ?
+
instance.send(name, *args) : instance.class.handle_no_task_error(name)
rescue ArgumentError => e
+
handle_argument_error?(instance, e, caller) ?
+
instance.class.handle_argument_error(self, e) : (raise e)
+
rescue NoMethodError => e
+
handle_no_method_error?(instance, e, caller) ?
+
instance.class.handle_no_task_error(name) : (raise e)
+
end
+
/Users/john/.rvm/gems/ruby-1.9.3-p125/gems/thor-0.14.6/lib/thor/invocation.rb
in
+ invoke_task
+
+
# Invoke the given task if the given args.
+
def invoke_task(task, *args) #:nodoc:
+
current = @_invocations[self.class]
+
+
unless current.include?(task.name)
+
current << task.name
+
task.run(self, *args)
end
+
end
+
+
# Invoke all tasks for the current instance.
+
def invoke_all #:nodoc:
+
self.class.all_tasks.map { |_, task| invoke_task(task) }
+
end
+
/Users/john/.rvm/gems/ruby-1.9.3-p125/gems/thor-0.14.6/lib/thor.rb
in
+ dispatch
+ task = Thor::DynamicTask.new(meth)
+
end
+
+
opts = given_opts || opts || []
+
config.merge!(:current_task => task, :task_options => task.options)
+
+
trailing = args[Range.new(arguments.size, -1)]
+
new(args, opts, config).invoke_task(task, trailing || [])
end
+
+
# The banner for this class. You can customize it if you are invoking the
+
# thor class by another ways which is not the Thor::Runner. It receives
+
# the task that is going to be invoked and a boolean which indicates if
+
# the namespace should be displayed as arguments.
+
#
+
/Users/john/.rvm/gems/ruby-1.9.3-p125/gems/thor-0.14.6/lib/thor/base.rb
in
+ start
+ #
+
# script = MyScript.new(args, options, config)
+
# script.invoke(:task, first_arg, second_arg, third_arg)
+
#
+
def start(given_args=ARGV, config={})
+
self.debugging = given_args.delete("--debug")
+
config[:shell] ||= Thor::Base.shell.new
+
dispatch(nil, given_args.dup, nil, config)
rescue Thor::Error => e
+
debugging ? (raise e) : config[:shell].error(e.message)
+
exit(1) if exit_on_failure?
+
end
+
+
# Allows to use private methods from parent in child classes as tasks.
+
#
+
/Users/john/Projects/attentive/bin/attentive
in
+ <top (required)>
+ system %{git add .}
+
system %{git add *}
+
system %{git commit -a -m "Update published site"}
+
system %{git checkout master}
+
end
+
end
+
+
Attentive::CLI.start
/Users/john/.rvm/gems/ruby-1.9.3-p125/bin/attentive
in
+ load
+
+
if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then
+
version = $1
+
ARGV.shift
+
end
+
+
gem 'attentive', version
+
load Gem.bin_path('attentive', 'attentive', version)
/Users/john/.rvm/gems/ruby-1.9.3-p125/bin/attentive
in
+ <main>
+
+
if ARGV.first =~ /^_(.*)_$/ and Gem::Version.correct? $1 then
+
version = $1
+
ARGV.shift
+
end
+
+
gem 'attentive', version
+
load Gem.bin_path('attentive', 'attentive', version)
No GET data.
+ + +No POST data.
+ + +Variable | +Value | +
---|---|
CONTENT_LENGTH | +0 |
+
HTTPS | +off |
+
PATH_INFO | +/ |
+
QUERY_STRING | ++ |
REQUEST_METHOD | +GET |
+
SCRIPT_NAME | ++ |
SERVER_NAME | +example.org |
+
SERVER_PORT | +80 |
+
rack.errors | +#<Object:0x00000101971920> |
+
rack.input | +#<StringIO:0x00000100b3b568> |
+
rack.logger | +#<Logger:0x0000010099a100 @progname=nil, @level=1, @default_formatter=#<Logger::Formatter:0x0000010099a0d8 @datetime_format=nil>, @formatter=nil, @logdev=#<Logger::LogDevice:0x00000100999f20 @shift_size=nil, @shift_age=nil, @filename=nil, @dev=#<StringIO:0x00000100b3b658>, @mutex=#<Logger::LogDevice::LogDeviceMutex:0x00000100999e30 @mon_owner=nil, @mon_count=0, @mon_mutex=#<Mutex:0x00000100999c28>>>> |
+
rack.multiprocess | +true |
+
rack.multithread | +true |
+
rack.request.cookie_hash | +{} |
+
rack.request.query_hash | +{} |
+
rack.request.query_string | ++ |
rack.run_once | +false |
+
rack.url_scheme | +http |
+
rack.version | +[1, 1] |
+
sinatra.error | +#<NameError: uninitialized constant Attentive::Sinatra::Pygments> |
+
You're seeing this error because you have
+enabled the show_exceptions
setting.