From ec82ce8b246deefdfabad5c5347db1e3d4b78e2c Mon Sep 17 00:00:00 2001 From: KF7EEL Date: Sun, 28 Feb 2021 12:25:19 -0800 Subject: [PATCH] add bulletin board rss, correct spelling of bulletin --- bridge_gps_data.py | 2 +- gps_data.py | 2 +- scripts/dashboard/dashboard.py | 24 +++++++++++++++++-- .../dashboard/dashboard_settings-SAMPLE.py | 3 +++ scripts/dashboard/templates/index.html | 1 + 5 files changed, 28 insertions(+), 4 deletions(-) diff --git a/bridge_gps_data.py b/bridge_gps_data.py index 0a41540..4604cc9 100755 --- a/bridge_gps_data.py +++ b/bridge_gps_data.py @@ -177,7 +177,7 @@ def dashboard_bb_write(call, dmr_id, time, bulletin): dash_bb = ast.literal_eval(os.popen('cat /tmp/gps_data_user_bb.txt').read()) # except: # dash_entries = [] - dash_bb.insert(0, {'call': call, 'dmr_id': dmr_id, 'time': time, 'bulliten':bulletin}) + dash_bb.insert(0, {'call': call, 'dmr_id': dmr_id, 'time': time, 'bulletin':bulletin}) with open("/tmp/gps_data_user_bb.txt", 'w') as user_bb_file: user_bb_file.write(str(dash_bb[:10])) user_bb_file.close() diff --git a/gps_data.py b/gps_data.py index 2c6e928..ed0eef8 100644 --- a/gps_data.py +++ b/gps_data.py @@ -170,7 +170,7 @@ def dashboard_bb_write(call, dmr_id, time, bulletin): dash_bb = ast.literal_eval(os.popen('cat /tmp/gps_data_user_bb.txt').read()) # except: # dash_entries = [] - dash_bb.insert(0, {'call': call, 'dmr_id': dmr_id, 'time': time, 'bulliten':bulletin}) + dash_bb.insert(0, {'call': call, 'dmr_id': dmr_id, 'time': time, 'bulletin':bulletin}) with open("/tmp/gps_data_user_bb.txt", 'w') as user_bb_file: user_bb_file.write(str(dash_bb[:10])) user_bb_file.close() diff --git a/scripts/dashboard/dashboard.py b/scripts/dashboard/dashboard.py index c45f18f..517140b 100644 --- a/scripts/dashboard/dashboard.py +++ b/scripts/dashboard/dashboard.py @@ -21,7 +21,7 @@ This is a web dashboard for the GPS/Data application. ''' -from flask import Flask, render_template, request +from flask import Flask, render_template, request, Response import ast, os from dashboard_settings import * import folium @@ -107,7 +107,7 @@ def get_bb_data(): tmp_bb = tmp_bb + '''  ''' + e['call'] + '''  ''' + str(e['dmr_id']) + ''' -  ''' + e['bulliten'] + '''  +  ''' + e['bulletin'] + '''   ''' + e['time'] + '''  ''' @@ -265,5 +265,25 @@ def view_map(): def map(): return render_template('map.html', title = dashboard_title, logo = logo) +@app.route('/bulletin_rss.xml') +def bb_rss(): + #return render_template('map.html', title = dashboard_title, logo = logo) + dash_bb = ast.literal_eval(os.popen('cat /tmp/gps_data_user_bb.txt').read()) + post_data = '' + rss_header = """ + + + """ + dashboard_title + """ - Bulletin Board Feed + """ + rss_link + """ + This is the Bulletin Board feed from """ + dashboard_title + """""" + for entry in dash_bb: + post_data = post_data + """ + + """ + entry['call'] + ' - ' + str(entry['dmr_id']) + """ + """ + rss_link + """ + """ + entry['bulletin'] + """ - """ + entry['time'] + """ + +""" + return Response(rss_header + post_data + "\n", mimetype='text/xml') if __name__ == '__main__': app.run(debug = True, port=dash_port, host=dash_host) diff --git a/scripts/dashboard/dashboard_settings-SAMPLE.py b/scripts/dashboard/dashboard_settings-SAMPLE.py index b856b1a..0ffd25b 100644 --- a/scripts/dashboard/dashboard_settings-SAMPLE.py +++ b/scripts/dashboard/dashboard_settings-SAMPLE.py @@ -52,3 +52,6 @@ contact_website = 'https://hbl.ink' map_center = (47.00, -120.00) zoom_level = 7 +# RSS feed link, shows in the link section of each RSS item. +rss_link = 'http://localhost:8092' + diff --git a/scripts/dashboard/templates/index.html b/scripts/dashboard/templates/index.html index 0aafc0f..df45a38 100644 --- a/scripts/dashboard/templates/index.html +++ b/scripts/dashboard/templates/index.html @@ -23,6 +23,7 @@ p { {% include 'header.html' %}

Page automatically reloads every 2 minutes.

+

Bulletin Board RSS Feed