- storeUrl
- sort / search - show sort by field
This commit is contained in:
parent
9022ed674b
commit
2644f0fccf
10 changed files with 349 additions and 51 deletions
|
|
@ -18,6 +18,9 @@ import oilcache
|
|||
from forms import forms
|
||||
from sortname import sortname
|
||||
|
||||
def httpExpires(sec):
|
||||
return cherrypy.lib.httptools.HTTPDate(time.gmtime(time.mktime(time.gmtime()) + sec))
|
||||
|
||||
class View:
|
||||
@expose(template=".templates.view")
|
||||
def view(self, item):
|
||||
|
|
@ -25,10 +28,12 @@ class View:
|
|||
|
||||
def icon(self, item):
|
||||
response.headerMap['Content-Type'] = "image/png"
|
||||
cherrypy.response.headerMap["Expires"] = httpExpires(60*60*24*30)
|
||||
return oilcache.loadIcon(item)
|
||||
|
||||
def icon_reflection(self, item):
|
||||
response.headerMap['Content-Type'] = "image/png"
|
||||
cherrypy.response.headerMap["Expires"] = httpExpires(60*60*24*30)
|
||||
return oilcache.loadIconReflection(item)
|
||||
|
||||
@expose()
|
||||
|
|
@ -108,10 +113,7 @@ class ArchiveJavascript:
|
|||
name = name.split('.')[0]
|
||||
archive = Archive.byHashId(name)
|
||||
response.headerMap['Content-Type'] = "application/x-javascript"
|
||||
secs = 60*60*24*30
|
||||
secs = 60
|
||||
expires = cherrypy.lib.httptools.HTTPDate(time.gmtime(time.mktime(time.gmtime()) + secs))
|
||||
cherrypy.response.headerMap["Expires"] = expires
|
||||
cherrypy.response.headerMap["Expires"] = httpExpires(60) #(60*60*24*30)
|
||||
return archive.js
|
||||
|
||||
class ArchiveStyleSheet:
|
||||
|
|
@ -120,10 +122,7 @@ class ArchiveStyleSheet:
|
|||
name = name.split('.')[0]
|
||||
archive = Archive.byHashId(name)
|
||||
response.headerMap['Content-Type'] = "text/css"
|
||||
secs = 60*60*24*30
|
||||
secs = 60
|
||||
expires = cherrypy.lib.httptools.HTTPDate(time.gmtime(time.mktime(time.gmtime()) + secs))
|
||||
cherrypy.response.headerMap["Expires"] = expires
|
||||
cherrypy.response.headerMap["Expires"] = httpExpires(60) #(60*60*24*30)
|
||||
return archive.css
|
||||
|
||||
class Root(controllers.RootController):
|
||||
|
|
@ -168,42 +167,27 @@ class Root(controllers.RootController):
|
|||
return dict(q = '', f = 'all', s = 'title', o = 0, n = 60, l = 'all', v = 'icon', length = 0)
|
||||
|
||||
_sort_map = {
|
||||
'id': 'imdb',
|
||||
'director': 'director_html',
|
||||
'writer': 'writer_html',
|
||||
'language': 'language_html',
|
||||
'releasedate': 'release_date',
|
||||
'cast': 'cast_html',
|
||||
'genre': 'genre_html',
|
||||
'keywords': 'keywords_html',
|
||||
'connections': 'connections_sort',
|
||||
'id': 'hashId',
|
||||
'author': 'author_sort',
|
||||
'releasedate': 'rel_date',
|
||||
'title': 'title_sort',
|
||||
'country': 'country_html',
|
||||
'producer': 'producer_html',
|
||||
'summary': 'plot',
|
||||
'trivia': 'plot',
|
||||
'date': 'latest_file_date',
|
||||
'year': 'release_date',
|
||||
'date': 'rel_date',
|
||||
}
|
||||
|
||||
def get_sort(self, s):
|
||||
s = str(self._sort_map.get(s, s))
|
||||
if s in ('release_date', 'size', 'pub_date'):
|
||||
if s in ('rel_date', 'size', 'pub_date'):
|
||||
s = '-%s' % s
|
||||
return s
|
||||
|
||||
_field_map = {
|
||||
'title': ArchiveItem.q.title,
|
||||
'author': ArchiveItem.q.author,
|
||||
'genre': ArchiveItem.q.genre,
|
||||
}
|
||||
|
||||
_search_map = {
|
||||
'summary': 'plot',
|
||||
'trivia': 'plot',
|
||||
'releasedate': 'release_date',
|
||||
'script': 'year',
|
||||
'title': 'year',
|
||||
'director': 'year'
|
||||
'releasedate': 'rel_date',
|
||||
}
|
||||
|
||||
@expose(template=".templates.iconview")
|
||||
|
|
@ -233,9 +217,13 @@ class Root(controllers.RootController):
|
|||
if v == 'quote':
|
||||
tg_template = ".templates.quoteview"
|
||||
|
||||
orderBy = [self.get_sort(s), 'title_sort', 'title']
|
||||
orderBy = [self.get_sort(s), 'title_sort', 'rel_date']
|
||||
if q:
|
||||
items = queryArchive(q)
|
||||
if f=='all':
|
||||
items = queryArchive(q, s)
|
||||
elif f in ('title', 'author', 'genre'):
|
||||
q = q.encode('utf-8')
|
||||
items = ArchiveItem.select(LIKE(self._field_map[f], '%'+q+'%') , orderBy=orderBy)
|
||||
else:
|
||||
items = ArchiveItem.select(orderBy = orderBy)
|
||||
sort = s
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue