예제 #1
0
def get_logs(rdb, channel, date):
    """Get logs with  specify date.

    :rdb: redis db instance
    :channel: IRC channel name without #
    :date: string represend the date
    :returns: list(logs)

    """
    channel, date = channel_name(channel), str_date(date)
    date = str_date(date)
    key = "%s:%s" % (channel, date)
    return rdb.lrange(key, 0, -1)
예제 #2
0
def get_logs(rdb, channel, date):
    """Get logs with  specify date.

    :rdb: redis db instance
    :channel: IRC channel name without #
    :date: string represend the date
    :returns: list(logs)

    """
    channel, date = channel_name(channel), str_date(date)
    date = str_date(date)
    key = "%s:%s" % (channel, date)
    return rdb.lrange(key, 0, -1)
예제 #3
0
def viewer(rdb, channel, date, slash):
    """Channel view.

    :rdb: redis DB instance
    :channel: IRC channel name without #
    :date: string represend the date

    """
    socketio = True if date == 'today' else False
    date = str_date(date)
    if date:
        rows = []
        for i in get_logs(rdb, channel, date):
            rows.append(irc_row(i))
        if is_reverse():
            rows.reverse()
        return bottle.template('viewer',
                               channel=channel,
                               date=date,
                               channels=get_channels(rdb),
                               rows=rows,
                               socketio=socketio,
                               autolinks=is_autolinks(),
                               reverse=is_reverse(),
                               server=bottle.request.urlparts[1],
                              )
    else:
        bottle.redirect('/channel/%s/today/' % (channel))
예제 #4
0
def viewer(rdb, channel, date, slash):
    """Channel view.

    :rdb: redis DB instance
    :channel: IRC channel name without #
    :date: string represend the date

    """
    socketio = True if date == 'today' else False
    date = str_date(date)
    if date:
        rows = []
        for i in get_logs(rdb, channel, date):
            rows.append(irc_row(i))
        if is_reverse():
            rows.reverse()
        return bottle.template(
            'viewer',
            channel=channel,
            date=date,
            channels=get_channels(rdb),
            rows=rows,
            socketio=socketio,
            autolinks=is_autolinks(),
            reverse=is_reverse(),
            server=bottle.request.urlparts[1],
        )
    else:
        bottle.redirect('/channel/%s/today/' % (channel))
예제 #5
0
def go2date(rdb):
    """API to get the log view.

    :rdb: redis DB instance

    """
    #. regx for date
    channel = bottle.request.forms.channel
    date = str_date(bottle.request.forms.date) \
            if is_strdate(bottle.request.forms.date) else None
    date = date if date else 'today'
    bottle.redirect("/channel/%s/%s/" % (urllib.quote_plus(channel), date))
예제 #6
0
def go2date(rdb):
    """API to get the log view.

    :rdb: redis DB instance

    """
    #. regx for date
    channel = bottle.request.forms.channel
    date = str_date(bottle.request.forms.date) \
            if is_strdate(bottle.request.forms.date) else None
    date = date if date else 'today'
    bottle.redirect("/channel/%s/%s/" % (
        urllib.quote_plus(channel), date))
예제 #7
0
def widget(rdb, channel, slash):
    """Widget view, date='today', socketio = autolinks = reverse = True.

    :rdb: redis DB instance
    :channel: IRC channel name without #

    """
    date = str_date('today')
    rows = []
    for i in get_logs(rdb, channel, date):
        rows.append(irc_row(i))
    rows.reverse()
    return bottle.template('viewer',
                           channel=channel,
                           date=date,
                           channels=get_channels(rdb),
                           rows=rows,
                           socketio=True,
                           autolinks=True,
                           reverse=True,
                           server=bottle.request.urlparts[1],
                           widget=True,
                          )
예제 #8
0
def show_quote(rdb, channel, date, line):
    """Show the quote.

    :rdb: redis DB instance
    :channel: IRC channel name without #
    :date: string represend the date
    :line: line number of logs in channel view

    """
    date = str_date(date)
    if date:
        try:
            logs = get_logs(rdb, channel , date)
            row = irc_row(logs[line - 1])
        except Exception:
            row = None
        return bottle.template('quote',
                               channel=channel,
                               date=date,
                               channels=get_channels(rdb),
                               row=row)
    else:
        bottle.redirect('/channel/%s/today/' % (channel))
예제 #9
0
def show_quote(rdb, channel, date, line):
    """Show the quote.

    :rdb: redis DB instance
    :channel: IRC channel name without #
    :date: string represend the date
    :line: line number of logs in channel view

    """
    date = str_date(date)
    if date:
        try:
            logs = get_logs(rdb, channel, date)
            row = irc_row(logs[line - 1])
        except Exception:
            row = None
        return bottle.template('quote',
                               channel=channel,
                               date=date,
                               channels=get_channels(rdb),
                               row=row)
    else:
        bottle.redirect('/channel/%s/today/' % (channel))
예제 #10
0
def widget(rdb, channel, slash):
    """Widget view, date='today', socketio = autolinks = reverse = True.

    :rdb: redis DB instance
    :channel: IRC channel name without #

    """
    date = str_date('today')
    rows = []
    for i in get_logs(rdb, channel, date):
        rows.append(irc_row(i))
    rows.reverse()
    return bottle.template(
        'viewer',
        channel=channel,
        date=date,
        channels=get_channels(rdb),
        rows=rows,
        socketio=True,
        autolinks=True,
        reverse=True,
        server=bottle.request.urlparts[1],
        widget=True,
    )