summaryrefslogtreecommitdiff
path: root/searx/webapp.py
diff options
context:
space:
mode:
authorAdam Tauber <asciimoo@gmail.com>2014-03-18 19:22:28 +0100
committerAdam Tauber <asciimoo@gmail.com>2014-03-18 19:22:28 +0100
commitf104553af465f37165123b2cc8286bffbc2b2d25 (patch)
tree00517662f6bbf7381a25280d0322eab508d5f1fd /searx/webapp.py
parenta9d075dcc13efb0740337587acb0d3176a17f814 (diff)
downloadsearxng-f104553af465f37165123b2cc8286bffbc2b2d25.tar.gz
searxng-f104553af465f37165123b2cc8286bffbc2b2d25.zip
[mod][fix] cookie expiration ++ pep8 compatibility
Diffstat (limited to 'searx/webapp.py')
-rw-r--r--searx/webapp.py20
1 files changed, 11 insertions, 9 deletions
diff --git a/searx/webapp.py b/searx/webapp.py
index 44865345a..2f6aa4abe 100644
--- a/searx/webapp.py
+++ b/searx/webapp.py
@@ -57,6 +57,8 @@ babel = Babel(app)
favicons = ['wikipedia', 'youtube', 'vimeo', 'soundcloud',
'twitter', 'stackoverflow', 'github']
+cookie_max_age = 60 * 60 * 24 * 365 * 23 # 23 years
+
@babel.localeselector
def get_locale():
@@ -159,8 +161,10 @@ def index():
# TODO, check if timezone is calculated right
if 'publishedDate' in result:
- if result['publishedDate'].replace(tzinfo=None) >= datetime.now() - timedelta(days=1):
- timedifference = datetime.now() - result['publishedDate'].replace(tzinfo=None)
+ if result['publishedDate'].replace(tzinfo=None)\
+ >= datetime.now() - timedelta(days=1):
+ timedifference = datetime.now() - result['publishedDate']\
+ .replace(tzinfo=None)
minutes = int((timedifference.seconds / 60) % 60)
hours = int(timedifference.seconds / 60 / 60)
if hours == 0:
@@ -168,7 +172,8 @@ def index():
else:
result['publishedDate'] = gettext(u'{hours} hour(s), {minutes} minute(s) ago').format(hours=hours, minutes=minutes) # noqa
else:
- result['pubdate'] = result['publishedDate'].strftime('%a, %d %b %Y %H:%M:%S %z')
+ result['pubdate'] = result['publishedDate']\
+ .strftime('%a, %d %b %Y %H:%M:%S %z')
result['publishedDate'] = format_date(result['publishedDate'])
if search.request_data.get('format') == 'json':
@@ -256,24 +261,21 @@ def preferences():
user_blocked_engines = request.cookies.get('blocked_engines', '').split(',') # noqa
if sorted(blocked_engines) != sorted(user_blocked_engines):
- # cookie max age: 4 weeks
resp.set_cookie(
'blocked_engines', ','.join(blocked_engines),
- max_age=60 * 60 * 24 * 7 * 4
+ max_age=cookie_max_age
)
if locale:
- # cookie max age: 4 weeks
resp.set_cookie(
'locale', locale,
- max_age=60 * 60 * 24 * 7 * 4
+ max_age=cookie_max_age
)
if lang:
- # cookie max age: 4 weeks
resp.set_cookie(
'language', lang,
- max_age=60 * 60 * 24 * 7 * 4
+ max_age=cookie_max_age
)
if selected_categories: