Commit 21b81efe authored by Michael Murtaugh's avatar Michael Murtaugh
Browse files

not sure what these changes were anymore

parent 2f6300ae
......@@ -8,14 +8,18 @@ all: $(html_from_md)
today:
touch `date +"%Y-%m-%d.md"`
fixnames:
rename "s/ /_/g" *
# Implicit rule to know how to make .html from .md
%.html: %.md
include.py $< | \
pandoc --from markdown \
--to html \
--standalone \
--css styles.css \
-o $@
$< -o $@
# special rule for debugging variables
print-%:
......
......@@ -16,7 +16,7 @@ form.target {
left: 0px;
top: 18px;
z-index: 1;
width: 360px;
width: 420px;
border-top: 5px solid aqua;
background: aqua;
padding: 5px;
......@@ -41,7 +41,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.is_text and not (item.ext == "html" or item.ext == "svg")%}?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}}?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 False %}?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>
......@@ -56,6 +56,7 @@ td.filecontrols.active {
</div>
<div id="filecontrols">
<button id="touchfile">touch</button>
<button id="editfile">edit</button>
<button id="renamefile">rename</button>
<button id="deletefile">delete</button>
<!-- <button id="remakefile">remake</button>
......@@ -107,14 +108,27 @@ touch.addEventListener("click", function () {
}
}, false);
function hasClass (el, className) {
if (el.classList)
return el.classList.contains(className);
else
return new RegExp('(^| )' + className + '( |$)', 'gi').test(el.className);
}
var fc = document.getElementById("filecontrols");
Array.prototype.slice.call(document.querySelectorAll("a.filecontrols")).forEach(function (x) {
x.addEventListener("click", function (e) {
e.preventDefault();
// console.log("click");
x.parentNode.appendChild(fc);
fc.style.display = "block";
x.parentNode.classList.add("active");
if (hasClass(x.parentNode, "active")) {
fc.style.display = "none";
x.parentNode.classList.remove("active");
} else {
x.parentNode.appendChild(fc);
fc.style.display = "block";
x.parentNode.classList.add("active");
}
})
});
fc.addEventListener("mouseleave", function () {
......@@ -123,6 +137,16 @@ fc.addEventListener("mouseleave", function () {
x.classList.remove("active");
});
});
fc.querySelector("#editfile").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+"?edit", originalPath);
}
});
fc.querySelector("#touchfile").addEventListener("click", function () {
var td = document.querySelector("td.filecontrols.active"),
td2, td2a, originalPath;
......
......@@ -30,7 +30,7 @@ def is_filename (f):
base, ext = os.path.splitext(f)
return len(ext) > 1 or f.endswith("/")
def humanize_bytes(bytes, precision=1):
def humanize_bytes(bytes, precision=0):
"""Return a humanized string representation of a number of bytes.
Assumes `from __future__ import division`.
......@@ -58,10 +58,10 @@ def humanize_bytes(bytes, precision=1):
(1<<30L, 'GB'),
(1<<20L, 'MB'),
(1<<10L, 'kB'),
(1, 'bytes')
(1, '')
)
if bytes == 1:
return '1 byte'
return '1'
for factor, suffix in abbrevs:
if bytes >= factor:
break
......
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 to comment