From ac083568438b7be1dcd7c9309882df65f91df530 Mon Sep 17 00:00:00 2001
From: mdipierro
Date: Sat, 21 Jul 2012 13:29:23 -0500
Subject: [PATCH] admin design shows private files, thanks Alan
---
VERSION | 2 +-
applications/admin/controllers/default.py | 17 ++++++-
applications/admin/views/default/design.html | 52 ++++++++++++++++++++
3 files changed, 68 insertions(+), 3 deletions(-)
diff --git a/VERSION b/VERSION
index 45616fdb..eee4796c 100644
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-Version 2.00.0 (2012-07-20 17:37:48) dev
+Version 2.00.0 (2012-07-21 13:29:17) dev
diff --git a/applications/admin/controllers/default.py b/applications/admin/controllers/default.py
index 711f0330..2ae19382 100644
--- a/applications/admin/controllers/default.py
+++ b/applications/admin/controllers/default.py
@@ -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)
diff --git a/applications/admin/views/default/design.html b/applications/admin/views/default/design.html
index 3664edbf..e5b92ab8 100644
--- a/applications/admin/views/default/design.html
+++ b/applications/admin/views/default/design.html
@@ -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"))}}
@@ -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')}}
+
+
+
+ {{=T("Private files")}}
+ {{=helpicon()}} {{=T("These files are not served, they are only available from within your app")}}
+
+
+
+
+ {{if not privates:}}
{{=T("There are no private files")}}
{{pass}}
+
+ {{
+ 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)
+ }}
+ -
+ {{=path[-1]}}/
+
{{
+ else:
+ path = path[:-1]
+ }}
+
+ {{
+ pass
+ pass
+ if filename:
+ }}-
+
+ {{=editfile('private',file, dict(id="private"))}} {{=deletefile([app,'private',file], dict(id="private",id2="private"))}}
+
+
+ {{=filename}}
+
+
{{
+ pass
+ pass
+ }}
+ {{pass}}
+
+
{{=file_create_form('%s/private/' % app, 'private')}}
+ {{=file_upload_form('%s/private/' % app, 'private')}}
+
+
+