todo panel in admin editor

This commit is contained in:
ilvalle
2013-12-05 11:43:23 +01:00
parent 3a6a8af9f6
commit b61b0bf3ad
4 changed files with 74 additions and 0 deletions
+31
View File
@@ -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():
"""
@@ -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;
}
@@ -227,7 +227,35 @@ $(document).on('click', 'a.font_button', function (e) {
<div id="myTabContent" class="tab-content">
</div>
</div>
<section id="windows_divs" class="tab-content ">
<div id="window_todo" class="tab-pane container-fluid">
{{=LOAD('default', 'todolist.load', vars={'app':app}, ajax=True, timeout=60000, times="infinity")}}
</div>
</section>
</div>
{{block footer}}
<div id="" class="navbar navbar-inverse navbar-fixed-bottom">
<div class="navbar-inner">
<ul id="windows_hooks" class="nav">
<li class="">
<a href="#window_todo">TODO</a>
</li>
</ul>
</div>
</div>
<script>
$('#windows_hooks li a').click(function (e) {
e.preventDefault();
if ( $(this).parent('li').hasClass('active') ) {
$(this).parent('li').removeClass('active');
$($(this).attr('href')).removeClass('active');
} else {
$(this).tab('show');
}
});
</script>
{{end}}
<script>
$(document).ready(function() {
var filesMenu = $('#files');
+2
View File
@@ -55,6 +55,7 @@
<!-- FOOTER
============== -->
{{block footer}}
<footer id="footer" class="fixed">
<p><span>{{=T('Powered by')}} {{=A('web2py', _href='http://www.web2py.com')}}&trade; {{=T('created by')}} Massimo Di Pierro &copy;2007-{{=request.now.year}}
{{if hasattr(T,'get_possible_languages_info'):}}
@@ -68,6 +69,7 @@
</span>{{pass}}
</p>
</footer><!-- /#footer -->
{{end}}
<!-- BS JAVASCRIPT
====================== -->