mobile admin, thanks Angelo

This commit is contained in:
Massimo Di Pierro
2011-12-09 20:55:57 -06:00
parent ac82f1e4e7
commit f0f8c8ce22
21 changed files with 313 additions and 319 deletions
@@ -1,40 +1,88 @@
{{extend 'default.mobile/layout.html'}}
{{
def A_info(*a,**b):
b['_data-role'] = 'button'
b['_data-icon'] = 'info'
b['_data-theme'] = 'b'
return A(*a,**b)
def A_gear(*a,**b):
b['_data-role'] = 'button'
b['_data-icon'] = 'gear'
return A(*a,**b)
def A_delete(*a,**b):
b['_data-role'] = 'button'
b['_data-icon'] = 'delete'
return A(*a,**b)
def A_check(*a,**b):
b['_data-role'] = 'button'
b['_data-icon'] = 'check'
return A(*a,**b)
def all(items):
return reduce(lambda a,b:a and b,items,True)
def peekfile(path,file):
return A_info(file.replace('\\\\','/'),_href=URL('peek', args=(app, path, file)))
def editfile(path,file):
return A_gear(SPAN(T('Edit')),_href=URL('edit', args=(app, path, file)))
def testfile(path,file):
return A_check(SPAN(T('Run tests')), _href=URL('test', args=(app, file)))
def editlanguagefile(path,file):
return A_gear(SPAN(T('Edit')),_href=URL('edit_language', args=(app, path, file)))
def file_upload_form(location):
form=FORM(T("upload file:")," ",
INPUT(_type="file",_name="file")," ",T("and rename it:")," ",
INPUT(_type="text",_name="filename",requires=IS_NOT_EMPTY),
INPUT(_type="hidden",_name="location",_value=location),
INPUT(_type="hidden",_name="sender",_value=URL('design',args=app)),
INPUT(_type="submit",_value=T("upload")),_action=URL('upload_file'))
return form
def file_create_form(location):
form=FORM(T("create file with filename:")," ",
INPUT(_type="text",_name="filename",requires=IS_NOT_EMPTY),
INPUT(_type="hidden",_name="location",_value=location),
INPUT(_type="hidden",_name="sender",_value=URL('design',args=app)),
INPUT(_type="submit",_value=T("Create")),_action=URL('create_file'))
return form
def upload_plugin_form(app):
form=FORM(T("upload plugin file:")," ",
INPUT(_type="file",_name="pluginfile"),
INPUT(_type="submit",_value=T("upload")))
return form
def deletefile(arglist):
return A_delete(SPAN(T('Delete')), _href=URL('delete',args=arglist,vars=dict(sender=request.function+'/'+app)))
}}
{{block sectionclass}}design {{=app}}{{end}}
<!-- MODELS -->
<div data-role="collapsible-set" data-content-theme="c">
<!-- MODELS -->
<div data-role="collapsible" data-content-theme="c">
<h3 id="models">
{{=T("Models")}}
<span class="tooltip">{{=helpicon()}} <span>{{=T("The data representation, define database tables and sets")}}</span></span>
</h3>
<div id="models_inner" class="component_contents">
<div id="models_inner">
{{if not models:}}<p><strong>{{=T("There are no models")}}</strong></p>{{else:}}
<div class="controls comptools">
<div data-role="controlgroup" data-type="horizontal">
{{=button(URL(a=app,c='appadmin',f='index'), T('database administration'))}}
{{if os.access(os.path.join(request.folder,'..',app,'databases','sql.log'),os.R_OK):}}
{{=button(URL('peek/%s/databases/sql.log'%app), 'sql.log')}}
{{pass}}
</div>
{{pass}}
<ul>
{{for m in models:}}
<li id="models__{{=m.replace('.','__')}}">
<span class="filetools controls">
<span data-role="controlgroup">
{{=peekfile('models',m)}}
{{=editfile('models',m)}}
{{=deletefile([app, 'models', m])}}
</span>
<span class="file">
{{=peekfile('models',m)}}
</span>
<span class="extras">
{{if len(defines[m]):}}{{=T("defines tables")}} {{pass}}{{=XML(', '.join([B(table).xml() for table in defines[m]]))}}
</span>
</li>
</br>
{{pass}}
</ul>
<div class="controls formfield">{{=file_create_form('%s/models/' % app)}}</div>
<div data-role="fieldcontain">{{=file_create_form('%s/models/' % app)}}</div>
</div>
</div>
<!-- FIND CONTROLLER FUNCTIONS -->
@@ -44,218 +92,165 @@ for c in controllers: controller_functions+=[c[:-3]+'/%s.html'%x for x in functi
}}
<!-- CONTROLLERS -->
<h3 id="controllers" onclick="collapse('controllers_inner');" class="component">
<div data-role="collapsible" data-content-theme="c">
<h3 id="controllers">
{{=T("Controllers")}}
<span class="tooltip">{{=helpicon()}} <span>{{=T("The application logic, each URL path is mapped in one exposed function in the controller")}}</span></span>
</h3>
<div id="controllers_inner" class="component_contents">
<div id="controllers_inner">
{{if not controllers:}}<p><strong>{{=T("There are no controllers")}}</strong></p>{{else:}}
<div class="controls comptools">
<div data-role="controlgroup" data-type="horizontal">
{{=button(URL(r=request,c='shell',f='index',args=app), T("shell"))}}
{{=button(URL('test',args=app), T("test"))}}
{{=button(URL('edit',args=[app,'cron','crontab']), T("crontab"))}}
</div>
{{pass}}
<ul>
{{for c in controllers:}}
<li id="controllers__{{=c.replace('.','__')}}">
<span class="filetools controls">
<span data-role="controlgroup">
{{=peekfile('controllers',c)}}
{{=editfile('controllers',c)}}
{{=deletefile([app, 'controllers', c])}}
{{=testfile('controllers',c)}}
</br>
</span>
<span class="file">
{{=peekfile('controllers',c)}}
</span>
<span class="extras">
{{if functions[c]:}}{{=T("exposes")}} {{pass}}{{=XML(', '.join([A(f,_href=URL(a=app,c=c[:-3],f=f)).xml() for f in functions[c]]))}}
</span>
</li>
{{pass}}
</ul>
<div class="controls formfield">{{=file_create_form('%s/controllers/' % app)}}</div>
<div data-role="fieldcontain">{{=file_create_form('%s/controllers/' % app)}}</div>
</div>
</div>
<!-- VIEWS -->
<h3 id="views" onclick="collapse('views_inner');" class="component">
<div data-role="collapsible" data-content-theme="c">
<h3 id="views">
{{=T("Views")}}
<span class="tooltip">{{=helpicon()}} <span>{{=T("The presentations layer, views are also known as templates")}}</span></span>
</h3>
<div id="views_inner" class="component_contents">
<div class="controls comptools">
<div id="views_inner">
<div data-role="controlgroup" data-type="horizontal">
{{=button(LAYOUTS_APP, T("download layouts"))}}
</div>
{{if not views:}}<p><strong>{{=T("There are no views")}}</strong></p>{{pass}}
<ul>
{{for c in views:}}
<li id="views__{{=c.replace('/','__').replace('.','__')}}">
<span class="filetools controls">
<span data-role="controlgroup">
{{=peekfile('views',c)}}
{{=editfile('views',c)}}
{{=deletefile([app, 'views', c])}}
</br>
</span>
<span class="file">
{{=peekfile('views',c)}}
</span>
<span class="extras">
{{if extend.has_key(c):}}{{=T("extends")}} <b>{{=extend[c]}}</b> {{pass}}
{{if include[c]:}}{{=T("includes")}} {{pass}}{{=XML(', '.join([B(f).xml() for f in include[c]]))}}
</span>
</li>
{{pass}}
</ul>
<div class="controls formfield">{{=file_create_form('%s/views/' % app)}}</div>
<div data-role="fieldcontain">{{=file_create_form('%s/views/' % app)}}</div>
</div>
</div>
<!-- LANGUAGES -->
<h3 id="languages" onclick="collapse('languages_inner');" class="component">
<div data-role="collapsible" data-content-theme="c">
<h3 id="languages">
{{=T("Languages")}}
<span class="tooltip">{{=helpicon()}} <span>{{=T("Translation strings for the application")}}</span></span>
</h3>
<div id="languages_inner" class="component_contents">
<div class="controls comptools">
<div id="languages_inner">
<div data-role="controlgroup" data-type="horizontal">
{{=button(URL('update_languages/'+app), T('update all languages'))}}
</div>
{{if not languages:}}<p><strong>{{=T("There are no translators, only default language is supported")}}</strong></p>{{pass}}
<ul>
{{if not languages:}}<p><strong>{{=T("There are no translators")}}</strong></p>{{pass}}
{{for file in languages:}}
<li id="languages__{{=file.replace('.','__')}}">
<span class="filetools controls">
<span data-role="controlgroup">
{{=peekfile('languages',file)}}
{{=editlanguagefile('languages',file)}}
{{=deletefile([app, 'languages', file])}}
</br>
</span>
<span class="file">
{{=peekfile('languages',file)}}
</span>
</li>
{{pass}}
</ul>
<div class="controls formfield">{{=file_create_form('%s/languages/' % app)}}{{=T('(something like "it-it")')}}</div>
<div data-role="fieldcontain">{{=file_create_form('%s/languages/' % app)}}</div>
</div>
</div>
<!-- STATIC -->
<h3 id="static" onclick="collapse('static_inner');" class="component">
<div data-role="collapsible" data-content-theme="c">
<h3 id="static">
{{=T("Static files")}}
<span class="tooltip">{{=helpicon()}} <span>{{=T("These files are served without processing, your images go here")}}</span></span>
</h3>
<div id="static_inner" class="component_contents">
<div class="controls comptools">
</div>
</h3>
<div id="static_inner">
{{if not statics:}}<p><strong>{{=T("There are no static files")}}</strong></p>{{pass}}
<ul>
<ul data-role="listview" data-inset="true">
{{
path=[]
from collections import OrderedDict
tree=OrderedDict()
for file in statics+['']:
items=file.split('/')
file_path=items[:-1]
filename=items[-1]
while path!=file_path:
if len(file_path)>=len(path) and all([v==file_path[k] for k,v in enumerate(path)]):
path.append(file_path[len(path)])
thispath='static__'+'__'.join(path)
}}
<li class="folder">
<a href="javascript:collapse('{{=thispath}}');" class="file">{{=path[-1]}}/</a>
<ul id="{{=thispath}}" style="display: none;" class="sublist">{{
else:
path = path[:-1]
}}
</ul></li>
{{
pass
pass
if filename:
}}<li>
<span class="filetools controls">
{{=editfile('static',file)}} {{=deletefile([app,'static',file])}}
</span>
<span class="file">
<a href="{{=URL(a=app,c='static',f=file)}}">{{=filename}}</a>
</span>
</li>{{
pass
items=file.partition('/')
if not items[0] in tree:
tree[items[0]] = []
pass
tree[items[0]].append(items[2])
pass
}}
{{for k, v in tree.iteritems():}}
{{if k:}}
<li><a>{{=k}}</a>
<ul data-theme='c'>
</br>
{{if len(v) == 1 and v[0] =='':}}
<span data-role="controlgroup">
{{=peekfile('static', k)}}
{{=editfile('static', k)}}
{{=deletefile([app, 'static', k])}}
</br>
</span>
</ul>
{{continue}}
{{for f in v:}}
<span data-role="controlgroup">
{{=peekfile('static/'+k, f)}}
{{=editfile('static/'+k, f)}}
{{=deletefile([app, 'static/'+k, f])}}
</br>
</span>
{{pass}}
</ul>
</li>
{{pass}}
</ul>
<div class="controls formfield">{{=file_create_form('%s/static/' % app)}}
{{pass}}
</ul>
<div data-role="fieldcontain">{{=file_create_form('%s/static/' % app)}}
{{=file_upload_form('%s/static/' % app)}}</div>
</div>
</div>
<!-- MODULES -->
<h3 id="modules" onclick="collapse('modules_inner');" class="component">
{{=T("Modules")}}
<span class="tooltip">{{=helpicon()}} <span>{{=T("Additional code for your application")}}</span></span>
</h3>
<div id="modules_inner" class="component_contents">
<div class="controls comptools">
</div>
<div data-role="collapsible" data-content-theme="c">
<h3 id="modules">
{{=T("Modules")}}</h3>
<div id="modules_inner">
{{if not modules:}}<p><strong>{{=T("There are no modules")}}</strong></p>{{pass}}
<ul>
{{for m in modules:}}
<li id="modules__{{=m.replace('/','__').replace('.','__')}}">
<span class="filetols controls">
<span data-role="controlgroup">
{{=peekfile('modules',m)}}
{{=editfile('modules',m)}}
{{if m!='__init__.py':}}{{=deletefile([app, 'modules', m])}}{{pass}}
</span>
<span class="file">
{{=peekfile('modules',m)}}
</span>
</li>
{{pass}}
</ul>
<div class="controls formfield">{{=file_create_form('%s/modules/' % app)}}
<div data-role="fieldcontain">{{=file_create_form('%s/modules/' % app)}}
{{=file_upload_form('%s/modules/' % app)}}</div>
</div>
</div>
<!-- PLUGINS -->
<h3 id="plugins" onclick="collapse('plugins_inner');" class="component">
<div data-role="collapsible" data-content-theme="c">
<h3 id="plugins" >
{{=T("Plugins")}}
<span class="tooltip">{{=helpicon()}} <span>{{=T("To create a plugin, name a file/folder plugin_[name]")}}</span></span>
</h3>
<div id="plugins_inner" class="component_contents">
<div class="controls comptools">
<div id="plugins_inner">
<div data-role="controlgroup" data-type="horizontal">
{{=button(PLUGINS_APP, T('download plugins'))}}
</div>
<div class="controls">
</div>
{{if plugins:}}
<ul>
<div data-role="controlgroup">
{{for plugin in plugins:}}
<li>
{{=A('plugin_%s' % plugin, _class='file', _href=URL('plugin', args=[app, plugin]))}}
</li>
{{=button(URL('plugin', args=[app, plugin]), 'plugin_%s' % plugin)}}
{{pass}}
</ul>
</div>
{{else:}}
<p><strong>{{=T('There are no plugins')}}</strong></p>
{{pass}}
<div class="controls formfield">{{=upload_plugin_form(app)}}</div>
<div data-role="fieldcontain">{{=upload_plugin_form(app)}}</div>
</div>
</div>
<script>
jQuery(document).ready(function(){
jQuery('#search').keyup(function(e){
var code = (e.keyCode ? e.keyCode : e.which);
if(code==13 && jQuery('#search').val()){
jQuery.getJSON('{{=URL('search',args=request.args)}}?keywords='+escape(jQuery('#search').val()),null,function(data, textStatus, xhr){
jQuery('.component_contents li, .formfield, .comptools').hide();
files=data['files'];
for(var i=0; i<files.length; i++)
jQuery('li#'+files[i].replace(/\//g,'__').replace('.','__')).slideDown();
jQuery('.flash').html('{{=T("Searching:")}} '+files.length+' {{=T("files")}}').slideDown();
});
} else if(code==13) {
jQuery('.component_contents li, .formfield, .comptools').slideDown();
jQuery('.flash').html('').hide();
}
});
});
</script>
</div>