ddfreyne changed the topic of #nanoc to: 3.6.8 (mar 22th) | web http://nanoc.ws/ | repo http://bit.ly/XE6e3G | issues http://bit.ly/VfXaSV | forum http://ho.io/n-discuss | irclog http://irclog.whitequark.org/nanoc
bensonshaji has joined #nanoc
<bensonshaji> I am able to generate custom category pages and how can I pull out list of posts for that category through a layout page?
<bensonshaji> here is my function:
<bensonshaji> def items_with_category(category)
<bensonshaji> @items.select {|i| (i[:category] || []).include?(category)}
<bensonshaji> end
bensonshaji has quit [Quit: Leaving]
relix has joined #nanoc
<bobthecow> !tell VitamineD I'll check it out. I'm not sure I have the original anymore.
<number-six> bobthecow: I'll pass that on when I see VitamineD here.
tom[] has quit [Ping timeout: 268 seconds]
tom[] has joined #nanoc
bensonshaji has joined #nanoc
<bensonshaji> I am unable to get an array of posts from the following code, Where am I going wrong?
<bensonshaji> def has_category?(category, post)
<bensonshaji> if post[:categories].nil?
<bensonshaji> post[:categories].include?(category)
<bensonshaji> else
<bensonshaji> false
<bensonshaji> end
<bensonshaji> end
<bensonshaji> def news_with_category(category, news=sorted_posts)
<bensonshaji> news.select { |post| has_category?(category, post) }
<bensonshaji> end
<bensonshaji> memoize :news_with_category
<bensonshaji> def news_by_category(news=posts)
<bensonshaji> categories = []
<bensonshaji> all_categories.each do |category|
<bensonshaji> categories << [category, news_with_category(category)]
<bensonshaji> end
<bensonshaji> categories
<bobthecow> bensonshaji: please use a pastebin (https://gist.github.com) when pasting code.
<bensonshaji> end
<bensonshaji> bobthecow, ok
<bensonshaji> I am able to get an array of categories but not the posts
<bobthecow> !tell VitamineD You're in luck! http://justinhileman.info/article/git-pretty/git-pretty.pdf
<number-six> bobthecow: I'll pass that on when I see VitamineD here.
<bobthecow> bensonshaji: checking it out.
<bobthecow> bensonshaji: any chance your categories are symbols or something weird, and not matching because of that?
<ddfreyne> bobthecow: https://github.com/nanoc/nanoc-core/pull/4 if you have other ideas let me know
<ddfreyne> (Or anyone else, actually)
<ddfreyne> Off to work! bbl.
<bobthecow> bensonshaji: ^
<bensonshaji> bobthecow, categories are like...
<bensonshaji> - linux
<bensonshaji> - ruby
<bensonshaji> bobthecow, no special symbols at all..
<bobthecow> okay. so they should be strings not symbols.
<bensonshaji> bobthecow, couldn't follow you...
<bobthecow> couldn't follow me where?
<bensonshaji> bobthecow, I meant I couldn't understand your answer...
<bobthecow> oh, the gist?
<bensonshaji> bensonshaji, yes
<bobthecow> that's not the answer, necessarily.
<bobthecow> that's a slightly more idiomatic version of your code.
<bobthecow> it should do the exact same thing.
<bobthecow> well, it should work if i understand your items correctly...
<bobthecow> but if your version doesn't work, then i don't know if this version will either.
<bensonshaji> bobthecow, this is the array I get when I run it
<bensonshaji> ["science", "tech"]
<bensonshaji> [["science", []], ["tech", []]]
<bobthecow> the first is all_categories
<bobthecow> the second is news_by_category
<bobthecow> ?
<bensonshaji> bobthecow, yes
<bobthecow> and did it do that when you replaced your module with my version, too?
<bensonshaji> where's your version?
<bobthecow> the gist i pasted.
<bensonshaji> bobthecow, nope...
<bobthecow> nope, it worked, or nope it didn't? :)
<bensonshaji> bobthecow, It didn't work... says undefined method categories on line 19
<bobthecow> oh, sorry. line 19 should be all_categories not categories
bensonshaji has quit [Ping timeout: 240 seconds]
jutah has joined #nanoc
VitamineD has joined #nanoc
alerante_ has joined #nanoc
alerante has quit [Ping timeout: 240 seconds]
relix has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
bensonshaji has joined #nanoc
<bensonshaji> bobthecow, still I cannnot get the array of posts, even after using your gist.
achal has joined #nanoc
alerante_ is now known as alerante
relix has joined #nanoc
jugglinmike has joined #nanoc
bensonshaji has quit [Ping timeout: 265 seconds]
relix has quit [Ping timeout: 268 seconds]
relix has joined #nanoc
bensonshaji has joined #nanoc
bensonshaji has quit [Quit: Leaving]
VitamineD has quit [Ping timeout: 268 seconds]
relix has quit [Quit: My MacBook Pro has gone to sleep. ZZZzzz…]
bensonshaji has joined #nanoc
bensonshaji has quit [Quit: Lingo - http://www.lingoirc.com]
jugglinmike has quit [Quit: Leaving.]
VitamineD has joined #nanoc
VitamineD1 has joined #nanoc
VitamineD has quit [Ping timeout: 268 seconds]
VitamineD1 is now known as VitamineD
achal has quit [Quit: Connection closed for inactivity]