Documentation additions. Fixes to compilation. Made true passthrough which works.

main
Cas Rusnov 6 years ago
parent 1093636728
commit 3922b13fb1
  1. 1
      MANIFEST.in
  2. 69
      READMES/project-layout.md
  3. 2
      TODO.md
  4. 2
      examples/pixywerk.com/Makefile
  5. 4
      examples/pixywerk.com/README.md
  6. 0
      examples/pixywerk.com/foo
  7. 3
      examples/pixywerk.com/publish/css/main.css
  8. BIN
      examples/pixywerk.com/publish/images/20190415-0.jpg
  9. 0
      examples/pixywerk.com/publish/images/placeholder
  10. 13
      examples/pixywerk.com/publish/index.html
  11. 18
      examples/pixywerk.com/publish/posts/2019-04-15.html
  12. 9
      examples/pixywerk.com/publish/templates/default.jinja2
  13. 6
      examples/pixywerk.com/src/.meta
  14. 3
      examples/pixywerk.com/src/css/main.css
  15. BIN
      examples/pixywerk.com/src/images/20190415-0.jpg
  16. 0
      examples/pixywerk.com/src/images/placeholder
  17. 5
      examples/pixywerk.com/src/index.thtml
  18. 12
      examples/pixywerk.com/src/posts/2019-04-15.thtml
  19. 4
      examples/pixywerk.com/src/posts/2019-04-15.thtml.meta
  20. 9
      examples/pixywerk.com/src/templates/default.jinja2
  21. 11
      pixywerk2/__main__.py
  22. 4
      pixywerk2/processors/passthrough.py
  23. 4
      pixywerk2/processors/processors.py
  24. 5
      setup.py

