Add unlisted apps dashboard

This commit is contained in:
Alexandre Aubin 2017-09-02 03:00:10 +02:00
parent 0f3a9c907e
commit 7f86c49a29
5 changed files with 210 additions and 0 deletions

61
unlistedapps/analyze.py Executable file
View file

@ -0,0 +1,61 @@
#!/usr/bin/python3
import datetime
import glob
import os
import json
import requests
def githubDateToDaysAgo(date):
now = datetime.datetime.now()
date = datetime.datetime.strptime(date, "%Y-%m-%dT%H:%M:%SZ")
return (now - date).days
official = json.loads(requests.get("https://raw.githubusercontent.com/YunoHost/apps/master/official.json").text)
community = json.loads(requests.get("https://raw.githubusercontent.com/YunoHost/apps/master/community.json").text)
official_apps = [ os.path.basename(app["url"]) for app in official.values() ]
community_apps = [ os.path.basename(app["url"]) for app in community.values() ]
unlisted_apps = []
for f in glob.glob("data/*.json"):
j = json.loads(open(f).read())
for item in j["items"]:
app = {
"name": item["name"],
"url": item["html_url"],
"owner": item["owner"]["login"],
"description": item["description"],
"updated_days_ago": githubDateToDaysAgo(item["updated_at"])
}
if str(item["size"]) == "0":
continue
if not app["name"].endswith("_ynh"):
continue
if app["name"] in official_apps or app["name"] in community_apps:
continue
app["name"] = app["name"].replace("_ynh", "")
unlisted_apps.append(app)
unlisted_apps = sorted(unlisted_apps, key=lambda x: x["updated_days_ago"])
#for app in unlisted_apps:
# print("%s %s %s %s" % (str(app["updated_days_ago"]),
# app["name"],
# app["owner"],
# app["description"]))
summary = {}
summary["unlisted_apps"] = unlisted_apps
with open("summary.json", "w") as f:
f.write(json.dumps(summary))

View file

6
unlistedapps/fetch.sh Executable file
View file

@ -0,0 +1,6 @@
#!/bin/bash
for PAGEID in `seq 1 5`
do
curl "https://api.github.com/search/repositories?q=_ynh&sort=updated&per_page=100&page=$PAGEID" > data/$PAGEID.json
done

44
unlistedapps/publish.py Executable file
View file

@ -0,0 +1,44 @@
#!/usr/bin/python3
import os
import json
from jinja2 import Template
from ansi2html import Ansi2HTMLConverter
from ansi2html.style import get_styles
###############################################################################
output_dir = "../www/"
template_path = os.path.join(output_dir,"template_unlistedapps.html")
output_path = os.path.join(output_dir,"unlistedapps.html")
summary_path = os.path.join("./", "summary.json")
###############################################################################
conv = Ansi2HTMLConverter()
shell_css = "\n".join(map(str, get_styles(conv.dark_bg, conv.scheme)))
def shell_to_html(shell):
return conv.convert(shell, False)
###############################################################################
if __name__ == '__main__':
# Fetch the list of all reports, sorted in reverse-chronological order
summary = json.load(open(summary_path))
# Generate the output using the template
template = open(template_path, "r").read()
t = Template(template)
result = t.render(data=summary, convert=shell_to_html, shell_css=shell_css)
open(output_path, "w").write(result)
print("Done.")

View file

@ -0,0 +1,99 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<meta charset="utf-8">
<title>Yunohost Pull Requests Dashboard</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<link rel="stylesheet" href="css/bootstrap.css" media="screen">
<link rel="stylesheet" href="skins/eden.css" media="screen">
<link href="//maxcdn.bootstrapcdn.com/font-awesome/4.3.0/css/font-awesome.min.css" rel="stylesheet">
<link href="css/animate.css" rel="stylesheet">
<style>
.navbar-holder-dark{
padding: 20px 20px 200px 20px;
background: #333333;
}
.container {
width:1250px;
}
.column-app-name {
width:230px;
text-align:center;
}
.column-app-description {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
max-width: 300px;
}
.column-app-updated {
width:170px;
}
</style>
</head>
<body>
<div class="container">
<div class="page-header" id="banner">
<div class="row">
<h1>Unlisted YunoHost apps</h1>
</div>
</div>
<div class="row">
<div class="col-md-10">
<table id="theApplist" class="table table-striped table-responsive">
<thead>
<tr>
<th></th>
<th>Description</th>
<th>Updated</th>
</tr>
</thead>
<tbody>
{% for app in data.unlisted_apps %}
<tr>
<td class="column-app-name">
<a class="btn btn-info" href="{{ app.url }}" style="font-size:1em">{{ app.name }}</a>
</td>
<td class="column-app-description"><strong>{{ app.description }}</strong></td>
<td class="column-app-updated">{{ app.updated_days_ago }} days ago</td>
{% endfor %}
</tbody>
</table>
</div>
</div>
<footer>
<div class="row">
<div class="col-lg-12">
<hr/>
<p>CSS Skin/boilerplate/whatever you call it : <a href="http://scripteden.com/download/eden-ui-bootstrap-3-skin/" rel="nofollow">Eden UI</a>. Generated with <a href="https://github.com/YunoHost/tartiflette">Tartiflette</a>!</p>
</div>
</div>
</footer>
</div>
<script src="https://code.jquery.com/jquery-2.1.3.min.js"></script>
<script src="js/bootstrap.min.js"></script>
</body>
</html>