Skip to content

Commit

Permalink
Issue #13 해결
Browse files Browse the repository at this point in the history
사소한 문제가 남았음
직전에 있던 채널의 롱폴링 대기 시간 동안 새로운 채널 로그가 갱신 안 됨
  • Loading branch information
sim0629 committed May 6, 2012
1 parent b836dfb commit 6c0c358
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 8 deletions.
2 changes: 1 addition & 1 deletion config.py.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ N_LINES = 32
SIRC_PORT = 2354

# IRC
SERVER = '115.92.130.250'
SERVER = 'irc.uriirc.org'
PORT = 16667
BOT_NAME = 's'

Expand Down
1 change: 1 addition & 0 deletions render/channel.html
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ <h1 id="channel">How to use SIRC</h1>
<li>Append the channel name to URL (as hash fragment) where you want to join.</li>
<li>(Ex) sirc.domain.com/<strong>#snucse12</strong></li>
<li>That's all.</li>
<li>Welcome, {{ account }}!</li>
<li>Enjoy your <strong>irc</strong>ing!</li>
<li>https://github.com/sim0629/sirc/wiki</li>
</ul>
Expand Down
2 changes: 1 addition & 1 deletion render/result.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<result>
<result channel="{{ channel }}">
{% for log in logs %}
<log>
<datetime><![CDATA[{{ log.datetime }}]]></datetime>
Expand Down
12 changes: 7 additions & 5 deletions static/js/sirc.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ var last_downdate = '';
// Utility

var add_process = function(xml, flag) {
if($('result', xml).attr('channel') != channel) return;
$('log', xml).each(function(i) {
var datetime = $(this).find('datetime').text();
var source = $(this).find('source').text();
Expand Down Expand Up @@ -87,7 +88,8 @@ var sirc_downdate = function(callback) {
dataType: 'xml',
success: function(xml) {
add_process(xml, 'downdate');
$('<li><a>more</a></li>').click(function() { $(this).remove(); return sirc_downdate(); }).prependTo($('ul#log'));
if($('log', xml).length > 0)
$('<li><a>more</a></li>').click(function() { $(this).remove(); return sirc_downdate(); }).prependTo($('ul#log'));
$('ul#log').listview('refresh');
if(callback) callback();
$.mobile.hidePageLoadingMsg();
Expand Down Expand Up @@ -123,7 +125,7 @@ var sirc_send = function() {
return false;
};

var sirc_join = function() {
var sirc_join = function(init) {
if(!window.location.hash) return;
channel = window.location.hash;
$('a#dummy').attr('name', channel.substr(1))
Expand All @@ -132,7 +134,7 @@ var sirc_join = function() {
$('ul#log').empty();
last_update = last_downdate = datetime_now();
sirc_downdate(function() { scroll(SCROLL_END, 1000); });
setTimeout("sirc_update();", 500);
if(init) setTimeout("sirc_update();", 500);
return false;
};

Expand All @@ -142,6 +144,6 @@ $(document).ready(function() {
$('a#setting').click(function() { $('div#menu').toggle(); return false; });
$('form#send').submit(function() { return sirc_send(); });
$('input#message').keydown(function (e) { if(e.keyCode == 13) return sirc_send(); });
$(window).hashchange(function() { return sirc_join(); });
sirc_join();
$(window).hashchange(function() { return sirc_join(false); });
sirc_join(true);
});
4 changes: 3 additions & 1 deletion wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ def update(environ, start_response, session, parameters):
if 'last_update' in parameters:
last_update = parse_datetime(parameters['last_update'][0].decode('utf-8'))
channel = parameters['channel'][0].decode('utf-8').lower()
context['channel'] = channel
logs = []
for i in xrange(30):
logs = list(db[channel].find({
Expand All @@ -134,6 +135,7 @@ def downdate(environ, start_response, session, parameters):
if 'last_downdate' in parameters:
last_downdate = parse_datetime(parameters['last_downdate'][0].decode('utf-8'))
channel = parameters['channel'][0].decode('utf-8').lower()
context['channel'] = channel
logs = db[channel].find({
'datetime': {"$lt": last_downdate},
}, limit = config.N_LINES, sort = [
Expand Down Expand Up @@ -172,7 +174,7 @@ def send(environ, start_response, session, parameters):
return [render('result.xml', context)]

def default(environ, start_response, session, parameters):
context = {}
context = {'account': session['account']}
db.session.remove({'datetime': {'$lt': datetime.datetime.now() - datetime.timedelta(1)}})
start_response('200 OK', [('Content-Type', 'text/html; charset=utf-8')])
return [render('channel.html', context)]
Expand Down

0 comments on commit 6c0c358

Please sign in to comment.