diff --git a/config/rackup.ru b/config/rackup.ru index 5c2d014..5730bcf 100644 --- a/config/rackup.ru +++ b/config/rackup.ru @@ -1,6 +1,6 @@ require 'rubygems' require 'sinatra' - + set :environment, :production require app_file = File.dirname(__FILE__) + "/../go_get_me_some" diff --git a/go_get_me_some.rb b/go_get_me_some.rb index 17adf73..e4b5534 100644 --- a/go_get_me_some.rb +++ b/go_get_me_some.rb @@ -1,5 +1,5 @@ # GET ME SOME SOURCE CODE! -# +# # Code by Nate Todd and Jonathan Crossman # Built because... YES WE CAN! # 2/6/09 is a day not unlike any other day @@ -29,11 +29,11 @@ def to_pretty(topic_time) case a when 0 then return "just now" when 1 then return "a second ago" - when 2..59 then return a.to_s+' seconds ago' + when 2..59 then return a.to_s+' seconds ago' when 60..119 then return 'a minute ago' #120 = 2 minutes when 120..3540 then return (a/60).to_i.to_s+' minutes ago' when 3541..7100 then return 'an hour ago' # 3600 = 1 hour - when 7101..82800 then return ((a+99)/3600).to_i.to_s+' hours ago' + when 7101..82800 then return ((a+99)/3600).to_i.to_s+' hours ago' when 82801..172000 then return 'a day ago' # 86400 = 1 day when 172001..518400 then return ((a+800)/(60*60*24)).to_i.to_s+' days ago' when 518400..1036800 then return 'a week ago' @@ -42,7 +42,7 @@ def to_pretty(topic_time) end end -before do +before do # kill trailing slashes for all requests except '/' request.env['PATH_INFO'].gsub!(/\/$/, '') if request.env['PATH_INFO'] != '/' end @@ -75,7 +75,7 @@ def to_pretty(topic_time) private def fetch_and_display(topic_url, img_number) - + # can't use CGI.escape() on deployment server, so using a gsub to catch spaces in the url topic = topic_url.gsub(/\s+/, '%20') doc = open("http://images.google.com/images?um=1&hl=en&client=safari&rls=en-us&btnG=Search+Images&ei=ubeLSbSgGqTUMbzxzZAL&gbv=1&ei=lLqLSYWsFaX6NJrzyIkL&q=#{topic}") { |f| Hpricot(f) } @@ -83,14 +83,14 @@ def fetch_and_display(topic_url, img_number) # fetch hotlinking image source anchor = (doc/'table[@align="center"]/tr/td/a[@href*="imgurl"]')[img_number.to_i - 1] @thumbnail = (anchor/'img').first['src'] unless anchor.nil? - + @remote_image_src = anchor['href'].match(/imgurl=(http:\/\/[^&]+(?:jpe?g|gif|png)?)/)[1] unless anchor.nil? - + # Create the entry Topic.new( :topic => topic, :timestamp => Time.now ).save unless anchor.nil? - + # Find a random entry @random_topic = Topic.first(:order => "random()", :select => "DISTINCT(topic)") - + haml :view end \ No newline at end of file diff --git a/public/go_get_me_some.js b/public/go_get_me_some.js index 8637fdd..5a3994f 100644 --- a/public/go_get_me_some.js +++ b/public/go_get_me_some.js @@ -1,6 +1,6 @@ window.onload = function(){ var img = document.getElementsByTagName('img')[0]; - + if (img && img.naturalHeight + img.naturalWidth == 0) img.src = thumbnail; } diff --git a/vendor/haml-2.0.5/Rakefile b/vendor/haml-2.0.5/Rakefile index 51f4f56..4e661f6 100644 --- a/vendor/haml-2.0.5/Rakefile +++ b/vendor/haml-2.0.5/Rakefile @@ -145,6 +145,6 @@ END result = RubyProf.profile { times.times { obj.render } } end - RubyProf.const_get("#{(ENV['OUTPUT'] || 'Flat').capitalize}Printer").new(result).print + RubyProf.const_get("#{(ENV['OUTPUT'] || 'Flat').capitalize}Printer").new(result).print end rescue LoadError; end diff --git a/vendor/haml-2.0.5/lib/haml.rb b/vendor/haml-2.0.5/lib/haml.rb index 3dd23e5..b5b6fbe 100644 --- a/vendor/haml-2.0.5/lib/haml.rb +++ b/vendor/haml-2.0.5/lib/haml.rb @@ -569,7 +569,7 @@ # # # -# ==== \ +# ==== \ # # The backslash character escapes the first character of a line, # allowing use of otherwise interpreted characters as plain text. @@ -921,7 +921,7 @@ # ...or by setting the Merb::Plugin.config[:haml] hash in init.rb in Merb... # # Merb::Plugin.config[:haml][:format] = :html5 -# +# # ...or by passing an options hash to Haml::Engine.new. # Available options are: # diff --git a/vendor/haml-2.0.5/lib/haml/html.rb b/vendor/haml-2.0.5/lib/haml/html.rb index 7ffe072..5828d6c 100644 --- a/vendor/haml-2.0.5/lib/haml/html.rb +++ b/vendor/haml-2.0.5/lib/haml/html.rb @@ -158,7 +158,7 @@ def to_haml(tabs = 0) end private - + def dynamic_attributes @dynamic_attributes ||= begin attributes.inject({}) do |dynamic, pair| @@ -177,19 +177,19 @@ def dynamic_attributes end end end - + def static_attribute?(name) attributes[name] and !dynamic_attribute?(name) end - + def dynamic_attribute?(name) HTML.options[:rhtml] and dynamic_attributes.key?(name) end - + def static_id? static_attribute? 'id' end - + def static_classname? static_attribute? 'class' end diff --git a/vendor/haml-2.0.5/lib/haml/precompiler.rb b/vendor/haml-2.0.5/lib/haml/precompiler.rb index 604e578..5c819f3 100644 --- a/vendor/haml-2.0.5/lib/haml/precompiler.rb +++ b/vendor/haml-2.0.5/lib/haml/precompiler.rb @@ -107,8 +107,8 @@ def locals_code(names) names.map do |name| # Can't use || because someone might explicitly pass in false with a symbol - sym_local = "_haml_locals[#{name.to_sym.inspect}]" - str_local = "_haml_locals[#{name.to_s.inspect}]" + sym_local = "_haml_locals[#{name.to_sym.inspect}]" + str_local = "_haml_locals[#{name.to_s.inspect}]" "#{name} = #{sym_local}.nil? ? #{str_local} : #{sym_local}" end.join(';') + ';' end @@ -603,7 +603,7 @@ def render_tag(line) else open_tag << "\n" unless parse || nuke_inner_whitespace || (self_closing && nuke_outer_whitespace) end - + push_merged_text(open_tag, tag_closed || self_closing || nuke_inner_whitespace ? 0 : 1, !nuke_outer_whitespace) diff --git a/vendor/haml-2.0.5/lib/haml/template/plugin.rb b/vendor/haml-2.0.5/lib/haml/template/plugin.rb index 9a7914d..5bfdfb0 100644 --- a/vendor/haml-2.0.5/lib/haml/template/plugin.rb +++ b/vendor/haml-2.0.5/lib/haml/template/plugin.rb @@ -47,7 +47,7 @@ def compile_template(handler, template, file_name, local_assigns) begin render_source = create_template_source(handler, template, render_symbol, local_assigns.keys) line_offset = @@template_args[render_symbol].size + handler.line_offset - + file_name = 'compiled-template' if file_name.blank? CompiledTemplates.module_eval(render_source, file_name, -line_offset) rescue Exception => e # errors from template code @@ -60,10 +60,10 @@ def compile_template(handler, template, file_name, local_assigns) # There's no way to tell Haml about the filename, # so we've got to insert it ourselves. e.backtrace[0].gsub!('(haml)', file_name) if e.is_a?(Haml::Error) - + raise ActionView::TemplateError.new(extract_base_path_from(file_name) || view_paths.first, file_name || template, @assigns, template, e) end - + @@compile_time[render_symbol] = Time.now # logger.debug "Compiled template #{file_name || template}\n ==> #{render_symbol}" if logger end diff --git a/vendor/haml-2.0.5/lib/sass.rb b/vendor/haml-2.0.5/lib/sass.rb index 2fcad00..43dd7f8 100644 --- a/vendor/haml-2.0.5/lib/sass.rb +++ b/vendor/haml-2.0.5/lib/sass.rb @@ -56,7 +56,7 @@ # sass input.sass output.css # # Use sass --help for full documentation. -# +# # Using Sass in Ruby code is very simple. # After installing the Haml gem, # you can use it by running require "sass" @@ -791,7 +791,7 @@ # ...or by setting the Merb::Plugin.config[:sass] hash in init.rb in Merb... # # Merb::Plugin.config[:sass][:style] = :compact -# +# # ...or by passing an options hash to Sass::Engine.new. # Available options are: # diff --git a/vendor/haml-2.0.5/test/haml/markaby/standard.mab b/vendor/haml-2.0.5/test/haml/markaby/standard.mab index aff8641..93c1896 100644 --- a/vendor/haml-2.0.5/test/haml/markaby/standard.mab +++ b/vendor/haml-2.0.5/test/haml/markaby/standard.mab @@ -18,14 +18,14 @@ html(:xmlns=>'http://www.w3.org/1999/xhtml', 'xml:lang'=>'en-US') do end self << "Wow.|" p do - self << "Holy cow " + - "multiline " + - "tags! " + - "A pipe (|) even!" + self << "Holy cow " + + "multiline " + + "tags! " + + "A pipe (|) even!" self << [1, 2, 3].collect { |n| "PipesIgnored|" } - self << [1, 2, 3].collect { |n| - n.to_s - }.join("|") + self << [1, 2, 3].collect { |n| + n.to_s + }.join("|") end div(:class => "silent") do foo = String.new diff --git a/vendor/haml-2.0.5/test/haml/results/filters.xhtml b/vendor/haml-2.0.5/test/haml/results/filters.xhtml index 6e192ec..9f61b22 100644 --- a/vendor/haml-2.0.5/test/haml/results/filters.xhtml +++ b/vendor/haml-2.0.5/test/haml/results/filters.xhtml @@ -1,6 +1,6 @@ TESTING HAHAHAHA! diff --git a/vendor/haml-2.0.5/test/haml/results/standard.xhtml b/vendor/haml-2.0.5/test/haml/results/standard.xhtml index ee5fe9a..e1718e9 100644 --- a/vendor/haml-2.0.5/test/haml/results/standard.xhtml +++ b/vendor/haml-2.0.5/test/haml/results/standard.xhtml @@ -34,7 +34,7 @@ hello
diff --git a/vendor/haml-2.0.5/test/haml/rhtml/action_view.rhtml b/vendor/haml-2.0.5/test/haml/rhtml/action_view.rhtml index bcb0d41..a3c9f2f 100644 --- a/vendor/haml-2.0.5/test/haml/rhtml/action_view.rhtml +++ b/vendor/haml-2.0.5/test/haml/rhtml/action_view.rhtml @@ -54,7 +54,7 @@ end %> diff --git a/vendor/haml-2.0.5/test/haml/rhtml/standard.rhtml b/vendor/haml-2.0.5/test/haml/rhtml/standard.rhtml index 549cc6b..52f97aa 100644 --- a/vendor/haml-2.0.5/test/haml/rhtml/standard.rhtml +++ b/vendor/haml-2.0.5/test/haml/rhtml/standard.rhtml @@ -46,7 +46,7 @@ end %> diff --git a/vendor/haml-2.0.5/test/haml/templates/_partial.haml b/vendor/haml-2.0.5/test/haml/templates/_partial.haml index 756b54b..f497a28 100644 --- a/vendor/haml-2.0.5/test/haml/templates/_partial.haml +++ b/vendor/haml-2.0.5/test/haml/templates/_partial.haml @@ -1,8 +1,8 @@ %p - @foo = + @foo = = @foo - @foo = 'value three' == Toplevel? #{haml_buffer.toplevel?} %p - @foo = + @foo = = @foo diff --git a/vendor/haml-2.0.5/test/haml/templates/action_view.haml b/vendor/haml-2.0.5/test/haml/templates/action_view.haml index 5b9fa04..0eef858 100644 --- a/vendor/haml-2.0.5/test/haml/templates/action_view.haml +++ b/vendor/haml-2.0.5/test/haml/templates/action_view.haml @@ -21,7 +21,7 @@ Wow.| %p = "Holy cow " + | - "multiline " + | + "multiline " + | "tags! " + | "A pipe (|) even!" | = [1, 2, 3].collect { |n| "PipesIgnored|" } diff --git a/vendor/haml-2.0.5/test/haml/templates/just_stuff.haml b/vendor/haml-2.0.5/test/haml/templates/just_stuff.haml index 29c4d57..82d8557 100644 --- a/vendor/haml-2.0.5/test/haml/templates/just_stuff.haml +++ b/vendor/haml-2.0.5/test/haml/templates/just_stuff.haml @@ -20,7 +20,7 @@ %p== Embedded? #{"twice! #{true}"}! %p== Embedded? #{"one"} af"t"er #{"another"}! = "stuff followed by whitespace" - + - if true %strong block with whitespace @@ -51,7 +51,7 @@ = "test" | "test" | -# Hard tabs shouldn't throw errors. - + - case :foo - when :bar %br Blah diff --git a/vendor/haml-2.0.5/test/haml/templates/partials.haml b/vendor/haml-2.0.5/test/haml/templates/partials.haml index d74f4b4..692dc12 100644 --- a/vendor/haml-2.0.5/test/haml/templates/partials.haml +++ b/vendor/haml-2.0.5/test/haml/templates/partials.haml @@ -1,12 +1,12 @@ - @foo = 'value one' %p - @foo = + @foo = = @foo - @foo = 'value two' %p - @foo = + @foo = = @foo = test_partial "partial" %p - @foo = + @foo = = @foo diff --git a/vendor/haml-2.0.5/test/haml/templates/silent_script.haml b/vendor/haml-2.0.5/test/haml/templates/silent_script.haml index 45199f0..e466883 100644 --- a/vendor/haml-2.0.5/test/haml/templates/silent_script.haml +++ b/vendor/haml-2.0.5/test/haml/templates/silent_script.haml @@ -36,5 +36,5 @@ - "foo | bar | baz" | - + %p boom diff --git a/vendor/haml-2.0.5/test/haml/templates/standard.haml b/vendor/haml-2.0.5/test/haml/templates/standard.haml index a3aaa5b..7206f57 100644 --- a/vendor/haml-2.0.5/test/haml/templates/standard.haml +++ b/vendor/haml-2.0.5/test/haml/templates/standard.haml @@ -16,7 +16,7 @@ Wow.| %p = "Holy cow " + | - "multiline " + | + "multiline " + | "tags! " + | "A pipe (|) even!" | = [1, 2, 3].collect { |n| "PipesIgnored|" } diff --git a/vendor/haml-2.0.5/test/haml/templates/whitespace_handling.haml b/vendor/haml-2.0.5/test/haml/templates/whitespace_handling.haml index 9f27195..e939f90 100644 --- a/vendor/haml-2.0.5/test/haml/templates/whitespace_handling.haml +++ b/vendor/haml-2.0.5/test/haml/templates/whitespace_handling.haml @@ -56,18 +56,18 @@ %strong This should! %textarea :preserve - ___ ___ ___ ___ + ___ ___ ___ ___ /\__\ /\ \ /\__\ /\__\ /:/ / /::\ \ /::| | /:/ / - /:/__/ /:/\:\ \ /:|:| | /:/ / - /::\ \ ___ /::\~\:\ \ /:/|:|__|__ /:/ / - /:/\:\ /\__\ /:/\:\ \:\__\ /:/ |::::\__\ /:/__/ - \/__\:\/:/ / \/__\:\/:/ / \/__/~~/:/ / \:\ \ - \::/ / \::/ / /:/ / \:\ \ - /:/ / /:/ / /:/ / \:\ \ + /:/__/ /:/\:\ \ /:|:| | /:/ / + /::\ \ ___ /::\~\:\ \ /:/|:|__|__ /:/ / + /:/\:\ /\__\ /:/\:\ \:\__\ /:/ |::::\__\ /:/__/ + \/__\:\/:/ / \/__\:\/:/ / \/__/~~/:/ / \:\ \ + \::/ / \::/ / /:/ / \:\ \ + /:/ / /:/ / /:/ / \:\ \ /:/ / /:/ / /:/ / \:\__\ \/__/ \/__/ \/__/ \/__/ - + Many thanks to diff --git a/vendor/haml-2.0.5/test/sass/templates/basic.sass b/vendor/haml-2.0.5/test/sass/templates/basic.sass index 71117bf..5d4bf61 100644 --- a/vendor/haml-2.0.5/test/sass/templates/basic.sass +++ b/vendor/haml-2.0.5/test/sass/templates/basic.sass @@ -1,6 +1,6 @@ -body +body :font Arial :background blue diff --git a/vendor/haml-2.0.5/test/sass/templates/complex.sass b/vendor/haml-2.0.5/test/sass/templates/complex.sass index 44c2f84..7bea777 100644 --- a/vendor/haml-2.0.5/test/sass/templates/complex.sass +++ b/vendor/haml-2.0.5/test/sass/templates/complex.sass @@ -64,7 +64,7 @@ body :padding 2px :border none -#menu +#menu :clear both :text-align right :height 20px @@ -74,7 +74,7 @@ body ul :margin 0 5px 0 0 :padding 0 - li + li :list-style-type none :margin 0 5px :padding 5px 5px 0 5px @@ -111,7 +111,7 @@ body :text-decoration underline // A hard tab: - + #content p, div @@ -124,9 +124,9 @@ body :width 200px .box :margin-top 10px - p + p :margin 0 1em auto 1em - .box.participants + .box.participants img :float left :margin 0 1em auto 1em @@ -166,12 +166,12 @@ body :margin-top 0 #content.contests - .container.information - .column.right + .container.information + .column.right .box :margin 1em 0 .box.videos - .thumbnail img + .thumbnail img :width 200px :height 150px :margin-bottom 5px @@ -180,7 +180,7 @@ body :text-decoration none a:hover :text-decoration underline - .box.votes + .box.votes a :display block :width 200px @@ -197,7 +197,7 @@ body :text-indent -9999px :border-top 5px solid #a20013 -#content.contests +#content.contests .container.video .box.videos h2 @@ -208,13 +208,13 @@ body :border-top 5px solid #a20013 table :width 100 - td + td :padding 1em :width 25 :vertical-align top p :margin 0 0 5px 0 - a:link, a:visited + a:link, a:visited :color #93d700 :text-decoration none a:hover @@ -227,13 +227,13 @@ body :margin 0 10px 0 0 :border 1px solid #6e000d -#content - .container.comments +#content + .container.comments .column :margin-top 15px .column.left :width 600px - .box + .box ol :margin 0 :padding 0 @@ -289,16 +289,16 @@ body :float right -.clear +.clear :clear both -.centered +.centered :text-align center img :border none -button.short +button.short :width 60px :height 22px :padding 0 0 2px 0 diff --git a/vendor/haml-2.0.5/test/sass/templates/constants.sass b/vendor/haml-2.0.5/test/sass/templates/constants.sass index 645da78..5b7eb01 100644 --- a/vendor/haml-2.0.5/test/sass/templates/constants.sass +++ b/vendor/haml-2.0.5/test/sass/templates/constants.sass @@ -74,7 +74,7 @@ :col :num= #12468a * 0.5 :col= #121212 * #020304 - + #div :num :num= 10 / 3.0 diff --git a/vendor/haml-2.0.5/test/sass/templates/subdir/nested_subdir/nested_subdir.sass b/vendor/haml-2.0.5/test/sass/templates/subdir/nested_subdir/nested_subdir.sass index aae9eeb..b4013c4 100644 --- a/vendor/haml-2.0.5/test/sass/templates/subdir/nested_subdir/nested_subdir.sass +++ b/vendor/haml-2.0.5/test/sass/templates/subdir/nested_subdir/nested_subdir.sass @@ -1,3 +1,2 @@ #pi :width 314px - \ No newline at end of file diff --git a/vendor/haml-2.0.5/test/sass/templates/subdir/subdir.sass b/vendor/haml-2.0.5/test/sass/templates/subdir/subdir.sass index bbe9810..efe8135 100644 --- a/vendor/haml-2.0.5/test/sass/templates/subdir/subdir.sass +++ b/vendor/haml-2.0.5/test/sass/templates/subdir/subdir.sass @@ -2,5 +2,4 @@ :font :size 20px :weight bold - - \ No newline at end of file + diff --git a/views/index.haml b/views/index.haml index 046abfd..ecb3faf 100644 --- a/views/index.haml +++ b/views/index.haml @@ -3,7 +3,7 @@ %p go-get-me-so.me/chicken %p go-get-me-so.me/responsible-adults %p go-get-me-so.me/internet-pants -%p +%p %b New addition: add a number after your topic to try other images %p go-get-me-so.me/chicken/2 @@ -15,15 +15,15 @@ \- = to_pretty(topic.timestamp) %br -%p +%p %a{ :href => '/list_topics' } Go Get Me Some Topics! %br -%p - By +%p + By %a{ :href => 'http://twitter.com/wondersquirrel' } WonderSquirrel - & + & %a{ :href => 'http://twitter.com/crossman' } Crossman \/ Powered by %a{ :href => 'http://www.sinatrarb.com/' } Sinatra - \/ Source code at + \/ Source code at %a{ :href => 'http://github.com/ntodd/go-get-me-some/tree/master' } Github \ No newline at end of file diff --git a/views/topics.haml b/views/topics.haml index 134385f..800fdc6 100644 --- a/views/topics.haml +++ b/views/topics.haml @@ -1,5 +1,5 @@ %h1 Go Get Me Some Topics! -%p +%p %a{ :href => '/' } Go Home - @topics.each do |topic| %a{ :href => topic.topic }< diff --git a/views/view.haml b/views/view.haml index c008088..453792f 100644 --- a/views/view.haml +++ b/views/view.haml @@ -7,6 +7,6 @@ %img{ :src => @remote_image, :style => 'max-height: 400px;'} - else %p You fail at the internet -%p +%p %a{ :href => "/"} ? %a{ :href => "/#{@random_topic.topic}"} >