diff --git a/oilarchive/config/app.cfg b/oilarchive/config/app.cfg index 75539ec..a331ac0 100644 --- a/oilarchive/config/app.cfg +++ b/oilarchive/config/app.cfg @@ -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 diff --git a/oilarchive/model.py b/oilarchive/model.py index 7b9020c..25a8ad9 100644 --- a/oilarchive/model.py +++ b/oilarchive/model.py @@ -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): diff --git a/oilarchive/templates/view.kid b/oilarchive/templates/view.kid index 4ac402b..52c808f 100644 --- a/oilarchive/templates/view.kid +++ b/oilarchive/templates/view.kid @@ -210,7 +210,7 @@ - ${XML(item.html)} + ${XML(item.htmlHighlight(search['q']))}