* Don't display 'in xxx minutes' for current meeting
* Support buntudot * Support multiple databases in the web interface * Show architecture for package info if not all/any
This commit is contained in:
@ -30,6 +30,8 @@ def q(txt):
|
||||
database = 'ubuntu'
|
||||
|
||||
form = cgi.FieldStorage()
|
||||
if 'db' in form:
|
||||
database = form['db'].value
|
||||
try:
|
||||
page = int(form['page'].value)
|
||||
except:
|
||||
@ -50,14 +52,14 @@ num = cur.fetchall()[0][0]
|
||||
npages = int(ceil(num / float(NUM_PER_PAGE)))
|
||||
out('·')
|
||||
for i in range(npages):
|
||||
out(' <a href="factoids.cgi?order=%s&page=%s">%d</a> ·' % (order_by, i, i+1))
|
||||
out(' <a href="factoids.cgi?db=%s&order=%s&page=%s">%d</a> ·' % (database, order_by, i, i+1))
|
||||
out('<br />Order by<br />·')
|
||||
out(' <a href="factoids.cgi?order=%s&page=%d">%s</a> ·' % ('name ASC', page, 'Name +'))
|
||||
out(' <a href="factoids.cgi?order=%s&page=%d">%s</a> ·' % ('name DESC', page, 'Name -'))
|
||||
out(' <a href="factoids.cgi?order=%s&page=%d">%s</a> ·' % ('popularity ASC', page, 'Popularity +'))
|
||||
out(' <a href="factoids.cgi?order=%s&page=%d">%s</a> ·' % ('popularity DESC', page, 'Popularity -'))
|
||||
out(' <a href="factoids.cgi?order=%s&page=%d">%s</a> ·' % ('added ASC', page, 'Date added +'))
|
||||
out(' <a href="factoids.cgi?order=%s&page=%d">%s</a> ·' % ('added DESC', page, 'Date added -'))
|
||||
out(' <a href="factoids.cgi?db=%s&order=%s&page=%d">%s</a> ·' % (database, 'name ASC', page, 'Name +'))
|
||||
out(' <a href="factoids.cgi?db=%s&order=%s&page=%d">%s</a> ·' % (database, 'name DESC', page, 'Name -'))
|
||||
out(' <a href="factoids.cgi?db=%s&order=%s&page=%d">%s</a> ·' % (database, 'popularity ASC', page, 'Popularity +'))
|
||||
out(' <a href="factoids.cgi?db=%s&order=%s&page=%d">%s</a> ·' % (database, 'popularity DESC', page, 'Popularity -'))
|
||||
out(' <a href="factoids.cgi?db=%s&order=%s&page=%d">%s</a> ·' % (database, 'added ASC', page, 'Date added +'))
|
||||
out(' <a href="factoids.cgi?db=%s&order=%s&page=%d">%s</a> ·' % (database, 'added DESC', page, 'Date added -'))
|
||||
|
||||
|
||||
out('<table cellspacing="0"><tr><th>Factoid</th><th>Value</th><th>Author</th></tr>')
|
||||
|
@ -124,10 +124,16 @@ div.log {
|
||||
<div class="main">
|
||||
<h1>Ubotu factoids</h1>
|
||||
<p>
|
||||
More help: <a href="http://wiki.ubuntu.com/">wiki.ubuntu.com</a> ·
|
||||
<a href="http://help.ubuntu.com/">help.ubuntu.com</a><br />
|
||||
More factoids: <a href="factoids.cgi?db=ubuntu">Ubuntu</a> ·
|
||||
<a href="factoids.cgi?db=buntudot">buntudot</a>
|
||||
<p>
|
||||
%s
|
||||
</p>
|
||||
<p>
|
||||
<a href="ubuntu.db">Factoid database file</a><br />
|
||||
<a href="ubuntu.db">Ubuntu factoid database file</a><br />
|
||||
<a href="buntudot.db">Buntudot factoid database file</a><br />
|
||||
©2006 Dennis Kaarsemaker
|
||||
</p>
|
||||
</div>
|
||||
|
@ -26,6 +26,8 @@ datadir = '/home/dennis/ubugtu/data/facts'
|
||||
def r(repo,section):
|
||||
if 'seveas' in repo:
|
||||
return 'Seveas'
|
||||
if 'buntudot' in repo:
|
||||
return 'buntudot'
|
||||
if '/' in section:
|
||||
return section[:section.find('/')]
|
||||
return 'main'
|
||||
@ -114,6 +116,7 @@ class Encyclopedia(callbacks.PluginRegexp):
|
||||
db,channel = fallback
|
||||
if channel not in self.databases:
|
||||
self.databases[channel] = sqlite.connect(os.path.join(datadir, '%s.db' % db))
|
||||
self.databases[channel].name = db
|
||||
return self.databases[channel]
|
||||
|
||||
def searchfactoid(self, irc, msg, match):
|
||||
@ -183,7 +186,7 @@ class Encyclopedia(callbacks.PluginRegexp):
|
||||
try:
|
||||
factoid = get_factoid(db, factoid, channel)
|
||||
if not factoid:
|
||||
irc.reply('I know nothing about %s - try searching bots.ubuntulinux.nl, help.ubuntu.com and wiki.ubuntu.com' % match.group('factoid'))
|
||||
irc.reply('I know nothing about %s - try searching http://bots.ubuntulinux.nl/factoids.cgi?db=%s' % (match.group('factoid'),db.name))
|
||||
return
|
||||
# Output factoid
|
||||
if noalias:
|
||||
@ -401,9 +404,10 @@ class Encyclopedia(callbacks.PluginRegexp):
|
||||
if not self._precheck(irc, msg, timeout=(msg.args[0],match.group('package'), match.group('distro'))):
|
||||
return
|
||||
distro = 'dapper'
|
||||
if (match.group('distro') in ('warty','hoary','breezy','dapper','edgy','breezy-seveas','dapper-seveas')):
|
||||
if (match.group('distro') in ('warty','hoary','breezy','dapper','edgy','breezy-seveas','dapper-seveas','dapper-buntudot')):
|
||||
distro = match.group('distro')
|
||||
data = commands.getoutput(self.aptcommand % (distro, distro, distro, 'show', match.group('package')))
|
||||
data2 = commands.getoutput(self.aptcommand % (distro, distro, distro, 'showsrc', match.group('package')))
|
||||
if not data or 'E: No packages found' in data:
|
||||
irc.reply('Package %s does not exist in %s' % (match.group('package'), distro))
|
||||
else:
|
||||
@ -418,9 +422,23 @@ class Encyclopedia(callbacks.PluginRegexp):
|
||||
if apt_pkg.VersionCompare(maxp['Version'], p['Version']) < 0:
|
||||
maxp = p
|
||||
del parser
|
||||
irc.reply("%s: %s. In repository %s, is %s. Version %s (%s), package size %s kB, installed size %s kB" %
|
||||
maxp2 = {'Version': '0'}
|
||||
packages2 = [x.strip() for x in data2.split('\n\n')]
|
||||
for p in packages2:
|
||||
if not p.strip():
|
||||
continue
|
||||
parser = FeedParser.FeedParser()
|
||||
parser.feed(p)
|
||||
p = parser.close()
|
||||
if apt_pkg.VersionCompare(maxp2['Version'], p['Version']) < 0:
|
||||
maxp2 = p
|
||||
del parser
|
||||
archs = ''
|
||||
if maxp2['Architecture'] not in ('all','any'):
|
||||
archs = ' (Only available for %s)' % maxp2['Architecture']
|
||||
irc.reply("%s: %s. In repository %s, is %s. Version %s (%s), package size %s kB, installed size %s kB%s" %
|
||||
(maxp['Package'], maxp['Description'].split('\n')[0], r(distro, maxp['Section']),
|
||||
maxp['Priority'], maxp['Version'], distro, int(maxp['Size'])/1024, maxp['Installed-Size']))
|
||||
maxp['Priority'], maxp['Version'], distro, int(maxp['Size'])/1024, maxp['Installed-Size'], archs))
|
||||
|
||||
def find(self, irc, msg, match):
|
||||
r"^!?find\s+(?P<package>\S+)(\s+(?P<distro>\S+))?"
|
||||
|
@ -41,10 +41,10 @@ def diff(delta):
|
||||
if delta.seconds > 3600:
|
||||
h = '%d hour%s ' % (int(delta.seconds/3600),s)
|
||||
s = ''
|
||||
seconds = delta.seconds % 3600
|
||||
if seconds > 120 or seconds < 60:
|
||||
minutes = (delta.seconds % 3600) / 60
|
||||
if minutes != 1:
|
||||
s = 's'
|
||||
return '%s%d minute%s' % (h,(seconds/60),s)
|
||||
return '%s%d minute%s' % (h,minutes,s)
|
||||
|
||||
class Webcal(callbacks.Plugin):
|
||||
"""@schedule <timezone>: display the schedule in your timezone"""
|
||||
@ -89,7 +89,7 @@ class Webcal(callbacks.Plugin):
|
||||
if ev0.startDate < now or (delta.days == 0 and delta.seconds < 10 * 60):
|
||||
preamble = 'Current meeting: %s' % ev0.summary.replace('Meeting','').strip()
|
||||
if num_events == 1:
|
||||
return '%s in %s' % (preamble, diff(delta))
|
||||
return preamble
|
||||
events = events[1:]
|
||||
preamble += ' | '
|
||||
# n_e = 1 -> next meeting
|
||||
|
@ -15,7 +15,8 @@
|
||||
<h1>Plugins</h1>
|
||||
<p>
|
||||
The plugins used by these bots can be found in the bzr branch located at
|
||||
http://bots.ubuntulinux.nl
|
||||
https://bots.ubuntulinux.nl - Tarballs of the plugins can be found in <a
|
||||
href="/tarballs">the tarballs folder</a>
|
||||
</p>
|
||||
<p>
|
||||
Bugs and feature requests can be filed at <a
|
||||
|
Reference in New Issue
Block a user