Commit 50076b05 by murtaugh

targets working in subdirectories

1 parent f8217e39
......@@ -31,8 +31,10 @@ form.target {
<div id="buttons" style="margin-top: 1em">
<button id="touch">touch</button>
<span id="targetbuttons">
<!-- Targets are implemented as actions that get triggered on a particular directory
They are implemented as forms that post to the CWD (rpath or request_label) with ?target=NAME -->
{% for t in targets %}
<form class="target" action="{{t}}"><input type="submit" value="{{t }}"></form>{% endfor %}
<form class="target" action="{{rurl}}"><input type="submit" name="target" value="{{t}}"></form>{% endfor %}
</span>
</div>
<script>
......
......@@ -68,7 +68,10 @@ def maker (path, queue):
try:
# _, filename = os.path.split(req['path'])
rpath = os.path.relpath(req['path'], req['cwd'])
if 'target' in req:
rpath = req['path']
else:
rpath = os.path.relpath(req['path'], req['cwd'])
cmd = ["make"]
cmd.extend(("-f", req['makefile']))
if 'force' in req:
......@@ -131,7 +134,7 @@ class FileSaver (Resource):
# return NOT_DONE_YET
class FileMaker (Resource):
def __init__(self, path, makeRequestsQueue, docroot, index="index.html", makefile=None, force=False):
def __init__(self, path, makeRequestsQueue, docroot, index="index.html", makefile=None, force=False, target=False):
# print ("FileMaker", path, docroot, makefile)
self.path = path
self.makeRequestsQueue = makeRequestsQueue
......@@ -139,6 +142,7 @@ class FileMaker (Resource):
self.makefile = makefile
self.index = index
self.force = force
self.target = target
# self.cwd = cwd
Resource.__init__(self)
self.childNotFound = NoResource("File not found.")
......@@ -158,16 +162,22 @@ class FileMaker (Resource):
# auto_index=True
fpath = os.path.join(self.docroot, urllib.unquote(request.path.lstrip("/")))
query = parse_qs2(urlparse(request.uri).query)
if request.method == "POST":
return FileSaver(fpath)
if request.path == '/' or request.path.endswith("/"):
return self.index.for_path(fpath)
if 'target' in query:
# HANDLE a ?target=NAME request
ret = FileMaker(query['target'], self.makeRequestsQueue, fpath, self.index, self.makefile, force=False, target=True)
ret.isLeaf = True
return ret
else:
return self.index.for_path(fpath)
# print ("fpath:{0}".format(fpath), file=sys.stderr)
r = None
# HOW TO AVOID THIS IF NOT NEEDED ?! >>>> ACTUALLY... or simply don't repeat again below!! (todo)
query = parse_qs2(urlparse(request.uri).query)
if self.makefile:
r = make_question_simple(fpath, self.makefile, self.docroot)
force = 'remake' in query
......@@ -209,6 +219,8 @@ class FileMaker (Resource):
d = {'path': self.path, 'request': request, 'makefile': self.makefile, 'cwd': self.docroot}
if self.force:
d['force'] = True
if self.target:
d['target'] = True
self.makeRequestsQueue.put(d)
return NOT_DONE_YET
......
......@@ -160,7 +160,10 @@ class MakeDirectoryListing (object):
'request_label': rpath,
'parent_link': parent_link
}
rurl = rpath
if not rurl.startswith("/"):
rurl = "/" + rurl
tvars['rurl'] = rurl
items = []
for file, is_dir, makeable, remake, missing, is_text in files:
classes = []
......
Styling with Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!