Browse files

Untested attempt at handling double hash versions of channels. Will b…

…reak people's bookmarks, since I'm cool like that
  • Loading branch information...
1 parent ff0c481 commit 3fe7536a28b003d36fada8ce8e7334c726b20342 @cschneid committed Feb 23, 2011
Showing with 10 additions and 5 deletions.
  1. +7 −2 irclogger.rb
  2. +3 −3 views/layout.haml
View
9 irclogger.rb
@@ -36,11 +36,14 @@ def info?
end
def self.find_by_channel_and_date(channel, date)
+ # Channels look like: .sinatra, or ..Paws. Sub it so it finds in the db right.
+ channel = channel.gsub(".", "#")
+
day_after = date + 1
filter(:timestamp > Time.local(date.year, date.month, date.day).to_i).
filter(:timestamp < Time.local(day_after.year, day_after.month, day_after.day).to_i).
- filter(:channel => "##{channel}").
+ filter(:channel => "#{channel}").
order(:timestamp)
end
end
@@ -142,9 +145,10 @@ def plain_entry(message)
get '/:channel/slice/:from/:to' do
@channel = params[:channel]
+ @channel = @channel.gsub(".", "#")
@messages = Message.filter(:timestamp > params[:from]).
filter(:timestamp < params[:to]).
- filter(:channel => "##{@channel}").
+ filter(:channel => "#{@channel}").
order(:timestamp).collect do |m|
{
:id => m.id ,
@@ -166,6 +170,7 @@ def plain_entry(message)
arr << row[:channel] if (row[:channel] =~ /^#/ && row[:channel] != "#datamapper http://datamapper.")
arr
}.collect do |channel|
+ channel = channel.gsub(".", "#")
{
:channel => channel,
:permalink => "http://irclogger.com/#{channel[1..-1]}"
View
6 views/layout.haml
@@ -3,7 +3,7 @@
%html
%title
- if @channel
- = "##{@channel} on #{@date} – "
+ = "#{@channel.gsub(/./, "#")} on #{@date} – "
irclogger – Freenode IRC logs
@@ -27,8 +27,8 @@
%a(href="/") Console
- @channels.each do |channel|
- %li(class="#{"current" if channel[1..-1] == @channel}")
- %a(href="/#{channel[1..-1]}/#{@date || "today"}")= channel
+ %li(class="#{"current" if channel.gsub(/#/, ".") == @channel}")
+ %a(href="/#{channel.gsub(/#/, '.')}/#{@date || "today"}")= channel
= yield

0 comments on commit 3fe7536

Please sign in to comment.