blob: b1d3a5ec33bcea8fb6ba9a51899efa9a6b1c64af (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
#!/usr/bin/env bash
# create text, assemble html file, add to articles
#web is a symlink to $HOME/src/web/example.com
ROOT="$HOME/web"
mkdir -p $ROOT/.tmp
cd $ROOT/.tmp || exit
EDITFILE="middle.html"
DATE=$(date +%Y-%m-%d)
read -r -p "Enter title: " TITLE
read -r -e -i "$DATE" -p "Enter date: " input
read -r -p "Enter description: " DESCRIPTION
ARTICLEDATE="${input:-$DATE}"
YEAR=$(echo "$ARTICLEDATE" | cut -c 1-4)
DEST="$ROOT/articles/$YEAR"
echo "<h2>$TITLE</h2>" > $EDITFILE
echo "<h5>$ARTICLEDATE</h5>" >> $EDITFILE
echo "<h4>$DESCRIPTION</h4>" >> $EDITFILE
micro +4:1 "$EDITFILE"
FIXEDTITLE=${TITLE// /-}
ARTICLE="$FIXEDTITLE.html"
echo "<!doctype html>
<html lang=\"en\">
<head>
<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\" >
<meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">
<link rel=\"stylesheet\" href=\"/style.css\">
<link rel=\"icon\" type=\"image/x-icon\" href=\"/favicon.ico\">
<title>$TITLE</title>
</head>
<body>
<header>
<h1>Bloggings</h1>
<a href=\"/index.php\">Back</a>
</header>
<main>
<article>" > "$ARTICLE"
cat "$EDITFILE" >> "$ARTICLE"
echo " </article>
</main>
<footer>
<p>ยง</p>
</footer>
</body>
</html>" >> "$ARTICLE"
mv "$ARTICLE" "$DEST"
echo "saved as $DEST/$ARTICLE"
|