gordonbrander / lettersmith_py Goto Github PK
View Code? Open in Web Editor NEWPython tools for static site generation
License: MIT License
Python tools for static site generation
License: MIT License
Installing the package locally (through pip
as an editable package as proposed in the docs) fails with the following traceback:
~/Projects/lettersmith_py master (env) % lettersmith_scaffold foo --type wiki
Traceback (most recent call last):
File "/home/benoit/Projects/lettersmith_py/env/bin/lettersmith_scaffold", line 11, in <module>
load_entry_point('lettersmith', 'console_scripts', 'lettersmith_scaffold')()
File "/home/benoit/Projects/lettersmith_py/lettersmith/bin/scaffold.py", line 30, in main
copy(scaffold_path, project_path, content=True)
File "/home/benoit/Projects/lettersmith_py/lettersmith/file.py", line 46, in copy
recursive=recursive, content=content)
File "/home/benoit/Projects/lettersmith_py/lettersmith/file.py", line 29, in _copy_dir
return subprocess.check_call(cmd)
File "/usr/lib/python3.7/subprocess.py", line 323, in check_call
retcode = call(*popenargs, **kwargs)
File "/usr/lib/python3.7/subprocess.py", line 304, in call
with Popen(*popenargs, **kwargs) as p:
File "/usr/lib/python3.7/subprocess.py", line 756, in __init__
restore_signals, start_new_session)
File "/usr/lib/python3.7/subprocess.py", line 1499, in _execute_child
raise child_exception_type(errno_num, err_msg, err_filename)
FileNotFoundError: [Errno 2] No such file or directory: 'rsync': 'rsync'
Dependency on rsync should be advertised and explained.
This isn't really an issue, just a note left to say thank you for putting lettersmith_py out there.
I picked it up while trying to make a static site for my Obsidian notes. I've made two now, and I'm enjoying learning new things every time I look at your code. Esp. w.r.t. functional programming -- lenses are a neat way to think about the problem of mutating data structures using functions!
Anyways, please feel free to close the issue whenever. Nothing biggie. Just wanted to say hi and say thanks.
Enjoy the Christmas/New Year season!
I get the following stacktrace when running lettersmith_site lettersmith.yaml (generated via lettersmith_scaffold . --type wiki)
I'm running Python 3.5.2 on Ubuntu 16.04
Traceback (most recent call last):
File "/usr/local/bin/lettersmith_site", line 9, in <module>
load_entry_point('lettersmith', 'console_scripts', 'lettersmith_site')()
File "/var/www/html/lettersmith_py/lettersmith/bin/site.py", line 155, in main
stats = Docs.write(docs, output_path=output_path)
File "/var/www/html/lettersmith_py/lettersmith/docs.py", line 23, in write
for doc in docs:
File "/var/www/html/lettersmith_py/lettersmith/bin/site.py", line 153, in <genexpr>
docs = (render_jinja(doc) for doc in docs)
File "/var/www/html/lettersmith_py/lettersmith/jinjatools.py", line 134, in render_doc
rendered = template.render({"doc": doc})
File "/usr/local/lib/python3.5/dist-packages/jinja2/environment.py", line 1008, in render
return self.environment.handle_exception(exc_info, True)
File "/usr/local/lib/python3.5/dist-packages/jinja2/environment.py", line 780, in handle_exception
reraise(exc_type, exc_value, tb)
File "/usr/local/lib/python3.5/dist-packages/jinja2/_compat.py", line 37, in reraise
raise value.with_traceback(tb)
File "theme/wiki/single.html", line 1, in top-level template code
{% extends "_layout.html" %}
File "theme/wiki/_layout.html", line 1, in top-level template code
{% extends "_base.html" %}
File "theme/wiki/_base.html", line 25, in top-level template code
{% block body %}{% endblock %}
File "theme/wiki/_layout.html", line 6, in block "body"
{% block main %}
File "theme/wiki/single.html", line 11, in block "main"
{% if index.backlink[doc.id_path] | len %}
File "/usr/local/lib/python3.5/dist-packages/jinja2/environment.py", line 411, in getitem
return obj[argument]
jinja2.exceptions.UndefinedError: 'dict object' has no attribute 'backlink'
Following the docs, running lettersmith_site lettersmith.yaml
does not work.
It appears that the theme installed from the scaffolding uses where_not("id_path", id_path)
which does not exist.
Traceback (most recent call last):
File "/home/benoit/Projects/lettersmith_py/env/bin/lettersmith_site", line 11, in <module>
load_entry_point('lettersmith', 'console_scripts', 'lettersmith_site')()
File "/home/benoit/Projects/lettersmith_py/lettersmith/bin/site.py", line 158, in main
stats = Docs.write(docs, output_path=output_path)
File "/home/benoit/Projects/lettersmith_py/lettersmith/docs.py", line 23, in write
for doc in docs:
File "/home/benoit/Projects/lettersmith_py/lettersmith/bin/site.py", line 156, in <genexpr>
docs = (render_jinja(doc) for doc in docs)
File "/home/benoit/Projects/lettersmith_py/lettersmith/jinjatools.py", line 123, in render_doc
template = env.select_template(doc.templates)
File "/home/benoit/Projects/lettersmith_py/env/lib/python3.7/site-packages/jinja2/environment.py", line 854, in select_template
return self._load_template(name, globals)
File "/home/benoit/Projects/lettersmith_py/env/lib/python3.7/site-packages/jinja2/environment.py", line 804, in _load_template
template = self.loader.load(self, name, globals)
File "/home/benoit/Projects/lettersmith_py/env/lib/python3.7/site-packages/jinja2/loaders.py", line 125, in load
code = environment.compile(source, name, filename)
File "/home/benoit/Projects/lettersmith_py/env/lib/python3.7/site-packages/jinja2/environment.py", line 591, in compile
self.handle_exception(exc_info, source_hint=source_hint)
File "/home/benoit/Projects/lettersmith_py/env/lib/python3.7/site-packages/jinja2/environment.py", line 780, in handle_exception
reraise(exc_type, exc_value, tb)
File "/home/benoit/Projects/lettersmith_py/env/lib/python3.7/site-packages/jinja2/_compat.py", line 37, in reraise
raise value.with_traceback(tb)
File "theme/wiki/all.html", line 14, in template
{% for li in index.values() | remove_index | where_not("id_path", id_path) | sort_by("title") %}
File "/home/benoit/Projects/lettersmith_py/env/lib/python3.7/site-packages/jinja2/environment.py", line 543, in _generate
optimized=self.optimized)
File "/home/benoit/Projects/lettersmith_py/env/lib/python3.7/site-packages/jinja2/compiler.py", line 82, in generate
generator.visit(node)
File "/home/benoit/Projects/lettersmith_py/env/lib/python3.7/site-packages/jinja2/visitor.py", line 38, in visit
return f(node, *args, **kwargs)
File "/home/benoit/Projects/lettersmith_py/env/lib/python3.7/site-packages/jinja2/compiler.py", line 799, in visit_Template
self.blockvisit(block.body, block_frame)
File "/home/benoit/Projects/lettersmith_py/env/lib/python3.7/site-packages/jinja2/compiler.py", line 378, in blockvisit
self.visit(node, frame)
File "/home/benoit/Projects/lettersmith_py/env/lib/python3.7/site-packages/jinja2/visitor.py", line 38, in visit
return f(node, *args, **kwargs)
File "/home/benoit/Projects/lettersmith_py/env/lib/python3.7/site-packages/jinja2/compiler.py", line 1108, in visit_For
self.visit(node.iter, frame)
File "/home/benoit/Projects/lettersmith_py/env/lib/python3.7/site-packages/jinja2/visitor.py", line 38, in visit
return f(node, *args, **kwargs)
File "/home/benoit/Projects/lettersmith_py/env/lib/python3.7/site-packages/jinja2/compiler.py", line 70, in new_func
return f(self, node, frame, **kwargs)
File "/home/benoit/Projects/lettersmith_py/env/lib/python3.7/site-packages/jinja2/compiler.py", line 1589, in visit_Filter
self.visit(node.node, frame)
File "/home/benoit/Projects/lettersmith_py/env/lib/python3.7/site-packages/jinja2/visitor.py", line 38, in visit
return f(node, *args, **kwargs)
File "/home/benoit/Projects/lettersmith_py/env/lib/python3.7/site-packages/jinja2/compiler.py", line 70, in new_func
return f(self, node, frame, **kwargs)
File "/home/benoit/Projects/lettersmith_py/env/lib/python3.7/site-packages/jinja2/compiler.py", line 1578, in visit_Filter
self.fail('no filter named %r' % node.name, node.lineno)
File "/home/benoit/Projects/lettersmith_py/env/lib/python3.7/site-packages/jinja2/compiler.py", line 315, in fail
raise TemplateAssertionError(msg, lineno, self.name, self.filename)
jinja2.exceptions.TemplateAssertionError: no filter named 'where_not'
Clumsy title but bear with me.
Using the 'blog' scaffold, you run the docs through wikidoc.py content_markdown()
, which first (because compose()
runs right-to-left) makes wikilinks, and then converts markdown to HTML (using GFM). But because you have already made your wikilinks nicely formatted in HTML, GFM ends up re-hrefing your href, for example:
from markdown import markdown as md
from mdx_gfm import GithubFlavoredMarkdownExtension
string = 'Here comes a link <a href="https://example.org" class="wikilink">link text</a>'
md(string, extensions=(GithubFlavoredMarkdownExtension(), ))
>>>'<p>Here comes a link <a href="<a href="https://example.org">https://example.org</a>" class="wikilink">link text</a></p>'
However this doesn't happen on transclude links:
string = '<aside>Here comes a link <a href="https://example.org" class="wikilink">link text</a></aside>'
md(string, extensions=(GithubFlavoredMarkdownExtension(), ))
>>>'<aside>Here comes a link <a href="https://example.org" class="wikilink">link text</a></aside>'
lettersmith_site lettersmith.yaml
Traceback (most recent call last):
File "/Users/user/.local/share/virtualenvs/pyenv-kdlYh41C/bin/lettersmith_site", line 11, in <module>
load_entry_point('lettersmith', 'console_scripts', 'lettersmith_site')()
File "/Users/user/src/lettersmith_py/lettersmith/bin/site.py", line 162, in main
stats = Docs.write(docs, output_path=output_path)
File "/Users/user/src/lettersmith_py/lettersmith/docs.py", line 23, in write
for doc in docs:
File "/Users/user/src/lettersmith_py/lettersmith/bin/site.py", line 160, in <genexpr>
docs = (render_jinja(doc) for doc in docs)
File "/Users/user/src/lettersmith_py/lettersmith/jinjatools.py", line 129, in render_doc
rendered = template.render({"doc": doc})
File "/Users/user/.local/share/virtualenvs/pyenv-kdlYh41C/lib/python3.7/site-packages/jinja2/asyncsupport.py", line 76, in render
return original_render(self, *args, **kwargs)
File "/Users/user/.local/share/virtualenvs/pyenv-kdlYh41C/lib/python3.7/site-packages/jinja2/environment.py", line 1008, in render
return self.environment.handle_exception(exc_info, True)
File "/Users/user/.local/share/virtualenvs/pyenv-kdlYh41C/lib/python3.7/site-packages/jinja2/environment.py", line 780, in handle_exception
reraise(exc_type, exc_value, tb)
File "/Users/user/.local/share/virtualenvs/pyenv-kdlYh41C/lib/python3.7/site-packages/jinja2/_compat.py", line 37, in reraise
raise value.with_traceback(tb)
File "theme/wiki/single.html", line 1, in top-level template code
{% extends "_layout.html" %}
File "theme/wiki/_layout.html", line 1, in top-level template code
{% extends "_base.html" %}
File "theme/wiki/_base.html", line 29, in top-level template code
{% block body %}{% endblock %}
File "theme/wiki/_layout.html", line 6, in block "body"
{% block main %}
File "theme/wiki/single.html", line 15, in block "main"
{% for li in backlink_index[id_path] | islice(100) %}
File "/Users/user/.local/share/virtualenvs/pyenv-kdlYh41C/lib/python3.7/site-packages/jinja2/environment.py", line 411, in getitem
return obj[argument]
jinja2.exceptions.UndefinedError: 'backlink_index' is undefined
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.