Skip to content

Commit

Permalink
refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
Thomas Bach committed Nov 30, 2011
1 parent aacc905 commit ed32dd0
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 9 deletions.
3 changes: 3 additions & 0 deletions taunus/resources.py
Expand Up @@ -33,6 +33,8 @@ class BaseFSObject(object):
Defines properties and functions that all objects in the
file system will share.
"""
supported_actions = []

def __init__(self, parent, name):
self.__parent__ = parent
self.__name__ = name
Expand All @@ -50,6 +52,7 @@ def path(self):
@property
def size(self):
return os.path.getsize(self.full_path())


class Directory(BaseFSObject):

Expand Down
4 changes: 2 additions & 2 deletions taunus/templates/base.pt
Expand Up @@ -6,7 +6,7 @@
<meta charset="UTF-8"/>
<link rel="stylesheet" href="${request.static_path('taunus:static/all.css')}"/>
<script src="http://yui.yahooapis.com/3.4.1/build/yui/yui-min.js"></script>
<title>Taunus - ${resource.path}</title>
<title>Taunus - ${context.path}</title>
</head>
<body>
<div class="page">
Expand All @@ -19,7 +19,7 @@
</div> <!-- closes bd -->
<nav class="hd topper">
<ul class="tabControl">
<li tal:repeat="(item, url_to_item) root_to_resource">
<li tal:repeat="(item, url_to_item) resource_lineage">
<a href="${url_to_item}">
<span>${item}</span>
</a>
Expand Down
11 changes: 8 additions & 3 deletions taunus/templates/directory.pt
Expand Up @@ -3,17 +3,22 @@
xmlns:metal="http://xml.zope.org/namespaces/metal"
metal:use-macro="base">
<tal:block metal:fill-slot="body">
<div id="dirlisting" class="data spec">
<div class="data spec">
<p id="dirlisting" class="yui3-skin-sam">
</p>
</div> <!-- closes data -->
<script>
YUI().use('datatable', function (Y) {
var cols = [
{ key: "action", label: "", abbr: "action", sortable: false },
{ key: "name", label: "Name", abbr: "name", sortable: "true" },
{ key: "size", label: "Size", abbr: "size", sortable: "true" }
];
var data = [
<tal:block tal:repeat="item resource">
{"name": "<a href='${item.path}'>${item}</a>", "size": ${item.size}},
<tal:block tal:repeat="item listing">
{ "action": ["foo", "bar"],
"name": "<a href='${item.path}'>${item}</a>",
"size": ${item.size} },
</tal:block>
];
var table = new Y.DataTable.Base({
Expand Down
11 changes: 7 additions & 4 deletions taunus/views/__init__.py
Expand Up @@ -7,10 +7,13 @@
@view_config(context='taunus.resources.Directory',
renderer='taunus:templates/directory.pt')
def view_directory(context, request):
return {'resource': context,
'root_to_resource': [ (r, resource_path(r), )
for r in reversed(
[ c for c in lineage(context) ]) ], }
listing = [ entry for entry in context ]
resource_lineage = [
(r, resource_path(r), ) for r in reversed(
[ c for c in lineage(context) ]) ]
return {'context': context,
'listing': listing,
'resource_lineage': resource_lineage, }

@view_config(context='taunus.resources.StdFile')
def serve_file(context, request):
Expand Down

0 comments on commit ed32dd0

Please sign in to comment.