knazarov.com/bin/page.sh

72 lines
1.4 KiB
Bash
Raw Normal View History

2023-06-12 12:40:15 +00:00
#!/usr/bin/env bash
2021-08-08 09:37:53 +00:00
expand() {
2023-10-25 23:34:18 +00:00
TITLE="$1"
DATE="$(echo "$2" | sed 's/Z/.000Z/')"
cat <<-"EOF"
2023-06-28 23:33:13 +00:00
<!DOCTYPE html>
2021-08-08 09:37:53 +00:00
<html lang="en">
<head>
2023-10-25 23:34:18 +00:00
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
2023-08-17 22:59:22 +00:00
EOF
2023-10-25 23:34:18 +00:00
if [ "$DATE" != "" ]; then
echo " <meta property=\"og:type\" content=\"article\">"
echo " <meta property=\"og:title\" content=\"$TITLE\">"
echo " <meta name=\"author\" content=\"Konstantin Nazarov\">"
echo " <meta property=\"article:published_time\" content=\"$DATE\"/>"
fi
2023-08-17 22:59:22 +00:00
2023-10-25 23:34:18 +00:00
cat <<-"EOF"
<link rel="stylesheet" type="text/css" href="/style.css">
<title>
2023-08-17 22:59:22 +00:00
EOF
2021-08-08 09:37:53 +00:00
2023-10-25 23:34:18 +00:00
echo " $TITLE"
2021-08-08 09:37:53 +00:00
2023-10-25 23:34:18 +00:00
cat <<-"EOF"
</title>
<link rel="alternate" type="application/rss+xml"
title="RSS Feed for knazarov.com" href="/rss.xml" />
2021-08-08 09:37:53 +00:00
</head>
<body>
2023-10-25 23:34:18 +00:00
<header id="header">
<a href="/">Konstantin Nazarov</a>
</header>
<nav id="menu">
<a href="/posts">posts</a>
<a href="https://videos.knazarov.com">videos</a>
<a href="/projects">projects</a>
<a href="/cv">cv</a>
<a href="/contact">contact</a>
<a href="/rss.xml"><img src="/rss.png" style="height: 15px; width: auto; vertical-align:middle;"></img></a>
</nav>
<main>
2021-08-08 09:37:53 +00:00
EOF
2023-10-25 23:34:18 +00:00
cat
cat <<-"EOF"
</main>
<footer>
</footer>
2021-08-08 09:37:53 +00:00
</body>
</html>
2023-08-17 22:59:22 +00:00
EOF
2021-08-08 09:37:53 +00:00
}
if [ -z "$1" ]; then
2023-10-25 23:34:18 +00:00
echo "Missing page title"
exit 1
2021-08-08 09:37:53 +00:00
fi
if [ -z "$2" ] && [ -t 0 ]; then
2023-10-25 23:34:18 +00:00
echo "Missing page body"
exit 1
2021-08-08 09:37:53 +00:00
fi
if [ ! -t 0 ]; then
2023-10-25 23:34:18 +00:00
expand "$1" "$2"
exit 0
2021-08-08 09:37:53 +00:00
fi
2023-08-17 22:59:22 +00:00
expand "$1" "$2" < "$3"