# HG changeset patch # User Tero Marttila # Date 1234177143 -7200 # Node ID 8157c41b3236924f04653efa524366eef44b5a23 # Parent 13975aa16b4ceb15ccd9f5be218336f6e451ddf8 improve search form & script diff -r 13975aa16b4c -r 8157c41b3236 log_search.py --- a/log_search.py Mon Feb 09 12:11:34 2009 +0200 +++ b/log_search.py Mon Feb 09 12:59:03 2009 +0200 @@ -53,11 +53,13 @@ def insert (self, channel, lines) : """ - Adds a sequence of LogLines from the given LogChannel to the index + Adds a sequence of LogLines from the given LogChannel to the index, and return the number of added items """ # validate the LogChannel assert channel.name + + count = 0 # iterate for line in lines : @@ -100,7 +102,13 @@ # XXX: what does this flag mean? if not self.db.put_doc(doc, hype.Database.PDCLEAN) : raise Exeception("Index put_doc failed") - + + # count + count += 1 + + # return + return count + def search_cond (self, cond) : """ Search using a raw hype.Condition diff -r 13975aa16b4c -r 8157c41b3236 static/irclogs.css --- a/static/irclogs.css Mon Feb 09 12:11:34 2009 +0200 +++ b/static/irclogs.css Mon Feb 09 12:59:03 2009 +0200 @@ -261,3 +261,25 @@ margin-left: 1em; } + +/* Search form */ +div#search { + margin-top: 25px; + + padding: 25px; + + text-align: center; +} + +div#search input[type=text] { + display: block; + + width: 40%; + margin: 0px auto 5px auto; + +} + +div#search-help { + text-align: left; +} + diff -r 13975aa16b4c -r 8157c41b3236 templates/channel.tmpl --- a/templates/channel.tmpl Mon Feb 09 12:11:34 2009 +0200 +++ b/templates/channel.tmpl Mon Feb 09 12:59:03 2009 +0200 @@ -38,7 +38,8 @@ Search:
  • - + +
  • diff -r 13975aa16b4c -r 8157c41b3236 templates/channel_search.tmpl --- a/templates/channel_search.tmpl Mon Feb 09 12:11:34 2009 +0200 +++ b/templates/channel_search.tmpl Mon Feb 09 12:59:03 2009 +0200 @@ -3,14 +3,31 @@ % if not search_query :
    ${channel.title} :: Search
    -
    -

    +

    % else :
    ${channel.title} :: Search '${search_query}'
    diff -r 13975aa16b4c -r 8157c41b3236 tools/search.py --- a/tools/search.py Mon Feb 09 12:11:34 2009 +0200 +++ b/tools/search.py Mon Feb 09 12:59:03 2009 +0200 @@ -22,16 +22,24 @@ channel = channels.channel_list.lookup(channel_name) for date_name in dates : - # parse date - date = datetime.datetime.strptime(date_name, '%Y-%m-%d').replace(tzinfo=channel.source.tz) - - print "%s..." % (date, ) + print "%s..." % (date_name, ), + lines = None + + try : + # parse date + date = datetime.datetime.strptime(date_name, '%Y-%m-%d').replace(tzinfo=channel.source.tz) - # load lines for date - lines = channel.source.get_date(date) + # load lines for date + lines = channel.source.get_date(date) + + except Exception, e : + print "Skipped: %s" % (e, ) + + else : + # insert + count = index.insert(channel, lines) - # insert - index.insert(channel, lines) + print "%d" % count def cmd_search (options, channel_name, query) : """ @@ -67,9 +75,10 @@ # define command-line arguments parser.add_option("-I", "--index", dest="index_path", help="Index database path", metavar="PATH", default="logs/index") - parser.add_option("--create", dest="create_index", help="Create index database", default=False) + parser.add_option("--create", dest="create_index", action="store_true", help="Create index database") parser.add_option("-f", "--formatter", dest="formatter_name", help="LogFormatter to use", default="irssi") parser.add_option("-z", "--timezone", dest="tz_name", help="Timezone for output", metavar="TZ", default="UTC") + parser.add_option("--skip-missing", dest="skip_missing", action="store_true", help="Skip missing logfiles") # parse options, args = parser.parse_args()