diff --git a/backend/backend.py b/backend/backend.py index 799fe552..cbab87d2 100644 --- a/backend/backend.py +++ b/backend/backend.py @@ -59,8 +59,9 @@ def _jinja2_filter_datetime(watch_obj, format="%Y-%m-%d %H:%M:%S"): return datetime.datetime.utcfromtimestamp(int(watch_obj['last_checked'])).strftime(format) -#@app.context_processor -#def timeago(): + +# @app.context_processor +# def timeago(): # def _timeago(lower_time, now): # return timeago.format(lower_time, now) # return dict(timeago=_timeago) @@ -70,8 +71,8 @@ def _jinja2_filter_datetimestamp(timestamp, format="%Y-%m-%d %H:%M:%S"): if timestamp == 0: return 'Not yet' return timeago.format(timestamp, time.time()) - #return timeago.format(timestamp, time.time()) - #return datetime.datetime.utcfromtimestamp(timestamp).strftime(format) + # return timeago.format(timestamp, time.time()) + # return datetime.datetime.utcfromtimestamp(timestamp).strftime(format) @app.route("/", methods=['GET']) @@ -83,7 +84,6 @@ def main_page(): # Sort by last_changed datastore.data['watching'].sort(key=lambda x: x['last_changed'], reverse=True) - output = render_template("watch-overview.html", watches=datastore.data['watching'], messages=messages) messages = [] return output @@ -135,7 +135,7 @@ def launch_checks(): global running_update_threads for watch in datastore.data['watching']: - if watch['last_checked'] <= time.time() - 3*60*60: + if watch['last_checked'] <= time.time() - 3 * 60 * 60: running_update_threads[watch['uuid']] = fetch_site_status.perform_site_check(uuid=watch['uuid'], datastore=datastore) running_update_threads[watch['uuid']].start() diff --git a/backend/fetch_site_status.py b/backend/fetch_site_status.py index 2d966bc0..9689dd9a 100644 --- a/backend/fetch_site_status.py +++ b/backend/fetch_site_status.py @@ -28,16 +28,12 @@ class perform_site_check(Thread): def save_response_html_output(self, output): # @todo maybe record a history.json, [timestamp, md5, filename] - - with open("{}/{}.txt".format(self.output_path, self.timestamp), 'w') as f: f.write(output) f.close() def save_response_stripped_output(self, output): - # @todo maybe record a history.json, [timestamp, md5, filename] - with open("{}/{}.stripped.txt".format(self.output_path, self.timestamp), 'w') as f: f.write(output) f.close() @@ -54,6 +50,7 @@ class perform_site_check(Thread): print("Checking", self.url) import html2text + self.ensure_output_path() try: r = requests.get(self.url, headers=headers, timeout=15, verify=False) diff --git a/backend/requirements.txt b/backend/requirements.txt index d48c15ce..ee29a712 100644 --- a/backend/requirements.txt +++ b/backend/requirements.txt @@ -13,7 +13,7 @@ validators bleach==3.2.1 html5lib==0.9999999 # via bleach - +timeago html2text # @notes diff --git a/backend/static/css/styles.css b/backend/static/css/styles.css index 4e57305e..ca974cb2 100644 --- a/backend/static/css/styles.css +++ b/backend/static/css/styles.css @@ -76,4 +76,16 @@ body:before { body:after,body:before { -webkit-clip-path: polygon(100% 0,0 0,0 77.5%,1% 77.4%,2% 77.1%,3% 76.6%,4% 75.9%,5% 75.05%,6% 74.05%,7% 72.95%,8% 71.75%,9% 70.55%,10% 69.3%,11% 68.05%,12% 66.9%,13% 65.8%,14% 64.8%,15% 64%,16% 63.35%,17% 62.85%,18% 62.6%,19% 62.5%,20% 62.65%,21% 63%,22% 63.5%,23% 64.2%,24% 65.1%,25% 66.1%,26% 67.2%,27% 68.4%,28% 69.65%,29% 70.9%,30% 72.15%,31% 73.3%,32% 74.35%,33% 75.3%,34% 76.1%,35% 76.75%,36% 77.2%,37% 77.45%,38% 77.5%,39% 77.3%,40% 76.95%,41% 76.4%,42% 75.65%,43% 74.75%,44% 73.75%,45% 72.6%,46% 71.4%,47% 70.15%,48% 68.9%,49% 67.7%,50% 66.55%,51% 65.5%,52% 64.55%,53% 63.75%,54% 63.15%,55% 62.75%,56% 62.55%,57% 62.5%,58% 62.7%,59% 63.1%,60% 63.7%,61% 64.45%,62% 65.4%,63% 66.45%,64% 67.6%,65% 68.8%,66% 70.05%,67% 71.3%,68% 72.5%,69% 73.6%,70% 74.65%,71% 75.55%,72% 76.35%,73% 76.9%,74% 77.3%,75% 77.5%,76% 77.45%,77% 77.25%,78% 76.8%,79% 76.2%,80% 75.4%,81% 74.45%,82% 73.4%,83% 72.25%,84% 71.05%,85% 69.8%,86% 68.55%,87% 67.35%,88% 66.2%,89% 65.2%,90% 64.3%,91% 63.55%,92% 63%,93% 62.65%,94% 62.5%,95% 62.55%,96% 62.8%,97% 63.3%,98% 63.9%,99% 64.75%,100% 65.7%); clip-path: polygon(100% 0,0 0,0 77.5%,1% 77.4%,2% 77.1%,3% 76.6%,4% 75.9%,5% 75.05%,6% 74.05%,7% 72.95%,8% 71.75%,9% 70.55%,10% 69.3%,11% 68.05%,12% 66.9%,13% 65.8%,14% 64.8%,15% 64%,16% 63.35%,17% 62.85%,18% 62.6%,19% 62.5%,20% 62.65%,21% 63%,22% 63.5%,23% 64.2%,24% 65.1%,25% 66.1%,26% 67.2%,27% 68.4%,28% 69.65%,29% 70.9%,30% 72.15%,31% 73.3%,32% 74.35%,33% 75.3%,34% 76.1%,35% 76.75%,36% 77.2%,37% 77.45%,38% 77.5%,39% 77.3%,40% 76.95%,41% 76.4%,42% 75.65%,43% 74.75%,44% 73.75%,45% 72.6%,46% 71.4%,47% 70.15%,48% 68.9%,49% 67.7%,50% 66.55%,51% 65.5%,52% 64.55%,53% 63.75%,54% 63.15%,55% 62.75%,56% 62.55%,57% 62.5%,58% 62.7%,59% 63.1%,60% 63.7%,61% 64.45%,62% 65.4%,63% 66.45%,64% 67.6%,65% 68.8%,66% 70.05%,67% 71.3%,68% 72.5%,69% 73.6%,70% 74.65%,71% 75.55%,72% 76.35%,73% 76.9%,74% 77.3%,75% 77.5%,76% 77.45%,77% 77.25%,78% 76.8%,79% 76.2%,80% 75.4%,81% 74.45%,82% 73.4%,83% 72.25%,84% 71.05%,85% 69.8%,86% 68.55%,87% 67.35%,88% 66.2%,89% 65.2%,90% 64.3%,91% 63.55%,92% 63%,93% 62.65%,94% 62.5%,95% 62.55%,96% 62.8%,97% 63.3%,98% 63.9%,99% 64.75%,100% 65.7%) -} \ No newline at end of file +} + + + + +.button-small { + font-size: 85%; +} + +a[target="_blank"]::after { + content: url(data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAoAAAAKCAYAAACNMs+9AAAAQElEQVR42qXKwQkAIAxDUUdxtO6/RBQkQZvSi8I/pL4BoGw/XPkh4XigPmsUgh0626AjRsgxHTkUThsG2T/sIlzdTsp52kSS1wAAAABJRU5ErkJggg==); + margin: 0 3px 0 5px; +} diff --git a/backend/store.py b/backend/store.py index 87ab621d..e45e9965 100644 --- a/backend/store.py +++ b/backend/store.py @@ -16,7 +16,7 @@ class ChangeDetectionStore: 'tag': None, 'last_checked': 0, 'last_changed': 0, - 'title': None, + 'title': 'xxx', 'uuid': str(uuid.uuid4()) } diff --git a/backend/templates/watch-overview.html b/backend/templates/watch-overview.html index e703eb09..3d972c7c 100644 --- a/backend/templates/watch-overview.html +++ b/backend/templates/watch-overview.html @@ -20,7 +20,7 @@ # - URL + Last Checked Last Changed @@ -32,7 +32,8 @@ {% for watch in watches %} {{ loop.index }} - {{ watch.url }} + {% if watch.title is not none %}{{ watch.title }}{% else %}{{ watch.url }}{% endif %} + {{watch|format_last_checked_time}} {% if watch.last_error is defined and watch.last_error != False %} !! {% endif %}