Created
July 29, 2011 02:26
-
-
Save jdlich/1113011 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ArgumentError: comparison of Fixnum with nil failed | |
=== COMPILATION STACK: | |
(empty) | |
=== BACKTRACE: | |
0. lib/helpers/resources.rb:45:in `sort_by' | |
1. lib/helpers/resources.rb:45:in `listings' | |
2. lib/helpers/resources.rb:64:in `new_listing' | |
3. layout /blog/:33:in `get_binding' | |
4. /Users/Jacob/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/erb.rb:753:in `eval' | |
5. /Users/Jacob/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/erb.rb:753:in `result' | |
6. /Users/Jacob/.rvm/gems/ruby-1.9.2-p290/gems/nanoc3-3.2.0b3/lib/nanoc3/filters/erb.rb:31:in `run' | |
7. /Users/Jacob/.rvm/gems/ruby-1.9.2-p290/gems/nanoc3-3.2.0b3/lib/nanoc3/helpers/rendering.rb:99:in `render' | |
8. layout /default/:50:in `get_binding' | |
9. /Users/Jacob/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/erb.rb:753:in `eval' | |
10. /Users/Jacob/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/erb.rb:753:in `result' | |
11. /Users/Jacob/.rvm/gems/ruby-1.9.2-p290/gems/nanoc3-3.2.0b3/lib/nanoc3/filters/erb.rb:31:in `run' | |
12. /Users/Jacob/.rvm/gems/ruby-1.9.2-p290/gems/nanoc3-3.2.0b3/lib/nanoc3/base/result_data/item_rep.rb:400:in `layout' | |
13. /Users/Jacob/.rvm/gems/ruby-1.9.2-p290/gems/nanoc3-3.2.0b3/lib/nanoc3/base/compilation/item_rep_proxy.rb:68:in `layout' | |
14. /Users/Jacob/.rvm/gems/ruby-1.9.2-p290/gems/nanoc3-3.2.0b3/lib/nanoc3/base/compilation/rule_context.rb:67:in `layout' | |
15. ./Rules:109:in `block in load' | |
16. /Users/Jacob/.rvm/gems/ruby-1.9.2-p290/gems/nanoc3-3.2.0b3/lib/nanoc3/base/compilation/rule.rb:68:in `instance_eval' | |
17. /Users/Jacob/.rvm/gems/ruby-1.9.2-p290/gems/nanoc3-3.2.0b3/lib/nanoc3/base/compilation/rule.rb:68:in `apply_to' | |
18. /Users/Jacob/.rvm/gems/ruby-1.9.2-p290/gems/nanoc3-3.2.0b3/lib/nanoc3/base/compilation/compiler.rb:377:in `compile_rep' | |
19. /Users/Jacob/.rvm/gems/ruby-1.9.2-p290/gems/nanoc3-3.2.0b3/lib/nanoc3/base/compilation/compiler.rb:333:in `block in compile_reps' | |
20. /Users/Jacob/.rvm/gems/ruby-1.9.2-p290/gems/nanoc3-3.2.0b3/lib/nanoc3/base/compilation/compiler.rb:326:in `loop' | |
21. /Users/Jacob/.rvm/gems/ruby-1.9.2-p290/gems/nanoc3-3.2.0b3/lib/nanoc3/base/compilation/compiler.rb:326:in `compile_reps' | |
22. /Users/Jacob/.rvm/gems/ruby-1.9.2-p290/gems/nanoc3-3.2.0b3/lib/nanoc3/base/compilation/compiler.rb:85:in `run' | |
23. /Users/Jacob/.rvm/gems/ruby-1.9.2-p290/gems/nanoc3-3.2.0b3/lib/nanoc3/base/source_data/site.rb:57:in `compile' | |
24. /Users/Jacob/.rvm/gems/ruby-1.9.2-p290/gems/nanoc3-3.2.0b3/lib/nanoc3/cli/commands/compile.rb:61:in `run' | |
25. /Users/Jacob/.rvm/gems/ruby-1.9.2-p290/gems/nanoc3-3.2.0b3/lib/nanoc3/cli/command.rb:51:in `block in call' | |
26. /Users/Jacob/.rvm/gems/ruby-1.9.2-p290/gems/nanoc3-3.2.0b3/lib/nanoc3/cli/error_handler.rb:40:in `handle_while' | |
27. /Users/Jacob/.rvm/gems/ruby-1.9.2-p290/gems/nanoc3-3.2.0b3/lib/nanoc3/cli/error_handler.rb:21:in `handle_while' | |
28. /Users/Jacob/.rvm/gems/ruby-1.9.2-p290/gems/nanoc3-3.2.0b3/lib/nanoc3/cli/command.rb:50:in `call' | |
29. /Users/Jacob/.rvm/gems/ruby-1.9.2-p290/gems/nanoc3-3.2.0b3/lib/nanoc3/cli/command.rb:43:in `call' | |
30. /Users/Jacob/.rvm/gems/ruby-1.9.2-p290/gems/nanoc3-3.2.0b3/lib/nanoc3/cli/commands/compile.rb:24:in `block in define' | |
31. /Users/Jacob/.rvm/gems/ruby-1.9.2-p290/gems/cri-2.0.2/lib/cri/command.rb:255:in `call' | |
32. /Users/Jacob/.rvm/gems/ruby-1.9.2-p290/gems/cri-2.0.2/lib/cri/command.rb:255:in `run' | |
33. /Users/Jacob/.rvm/gems/ruby-1.9.2-p290/gems/cri-2.0.2/lib/cri/command.rb:272:in `run' | |
34. /Users/Jacob/.rvm/gems/ruby-1.9.2-p290/gems/nanoc3-3.2.0b3/lib/nanoc3/cli.rb:40:in `block in run' | |
35. /Users/Jacob/.rvm/gems/ruby-1.9.2-p290/gems/nanoc3-3.2.0b3/lib/nanoc3/cli/error_handler.rb:40:in `handle_while' | |
36. /Users/Jacob/.rvm/gems/ruby-1.9.2-p290/gems/nanoc3-3.2.0b3/lib/nanoc3/cli/error_handler.rb:21:in `handle_while' | |
37. /Users/Jacob/.rvm/gems/ruby-1.9.2-p290/gems/nanoc3-3.2.0b3/lib/nanoc3/cli.rb:37:in `run' | |
38. /Users/Jacob/.rvm/gems/ruby-1.9.2-p290/gems/nanoc3-3.2.0b3/bin/nanoc3:12:in `<top (required)>' | |
39. /Users/Jacob/.rvm/gems/ruby-1.9.2-p290/bin/nanoc3:19:in `load' | |
40. /Users/Jacob/.rvm/gems/ruby-1.9.2-p290/bin/nanoc3:19:in `<main>' | |
If you believe this is a bug in nanoc, please do report it at | |
<https://github.com/ddfreyne/nanoc/issues/new>--thanks! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Nanoc3::Helpers | |
module Resources | |
# used in layouts, allows for listing.address and home.features, etc | |
def listing | |
Resource.new(item) | |
end | |
def home | |
Resource.new(item) | |
end | |
def land | |
Resource.new(item) | |
end | |
def commercial | |
Resource.new(item) | |
end | |
def neighborhood | |
Resource.new(item) | |
end | |
def article | |
Resource.new(item) | |
end | |
# grabs all listing item and provides options for filtering | |
# homes and land as well as ordering by date or price | |
def listings options={} | |
items = @items.select { |item| item[:kind] == 'listing' } | |
items = items.select do |item| | |
if options[:type] | |
item[:type] == options[:type] | |
elsif options[:neighborhood] | |
item[:neighborhood] == options[:neighborhood] | |
else | |
item[:kind] == 'listing' | |
end | |
end | |
items.map { |item| Resource.new(item) }.sort_by { |item| item.price }.reverse | |
end | |
def sorted_listings | |
listings = @items.select { |item| item[:kind] == 'listing' }.map { |item| Resource.new(item) } | |
listings.sort_by do |l| | |
time = l.created_at | |
time.is_a?(String) ? Time.parse(time) : time | |
end.reverse | |
end | |
def featured_listing | |
featured_listing = @items.find { |i| i[:featured] } | |
Resource.new(featured_listing) | |
end | |
def new_listing address | |
listings(:type => 'home').find { |l| l.address == address } | |
end | |
# finds the next home in the array of home items | |
# loops back to the beginning | |
def next_home home | |
homes = listings(:type => 'home') | |
index = homes.index(homes.find { |h| h.address == home.address }) | |
if homes[index + 1] == nil | |
homes[0] | |
else | |
homes[index + 1] | |
end | |
end | |
# find the previous home | |
# loops by default | |
def prev_home home | |
homes = listings(:type => 'home') | |
index = homes.index(homes.find { |h| h.address == home.address }) | |
homes[index - 1] | |
end | |
# finds the next land in the array of land items | |
# loops back to the beginning | |
def next_land land | |
lands = listings(:type => 'land') | |
index = lands.index(lands.find { |h| h.address == land.address }) | |
if lands[index + 1] == nil | |
lands[0] | |
else | |
lands[index + 1] | |
end | |
end | |
# find the previous land | |
# loops by default | |
def prev_land land | |
lands = listings(:type => 'land') | |
index = lands.index(lands.find { |h| h.address == land.address }) | |
lands[index - 1] | |
end | |
# finds the next commercial property in the array of commercial items | |
# loops back to the beginning | |
def next_commercial commercial | |
commercials = listings(:type => 'commercial') | |
index = commercials.index(commercials.find { |c| c.address == commercial.address }) | |
if commercials[index + 1] == nil | |
commercials[0] | |
else | |
commercials[index + 1] | |
end | |
end | |
# find the previous commercial property | |
# loops by default | |
def prev_commercial commercial | |
commercials = listings(:type => 'commercial') | |
index = commercials.index(commercials.find { |h| h.address == commercial.address }) | |
commercials[index - 1] | |
end | |
# grab all of the neighborhoods and create an array of | |
# Nieghborhood class instances (ordered by the number | |
# in the file name) | |
def neighborhoods | |
@items.select { |item| item[:kind] == 'neighborhood' }. | |
map { |item| Resource.new(item) } | |
end | |
def categories | |
Dir['content/blog/*']. | |
reject { |f| f.match /(html|xml)/ }. | |
map { |f| f.gsub('content/blog/','') }. | |
map { |f| titleize(f) } | |
end | |
# used on blog main page | |
def first_paragraph article | |
if article[:address] | |
# first paragraph for new listing articles is the first | |
# paragraph of the description of the address | |
new_listing(article[:address]).description.split('. ').first + '.' | |
else | |
doc = Nokogiri::HTML(article.compiled_content(:snapshot => :pre)) | |
first_paragraph = doc.css('p')[0] | |
first_paragraph.content = "#{first_paragraph.content} <a href=\"#{article.path}\">Continue reading …</a>" | |
first_paragraph.content | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment