First working prototype

This commit is contained in:
Konstantin Nazarov 2021-08-15 21:11:40 +01:00
parent c4ea910ffc
commit 1baaf4b842
Signed by: knazarov
GPG key ID: 4CFE0A42FA409C22
7 changed files with 99 additions and 28 deletions

19
Makefile Normal file
View file

@ -0,0 +1,19 @@
ODIR=output
PAGES_SRC := $(wildcard pages/*)
PAGES_DST := $(patsubst pages/%,$(ODIR)/%/index.html,$(PAGES_SRC))
all: $(PAGES_DST) $(ODIR)/style.css $(ODIR)/index.html
$(ODIR)/%/index.html: pages/%/note.md
mkdir -p "$(dir $@)"
cat "$<" | ./mdpage.sh > "$@"
$(ODIR)/index.html: index.md
cat index.md | ./mdpage.sh --notitle > "$@"
$(ODIR)/style.css: style.css
cp style.css $(ODIR)/style.css
clean:
rm -rf $(ODIR)/*

11
index.md Normal file
View file

@ -0,0 +1,11 @@
Subject: Konstantin Nazarov
Hi!
If you are here, you may take a look at some featured posts:
- one
- two
- three
Or at some of my projects:

View file

@ -96,7 +96,7 @@ function parse_list(str, buf, result, i, ind, line, lines, indent, is_bullet)
split(str, lines, "\n"); split(str, lines, "\n");
str = "" str = ""
for (i in lines) { for (i=1; i<=length(lines); i++) {
line = lines[i]; line = lines[i];
if (match(line, /^[[:space:]]*[-+*][[:space:]]/) || if (match(line, /^[[:space:]]*[-+*][[:space:]]/) ||
@ -116,7 +116,7 @@ function parse_list(str, buf, result, i, ind, line, lines, indent, is_bullet)
else else
result = "<ol>\n" result = "<ol>\n"
for (i in lines) { for (i=1; i<=length(lines); i++) {
line = lines[i]; line = lines[i];
if (match(line, "[^ ]") > indent) { if (match(line, "[^ ]") > indent) {
@ -190,39 +190,63 @@ function is_escape_sequence(str, i, sstr) {
function extract_link(str, i, sstr) { function extract_link(str, i, sstr) {
sstr=substr(str, i, length(str) - i + 1); sstr=substr(str, i, length(str) - i + 1);
if (!match(sstr, /^\[([^\[\]]*)\]\( *([^() ]*)( +"([^"]*)")? *\)/, arr)) if (!match(sstr, /^\[([^\[\]]*)\]\( *([^() ]*)( +"([^"]*)")? *\)/))
return ""; return "";
return substr(str, i, RLENGTH); return substr(str, i, RLENGTH);
} }
function parse_link(str, arr) { function parse_link(str, arr) {
if (!match(str, /^\[([^\[\]]*)\]\( *([^() ]*)( +"([^"]*)")? *\)/, arr)) match(str, /^\[([^\[\]]*)\]/);
return ""; name = substr(str, 2, RLENGTH-2);
sub(/^\[([^\[\]]*)\]/, "", str);
if (arr[4] == "") { sub(/^ *\( */, "", str);
return "<a href=\"" arr[2] "\">" arr[1] "</a>" sub(/ *\) *$/, "", str);
match(str, /^[^() ]*/);
url = substr(str, 1, RLENGTH);
sub(/^[^() ]*/, "", str);
sub(/^ *"/, "", str);
sub(/" *$/, "", str);
title = str;
if (title == "") {
return "<a href=\"" url "\">" name "</a>"
} }
return "<a href=\"" arr[2] "\" title=\"" arr[4] "\">" arr[1] "</a>" return "<a href=\"" url "\" title=\"" title "\">" name "</a>"
} }
function extract_image(str, i, sstr) { function extract_image(str, i, sstr) {
sstr=substr(str, i, length(str) - i + 1); sstr=substr(str, i, length(str) - i + 1);
if (!match(sstr, /^!\[([^\[\]]*)\]\( *([^() ]*)( +"([^"]*)")? *\)/, arr)) if (!match(sstr, /^!\[([^\[\]]*)\]\( *([^() ]*)( +"([^"]*)")? *\)/))
return ""; return "";
return substr(str, i, RLENGTH); return substr(str, i, RLENGTH);
} }
function parse_image(str, arr) { function parse_image(str, arr) {
if (!match(str, /^!\[([^\[\]]*)\]\( *([^() ]*)( +"([^"]*)")? *\)/, arr)) match(str, /^!\[([^\[\]]*)\]/);
return ""; name = substr(str, 3, RLENGTH-3);
sub(/^!\[([^\[\]]*)\]/, "", str);
if (arr[4] == "") { sub(/^ *\( */, "", str);
return "<img src=\"" arr[2] "\" alt=\"" arr[1] "\" />" sub(/ *\) *$/, "", str);
match(str, /^[^() ]*/);
url = substr(str, 1, RLENGTH);
sub(/^[^() ]*/, "", str);
sub(/^ *"/, "", str);
sub(/" *$/, "", str);
title = str;
if (title == "") {
return "<img src=\"" url "\" alt=\"" name "\" />"
} }
return "<img src=\"" arr[2] "\" alt=\"" arr[1] "\" title=\"" arr[4] "\" />" return "<img src=\"" url "\" alt=\"" name "\" title=\"" title "\" />"
} }
function is_link(str, i) { function is_link(str, i) {
@ -339,7 +363,7 @@ function parse_blockquote(str, i, lines, line, buf, result) {
split(str, lines, "\n"); split(str, lines, "\n");
str = "" str = ""
for (i in lines) { for (i=1; i<=length(lines); i++) {
line = lines[i]; line = lines[i];
if (match(line, /^>/)) if (match(line, /^>/))
@ -352,7 +376,7 @@ function parse_blockquote(str, i, lines, line, buf, result) {
result = "<blockquote>"; result = "<blockquote>";
buf = ""; buf = "";
for (i in lines) { for (i=1; i<=length(lines); i++) {
line = lines[i]; line = lines[i];
gsub(/^> ?/, "", line); gsub(/^> ?/, "", line);
@ -380,7 +404,7 @@ function parse_code(str, i, lines, result) {
result = ""; result = "";
split(str, lines, "\n"); split(str, lines, "\n");
for (i in lines) { for (i=1; i<=length(lines); i++) {
line = lines[i]; line = lines[i];
gsub(/^ /, "", line); gsub(/^ /, "", line);
result = result "\n" line; result = result "\n" line;
@ -424,7 +448,7 @@ function parse_body(str, body, line, lines, result, i) {
result = ""; result = "";
body = ""; body = "";
for (i in lines) { for (i=1; i<=length(lines); i++) {
line = lines[i]; line = lines[i];
if (line_continues(body, line)) { if (line_continues(body, line)) {
if (body != "") if (body != "")

View file

@ -12,7 +12,7 @@ render() {
TITLE="${line#* }" TITLE="${line#* }"
fi fi
if [[ ! "$line" =~ ^[^\ ]*:\ .*$ ]]; then if [[ ! "$line" =~ ^[^\ ]*:\ .*$ ]]; then
LASTLINE="line" LASTLINE="$line"
break break
fi fi
done done

10
page.sh
View file

@ -6,7 +6,7 @@ expand() {
<html lang="en"> <html lang="en">
<head> <head>
<meta name="viewport" content="width=device-width, initial-scale=1.0"> <meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" type="text/css" href="style.css"> <link rel="stylesheet" type="text/css" href="/style.css">
<title> <title>
EOF EOF
@ -21,10 +21,10 @@ expand() {
</div> </div>
<div id="menu"> <div id="menu">
<a href="/">home</a> <a href="/">home</a>
<a href="/">posts</a> <a href="/posts">posts</a>
<a href="/">projects</a> <a href="/projects">projects</a>
<a href="/">about</a> <a href="/about">about</a>
<a href="/">contact</a> <a href="/contact">contact</a>
</div> </div>
EOF EOF
cat cat

10
pages/about/note.md Normal file
View file

@ -0,0 +1,10 @@
Subject: About me
Hi,
My name is Konstantin. I'm a software engineering professional with 15 years of experience. During my career I worked with a diverse set of technologies, ranging from RTOS kernel development to highly loaded web services.
Currently I work at Tarantool where I manage a team building enterprise solutions based off our own database and application server.
I offer consulting in application architecture and implementing MVPs.
For individuals I offer productivity and goal setting coaching.

7
pages/contact/note.md Normal file
View file

@ -0,0 +1,7 @@
Subject: Contacts
The best and most reliable way to contact me is by email: [mail@knazarov.com](mailto:mail@knazarov.com). I read and answer everything.
If you find that I didn't - it is most likely due to your message ending up in my Spam folder. Try sending it again with different
subject and/or from different email address.
If you would like to chat with me - write to [this telegram account](https://t.me/racktear).