admin design shows private files, thanks Alan

This commit is contained in:
mdipierro
2012-07-21 13:29:23 -05:00
parent 3b0935a68b
commit ac08356843
3 changed files with 68 additions and 3 deletions
+1 -1
View File
@@ -1 +1 @@
Version 2.00.0 (2012-07-20 17:37:48) dev
Version 2.00.0 (2012-07-21 13:29:17) dev
+15 -2
View File
@@ -854,6 +854,11 @@ def design():
modules = modules=[x.replace('\\','/') for x in modules]
modules.sort()
# Get all private files
privates = listdir(apath('%s/private/' % app, r=request), '[^\.#].*')
privates = [x.replace('\\','/') for x in privates]
privates.sort()
# Get all static files
statics = listdir(apath('%s/static/' % app, r=request), '[^\.#].*')
statics = [x.replace('\\','/') for x in statics]
@@ -908,6 +913,7 @@ def design():
modules=filter_plugins(modules,plugins),
extend=extend,
include=include,
privates=filter_plugins(privates,plugins),
statics=filter_plugins(statics,plugins),
languages=languages,
plurals=plurals,
@@ -924,7 +930,7 @@ def delete_plugin():
redirect(URL('design', args=app, anchor=request.vars.id))
elif 'delete' in request.vars:
try:
for folder in ['models','views','controllers','static','modules']:
for folder in ['models','views','controllers','static','modules', 'private']:
path=os.path.join(apath(app,r=request),folder)
for item in os.listdir(path):
if item.rsplit('.',1)[0] == plugin_name:
@@ -994,6 +1000,11 @@ def plugin():
modules = modules=[x.replace('\\','/') for x in modules]
modules.sort()
# Get all private files
privates = listdir(apath('%s/private/' % app, r=request), '[^\.#].*')
privates = [x.replace('\\','/') for x in privates]
privates.sort()
# Get all static files
statics = listdir(apath('%s/static/' % app, r=request), '[^\.#].*')
statics = [x.replace('\\','/') for x in statics]
@@ -1023,6 +1034,7 @@ def plugin():
modules=filter_plugins(modules),
extend=extend,
include=include,
privates=filter_plugins(privates),
statics=filter_plugins(statics),
languages=languages,
crontab=crontab)
@@ -1142,10 +1154,11 @@ def create_file():
# coding: utf8
from gluon import *\n""")[1:]
elif path[-8:] == '/static/':
elif (path[-8:] == '/static/') or (path[-9:] == '/private/'):
if request.vars.plugin and not filename.startswith('plugin_%s/' % request.vars.plugin):
filename = 'plugin_%s/%s' % (request.vars.plugin, filename)
text = ''
else:
redirect(request.vars.sender+anchor)
@@ -57,6 +57,7 @@ def deletefile(arglist, vars={}):
{{=button('#languages', T("languages"))}}
{{=button('#static', T("static"))}}
{{=button('#modules', T("modules"))}}
{{=button('#private', T("private files"))}}
{{=button('#plugins', T("plugins"))}}
</span>
</p>
@@ -318,6 +319,57 @@ for c in controllers: controller_functions+=[c[:-3]+'/%s.html'%x for x in functi
{{=file_upload_form('%s/modules/' % app, 'modules')}}</div>
</div>
<!-- PRIVATE -->
<h3 id="private" onclick="collapse('private_inner');" class="component">
{{=T("Private files")}}
<span class="tooltip">{{=helpicon()}} <span>{{=T("These files are not served, they are only available from within your app")}}</span></span>
</h3>
<div id="private_inner" class="component_contents">
<div class="controls comptools">
</div>
{{if not privates:}}<p><strong>{{=T("There are no private files")}}</strong></p>{{pass}}
<ul>
{{
path=[]
for file in privates+['']:
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='private__'+'__'.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('private',file, dict(id="private"))}} {{=deletefile([app,'private',file], dict(id="private",id2="private"))}}
</span>
<span class="file">
{{=filename}}
</span>
</li>{{
pass
pass
}}
{{pass}}
</ul>
<div class="controls formfield">{{=file_create_form('%s/private/' % app, 'private')}}
{{=file_upload_form('%s/private/' % app, 'private')}}</div>
</div>
<!-- PLUGINS -->
<h3 id="plugins" onclick="collapse('plugins_inner');" class="component">