@ -0,0 +1 @@
include pixywerk2/defaults/*.yaml

@ -0,0 +1,69 @@
# Project Layout #
It is recommended that in general your project for PixyWerk2 site be layed out like:
```
project_top/
Makefile - Convenient for building your site
src/ - All "source" pages are contained in here.
.meta - Top-level default metadata is set here
templates/ - Templates go in here
default.jinja2 - Default template that will be used if none are specified
publish/ - The path the build process will create, where the post-processed files go.
```
## Makefile ##
Makefile is suggested, but not essential, for encapsulating your build commands to produce your
site. Something as simple as:
```
build: src/templates/* src/*
python -mpixywerk2 src publish
```
## src/ ##
This is the top level path that all of your templates, page fragments, images, etc. will be stored. This is basically the "source code" for your site.
## src/.meta ##
This is the top level metadata that is used as the default for all subsidiary metadata. It is in JSON format (with JS style comments). See <METADATA.md> for more information.
Example .meta file:
```
{
"title": "My Website", // this is the default title applied if none are specified
"author": "Super Web Dude",
"site_root": "http://example.com",
"uuid-oid-root": "example.com-", // this is used to generate UUIDs
}
```
## src/templates/ ##
Templates are all stored here, as this is the search path for Jinja.
## templates/default.jinja2 ##
If a page specifies a `template` metadata key, the named template is used, however, if not this template is used. Generally speaking this is a complete HTML file, with the `{{ content }}` template string placed where the content of subsidiary pages will be embedded.
A simple default.jinja2 example:
```
<!DOCTYPE html>
<html>
<head>
<title>{{ title }}</title>
</head>
<body>
{{content}}
</body>
</html>
```
## publish/ ##
This is arbitrary, and will be created by pixywerk at build time, but it will be the root path that should be published to your web server.

@ -1,6 +1,6 @@
# TODO # # TODO #
* Pygments pretty printing of source code et al. including exposing that to the template API. * Pygments pretty printing of source code et al. including exposing that to the template API (`pygment_format(get_file_content('whatever.py'))`).
* Smart CSS things (fill in the processors) * Smart CSS things (fill in the processors)
# Maybe # # Maybe #

@ -0,0 +1,2 @@
build: src/templates/* src/* src/images/* src/posts/*
python -mpixywerk2 src publish

@ -0,0 +1,4 @@
# Pixywerk.com Example #
This is an example blog system with the features most blogs would have (posts, tag cloud, atom/rss feeds,
index with images).

@ -0,0 +1,3 @@
body { margin: 10% 10% 0 10% }

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

@ -0,0 +1,13 @@
<html>
<head>
<title></title>
<link rel="stylesheet" type="text/css" href="css/main.css">
</head>
<body>
<p>This is my index!!</p>
for i in posts[:5]:
get metadata, fill in post image/text summary with link
</body>
</html>

@ -0,0 +1,18 @@
<html>
<head>
<title>My first post</title>
<link rel="stylesheet" type="text/css" href="css/main.css">
</head>
<body>
<img src="../images/20190415-0.jpg" class="featured">
<div class="byline">
<p>Author: Cas Rusnov</p>
<p>Published: 2019-04-16T01:42:27.156392+00:00
</p>
</div>
<p>This is an example post!</p>
<p>yo fresh</p>
<p>There are many posts like it but this one is mine.</p>
</body>
</html>

@ -0,0 +1,9 @@
<html>
<head>
<title>{{ metadata.title }}</title>
<link rel="stylesheet" type="text/css" href="css/main.css">
</head>
<body>
{{ content }}
</body>
</html>

@ -0,0 +1,6 @@
{
"author": "Cas Rusnov",
"author_email": "rusnovn@gmail.com",
"uuid-oid-root": "pixywerk.com/",
"site_root": "https://pixywerk.com/"
}

@ -0,0 +1,3 @@
body { margin: 10% 10% 0 10% }

Binary file not shown.

After

Width:  |  Height:  |  Size: 72 KiB

@ -0,0 +1,5 @@
<p>This is my index!!</p>
for i in posts[:5]:
get metadata, fill in post image/text summary with link

@ -0,0 +1,12 @@
<img src="{{ metadata.featured }}" class="featured">
<div class="byline">
<p>Author: {{ metadata.author }}</p>
<p>Published: {{ get_time_iso8601(metadata.stat.ctime) }}
{% if metadata.stat.mtime-metadata.stat.ctime > 512 %}
Updated: {{ get_time_iso8601(metadata.stat.mtime) }}
{% endif %}
</p>
</div>
<p>This is an example post!</p>
<p>yo fresh</p>
<p>There are many posts like it but this one is mine.</p>

@ -0,0 +1,4 @@
{
"title":"My first post",
"featured":"../images/20190415-0.jpg"
}

@ -0,0 +1,9 @@
<html>
<head>
<title>{{ metadata.title }}</title>
<link rel="stylesheet" type="text/css" href="css/main.css">
</head>
<body>
{{ content }}
</body>
</html>

@ -8,12 +8,14 @@
import argparse import argparse
import logging import logging
import os import os
import shutil
import sys import sys
import time import time
from typing import Dict, List, cast from typing import Dict, List, cast
from .processchain import ProcessorChains from .processchain import ProcessorChains
from .processors.processors import PassthroughException
from .metadata import MetaTree from .metadata import MetaTree
from .template_tools import file_list, file_name, file_content, file_metadata, time_iso8601 from .template_tools import file_list, file_name, file_content, file_metadata, time_iso8601
@ -73,8 +75,11 @@ def main() -> int:
"dir-template": "default-dir.jinja2", "dir-template": "default-dir.jinja2",
"filters": {}, "filters": {},
"build-time": time.time(), "build-time": time.time(),
"build-datetime": time.ctime(),
"uuid-oid-root": "pixywerk", "uuid-oid-root": "pixywerk",
"summary": "",
"description": "",
"author": "",
"author_email": ""
} }
meta_tree = MetaTree(args.root, default_metadata) meta_tree = MetaTree(args.root, default_metadata)
file_list_cache = cast(Dict, {}) file_list_cache = cast(Dict, {})
@ -109,9 +114,13 @@ def main() -> int:
chain = process_chains.get_chain_for_filename(os.path.join(root, f), ctx=metadata) chain = process_chains.get_chain_for_filename(os.path.join(root, f), ctx=metadata)
print("process {} -> {}".format(os.path.join(root, f), os.path.join(target_dir, chain.output_filename))) print("process {} -> {}".format(os.path.join(root, f), os.path.join(target_dir, chain.output_filename)))
if not args.dry_run: if not args.dry_run:
try:
with open(os.path.join(target_dir, chain.output_filename), "w") as outfile: with open(os.path.join(target_dir, chain.output_filename), "w") as outfile:
for line in chain.output: for line in chain.output:
outfile.write(line) outfile.write(line)
except PassthroughException:
shutil.copyfile(os.path.join(root, f), os.path.join(target_dir, chain.output_filename))
return 0 return 0

@ -2,7 +2,7 @@
import os import os
from .processors import Processor from .processors import Processor, PassthroughException
from ..utils import guess_mime from ..utils import guess_mime
from typing import Iterable, Optional, Dict, cast from typing import Iterable, Optional, Dict, cast
@ -49,7 +49,7 @@ class PassThrough(Processor):
Returns: Returns:
iterable: The post-processed output stream iterable: The post-processed output stream
""" """
return input_file raise PassthroughException("passthrough")
def extension(self, oldname: str, ctx: Optional[Dict] = None) -> str: def extension(self, oldname: str, ctx: Optional[Dict] = None) -> str:
"""Return the mimetype of the post-processed file. """Return the mimetype of the post-processed file.

@ -3,6 +3,10 @@ import abc
from typing import Iterable, Optional, Dict from typing import Iterable, Optional, Dict
class PassthroughException(Exception):
"""Raised when the processor would like the file to pass through unchanged."""
class ProcessorException(Exception): # pragma: no cover class ProcessorException(Exception): # pragma: no cover
"""A base exception class to be used by processor objects.""" """A base exception class to be used by processor objects."""

@ -43,12 +43,13 @@ setup(
# 'cookbook = spicerack.cookbook:main', # 'cookbook = spicerack.cookbook:main',
# ], # ],
# }, # },
include_package_data=True,
extras_require=EXTRAS_REQUIRE, extras_require=EXTRAS_REQUIRE,
install_requires=INSTALL_REQUIRES, install_requires=INSTALL_REQUIRES,
keywords=["cms", "website", "compiler"] keywords=["cms", "website", "compiler"],
license="MIT", license="MIT",
long_description=LONG_DESCRIPTION, long_description=LONG_DESCRIPTION,
name="pixywerk2", # Must be the same used for __version__ in __init__.py name="pixywerk2",
packages=find_packages(exclude=["*.tests", "*.tests.*"]), packages=find_packages(exclude=["*.tests", "*.tests.*"]),
platforms=["GNU/Linux"], platforms=["GNU/Linux"],
setup_requires=SETUP_REQUIRES, setup_requires=SETUP_REQUIRES,