|
|
@@ -124,11 +124,19 @@ class Page: |
|
|
|
|
|
|
|
|
|
|
|
@cli |
|
|
|
def fragment(title: str): |
|
|
|
"""Create a new fragment and open it in iA Writer.""" |
|
|
|
fragment_path = DAVID / "2020" / "fragments" / f"{title}.md" |
|
|
|
open(fragment_path, "w+").write(f"## {title}") |
|
|
|
os.popen(f'open -a "iA Writer" "{fragment_path}"') |
|
|
|
def orphans(): |
|
|
|
"""Print out fragments not linked to any page.""" |
|
|
|
linked_fragments = [] |
|
|
|
for file_path in each_markdown_from(DAVID / "2020"): |
|
|
|
for line in open(file_path).readlines(): |
|
|
|
if line.startswith(".. include:: fragments/"): |
|
|
|
linked_fragments.append(line[len(".. include:: fragments/") : -1]) |
|
|
|
all_fragments = [] |
|
|
|
for file_path in each_markdown_from(DAVID / "2020" / "fragments"): |
|
|
|
all_fragments.append(file_path[len("david/2020/fragments/") :]) |
|
|
|
for fragment_filename in set(all_fragments) - set(linked_fragments): |
|
|
|
# Prepending path for easy command+click from fish. |
|
|
|
print(DAVID / "2020" / "fragments" / fragment_filename) |
|
|
|
|
|
|
|
|
|
|
|
@cli |