Commit c3688289 by murtaugh

view button

parent 024a0f59
......@@ -21,6 +21,9 @@ form.target {
background: aqua;
padding: 5px;
}
#filecontrols button {
margin-bottom: 5px;
}
td.filecontrols {
position: relative;
}
......@@ -41,7 +44,7 @@ td.filecontrols.active {
{% if item.is_dir %}
<tr class="{{item.classes}}"><td class="filecontrols" valign="top"><a class="filecontrols" href="{{item.link}}"><img src="/__makeserver__/icons/directory.symbolic.png" alt="[DIR]"></a></td><td class="filename"><a href="{{item.link}}">{{item.label}}</a></td><td align="right">{% if item.lasmod %}{{item.lastmod | strftime("%Y-%m-%d %H:%M")}}{%else%}&mdash;{%endif%}</td><td align="right"> - </td><td>&nbsp;</td></tr>
{% else %}
<tr class="{{item.classes}}"><td class="filecontrols" valign="top"><a class="filecontrols" href="{{item.link}}?edit"><img src="/__makeserver__/icons/{% if item.is_text %}text{%else%}generic{%endif%}.symbolic.png" alt="[ ]" border="0"></a></td><td class="filename"><a href="{{item.link}}{% if item.remake %}?preview{% elif item.is_text and not item.makeable %}?edit{% endif %}">{{item.label}}</a></td><td align="right">{% if item.lastmod %}{{item.lastmod | strftime("%Y-%m-%d %H:%M")}}{%else%}&mdash;{%endif%} </td><td align="right">{{item.size|humanize_bytes}}</td><td>&nbsp;</td></tr>
<tr class="{{item.classes}}"><td class="filecontrols" valign="top"><a class="filecontrols" href="{{item.link}}"><img src="/__makeserver__/icons/{% if item.is_text %}text{%else%}generic{%endif%}.symbolic.png" alt="[ ]" border="0"></a></td><td class="filename"><a href="{{item.link}}{% if item.remake %}?preview{% elif item.is_text and not item.makeable %}?edit{% endif %}">{{item.label}}</a></td><td align="right">{% if item.lastmod %}{{item.lastmod | strftime("%Y-%m-%d %H:%M")}}{%else%}&mdash;{%endif%} </td><td align="right">{{item.size|humanize_bytes}}</td><td>&nbsp;</td></tr>
{% endif %}
{% endfor %}
</table>
......@@ -57,6 +60,7 @@ td.filecontrols.active {
<div id="filecontrols">
<button id="touchfile">touch</button>
<button id="editfile">edit</button>
<button id="viewfile">view</button><br>
<button id="renamefile">rename</button>
<button id="deletefile">delete</button>
<!-- <button id="remakefile">remake</button>
......@@ -147,6 +151,16 @@ fc.querySelector("#editfile").addEventListener("click", function () {
window.open(originalPath+"?edit", originalPath);
}
});
fc.querySelector("#viewfile").addEventListener("click", function () {
var td = document.querySelector("td.filecontrols.active"),
td2, td2a, originalPath;
if (td) {
td2 = td.parentNode.querySelector("td.filename");
td2a = td2.querySelector("a");
originalPath = td2a.textContent;
window.open(originalPath, originalPath);
}
});
fc.querySelector("#touchfile").addEventListener("click", function () {
var td = document.querySelector("td.filecontrols.active"),
td2, td2a, originalPath;
......
......@@ -183,18 +183,20 @@ class FileSaver (Resource):
# self.makeRequestsQueue.put({'path': self.path, 'request': request, 'makefile': self.makefile, 'cwd': self.docroot})
# return NOT_DONE_YET
from twisted.python.compat import networkString, intToBytes, nativeString, _PY3
class PreFileMaker (Resource):
def __init__(self, path, force=False):
self.path = path
self.isLeaf = True
self.force = force
self.type = "text/html"
def render_GET(self, request):
# print ("FileSaver.POST", self.path, request)
redurl = self.path
if self.force:
redurl += "?force"
return """<!DOCTYPE html>
ret= """<!DOCTYPE html>
<html>
<head>
<meta http-equiv="refresh" content="0; url={0}">
......@@ -204,6 +206,9 @@ class PreFileMaker (Resource):
</body>
</html>
""".format(redurl, self.path.lstrip("/"))
request.setHeader(b"content-type", networkString("text/html"))
request.setHeader(b"content-length", intToBytes(len(ret)))
return ret
class FileMaker (Resource):
def __init__(self, path, makeRequestsQueue, docroot, index="index.html", makefile=None, force=False, target=False):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment