summaryrefslogtreecommitdiff
path: root/helper.py
diff options
context:
space:
mode:
authorRené 'Necoro' Neumann <necoro@necoro.net>2010-04-08 00:50:57 +0200
committerRené 'Necoro' Neumann <necoro@necoro.net>2010-04-08 00:50:57 +0200
commit3b8dc6b9595a3e2abfbc2d031c09635f28677c56 (patch)
treecab625d5a6a6259005e4752598e39a502cc25269 /helper.py
parentc655f9f76944de41d9f138e2cd61450da9adce49 (diff)
downloadweb-3b8dc6b9595a3e2abfbc2d031c09635f28677c56.tar.gz
web-3b8dc6b9595a3e2abfbc2d031c09635f28677c56.tar.bz2
web-3b8dc6b9595a3e2abfbc2d031c09635f28677c56.zip
Added changelog
Diffstat (limited to 'helper.py')
-rw-r--r--helper.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/helper.py b/helper.py
index 7f97824..1828b5e 100644
--- a/helper.py
+++ b/helper.py
@@ -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])