Show contents of LICENSE
This commit is contained in:
parent
ae43e1e54d
commit
d147e56080
14
notes2web.py
14
notes2web.py
@ -140,6 +140,13 @@ def main(args):
|
|||||||
|
|
||||||
args.output_dir.mkdir(parents=True, exist_ok=True)
|
args.output_dir.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
|
notes_license = "This note has no copyright license.",
|
||||||
|
print(f"{notes_license=}")
|
||||||
|
license_path = args.notes.joinpath("LICENSE")
|
||||||
|
if license_path.exists():
|
||||||
|
with open(license_path) as fp:
|
||||||
|
notes_license = fp.read()
|
||||||
|
|
||||||
markdown_files, plaintext_files, other_files = get_files(args.notes)
|
markdown_files, plaintext_files, other_files = get_files(args.notes)
|
||||||
|
|
||||||
all_entries=[]
|
all_entries=[]
|
||||||
@ -190,7 +197,11 @@ def main(args):
|
|||||||
# update file if required
|
# update file if required
|
||||||
if update_required(filename, output_filename) or args.force:
|
if update_required(filename, output_filename) or args.force:
|
||||||
filehistory = git_filehistory(args.notes, filename)
|
filehistory = git_filehistory(args.notes, filename)
|
||||||
html = pypandoc.convert_file(filename, 'html', extra_args=[f'--template={args.template}', '-V', f'filehistory={filehistory}'])
|
html = pypandoc.convert_file(filename, 'html', extra_args=[
|
||||||
|
f'--template={args.template}',
|
||||||
|
'-V', f'filehistory={filehistory}',
|
||||||
|
'-V', f'licenseFull={notes_license}'
|
||||||
|
])
|
||||||
pathlib.Path(output_filename).parent.mkdir(parents=True, exist_ok=True)
|
pathlib.Path(output_filename).parent.mkdir(parents=True, exist_ok=True)
|
||||||
|
|
||||||
with open(output_filename, 'w+') as fp:
|
with open(output_filename, 'w+') as fp:
|
||||||
@ -211,6 +222,7 @@ def main(args):
|
|||||||
html = re.sub(r'\$title\$', title, TEXT_ARTICLE_TEMPLATE_HEAD)
|
html = re.sub(r'\$title\$', title, TEXT_ARTICLE_TEMPLATE_HEAD)
|
||||||
html = re.sub(r'\$h1title\$', title, html)
|
html = re.sub(r'\$h1title\$', title, html)
|
||||||
html = re.sub(r'\$raw\$', os.path.basename(filename), html)
|
html = re.sub(r'\$raw\$', os.path.basename(filename), html)
|
||||||
|
html = re.sub(r'\$licenseFull\$', notes_license, html)
|
||||||
html = html.replace('$filehistory$', filehistory)
|
html = html.replace('$filehistory$', filehistory)
|
||||||
with open(filename) as fp:
|
with open(filename) as fp:
|
||||||
html += fp.read().replace("<", "<").replace(">", ">")
|
html += fp.read().replace("<", "<").replace(">", ">")
|
||||||
|
@ -41,6 +41,10 @@ doing it for me:
|
|||||||
- notes2web indexes [ATX-style headings](https://pandoc.org/MANUAL.html#atx-style-headings) for
|
- notes2web indexes [ATX-style headings](https://pandoc.org/MANUAL.html#atx-style-headings) for
|
||||||
searching
|
searching
|
||||||
- notes2web attempts to display file history through the `git log` command
|
- notes2web attempts to display file history through the `git log` command
|
||||||
|
- notes2web looks for the plaintext file `LICENSE` in the root directory of your notes
|
||||||
|
|
||||||
|
This is optional but if you would like to add a license you can find one
|
||||||
|
[here](https://choosealicense.com).
|
||||||
|
|
||||||
## CLI Usage
|
## CLI Usage
|
||||||
|
|
||||||
|
@ -17,6 +17,7 @@
|
|||||||
]</p>
|
]</p>
|
||||||
<p class="smallText">
|
<p class="smallText">
|
||||||
written by $for(author)$$author$$sep$, $endfor$
|
written by $for(author)$$author$$sep$, $endfor$
|
||||||
|
</p>
|
||||||
<p class="smallText">
|
<p class="smallText">
|
||||||
syntax highlighting based on <a href="https://pygments.org/">Pygments'</a> default
|
syntax highlighting based on <a href="https://pygments.org/">Pygments'</a> default
|
||||||
colors
|
colors
|
||||||
@ -30,6 +31,12 @@
|
|||||||
</summary>
|
</summary>
|
||||||
$filehistory$
|
$filehistory$
|
||||||
</details>
|
</details>
|
||||||
|
<details>
|
||||||
|
<summary class="smallText">
|
||||||
|
License
|
||||||
|
</summary>
|
||||||
|
<pre>$licenseFull$</pre>
|
||||||
|
</details>
|
||||||
<div>
|
<div>
|
||||||
$body$
|
$body$
|
||||||
</body>
|
</body>
|
||||||
|
@ -17,6 +17,12 @@
|
|||||||
</summary>
|
</summary>
|
||||||
$filehistory$
|
$filehistory$
|
||||||
</details>
|
</details>
|
||||||
|
<details>
|
||||||
|
<summary class="smallText">
|
||||||
|
License
|
||||||
|
</summary>
|
||||||
|
<pre>$licenseFull$</pre>
|
||||||
|
</details>
|
||||||
</div>
|
</div>
|
||||||
<h1>$title$</h1>
|
<h1>$title$</h1>
|
||||||
<p> This file was not rendered by notes2web because it is a plaintext file, not a markdown
|
<p> This file was not rendered by notes2web because it is a plaintext file, not a markdown
|
||||||
|
Reference in New Issue
Block a user