mirror of
https://github.com/alvierahman90/gronk.git
synced 2024-11-22 07:19:53 +00:00
put versions and commits on landing page
This commit is contained in:
parent
32a32b873e
commit
df8febd3cf
3
Makefile
3
Makefile
@ -1,5 +1,6 @@
|
|||||||
install:
|
install:
|
||||||
cp notes2web.py n2w_add_uuid.py /usr/local/bin
|
cp n2w_add_uuid.py /usr/local/bin
|
||||||
|
sed "s/N2W_COMMIT = \"\"/N2W_COMMIT = \"$$(git rev-parse HEAD)\"/" notes2web.py > /usr/local/bin/notes2web.py
|
||||||
pip3 install -r requirements.txt
|
pip3 install -r requirements.txt
|
||||||
mkdir -p /opt/notes2web
|
mkdir -p /opt/notes2web
|
||||||
cp -r templates /opt/notes2web
|
cp -r templates /opt/notes2web
|
||||||
|
15
notes2web.py
15
notes2web.py
@ -21,6 +21,10 @@ INDEX_TEMPLATE_FOOT = None
|
|||||||
INDEX_TEMPLATE_HEAD = None
|
INDEX_TEMPLATE_HEAD = None
|
||||||
EXTRA_INDEX_CONTENT = None
|
EXTRA_INDEX_CONTENT = None
|
||||||
|
|
||||||
|
N2W_COMMIT = ""
|
||||||
|
# how many characters of a commit to show on landing page
|
||||||
|
COMMIT_SHA1_NCHARS = 7
|
||||||
|
|
||||||
|
|
||||||
def is_plaintext(filename):
|
def is_plaintext(filename):
|
||||||
return re.match(r'^text/', magic.from_file(str(filename), mime=True)) is not None
|
return re.match(r'^text/', magic.from_file(str(filename), mime=True)) is not None
|
||||||
@ -65,6 +69,15 @@ def get_inherited_tags(file, base_folder):
|
|||||||
return list(set(tags))
|
return list(set(tags))
|
||||||
|
|
||||||
|
|
||||||
|
def git_head_sha1(working_dir):
|
||||||
|
git_response = subprocess.run(
|
||||||
|
[ 'git', f"--git-dir={working_dir.joinpath('.git')}", 'rev-parse', 'HEAD' ],
|
||||||
|
stdout=subprocess.PIPE
|
||||||
|
).stdout.decode('utf-8')
|
||||||
|
|
||||||
|
return git_response.strip()
|
||||||
|
|
||||||
|
|
||||||
def git_filehistory(working_dir, filename):
|
def git_filehistory(working_dir, filename):
|
||||||
print(f"{pathlib.Path(filename).relative_to(working_dir)=}")
|
print(f"{pathlib.Path(filename).relative_to(working_dir)=}")
|
||||||
git_response = subprocess.run(
|
git_response = subprocess.run(
|
||||||
@ -392,6 +405,8 @@ def main(args):
|
|||||||
with open(args.home_index) as fp2:
|
with open(args.home_index) as fp2:
|
||||||
html = re.sub(r'\$title\$', args.output_dir.parts[0], fp2.read())
|
html = re.sub(r'\$title\$', args.output_dir.parts[0], fp2.read())
|
||||||
html = re.sub(r'\$h1title\$', args.output_dir.parts[0], html)
|
html = re.sub(r'\$h1title\$', args.output_dir.parts[0], html)
|
||||||
|
html = re.sub(r'\$n2w_commit\$', N2W_COMMIT[0:COMMIT_SHA1_NCHARS], html)
|
||||||
|
html = re.sub(r'\$notes_git_head_sha1\$', git_head_sha1(args.notes)[0:COMMIT_SHA1_NCHARS], html)
|
||||||
|
|
||||||
html = re.sub(r'\$data\$', json.dumps(all_entries), html)
|
html = re.sub(r'\$data\$', json.dumps(all_entries), html)
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ Browse <a href="/notes">here</a> or by tag <a href="/.tags">here</a>.
|
|||||||
<div id="results">
|
<div id="results">
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p class="smallText"> page generated by <a href="https://github.com/alvierahman90/notes2web">notes2web</a></p>
|
<p class="smallText"> page generated by <a href="https://github.com/alvierahman90/notes2web">notes2web</a> (commit $n2w_commit$) notes commit $notes_git_head_sha1$</p>
|
||||||
</div>
|
</div>
|
||||||
<script src="/fuse.js"> </script>
|
<script src="/fuse.js"> </script>
|
||||||
<script> const data = $data$ </script>
|
<script> const data = $data$ </script>
|
||||||
|
Loading…
Reference in New Issue
Block a user