aboutsummaryrefslogtreecommitdiff
path: root/blogthis
blob: 43e4e51437aa84ddbe7ac3a554d28786e662b8d1 (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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
#!/usr/bin/env bash

# create text, assemble html file, add to articles, upload

#web is a symlink to $HOME/src/web/example.com
ROOT="$HOME/web"

mkdir -p $ROOT/.tmp   
cd $ROOT/.tmp || exit
rm *
EDITTMP="tmp.txt"
EDITHTM="tmp.html"
HEADTMP="top.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"

# build header
echo "<h2>$TITLE</h2>" > "$HEADTMP"
echo "<h5>$ARTICLEDATE</h5>" >> "$HEADTMP"
echo "<h4>$DESCRIPTION</h4>" >> "$HEADTMP"
echo "<br>" >> "$HEADTMP"

# write article
micro +6:1 "$EDITTMP"

# concatenate
md2html -o "$EDITHTM" "$EDITTMP" 
cat "$EDITHTM" >> "$HEADTMP"
mv "$HEADTMP" "$EDITHTM" 

# build final html article
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 "$EDITHTM" >> "$ARTICLE"

echo "      </article>
    </main>
    <footer>
      <p>ยง</p>
    </footer>
  </body>
</html>" >> "$ARTICLE"

mv "$ARTICLE" "$DEST"
#tidy -m --tidy-mark no "$DEST/$ARTICLE"
prettier --write "$DEST/$ARTICLE"

clear
cat "$DEST/$ARTICLE"

echo "--------------------------"
echo "saved as $DEST/$ARTICLE"

read -rp "Update the sitemap and rss feed, then upload to your server? ; " choix

if [ "$choix" != "n" ] ; then
    blogsitemap; blogrss ; blogsend
fi