now with search term highlights
This commit is contained in:
parent
0f4565b8ab
commit
d54890aa83
3 changed files with 12 additions and 4 deletions
|
@ -32,7 +32,7 @@ tg.empty_flash = False
|
|||
# tg.include_widgets = []
|
||||
|
||||
# Set to True if the scheduler should be started
|
||||
# tg.scheduler = False
|
||||
tg.scheduler = False
|
||||
|
||||
# VISIT TRACKING
|
||||
# Each visit to your application will be assigned a unique visit ID tracked via
|
||||
|
|
|
@ -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()
|
||||
|
@ -174,6 +179,9 @@ class ArchiveItem(SQLObject):
|
|||
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):
|
||||
archiveId = UnicodeCol(alternateID = True, length = 1000)
|
||||
|
|
|
@ -210,7 +210,7 @@
|
|||
<tr>
|
||||
<td class="boxWhiteLeftMiddle"></td>
|
||||
<td class="boxWhiteCenterMiddle" style="width: 848px">
|
||||
${XML(item.html)}
|
||||
${XML(item.htmlHighlight(search['q']))}
|
||||
</td>
|
||||
<td class="boxWhiteRightMiddle"></td>
|
||||
</tr>
|
||||
|
|
Loading…
Reference in a new issue