Commit c26a1a01 authored by murtaugh's avatar murtaugh

added a makefile cookbook

parent 7d436aba
......@@ -16,3 +16,11 @@ Install
To do
--------------------------
* (websockets-based) view to monitor output of make command
makewiki (aka cookbook)
--------------------------
Curated set of deployable makefiles
For instance to convert AVI to webm
avi=$(shell ls *.AVI)
aviwebm=$(avi:%.AVI=%.webm)
all: $(aviwebm)
%.webm: %.AVI
ffmpeg -i $< -s 360x270 -c:a libvorbis -c:v libvpx $@
# find all .md files in the directory
# mdsrc=$(shell ls *.md)
mdsrc=$(shell find . -iname "*.md")
# mdsrc=$(wildcard *.md */*.md **/*.md )
# map *.mp => *.html for mdsrc
html_from_md=$(mdsrc:%.md=%.html)
all: $(html_from_md)
fixnames:
rename "s/ /_/g" *
today:
touch `date +"%Y-%m-%d.md"`
now_folder:
mkdir `date +"%Y-%m-%d-%H%M%S"`
# Implicit rule to know how to make .html from .md
%.html: %.md
include.py $< | \
pandoc --from markdown \
--to html \
--standalone \
--smart \
--section-divs \
--css styles.css | \
html5tidy \
--alternate /$<?edit "Edit source" "text/html" \
--script /__makeserver__/links.js > $@
# special rule for debugging variables
print-%:
@echo '$*=$($*)'
......@@ -38,7 +38,7 @@ def editable (path):
_, ext = os.path.splitext(path)
ext = ext.lower()[1:]
# print (f"editable? ext {ext}", file=sys.stderr)
return ((ext not in ("html", "htm")) and not is_binary_file(path))
return ((ext not in ("html", "htm")) and not os.path.isdir(path) and not is_binary_file(path))
# From aiohttp/web_urldispatcher.py
def directory_as_html(filepath, directory, prefix, editor_url=None):
......@@ -84,7 +84,7 @@ def directory_as_html(filepath, directory, prefix, editor_url=None):
ul = "<ul>\n{}\n</ul>".format('\n'.join(index_list))
body = "<body>\n{}\n{}\n</body>".format(h1, ul)
head_str = "<head>\n<title>{}</title>\n</head>".format(index_of)
head_str = "<head>\n<title>{}</title>\n<link rel=\"stylesheet\" href=\"/include/index.css\"></script>\n<script src=\"/include/index.js\"></script>\n</head>".format(index_of)
html = "<html>\n{}\n{}\n</html>".format(head_str, body)
return html
......@@ -111,14 +111,25 @@ async def route_post (request):
print ("POST", path, file=sys.stderr)
if os.path.exists(path) and os.path.isfile(path):
data = await request.post()
resp = {}
# SAVE
if 'text' in data:
text = data['text']
# doing file io inline here is not strictly speaking very async ;)
with open(path, "w") as f:
f.write(text)
return web.Response(text=json.dumps({"response": "ok"}), content_type="application/json")
else:
return web.Response(text=f"no text")
resp['text'] = 'ok'
# RENAME
if 'name' in data:
newpath = os.path.join(os.path.split(path)[0], data['name'])
if path != newpath:
os.rename(path, newpath)
resp['name'] = 'ok'
# DELETE
if 'delete' in data:
os.remove(path)
resp['delete'] = 'ok'
return web.Response(text=json.dumps(resp), content_type="application/json")
else:
return web.Response(text=f"post not allowed on {path}")
......
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