From b61b0bf3ad1a80b1ab3ec7e65e206b24f0de01e6 Mon Sep 17 00:00:00 2001 From: ilvalle Date: Thu, 5 Dec 2013 11:43:23 +0100 Subject: [PATCH] todo panel in admin editor --- applications/admin/controllers/default.py | 31 +++++++++++++++++++ .../admin/static/css/web2py-codemirror.css | 13 ++++++++ applications/admin/views/default/edit.html | 28 +++++++++++++++++ applications/admin/views/layout.html | 2 ++ 4 files changed, 74 insertions(+) diff --git a/applications/admin/controllers/default.py b/applications/admin/controllers/default.py index 221458de..aa95bb88 100644 --- a/applications/admin/controllers/default.py +++ b/applications/admin/controllers/default.py @@ -773,6 +773,37 @@ def edit(): else: return response.json(file_details) +def todolist(): + """ Returns all TODO of the requested app + """ + app = request.vars.app or '' + app_path = apath('%(app)s' % {'app':app}, r=request) + dirs=['models', 'controllers', 'modules', 'private' ] + def listfiles(app, dir, regexp='.*\.py$'): + files = sorted( listdir(apath('%(app)s/%(dir)s/' % {'app':app, 'dir':dir}, r=request), regexp)) + files = [x.replace(os.path.sep, '/') for x in files if not x.endswith('.bak')] + return files + + pattern = '#(todo)+\s+(.*)' + regex = re.compile(pattern, re.IGNORECASE) + + output = [] + for d in dirs: + for f in listfiles(app, d): + matches = [] + filename= apath(os.path.join(app, d, f), r=request) + + with open(filename, 'r') as f_s: + src = f_s.read() + for m in regex.finditer(src): + start = m.start() + lineno = src.count('\n', 0, start) + 1 + matches.append({'text':m.group(0), 'lineno':lineno}) + if len(matches) != 0: + output.append({'filename':f,'matches':matches, 'dir':d}) + + return {'todo':output, 'app': app} + def resolve(): """ diff --git a/applications/admin/static/css/web2py-codemirror.css b/applications/admin/static/css/web2py-codemirror.css index a11e8d88..f5f80211 100644 --- a/applications/admin/static/css/web2py-codemirror.css +++ b/applications/admin/static/css/web2py-codemirror.css @@ -1,3 +1,4 @@ +/* TODO rename this file as web2py-editor.css */ /* Fullscreen */ .CodeMirror-fullscreen { z-index: 1030; @@ -36,3 +37,15 @@ /*.nav-tabs>li { min-width: 100px; }*/ + +#windows_divs > div { + position: fixed; + height: 30%; + left: 0; + background: white; + right: 0; + bottom: 41px; + z-index: 1030; + overflow: inherit; + border-top: 1px solid #ddd; +} diff --git a/applications/admin/views/default/edit.html b/applications/admin/views/default/edit.html index 9187a4c4..15ab9317 100644 --- a/applications/admin/views/default/edit.html +++ b/applications/admin/views/default/edit.html @@ -227,7 +227,35 @@ $(document).on('click', 'a.font_button', function (e) {
+
+
+ {{=LOAD('default', 'todolist.load', vars={'app':app}, ajax=True, timeout=60000, times="infinity")}} +
+
+{{block footer}} + + + +{{end}}