mirror of
https://github.com/alvierahman90/gronk.git
synced 2024-11-28 18:09:53 +00:00
initial commit
This commit is contained in:
commit
e2413adfaa
8
Makefile
Normal file
8
Makefile
Normal file
@ -0,0 +1,8 @@
|
||||
install:
|
||||
cp gen_notes.sh /usr/local/bin
|
||||
mkdir -p /opt/gen_notes
|
||||
cp -r templates /opt/gen_notes
|
||||
cp styles.css /opt/gen_notes
|
||||
|
||||
clean:
|
||||
rm -rf /usr/local/bin/gen_notes.sh /opt/gen_notes
|
60
gen_notes.sh
Executable file
60
gen_notes.sh
Executable file
@ -0,0 +1,60 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
[[ -z "$1" ]] && echo "USAGE: $0 NOTES_DIRECTORY" && exit 0
|
||||
|
||||
function _render {
|
||||
echo "rendering $1"
|
||||
pandoc\
|
||||
--toc\
|
||||
--standalone\
|
||||
-t html\
|
||||
--template /opt/gen_notes/templates/article.html\
|
||||
-o "$(dirname "$1")/index.html"\
|
||||
"$1"\
|
||||
--mathjax
|
||||
}
|
||||
|
||||
function _renderindex {
|
||||
echo "rendering $1"
|
||||
pandoc\
|
||||
-t html\
|
||||
--template /opt/gen_notes/templates/index.html\
|
||||
-o index.html\
|
||||
"$1"
|
||||
}
|
||||
|
||||
function _addtolist {
|
||||
echo "adding $1 to list of notes"
|
||||
pandoc\
|
||||
-t html\
|
||||
-V "filepath=$(dirname "$1")"\
|
||||
--template /opt/gen_notes/templates/listitem.html\
|
||||
"$1"\
|
||||
>> index.md
|
||||
}
|
||||
|
||||
export -f _render
|
||||
export -f _addtolist
|
||||
|
||||
#render each markdown file
|
||||
|
||||
for var in "$@"
|
||||
do
|
||||
find "$var" -name '*.md' -exec bash -c "_render '{}'" \;
|
||||
done
|
||||
|
||||
# create an intermediate markdown file of links to each article
|
||||
echo "---
|
||||
title: alv's notes
|
||||
---" > index.md
|
||||
|
||||
for var in "$@"
|
||||
do
|
||||
echo "<h1>$var notes</h1>" >> index.md
|
||||
find "$var" -name '*.md' -exec bash -c "_addtolist '{}'" \;
|
||||
done
|
||||
|
||||
_renderindex index.md
|
||||
|
||||
echo "copying styles.css to current directory"
|
||||
cp /opt/gen_notes/styles.css .
|
50
styles.css
Normal file
50
styles.css
Normal file
@ -0,0 +1,50 @@
|
||||
body {
|
||||
font-family: "Open Sans", sans-serif;
|
||||
color: #454545;
|
||||
font-size: 16px;
|
||||
margin: 2em auto;
|
||||
max-width: 800px;
|
||||
padding: 1em;
|
||||
line-height: 1.4;
|
||||
text-align: justify;
|
||||
background-color: #fefefe;
|
||||
}
|
||||
|
||||
a { color: #07a; }
|
||||
a:visited { color: #941352; }
|
||||
|
||||
img[class="centered"] {
|
||||
margin: 0 auto;
|
||||
display: block;
|
||||
}
|
||||
|
||||
table {
|
||||
border-collapse: collapse;
|
||||
margin: 1em auto;
|
||||
}
|
||||
th, td {
|
||||
padding: 1em;
|
||||
border: 1px solid #454545;
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
|
||||
pre {
|
||||
background-color: #d9d9d9 ;
|
||||
color: #000;
|
||||
padding: 1em;
|
||||
}
|
||||
|
||||
details {
|
||||
padding: 1em 0 1em 0;
|
||||
}
|
||||
|
||||
li {
|
||||
margin-bottom: 1em;
|
||||
}
|
||||
|
||||
img {
|
||||
margin: 0 auto;
|
||||
display: block;
|
||||
max-width: 100%;
|
||||
}
|
11
templates/article.html
Normal file
11
templates/article.html
Normal file
@ -0,0 +1,11 @@
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta charset="utf-8">
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Open+Sans&display=swap" />
|
||||
<link rel="stylesheet" type="text/css" href="/styles.css" />
|
||||
<script src="https://polyfill.io/v3/polyfill.min.js?features=es6"></script>
|
||||
<script id="MathJax-script" async src="https://cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js"></script>
|
||||
<title>$title$</title>
|
||||
</head>
|
||||
|
||||
<body> $body$ </body>
|
10
templates/index.html
Normal file
10
templates/index.html
Normal file
@ -0,0 +1,10 @@
|
||||
<head>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1">
|
||||
<meta charset="utf-8">
|
||||
<link rel="stylesheet" href="https://fonts.googleapis.com/css2?family=Open+Sans&display=swap" />
|
||||
<link rel="stylesheet" type="text/css" href="/styles.css" />
|
||||
<title>$title$</title>
|
||||
</head>
|
||||
<body>
|
||||
$body$
|
||||
</body>
|
1
templates/listitem.html
Normal file
1
templates/listitem.html
Normal file
@ -0,0 +1 @@
|
||||
<li><a href="$filepath$">$title$</a></li>
|
Loading…
Reference in New Issue
Block a user