diff options
author | René 'Necoro' Neumann <necoro@necoro.net> | 2010-04-08 00:50:57 +0200 |
---|---|---|
committer | René 'Necoro' Neumann <necoro@necoro.net> | 2010-04-08 00:50:57 +0200 |
commit | 3b8dc6b9595a3e2abfbc2d031c09635f28677c56 (patch) | |
tree | cab625d5a6a6259005e4752598e39a502cc25269 /helper.py | |
parent | c655f9f76944de41d9f138e2cd61450da9adce49 (diff) | |
download | web-3b8dc6b9595a3e2abfbc2d031c09635f28677c56.tar.gz web-3b8dc6b9595a3e2abfbc2d031c09635f28677c56.tar.bz2 web-3b8dc6b9595a3e2abfbc2d031c09635f28677c56.zip |
Added changelog
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]) |