Skip to content
Browse files

Fix a few UI bugs.

  • Loading branch information...
1 parent 1e0744c commit 802bedb6c1d9c68b99e751945c11b30efca1965b @whitequark committed
Showing with 16 additions and 12 deletions.
  1. +4 −4 lib/irclogger/viewer.rb
  2. +8 −4 lib/irclogger/viewer_helpers.rb
  3. +2 −2 public/application.js
  4. +2 −2 views/channel.haml
View
8 lib/irclogger/viewer.rb
@@ -40,7 +40,7 @@ class Viewer < Sinatra::Base
end
get '/:channel/search' do
- @channel = parse_channel(params[:channel])
+ @channel = channel_unescape(params[:channel])
@limit = 300
if params[:q].length >= 3
@@ -58,7 +58,7 @@ class Viewer < Sinatra::Base
get '/:channel/stream', provides: 'text/event-stream' do
response['X-Accel-Buffering'] = 'no'
- channel = parse_channel(params[:channel])
+ channel = channel_unescape(params[:channel])
last_message_id = env['HTTP_LAST_EVENT_ID'] || params['last_id']
last_messages = Message.recent_for_channel(channel, last_message_id.to_i)
@@ -90,7 +90,7 @@ class Viewer < Sinatra::Base
end
get '/:channel/:date?' do
- @channel = parse_channel(params[:channel])
+ @channel = channel_unescape(params[:channel])
@date = Date.parse(params[:date]) rescue nil
if @date
@@ -107,4 +107,4 @@ class Viewer < Sinatra::Base
end
end
end
-end
+end
View
12 lib/irclogger/viewer_helpers.rb
@@ -4,14 +4,18 @@ module IrcLogger
module ViewerHelpers
include Rack::Utils
- def channel_url(channel, postfix=nil)
- "/#{channel[1..-1].gsub('#', '.')}/#{postfix}"
+ def channel_escape(channel)
+ channel[1..-1].gsub('#', '.')
end
- def parse_channel(channel)
+ def channel_unescape(channel)
"##{channel.gsub('.', '#')}"
end
+ def channel_url(channel, postfix=nil)
+ "/#{channel_escape channel}/#{postfix}"
+ end
+
def nick_class(nick)
color = Zlib.crc32(nick) % 16 + 1
"nick nick-#{color}"
@@ -104,4 +108,4 @@ def calendar(channel, date=nil, links=true)
end
end
end
-end
+end
View
4 public/application.js
@@ -202,7 +202,7 @@ var Live = {
start: function() {
var $this = this;
- var url = '/' + this.channel + '/stream?last_id=' + this.lastId;
+ var url = '/' + this.channel + '/stream?last_id=' + (this.lastId || "");
this.eventSource = new EventSource(url);
this.eventSource.onmessage = function(event) {
@@ -254,7 +254,7 @@ var Live = {
return false;
});
- if(this.button.attr('data-autostart')) {
+ if(this.button.attr('data-autostart') !== undefined) {
this.toggle();
}
}
View
4 views/channel.haml
@@ -12,8 +12,8 @@
- if @is_today
- last_id = @messages.last.id if @messages.any?
%a{href: '#', id: 'live_logging', style: 'display: none',
- data: { channel: channel_url(@channel),
+ data: { channel: channel_escape(@channel),
lastId: last_id,
autostart: true }} Live updates
- = haml :_messages, locals: { messages: @messages, dates: false }
+ = haml :_messages, locals: { messages: @messages, dates: false }

0 comments on commit 802bedb

Please sign in to comment.
Something went wrong with that request. Please try again.