From 1baaf4b84250ddc6f3645d31bc789f54f9c30397 Mon Sep 17 00:00:00 2001 From: Konstantin Nazarov Date: Sun, 15 Aug 2021 21:11:40 +0100 Subject: [PATCH] First working prototype --- Makefile | 19 ++++++++++++ index.md | 11 +++++++ markdown.awk | 68 +++++++++++++++++++++++++++++-------------- mdpage.sh | 2 +- page.sh | 10 +++---- pages/about/note.md | 10 +++++++ pages/contact/note.md | 7 +++++ 7 files changed, 99 insertions(+), 28 deletions(-) create mode 100644 Makefile create mode 100644 index.md create mode 100644 pages/about/note.md create mode 100644 pages/contact/note.md diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..c476eec --- /dev/null +++ b/Makefile @@ -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)/* diff --git a/index.md b/index.md new file mode 100644 index 0000000..d998205 --- /dev/null +++ b/index.md @@ -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: diff --git a/markdown.awk b/markdown.awk index 99b6517..e689dd8 100644 --- a/markdown.awk +++ b/markdown.awk @@ -96,7 +96,7 @@ function parse_list(str, buf, result, i, ind, line, lines, indent, is_bullet) split(str, lines, "\n"); str = "" - for (i in lines) { + for (i=1; i<=length(lines); i++) { line = lines[i]; if (match(line, /^[[:space:]]*[-+*][[:space:]]/) || @@ -116,7 +116,7 @@ function parse_list(str, buf, result, i, ind, line, lines, indent, is_bullet) else result = "
    \n" - for (i in lines) { + for (i=1; i<=length(lines); i++) { line = lines[i]; if (match(line, "[^ ]") > indent) { @@ -182,47 +182,71 @@ function is_html_tag(str, i, sstr) { } function is_escape_sequence(str, i, sstr) { - sstr=substr(str, i, length(str) - i + 1); + sstr=substr(str, i, length(str) - i + 1); return match(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 substr(str, i, RLENGTH); } function parse_link(str, arr) { - if (!match(str, /^\[([^\[\]]*)\]\( *([^() ]*)( +"([^"]*)")? *\)/, arr)) - return ""; + match(str, /^\[([^\[\]]*)\]/); + name = substr(str, 2, RLENGTH-2); + sub(/^\[([^\[\]]*)\]/, "", str); - if (arr[4] == "") { - return "" arr[1] "" + sub(/^ *\( */, "", str); + sub(/ *\) *$/, "", str); + + match(str, /^[^() ]*/); + url = substr(str, 1, RLENGTH); + + sub(/^[^() ]*/, "", str); + sub(/^ *"/, "", str); + sub(/" *$/, "", str); + title = str; + + if (title == "") { + return "" name "" } - return "" arr[1] "" + return "" name "" } 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 substr(str, i, RLENGTH); } function parse_image(str, arr) { - if (!match(str, /^!\[([^\[\]]*)\]\( *([^() ]*)( +"([^"]*)")? *\)/, arr)) - return ""; + match(str, /^!\[([^\[\]]*)\]/); + name = substr(str, 3, RLENGTH-3); + sub(/^!\[([^\[\]]*)\]/, "", str); - if (arr[4] == "") { - return "\""" + sub(/^ *\( */, "", str); + sub(/ *\) *$/, "", str); + + match(str, /^[^() ]*/); + url = substr(str, 1, RLENGTH); + + sub(/^[^() ]*/, "", str); + sub(/^ *"/, "", str); + sub(/" *$/, "", str); + title = str; + + if (title == "") { + return "\""" } - return "\""" + return "\""" } function is_link(str, i) { @@ -339,7 +363,7 @@ function parse_blockquote(str, i, lines, line, buf, result) { split(str, lines, "\n"); str = "" - for (i in lines) { + for (i=1; i<=length(lines); i++) { line = lines[i]; if (match(line, /^>/)) @@ -352,7 +376,7 @@ function parse_blockquote(str, i, lines, line, buf, result) { result = "
    "; buf = ""; - for (i in lines) { + for (i=1; i<=length(lines); i++) { line = lines[i]; gsub(/^> ?/, "", line); @@ -380,7 +404,7 @@ function parse_code(str, i, lines, result) { result = ""; split(str, lines, "\n"); - for (i in lines) { + for (i=1; i<=length(lines); i++) { line = lines[i]; gsub(/^ /, "", line); result = result "\n" line; @@ -421,10 +445,10 @@ function parse_block(str) { function parse_body(str, body, line, lines, result, i) { split(str, lines, "\n"); - result = ""; + result = ""; body = ""; - for (i in lines) { + for (i=1; i<=length(lines); i++) { line = lines[i]; if (line_continues(body, line)) { if (body != "") diff --git a/mdpage.sh b/mdpage.sh index d31641c..2e5d070 100755 --- a/mdpage.sh +++ b/mdpage.sh @@ -12,7 +12,7 @@ render() { TITLE="${line#* }" fi if [[ ! "$line" =~ ^[^\ ]*:\ .*$ ]]; then - LASTLINE="line" + LASTLINE="$line" break fi done diff --git a/page.sh b/page.sh index 0184db1..91a1b43 100755 --- a/page.sh +++ b/page.sh @@ -6,7 +6,7 @@ expand() { - + EOF @@ -21,10 +21,10 @@ expand() { </div> <div id="menu"> <a href="/">home</a> - <a href="/">posts</a> - <a href="/">projects</a> - <a href="/">about</a> - <a href="/">contact</a> + <a href="/posts">posts</a> + <a href="/projects">projects</a> + <a href="/about">about</a> + <a href="/contact">contact</a> </div> EOF cat diff --git a/pages/about/note.md b/pages/about/note.md new file mode 100644 index 0000000..29bb042 --- /dev/null +++ b/pages/about/note.md @@ -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. diff --git a/pages/contact/note.md b/pages/contact/note.md new file mode 100644 index 0000000..c6b42ab --- /dev/null +++ b/pages/contact/note.md @@ -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).