diff options
Diffstat (limited to 'helper.py')
-rw-r--r-- | helper.py | 26 |
1 files changed, 26 insertions, 0 deletions
@@ -1,6 +1,8 @@ import web import os import Image +import markdown +import cStringIO opj = os.path.join @@ -51,3 +53,27 @@ def getImages (path, tmpPath, size): desc = d.read().strip() yield (imgUrl, thumbUrl, desc) + +def getChangelogs (path): + if path[0] != '/': path = '/' + path + appPath = appdir(path[1:]) + + md = markdown.Markdown(safe_mode = "escape", output_format = "html4") + + def ver_to_int (x): + x = x.split(".")[:-1] + + pow = 3 + res = 0 + for i in x: + res += int(i) ** pow + pow -= 1 + return res + + for f in sorted((f for f in os.listdir(appPath) if f.endswith(".txt") and not f[0] == "."), key = ver_to_int, reverse = True): + io = cStringIO.StringIO() + md.convertFile(input = opj(appPath, f), output = io, encoding="utf8") + html = io.getvalue() + io.close() + + yield (html, f[:-4]) |