better Expose
This commit is contained in:
@@ -1 +1 @@
|
|||||||
Version 2.4.5-stable+timestamp.2013.03.29.02.31.04
|
Version 2.4.5-stable+timestamp.2013.03.31.15.30.02
|
||||||
|
|||||||
@@ -7,8 +7,7 @@
|
|||||||
|
|
||||||
response.logo = A(B('web',SPAN(2),'py'),XML('™ '),
|
response.logo = A(B('web',SPAN(2),'py'),XML('™ '),
|
||||||
_class="brand",_href="http://www.web2py.com/")
|
_class="brand",_href="http://www.web2py.com/")
|
||||||
response.title = ' '.join(
|
response.title = request.application.replace('_',' ').title()
|
||||||
word.capitalize() for word in request.application.split('_'))
|
|
||||||
response.subtitle = T('customize me!')
|
response.subtitle = T('customize me!')
|
||||||
|
|
||||||
## read more at http://dev.w3.org/html5/markup/meta.name.html
|
## read more at http://dev.w3.org/html5/markup/meta.name.html
|
||||||
|
|||||||
@@ -91,16 +91,18 @@
|
|||||||
|
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<!-- Masthead ================================================== -->
|
<!-- Masthead ================================================== -->
|
||||||
|
{{if response.title:}}
|
||||||
<header class="mastheader row" id="header">
|
<header class="mastheader row" id="header">
|
||||||
<div class="span12">
|
<div class="span12">
|
||||||
<div class="page-header">
|
<div class="page-header">
|
||||||
<h1>
|
<h1>
|
||||||
{{=response.title or request.application}}
|
{{=response.title}}
|
||||||
<small>{{=response.subtitle or ''}}</small>
|
<small>{{=response.subtitle or ''}}</small>
|
||||||
</h1>
|
</h1>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</header>
|
</header>
|
||||||
|
{{pass}}
|
||||||
|
|
||||||
<section id="main" class="main row">
|
<section id="main" class="main row">
|
||||||
{{if left_sidebar_enabled:}}
|
{{if left_sidebar_enabled:}}
|
||||||
|
|||||||
+37
-12
@@ -4833,14 +4833,27 @@ class PluginManager(object):
|
|||||||
|
|
||||||
|
|
||||||
class Expose(object):
|
class Expose(object):
|
||||||
def __init__(self, base=None, basename='base', extensions=None, allow_download=True):
|
def __init__(self, base=None, basename=None, extensions=None, allow_download=True):
|
||||||
"""
|
"""
|
||||||
extensions: an optional list of file extensions for filtering displayed files:
|
Usage:
|
||||||
|
|
||||||
|
def static():
|
||||||
|
return dict(files=Expose())
|
||||||
|
|
||||||
|
or
|
||||||
|
|
||||||
|
def static():
|
||||||
|
path = os.path.join(request.folder,'static','public')
|
||||||
|
return dict(files=Expose(path,basename='public'))
|
||||||
|
|
||||||
|
extensions:
|
||||||
|
an optional list of file extensions for filtering displayed files:
|
||||||
['.py', '.jpg']
|
['.py', '.jpg']
|
||||||
allow_download: whether to allow downloading selected files
|
allow_download: whether to allow downloading selected files
|
||||||
"""
|
"""
|
||||||
current.session.forget()
|
current.session.forget()
|
||||||
base = base or os.path.join(current.request.folder, 'static')
|
base = base or os.path.join(current.request.folder, 'static')
|
||||||
|
basename = basename or current.request.function
|
||||||
self.basename = basename
|
self.basename = basename
|
||||||
self.args = current.request.raw_args and \
|
self.args = current.request.raw_args and \
|
||||||
[arg for arg in current.request.raw_args.split('/') if arg] or []
|
[arg for arg in current.request.raw_args.split('/') if arg] or []
|
||||||
@@ -4857,8 +4870,14 @@ class Expose(object):
|
|||||||
if os.path.isdir(f) and not self.isprivate(f)]
|
if os.path.isdir(f) and not self.isprivate(f)]
|
||||||
self.filenames = [f[len(path) - 1:] for f in sorted(glob.glob(path))
|
self.filenames = [f[len(path) - 1:] for f in sorted(glob.glob(path))
|
||||||
if not os.path.isdir(f) and not self.isprivate(f)]
|
if not os.path.isdir(f) and not self.isprivate(f)]
|
||||||
|
if 'README' in self.filenames:
|
||||||
|
readme = open(os.path.join(filename,'README')).read()
|
||||||
|
self.paragraph = MARKMIN(readme)
|
||||||
|
else:
|
||||||
|
self.paragraph = None
|
||||||
if extensions:
|
if extensions:
|
||||||
self.filenames = [f for f in self.filenames if os.path.splitext(f)[-1] in extensions]
|
self.filenames = [f for f in self.filenames
|
||||||
|
if os.path.splitext(f)[-1] in extensions]
|
||||||
|
|
||||||
def breadcrumbs(self, basename):
|
def breadcrumbs(self, basename):
|
||||||
path = []
|
path = []
|
||||||
@@ -4872,8 +4891,10 @@ class Expose(object):
|
|||||||
|
|
||||||
def table_folders(self):
|
def table_folders(self):
|
||||||
if self.folders:
|
if self.folders:
|
||||||
return SPAN(H3('Folders'), TABLE(*[TR(TD(A(folder, _href=URL(args=self.args + [folder]))))
|
return SPAN(H3('Folders'), TABLE(
|
||||||
for folder in self.folders]))
|
*[TR(TD(A(folder, _href=URL(args=self.args + [folder]))))
|
||||||
|
for folder in self.folders],
|
||||||
|
**dict(_class="table")))
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@@ -4882,20 +4903,24 @@ class Expose(object):
|
|||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def isimage(f):
|
def isimage(f):
|
||||||
return os.path.splitext(f)[-1].lower() in ('.png', '.jpg', '.jpeg', '.gif', '.tiff')
|
return os.path.splitext(f)[-1].lower() in (
|
||||||
|
'.png', '.jpg', '.jpeg', '.gif', '.tiff')
|
||||||
|
|
||||||
def table_files(self, width=160):
|
def table_files(self, width=160):
|
||||||
if self.filenames:
|
if self.filenames:
|
||||||
return SPAN(H3('Files'), TABLE(*[TR(TD(A(f, _href=URL(args=self.args + [f]))),
|
return SPAN(H3('Files'),
|
||||||
TD(IMG(_src=URL(args=self.args + [f]),
|
TABLE(*[TR(TD(A(f, _href=URL(args=self.args + [f]))),
|
||||||
_style='max-width:%spx' % width)
|
TD(IMG(_src=URL(args=self.args + [f]),
|
||||||
if width and self.isimage(f) else ''))
|
_style='max-width:%spx' % width)
|
||||||
for f in self.filenames]))
|
if width and self.isimage(f) else ''))
|
||||||
|
for f in self.filenames],
|
||||||
|
**dict(_class="table")))
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
def xml(self):
|
def xml(self):
|
||||||
return DIV(
|
return DIV(
|
||||||
H2(self.breadcrumbs(self.basename)),
|
H2(self.breadcrumbs(self.basename)),
|
||||||
|
self.paragraph or '',
|
||||||
self.table_folders(),
|
self.table_folders(),
|
||||||
self.table_files()).xml()
|
self.table_files()).xml()
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user