summaryrefslogtreecommitdiff
path: root/website/helpers.py
diff options
context:
space:
mode:
authorJayaram Pai2014-05-04 16:49:50 +0530
committerJayaram Pai2014-05-04 16:49:50 +0530
commit8a3043c012ebb748d57f55c6c52bd4672ace4568 (patch)
tree4a5baf39e730d8214210c9342e486e665858ac5c /website/helpers.py
parent0eded11fe3dc48f05adcf53a7f9a352b88ed24f4 (diff)
downloadspoken-tutorial-forums-8a3043c012ebb748d57f55c6c52bd4672ace4568.tar.gz
spoken-tutorial-forums-8a3043c012ebb748d57f55c6c52bd4672ace4568.tar.bz2
spoken-tutorial-forums-8a3043c012ebb748d57f55c6c52bd4672ace4568.zip
added pretty urls to questions
Diffstat (limited to 'website/helpers.py')
-rw-r--r--website/helpers.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/website/helpers.py b/website/helpers.py
index 0d67da0..bf5217b 100644
--- a/website/helpers.py
+++ b/website/helpers.py
@@ -1,3 +1,5 @@
+import re
+
def get_video_info(path):
"""Uses ffmpeg to determine information about a video. This has not been broadly
tested and your milage may vary"""
@@ -27,3 +29,12 @@ def get_video_info(path):
info_m['width'] = int(info_m['width'])
info_m['height'] = int(info_m['height'])
return info_m
+
+def prettify(string):
+ string = string.lower()
+ string = string.replace('-', ' ')
+ string = string.strip()
+ string = string.replace(' ', '-')
+ string = re.sub('[^A-Za-z0-9\-]+', '', string)
+ string = re.sub('-+', '-', string)
+ return string