knazarov.com/bin/page.sh

60 lines
1 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-06-11 17:41:26 +00:00
TITLE="$1"
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-06-28 23:33:13 +00:00
<meta charset="UTF-8">
2021-08-08 09:37:53 +00:00
<meta name="viewport" content="width=device-width, initial-scale=1.0">
2021-08-15 20:11:40 +00:00
<link rel="stylesheet" type="text/css" href="/style.css">
2021-08-08 09:37:53 +00:00
<title>
EOF
echo " $TITLE"
cat <<-"EOF"
</title>
2021-09-12 16:26:29 +00:00
<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>
<div id="header">
<a href="/">Konstantin Nazarov</a>
</div>
<div id="menu">
<a href="/">home</a>
2021-08-15 20:11:40 +00:00
<a href="/posts">posts</a>
<a href="/projects">projects</a>
2023-06-12 13:38:36 +00:00
<a href="/cv">cv</a>
2021-08-15 20:11:40 +00:00
<a href="/about">about</a>
<a href="/contact">contact</a>
2021-08-08 09:37:53 +00:00
</div>
2021-08-21 21:48:36 +00:00
<div id="content">
2021-08-08 09:37:53 +00:00
EOF
cat
cat <<-"EOF"
2021-08-21 21:48:36 +00:00
</div>
2021-08-08 09:37:53 +00:00
</body>
</html>
EOF
}
if [ -z "$1" ]; then
echo "Missing page title"
exit 1
fi
if [ -z "$2" ] && [ -t 0 ]; then
echo "Missing page body"
exit 1
fi
if [ ! -t 0 ]; then
expand "$1"
exit 0
fi
expand "$1" < "$2"