Memory / Work / djcev.com
Created ,
last updated .
Tags:
freebsd,
linux,
meta,
python,
shell,
software,
website.
Notes taken while working on this website.
Useful Git commands
Echo a file in a specific commit (specified by ID), redirect to a new path:
git show $commit:$path > $newpath
Remove sensitive data from a Git repo
- https://stackoverflow.com/questions/872565/
- https://chrisshort.net/permanently-remove-any-record-of-a-file-from-git/
Importing Mastodon Archive Data
References, useful links:
Wrote a new script based on mastodon-data-viewer that handles filtering unwanted toots & writes each toot to its own file for rendering by blogofile_blog. These files still need to be edited after the fact (to update hashtags and to possibly further redact content) but the script handles most of the work.
Procedure:
- Unpack the downloaded archive tarball (hostname-archive-id.tar.gz)
- Copy mastodon-archive-blogofile.py to the directory created above
- Run mastodon-archive-blogofile.py, redirect output to a file
- The file created thru the redirect above is a list of cp(1) commands that will copy the media attachments (well, the images anyway) to the site gfx directory
- This will create files, one per toot, in a hostname_account dir
- Take a look at the files in the hostname_account dir; do they look right?
- If yes you can start copying them into the blog _posts directory & start editing them. (They will need to be cleaned up, tags edited, etc.)
- Don't forget to run the media attachments copy script before building the site.
Simple CGI comments
References:
- https://forums.digitalpoint.com/threads/flat-file-comments-script.2773566/
- https://github.com/rosslagerwall/simplecommentsystem
- https://docs.python.org/3.8/library/fcntl.html#fcntl.flock
- https://github.com/posativ/isso/blob/master/docs/docs/reference/server-config.rst#guard
- https://www.tutorialspoint.com/python/python_cgi_programming.htm
needs some kind of rate limiting, also file locking (fnctl.flock)
Alternative to CGI comments: double down on mentions
Write up a "how to comment" guide modeled after How To Post Replies To Fogknife articles.
Font & Container Sizing
Left (content) / Right (sidebar) layout: 65% 35% ?
font-size 2.5vw = 16px at 640 wide, 18px at 720, 20px at 800.
Max width for full-screen is 38em (leaving 2em for margins) when font-size is 2.5vw (2.5 * 40 = 100)
38em + 10em sidebar + 4em for margins = 52em; 52em at 18px transitions at 972px wide (i.e., 18 * (52 + 2), adding 2em for extra margin).
One readability guide suggests between 50 and 75 characters per line; I'm going over that (by a little bit) fairly often. (guide in question: https://baymard.com/blog/line-length-readability .)
Rewriting and/or Simplifying Blogofile
Overall program sequence (something like this, not guaranteed to be accurate):
- load config file
- read _config.py with def load_config
- parse commandline arguments (overriding config file)
- need an output directory override in particular
- check sanity of CLI arguments (and maybe also config file)
- erase files in output dir
- set up Mako Template engine
- initialize the engine with a lookup path & store it for later
- reference template.MakoTemplate
- iterate over contents of _posts and _memory; _controllers/blog code
- this collects filenames & creates a collection of Post objects
- apply_filters (markdown) is run when Post objects are created
- this also collects vimwiki pages in _memory
- this collects filenames & creates a collection of Post objects
- iterate over the posts collection(s) and render various templates
- permapages
- chronological
- monthly & yearly archives, then archive_index
- category chronological views
- tag indexes
- RSS & Atom feeds
- render git/* (gitview) & copy to output dir
- rewrite data dicts as objects? Or rework them as a Hierarchical Cache?
- copy files not handled by the above three processes (use ignore regex)
- was writer.__write_files()
- notably copies css, gfx, snd, vid, etc.
- cleanup?
the sequence for calling a Mako template looks like this:
- call materialize_template(template_name, location, attrs{})
- create new MakoTemplate object. within init function:
- instantiate & store a mako.lookup.TemplateLookup
- MakoTemplate.create_lookup(...)
- instantiate mako.template.Template with the lookup from above
- instantiate & store a mako.lookup.TemplateLookup
- extend the object's dict with attrs passed in step 1
- template object render function.
- build template context obj containing template name & render path
- call render() on the mako template object
- render() then calls template.write() which writes to location from step 1
Really need to rework the post visibility system. Visible in: archive, chronological (main), feeds,