diff --git a/changedetectionio/__init__.py b/changedetectionio/__init__.py index 61e8ca3e..d3388972 100644 --- a/changedetectionio/__init__.py +++ b/changedetectionio/__init__.py @@ -430,15 +430,26 @@ def changedetection_app(config=None, datastore_o=None): has_unviewed=datastore.has_unviewed, hosted_sticky=os.getenv("SALTED_PASS", False) == False, queued_uuids=[q_uuid.item['uuid'] for q_uuid in update_q.queue], + sort_attribute=request.args.get('sort') if request.args.get('sort') else request.cookies.get('sort'), + sort_order=request.args.get('order') if request.args.get('order') else request.cookies.get('order'), system_default_fetcher=datastore.data['settings']['application'].get('fetch_backend'), tags=existing_tags, watches=sorted_watches ) - if session.get('share-link'): del(session['share-link']) - return output + + resp = make_response(output) + + # The template can run on cookie or url query info + if request.args.get('sort'): + resp.set_cookie('sort', request.args.get('sort')) + if request.args.get('order'): + resp.set_cookie('order', request.args.get('order')) + + return resp + # AJAX endpoint for sending a test diff --git a/changedetectionio/model/Watch.py b/changedetectionio/model/Watch.py index c2b48c2e..ca654d04 100644 --- a/changedetectionio/model/Watch.py +++ b/changedetectionio/model/Watch.py @@ -20,6 +20,7 @@ base_config = { 'body': None, 'check_unique_lines': False, # On change-detected, compare against all history if its something new 'check_count': 0, + 'date_created': None, 'consecutive_filter_failures': 0, # Every time the CSS/xPath filter cannot be located, reset when all is fine. 'extract_text': [], # Extract text by regex after filters 'extract_title_as_title': False, diff --git a/changedetectionio/store.py b/changedetectionio/store.py index f7bffbe8..123e5db7 100644 --- a/changedetectionio/store.py +++ b/changedetectionio/store.py @@ -316,7 +316,8 @@ class ChangeDetectionStore: # #Re 569 new_watch = Watch.model(datastore_path=self.datastore_path, default={ 'url': url, - 'tag': tag + 'tag': tag, + 'date_created': int(time.time()) }) new_uuid = new_watch['uuid'] @@ -679,3 +680,13 @@ class ChangeDetectionStore: except: continue return + + # We don't know when the date_created was in the past until now, so just add an index number for now. + def update_11(self): + i = 0 + for uuid, watch in self.data['watching'].items(): + if not watch.get('date_created'): + watch['date_created'] = i + i+=1 + return + diff --git a/changedetectionio/templates/watch-overview.html b/changedetectionio/templates/watch-overview.html index 24027ff4..9aa5e5e7 100644 --- a/changedetectionio/templates/watch-overview.html +++ b/changedetectionio/templates/watch-overview.html @@ -49,18 +49,18 @@ {% endfor %} - {% set sort_order = request.args.get('order', 'asc') == 'asc' %} - {% set sort_attribute = request.args.get('sort', 'last_changed') %} + {% set sort_order = sort_order or 'asc' %} + {% set sort_attribute = sort_attribute or 'last_changed' %} {% set pagination_page = request.args.get('page', 0) %}
# | -- {% set link_order = "desc" if sort_order else "asc" %} + {% set link_order = "desc" if sort_order == 'asc' else "asc" %} {% set arrow_span = "" %} + | # | +Website | Last Checked | Last Changed | @@ -69,8 +69,7 @@
---|