--- 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
--- 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;
+}
+
--- 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 @@
<a href="${h.build_url(urls.channel_search, channel=channel)}">Search:</a>
</li><li class="join-left">
<form action="${urls.channel_search.build(req, channel=channel)}" method="GET">
- <input name="q" value="${search_query if search_query else ''}"></input>
+ <input type="hidden" name="count" value="100" />
+ <input type="text" name="q" value="${search_query if search_query else ''}" />
<input type="submit" value="Go »" />
</form>
</li>
--- 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 :
<div id="title">${channel.title} :: Search</div>
-<form action="${h.build_url(urls.channel_search, channel=channel)}" method="GET">
- <p>
+<div id="search">
+ <form action="${h.build_url(urls.channel_search, channel=channel)}" method="GET">
<input type="text" name="q" />
<input type="submit" value="Search" />
- </p>
-</form>
+
+ Results/page: <select name="count">
+ <option value="50">50</option>
+ <option value="100">100</option>
+ <option value="200">200</option>
+ <option value="">∞</option>
+ </select>
+ </form>
+
+ <div id="search-help">
+ <p>Search powered by <a href="http://hyperestraier.sourceforge.net/">Hyper Estraier</a>:</p>
-<p>Search for something.</p>
+ <ul>
+ <li>Group words together using quotes: <tt>"united nations"</tt></li>
+ <li>Searching for multiple words is AND: <tt>internet security</tt></li>
+ <li>To exclude terms, use <strong>!</strong> : <tt>hacker ! cracker</tt></li>
+ <li>Union (i.e. <q>or</q>) using <strong>|</strong> : <tt>proxy | firewall</tt></li>
+ <li>Search is case-insensitive</li>
+ </ul>
+ </div>
+</div>
% else :
<div id="title">${channel.title} :: Search '${search_query}'</div>
--- 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()