now with search term highlights
This commit is contained in:
parent
0f4565b8ab
commit
d54890aa83
3 changed files with 12 additions and 4 deletions
|
|
@ -58,6 +58,13 @@ WHERE %s ORDER BY %s""" % \
|
|||
return result
|
||||
|
||||
class ArchiveItem(SQLObject):
|
||||
#after creating manual changes to db neede:
|
||||
'''
|
||||
ALTER TABLE archive_item ADD FULLTEXT (title, description, text);
|
||||
ALTER TABLE archive_item CHANGE size size bigint;
|
||||
ALTER TABLE archive_item CHANGE html html longtext;
|
||||
ALTER TABLE archive_item CHANGE text text longtext;
|
||||
'''
|
||||
hashId = UnicodeCol(alternateID = True, length=128)
|
||||
archiveItemId = UnicodeCol()
|
||||
icon = UnicodeCol() # -> url (128x128)
|
||||
|
|
@ -87,8 +94,6 @@ class ArchiveItem(SQLObject):
|
|||
#score is only available if loaded via queryArchive
|
||||
score = -1
|
||||
|
||||
#Fulltext search
|
||||
#ALTER TABLE archive_item ADD FULLTEXT (title, description, text);
|
||||
|
||||
def _get_filetype(self):
|
||||
return self.downloadUrl.split('.')[-1].upper()
|
||||
|
|
@ -173,6 +178,9 @@ class ArchiveItem(SQLObject):
|
|||
def setHashId(self):
|
||||
salt = u'%s/%s' % (self.archive.archiveName, self.archiveItemId)
|
||||
self.hashID = md5.new(salt.encode('utf-8')).hexdigest()
|
||||
|
||||
def htmlHighlight(self, term):
|
||||
return utils.highlightText(self.html, term)
|
||||
|
||||
|
||||
class Archive(SQLObject):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue