diff --git a/applications/admin/controllers/default.py b/applications/admin/controllers/default.py index 221458de..0999df33 100644 --- a/applications/admin/controllers/default.py +++ b/applications/admin/controllers/default.py @@ -750,6 +750,7 @@ def edit(): return response.json({'file_hash': file_hash, 'saved_on': saved_on, 'functions': functions, 'controller': controller, 'application': request.args[0], 'highlight': highlight}) else: file_details = dict(app=request.args[0], + lineno=request.vars.lineno or 1, editor_settings=preferences, filename=filename, realfilename=realfilename, @@ -773,6 +774,35 @@ 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 = '#\s*(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..39b5311b 100644 --- a/applications/admin/static/css/web2py-codemirror.css +++ b/applications/admin/static/css/web2py-codemirror.css @@ -1,7 +1,13 @@ +/* TODO rename this file as web2py-editor.css */ /* Fullscreen */ .CodeMirror-fullscreen { z-index: 1030; } +.CodeMirror { + border-top: 1px solid #ddd; + /*border-left: 1px solid #ddd;*/ + border-bottom: 1px solid #ddd; +} /* BREAKPOINTS */ @@ -36,3 +42,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/static/js/ajax_editor.js b/applications/admin/static/js/ajax_editor.js index 2b355fe4..8a7916a4 100644 --- a/applications/admin/static/js/ajax_editor.js +++ b/applications/admin/static/js/ajax_editor.js @@ -248,7 +248,7 @@ function keepalive(url) { }); } -function load_file(url) { +function load_file(url, lineno) { $.ajax({ type: "GET", contentType: 'application/json', @@ -263,13 +263,13 @@ function load_file(url) { var tab_header = '
  • ' + json['realfilename'] + '
  • '; var tab_body = '
    ' + json['plain_html'] + '
    '; if(json['force'] === false) { - $('#filesTab').append($(tab_header)); - $('#myTabContent').append($(tab_body)); + $('#myTabContent').append($(tab_body)); // First load the body + $('#filesTab').append($(tab_header)); // Then load the header which trigger the shown event } else { $('#' + json['id']).html($(tab_body)); } } - $("a[href='#" + json['id'] + "']").click(); + $("a[href='#" + json['id'] + "']").trigger('click', lineno); } }, error: function (x) { diff --git a/applications/admin/views/default/edit.html b/applications/admin/views/default/edit.html index 9187a4c4..4e8d0427 100644 --- a/applications/admin/views/default/edit.html +++ b/applications/admin/views/default/edit.html @@ -52,12 +52,17 @@ @@ -227,7 +233,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}}
    diff --git a/applications/admin/views/default/todolist.load b/applications/admin/views/default/todolist.load new file mode 100644 index 00000000..00aceb92 --- /dev/null +++ b/applications/admin/views/default/todolist.load @@ -0,0 +1,15 @@ +
    + +

    TODO

    + + +
    diff --git a/applications/admin/views/layout.html b/applications/admin/views/layout.html index d1bdbe37..4f3ab932 100644 --- a/applications/admin/views/layout.html +++ b/applications/admin/views/layout.html @@ -55,6 +55,7 @@ + {{block footer}} + {{end}}