diff --git a/oilarchive/controllers.py b/oilarchive/controllers.py index 37d35b3..0219f48 100644 --- a/oilarchive/controllers.py +++ b/oilarchive/controllers.py @@ -259,6 +259,8 @@ class Root(controllers.RootController): if v == 'quote': tg_template = ".templates.quoteview" + if f != 'all' and s == 'relevance': + s='title' orderBy = [self.get_sort(s), 'title_sort', 'rel_date'] if q: q = q.encode('utf-8') @@ -273,11 +275,13 @@ class Root(controllers.RootController): sort = sort[1:] sort = self._search_map.get(sort, sort) sort = self._sort_map.get(sort, sort) - print sort if type(items) == list: search['length'] = len(items) else: search['length'] = items.count() + if o > search['length']: + o = 0 + search['o'] = 0 cherrypy.session['search'] = search return dict(items = items[o:o+n], sort = sort, search = search, tg_template = tg_template) diff --git a/oilarchive/model.py b/oilarchive/model.py index 25a8ad9..31932c1 100644 --- a/oilarchive/model.py +++ b/oilarchive/model.py @@ -63,6 +63,7 @@ class ArchiveItem(SQLObject): 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 description description longtext; ALTER TABLE archive_item CHANGE text text longtext; ''' hashId = UnicodeCol(alternateID = True, length=128) diff --git a/oilarchive/static/js/archive.js b/oilarchive/static/js/archive.js index 3322845..10a0256 100644 --- a/oilarchive/static/js/archive.js +++ b/oilarchive/static/js/archive.js @@ -20,7 +20,7 @@ function submitFind() { var s = document.getElementById('selectSort').value; var f = document.getElementById('selectFind').value; var q = document.getElementById('inputFind').value; - document.location.href = '/search?l=' + l + '&v=' + v + '&s=' + s + '&f=' + f + '&q=' + q; + document.location.href = '/search?o=0&l=' + l + '&v=' + v + '&s=' + s + '&f=' + f + '&q=' + q; } function mouseOver(id, view) { diff --git a/oilarchive/utils.py b/oilarchive/utils.py index 44919aa..69fb0fe 100644 --- a/oilarchive/utils.py +++ b/oilarchive/utils.py @@ -15,6 +15,12 @@ def fix_ampersands(value): ''' highlight search term in text, scipping html tags and script elements ''' +def insideTag(s): + return not (s.rfind('<') == -1 or s.rfind('>') > s.rfind('<')) + +def insideScript(s): + return not (s.rfind('') > s.rfind('' highlightEnd = u'' @@ -22,18 +28,20 @@ def highlightText(text, term): if term.strip(): term = term.lower() textLower = text.lower() + fullTextLower = textLower termLength = len(term) + fullPos = 0 while text: i = textLower.find(term) if i == -1: output += text break - if textLower[:i].rfind('<') <= textLower[:i].rfind('>') and \ - textLower[:i].rfind('/script>') >= textLower[:i].rfind('