kopia lustrzana https://github.com/dgtlmoon/changedetection.io
Make records in the overview that have a difference that have not been viewed in the [diff] tab bold
rodzic
ec98415c4d
commit
426b09b7e1
|
@ -90,6 +90,8 @@ def main_page():
|
||||||
# Sort by last_changed and add the uuid which is usually the key..
|
# Sort by last_changed and add the uuid which is usually the key..
|
||||||
sorted_watches = []
|
sorted_watches = []
|
||||||
for uuid, watch in datastore.data['watching'].items():
|
for uuid, watch in datastore.data['watching'].items():
|
||||||
|
|
||||||
|
|
||||||
if limit_tag != None:
|
if limit_tag != None:
|
||||||
# Support for comma separated list of tags.
|
# Support for comma separated list of tags.
|
||||||
for tag_in_watch in watch['tag'].split(','):
|
for tag_in_watch in watch['tag'].split(','):
|
||||||
|
@ -249,6 +251,8 @@ def diff_history_page(uuid):
|
||||||
dates.sort(reverse=True)
|
dates.sort(reverse=True)
|
||||||
dates = [str(i) for i in dates]
|
dates = [str(i) for i in dates]
|
||||||
|
|
||||||
|
# Save the current newest history as the most recently viewed
|
||||||
|
datastore.set_last_viewed(uuid, dates[0])
|
||||||
|
|
||||||
newest_file = watch['history'][dates[0]]
|
newest_file = watch['history'][dates[0]]
|
||||||
with open(newest_file, 'r') as f:
|
with open(newest_file, 'r') as f:
|
||||||
|
|
|
@ -48,7 +48,13 @@ section.content {
|
||||||
/* table related */
|
/* table related */
|
||||||
.watch-table {
|
.watch-table {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.watch-table tr.unviewed {
|
||||||
|
font-weight: bold;
|
||||||
|
}
|
||||||
|
|
||||||
.watch-tag-list {
|
.watch-tag-list {
|
||||||
color: #e70069;
|
color: #e70069;
|
||||||
white-space: nowrap;
|
white-space: nowrap;
|
||||||
|
|
|
@ -41,6 +41,8 @@ class ChangeDetectionStore:
|
||||||
'tag': None,
|
'tag': None,
|
||||||
'last_checked': 0,
|
'last_checked': 0,
|
||||||
'last_changed': 0,
|
'last_changed': 0,
|
||||||
|
'last_viewed': 0, # history key value of the last viewed via the [diff] link
|
||||||
|
'newest_history_key': "",
|
||||||
'title': None,
|
'title': None,
|
||||||
'previous_md5': "",
|
'previous_md5': "",
|
||||||
'uuid': str(uuid_builder.uuid4()),
|
'uuid': str(uuid_builder.uuid4()),
|
||||||
|
@ -77,7 +79,8 @@ class ChangeDetectionStore:
|
||||||
_blank = deepcopy(self.generic_definition)
|
_blank = deepcopy(self.generic_definition)
|
||||||
_blank.update(watch)
|
_blank.update(watch)
|
||||||
self.__data['watching'].update({uuid: _blank})
|
self.__data['watching'].update({uuid: _blank})
|
||||||
print("Watching:", uuid, _blank['url'])
|
self.__data['watching'][uuid]['newest_history_key'] = self.get_newest_history_key(uuid)
|
||||||
|
print("Watching:", uuid, self.__data['watching'][uuid]['url'])
|
||||||
|
|
||||||
# First time ran, doesnt exist.
|
# First time ran, doesnt exist.
|
||||||
except (FileNotFoundError, json.decoder.JSONDecodeError):
|
except (FileNotFoundError, json.decoder.JSONDecodeError):
|
||||||
|
@ -87,6 +90,28 @@ class ChangeDetectionStore:
|
||||||
self.add_watch(url='https://www.gov.uk/coronavirus', tag='Covid')
|
self.add_watch(url='https://www.gov.uk/coronavirus', tag='Covid')
|
||||||
self.add_watch(url='https://changedetection.io', tag='Tech news')
|
self.add_watch(url='https://changedetection.io', tag='Tech news')
|
||||||
|
|
||||||
|
# Returns the newest key, but if theres only 1 record, then it's counted as not being new, so return 0.
|
||||||
|
def get_newest_history_key(self, uuid):
|
||||||
|
if len(self.__data['watching'][uuid]['history']) == 1:
|
||||||
|
return 0
|
||||||
|
|
||||||
|
dates = list(self.__data['watching'][uuid]['history'].keys())
|
||||||
|
# Convert to int, sort and back to str again
|
||||||
|
dates = [int(i) for i in dates]
|
||||||
|
dates.sort(reverse=True)
|
||||||
|
if len(dates):
|
||||||
|
# always keyed as str
|
||||||
|
return str(dates[0])
|
||||||
|
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
def set_last_viewed(self, uuid, timestamp):
|
||||||
|
self.data['watching'][uuid].update({'last_viewed': str(timestamp)})
|
||||||
|
self.needs_write = True
|
||||||
|
|
||||||
def update_watch(self, uuid, update_obj):
|
def update_watch(self, uuid, update_obj):
|
||||||
|
|
||||||
with self.lock:
|
with self.lock:
|
||||||
|
@ -99,11 +124,13 @@ class ChangeDetectionStore:
|
||||||
del(update_obj[dict_key])
|
del(update_obj[dict_key])
|
||||||
|
|
||||||
self.__data['watching'][uuid].update(update_obj)
|
self.__data['watching'][uuid].update(update_obj)
|
||||||
|
self.__data['watching'][uuid]['newest_history_key'] = self.get_newest_history_key(uuid)
|
||||||
|
|
||||||
self.needs_write = True
|
self.needs_write = True
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def data(self):
|
def data(self):
|
||||||
|
|
||||||
return self.__data
|
return self.__data
|
||||||
|
|
||||||
def get_all_tags(self):
|
def get_all_tags(self):
|
||||||
|
|
|
@ -41,7 +41,9 @@
|
||||||
|
|
||||||
{% for watch in watches %}
|
{% for watch in watches %}
|
||||||
<tr id="{{ watch.uuid }}"
|
<tr id="{{ watch.uuid }}"
|
||||||
class="{{ loop.cycle('pure-table-odd', 'pure-table-even') }} {% if watch.last_error is defined and watch.last_error != False %}error{% endif %}">
|
class="{{ loop.cycle('pure-table-odd', 'pure-table-even') }}
|
||||||
|
{% if watch.last_error is defined and watch.last_error != False %}error{% endif %}
|
||||||
|
{% if watch.newest_history_key| int > watch.last_viewed| int %}unviewed{% endif %}">
|
||||||
<td>{{ loop.index }}</td>
|
<td>{{ loop.index }}</td>
|
||||||
<td class="title-col">{{watch.title if watch.title is not none else watch.url}}
|
<td class="title-col">{{watch.title if watch.title is not none else watch.url}}
|
||||||
<a class="external" target=_blank href="{{ watch.url }}"></a>
|
<a class="external" target=_blank href="{{ watch.url }}"></a>
|
||||||
|
|
Ładowanie…
Reference in New Issue