#!/bin/sh #llllmmmm11234567892123456789312345678941234567895123456789612345678971234567890 set -ex <"$0" python3 -c ' import os, sys class File: attributes = []; content = ""; substitutions = dict() figurative = True; stub = True def addattribute(self, *args): for a in args: # sloppy but works if a == "stub": self.stub = True elif a == "verbatim": self.stub = False elif a == "figuratively": self.figurative = True elif a == "literally": self.figurative = False def __init__(self, **kwargs): for key in kwargs: if key == "attributes": self.addattribute(*kwargs[key]) else: setattr(self, key, kwargs[key]) files = dict() for part in reversed(sys.stdin.read().split("\n\n\n")): name = "." + part.split("\n")[0] if "\t" in "." + name: attributes = name.split("\t")[1].split(",") name = name.split("\t")[0] else: attributes = [] if len(name) <= 1 or name[1] != "/" or "ignore" in attributes: continue content = part.split("\n\n")[0].split("\n") substitutions = dict() if(len(content) > 1): for s in content[1:]: s = s.split("\t") if len(s) == 2: substitutions[s[0]] = s[1] mode = "replace" for attribute in attributes: if attribute in ["append", "replace"]: mode = attribute attributes = list(set(attributes) ^ {"append", "replace"}) content = part[len("\n".join(content))+2:] file = File(attributes = attributes, content = content + "\n", substitutions = substitutions) if mode == "append": if not(name in files): sys.stderr.write(sys.argv[0] + ": " + name + ": " + "appending to nothing\n") else: file.content = files[name].content + file.content files[name] = file for name in files: if files[name].stub: p = ""; s = ""; d = name while True: d = os.path.dirname(d) if (p == "" and os.path.join(d, "Prefix") in files.keys()): p = files[os.path.join(d, "Prefix")].content if (s == "" and os.path.join(d, "Suffix") in files.keys()): s = files[os.path.join(d, "Suffix")].content if d == "." or (not(p == "") and not(s == "")): break files[name].content = p + files[name].content + s if files[name].figurative: content = files[name].content for s in files[name].substitutions: instances = [] i = 0 while True: instance = content.find(s, i) if instance == -1: break instances += [instance] i = instance + len(s) if len(instances) == 0: continue for i in reversed(instances): content = (content[:i] + files[name].substitutions[s] + content[i+len(s):]) files[name].content = content # TODO error checking if not(os.path.isdir(os.path.dirname(name))): os.makedirs(os.path.dirname(name)) with open(name, "w") as fd: fd.write(files[name].content) d = ""; bucket = "#!/bin/sh\n" for name in files: d = name while True: if os.path.dirname(d) == ".": mop = ("rm " + "-r " * os.path.isdir(d) + name # yeah this sucks + "\n" ) if not(mop in bucket): bucket += mop break else: d = os.path.dirname(d) if len(bucket.split("\n")) > 2: with open("./cleanup.sh", "w") as fd: fd.write(bucket) ' test -x homepage.local \ && exec ./homepage.local \ || test -e homepage.local \ && exec sh ./homepage.local \ || exit 0 /LICENSE verbatim Other than noted exceptions, this is free and unencumbered data released into the public domain. Anyone is free to copy, modify, publish, use, compile, sell, or distribute this data, either in source code form or as a compiled binary, for any purpose, commercial or non-commercial, and by any means. In jurisdictions that recognize copyright laws, the author or authors of this data dedicate any and all copyright interest in the data to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights to this data under copyright law. THE DATA IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE DATA OR THE USE OR OTHER DEALINGS IN THE DATA. For more information, please refer to /homepage.html $!TITLE "homepage" documentation $!DESCRIPTION one file, one website

"homepage" documentation

the forest

homepage is a single-file static site generator written in UNIX sh(1) shell script, the goal being to contain a website with heirarchical page organization within a single file that can be run to extract it out to the filesystem, almost like a self-extracting UNIX tape archive that documents its own layout in a UTF-8 script closer to English.

trees

files

To add a file to your homepage, append three newlines ('\n', or the Enter/Return key on your keyboard) to the end of the homepage file, followed by the path of the file to add. A homepage file path starts with a slash ('/') and is followed by the path to the file relative to the prefix directory (the directory containing homepage). A file path that starts with a hash ('#') is discarded. For all non-slash- non-hash- prefixed file paths, the behavior of homepage is undefined.

file attributes

On the same line as the file path, if, after the path, a tab ('\t') is present, the substring following the first tab in the line and spanning to and excluding the next tab or newline describes the attributes of the file as it is exported to the file system. These file attributes are delimited by commas (',') and there's no limit to the amount of attributes a file can have, though in the event of conflicting attributes the later attribute "wins" the conflict.

attribute default?action
"figuratively"yes Indicates the file should be subject to macro expansion.
"ignore" no Ignore the current entry.
"literally" no Opposite of "figuratively".
"stub" yes Indicates the file should be exported to the filesystem with the appropriate Prefix and Suffix files prepended or appended.
"verbatim" no Opposite of "stub".
/praise/index.html append,literally
  • [] Doctor Eli Selig !!JQHA6kqyl91: >Maid Phone user / >mfw / ["Heart hands.jpg"]
  • /praise/Prefix verbatim