|
@@ -55,6 +55,61 @@ def lightgallery(links):
|
55
|
55
|
print '</div>'
|
56
|
56
|
|
57
|
57
|
# -----------------------------------------------------------------------------
|
|
58
|
+# github helper macros
|
|
59
|
+# -----------------------------------------------------------------------------
|
|
60
|
+
|
|
61
|
+import urllib, json
|
|
62
|
+
|
|
63
|
+def restRequest(url):
|
|
64
|
+ response = urllib.urlopen(url)
|
|
65
|
+ data = json.loads(response.read())
|
|
66
|
+ return data
|
|
67
|
+
|
|
68
|
+def restReleases(user, repo):
|
|
69
|
+ s = "https://api.github.com/repos/"
|
|
70
|
+ s += user
|
|
71
|
+ s += "/"
|
|
72
|
+ s += repo
|
|
73
|
+ s += "/releases"
|
|
74
|
+ return restRequest(s)
|
|
75
|
+
|
|
76
|
+def printLatestRelease(user, repo):
|
|
77
|
+ repo_url = "https://github.com/" + user + "/" + repo
|
|
78
|
+ print("<div class=\"releasecard\">")
|
|
79
|
+ print("Release builds for " + repo + " are <a href=\"" + repo_url + "/releases\">available on GitHub</a>.<br>\n")
|
|
80
|
+
|
|
81
|
+ releases = restReleases(user, repo)
|
|
82
|
+ if len(releases) <= 0:
|
|
83
|
+ print("No release has been published on GitHub yet.")
|
|
84
|
+ print("</div>")
|
|
85
|
+ return
|
|
86
|
+
|
|
87
|
+ releases.sort(key=lambda x: x["published_at"], reverse=True)
|
|
88
|
+ r = releases[0]
|
|
89
|
+ release_url = r["html_url"]
|
|
90
|
+ print("Latest release of <a href=\"" + repo_url + "\">" + repo + "</a>, at the time of this writing: <a href=\"" + release_url + "\">" + r["name"] + "</a> (" + datetime.strptime(r["published_at"], "%Y-%m-%dT%H:%M:%SZ").strftime("%Y-%m-%d %H:%M:%S") + ")\n")
|
|
91
|
+
|
|
92
|
+ if len(r["assets"]) <= 0:
|
|
93
|
+ print("<br>No release assets have been published on GitHub for that.")
|
|
94
|
+ print("</div>")
|
|
95
|
+ return
|
|
96
|
+
|
|
97
|
+ print("<ul>")
|
|
98
|
+ print("Release Assets:")
|
|
99
|
+ for a in r["assets"]:
|
|
100
|
+ size = int(a["size"])
|
|
101
|
+ ss = " "
|
|
102
|
+ if size >= (1024 * 1024):
|
|
103
|
+ ss += "(%.1f MiB)" % (size / (1024.0 * 1024.0))
|
|
104
|
+ elif size >= 1024:
|
|
105
|
+ ss += "(%d KiB)" % (size // 1024)
|
|
106
|
+ else:
|
|
107
|
+ ss += "(%d Byte)" % (size)
|
|
108
|
+
|
|
109
|
+ print("<li><a href=\"" + a["browser_download_url"] + "\">" + a["name"] + "</a>" + ss)
|
|
110
|
+ print("</ul></div>")
|
|
111
|
+
|
|
112
|
+# -----------------------------------------------------------------------------
|
58
|
113
|
# preconvert hooks
|
59
|
114
|
# -----------------------------------------------------------------------------
|
60
|
115
|
|