diff --git a/app/app.py b/app/app.py
index 49fe974..441faa8 100644
--- a/app/app.py
+++ b/app/app.py
@@ -174,13 +174,26 @@ def appsobservatory_history():
data = json.loads(open("./app/scripts/appListsHistory/count_history.json").read())
return render_template('applist_history.html', data=data)
-
@main.route('/appsobservatory/news')
def appsobservatory_news():
news_per_date = json.loads(open("./app/scripts/appListsHistory/news.json").read())
return render_template('applist_news.html', news_per_date=list(reversed(list(news_per_date.items()))))
+@main.route('/appsobservatory/news/rss')
+def appsobservatory_news_rss():
+ rss_news_per_date = json.loads(open("./app/scripts/appListsHistory/news_rss.json").read())
+ rss_xml = render_template('applist_news_rss.xml', rss_news_per_date=list(reversed(list(rss_news_per_date.items()))))
+ response = make_response(rss_xml)
+ response.headers['Content-Type'] = 'application/rss+xml'
+ response.headers['Content-Disposition'] = "inline; filename=YNH_catalog_news.xml"
+ return response
+@main.app_template_filter()
+def format_datetime(value, format="%d %b %Y %I:%M %p"):
+ if value is None:
+ return ""
+ return datetime.strptime(value, "%b %d %Y").strftime(format)
+
@main.route('/appsobservatory/unlisted')
def appsobservatory_unlisted():
diff --git a/app/scripts/appListsHistory/rss_template.html b/app/scripts/appListsHistory/rss_template.html
deleted file mode 100644
index d9bab68..0000000
--- a/app/scripts/appListsHistory/rss_template.html
+++ /dev/null
@@ -1,77 +0,0 @@
-{% if data.new %}
-
New apps
-
-{% for app in data.new %}
-- {{ app.name.title() }}
- ({{ app.state }}{% if app.level %}, level {{ app.level }}{% endif %})
-{% endfor %}
-
-{% endif %}
-
-{% if data.improvements %}
-Improvements
-
-{% for app, changes in data.improvements %}
-- {{ app.name.title() }}:
- {% for change in changes %}
- {% if change == "updated" %}
- Updated{{ "," if not loop.last }}
- {% elif change[0] == "state" %}
- State {{ change[1] }} -> {{ change[2] }}{{ "," if not loop.last }}
- {% elif change[0] == "level" %}
- Level {{ change[1] }} -> {{ change[2] }}{{ "," if not loop.last }}
- {% endif %}
- {% endfor %}
-
-{% endfor %}
-
-{% endif %}
-
-{% if data.updates %}
-Updates
-
-{% for app, changes in data.updates %}
-- {{ app.name.title() }}:
- {% for change in changes %}
- {% if change == "updated" %}
- Updated{{ "," if not loop.last }}
- {% elif change[0] == "state" %}
- State {{ change[1] }} -> {{ change[2] }}{{ "," if not loop.last }}
- {% elif change[0] == "level" %}
- Level {{ change[1] }} -> {{ change[2] }}{{ "," if not loop.last }}
- {% endif %}
- {% endfor %}
-
-{% endfor %}
-
-{% endif %}
-
-{% if data.regressions %}
-Regressions
-
-{% for app, changes in data.regressions %}
-- {{ app.name.title() }}:
- {% for change in changes %}
- {% if change == "updated" %}
- Updated{{ "," if not loop.last }}
- {% elif change[0] == "state" %}
- State {{ change[1] }} -> {{ change[2] }}{{ "," if not loop.last }}
- {% elif change[0] == "level" %}
- Level {{ change[1] }} -> {{ change[2] }}{{ "," if not loop.last }}
- {% endif %}
- {% endfor %}
-
-{% endfor %}
-
-{% endif %}
-
-{% if data.removed %}
-Apps removed
-
-{% for app in data.removed %}
-- {{ app.name.title() }}
-({{ app.state }}{% if app.level %}, level {{ app.level }}{% endif %})
-
-{% endfor %}
-
-{% endif %}
diff --git a/app/scripts/appListsHistory/script.py b/app/scripts/appListsHistory/script.py
index 1be0136..1208ed8 100644
--- a/app/scripts/appListsHistory/script.py
+++ b/app/scripts/appListsHistory/script.py
@@ -1,8 +1,10 @@
import toml
import json
+import markdown
import os
import sys
import inspect
+import requests
from datetime import datetime
currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))
@@ -148,7 +150,6 @@ def make_news():
else:
return int(lev)
-
for d in time_points_until_today:
d_label = d.strftime("%b %d %Y")
@@ -167,19 +168,45 @@ def make_news():
news = news_per_date[d_label]
for app in set(apps_previous_good & apps_current_broken):
- news["broke"].append((app, j[app]["url"]))
+ news["broke"].append([app, j[app]["url"], j[app].get("branch", "master"), j[app].get("category", ""), j[app].get("subtags", "")])
for app in set(apps_previous_broken & apps_current_good):
- news["repaired"].append((app, j[app]["url"]))
+ news["repaired"].append([app, j[app]["url"], j[app].get("branch", "master"), j[app].get("category", ""), j[app].get("subtags", "")])
for app in set(apps_current - apps_previous):
- news["added"].append((app, j[app]["url"]))
+ news["added"].append([app, j[app]["url"], j[app].get("branch", "master"), j[app].get("category", ""), j[app].get("subtags", "")])
for app in set(apps_previous - apps_current):
- news["removed"].append((app, previous_j[app]["url"]))
+ news["removed"].append([app, previous_j[app]["url"], previous_j[app].get("branch", "master"), previous_j[app].get("category", ""), previous_j[app].get("subtags", "")])
previous_j = j
json.dump(news_per_date, open('news.json', 'w'))
+
+ # Generate json for RSS feed
+ rss_number_of_times_points_to_include = 2
+ rss_d_label = list(news_per_date)[-rss_number_of_times_points_to_include:]
+ rss_feed = {k:news_per_date.get(k) for k in rss_d_label}
+
+ for d, status_list in rss_feed.items():
+ print("Pushing all entries from " + d + " to RSS feed...")
+ for status, apps_list in status_list.items():
+ for app in apps_list:
+ # Memo: at this point, 'app' list's indexes correspond to [0] - app name, [1] - app url, [2] - app branch name, [3] - app category, [4] - app subtags
+
+ # Merge list of category and subtags into a unique string and store it in [3]
+ if app[3] and app[4]:
+ app[3] = app[3] + ", " + ", ".join(app[4])
+ # Retrieve app README and store it in [4]
+ print("Retrieve Github README for app " + app[0])
+ readme_url = "https://raw.githubusercontent.com/YunoHost-Apps/" + app[0] + "_ynh/" + app[2] + "/README.md"
+ r = requests.get(readme_url)
+ readme_md = r.text
+ readme_md = readme_md.replace("./doc/screenshots/", "https://raw.githubusercontent.com/YunoHost-Apps/" + app[0] + "_ynh/" + app[2] + "/doc/screenshots/")
+ readme_html = markdown.markdown(readme_md)
+ app[4] = readme_html
+
+ json.dump(rss_feed, open('news_rss.json', 'w'))
+
def update_catalog_stats(app, history):
print(app)
diff --git a/app/static/css/tartiflette.css b/app/static/css/tartiflette.css
index 5c9e08a..8096ca1 100644
--- a/app/static/css/tartiflette.css
+++ b/app/static/css/tartiflette.css
@@ -66,3 +66,6 @@ td.ci-app-test-result > div.danger { background-color: rgb(225,80,62); }
text-overflow: ellipsis;
max-width:400px;
}
+
+.btn-rss { background-color: #ee802f; border-color: #ee802f; }
+.btn-rss:hover, .btn-rss:not(:disabled):not(.disabled):active { background-color: #ca630c; border-color: #c15b00; }
diff --git a/app/templates/applist_news.html b/app/templates/applist_news.html
index f08d6ad..a0d309c 100644
--- a/app/templates/applist_news.html
+++ b/app/templates/applist_news.html
@@ -2,6 +2,12 @@
{% block content %}
+
+
+
+
+
+
{% for date, news in news_per_date %}
@@ -9,28 +15,29 @@
{{ date }}
- {% for app, url in news["added"] %}
+ {% for app in news["added"] %}
+ {# MEMO: app list's indexes correspond to [0] - app name, [1] - app url, [2] - app Github branch name, [3] - app description (keywords), [4] - app readme in HTML #}
-
Added
- {{app}}
+ {{app[0]}}
{% endfor %}
- {% for app, url in news["repaired"] %}
+ {% for app in news["repaired"] %}
-
Repaired
- {{app}}
+ {{app[0]}}
{% endfor %}
- {% for app, url in news["broke"] %}
+ {% for app in news["broke"] %}
-
Broke
- {{app}}
+ {{app[0]}}
{% endfor %}
- {% for app, url in news["removed"] %}
+ {% for app in news["removed"] %}
-
Removed
- {{app}}
+ {{app[0]}}
{% endfor %}
diff --git a/app/templates/applist_news_rss.xml b/app/templates/applist_news_rss.xml
new file mode 100644
index 0000000..a075317
--- /dev/null
+++ b/app/templates/applist_news_rss.xml
@@ -0,0 +1,31 @@
+
+
+
+ YNH Catalog News
+ {{ url_for('main.appsobservatory_news')}}
+
+ YunoHost apps catalog's news
+ {%- for date, status_list in rss_news_per_date %}
+ {%- for status in ("added", "repaired", "broke", "removed") %}
+ {%- for app in status_list[status] %}
+ {#- MEMO: app list's indexes correspond to [0] - app name, [1] - app url, [2] - app Github branch name, [3] - app description (keywords), [4] - app readme in HTML #}
+ -
+ [{{ status|upper }}] {{ app[0]|capitalize }}
+ {{ app[1] }}
+ {{ app[1] }}#{{ date|format_datetime("%Y%m%d") }}
+ {{ date|format_datetime("%a, %d %b %Y %H:%M:%S +0000") }}
+ {{ app[3]|capitalize }}
+
+
+ {% endfor -%}
+ {% endfor -%}
+ {% endfor %}
+
+