-
Notifications
You must be signed in to change notification settings - Fork 0
/
generate.sh
executable file
·86 lines (72 loc) · 1.79 KB
/
generate.sh
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
85
86
#!/bin/sh
day=$(date "+%Y-%m-%d")
hour=$(date "+%H:%M:%S")
date=$(date)
pipotron_run() {
type="$1"
title_filters="${2:-cat}"
body_filters="${3:-cat}"
body=$(docker run moul/pipotron "$type" | $body_filters)
title=$(echo "$body" | head -n 1 | $title_filters | sed 's/<br>//' | sed -e's/[[:space:]]*$//' | awk -v len=40 '{ if (length($0) > len) print substr($0, 1, len-3) "..."; else print; }' | iconv -t utf-8 -c)
mkdir -p content/post/pipotron/$type/$day-$hour
cat > content/post/pipotron/$type/$day-$hour/index.md <<EOF
---
title: "$title"
date: "$date"
tags: ["$type", "pipotron"]
author: m1ch3l
categories: ["generated"]
slug: "$type/$day-$hour"
---
$body
EOF
}
pipotron_save() {
type="$1"
title="$2"
filename="$3"
body="$4"
mkdir -p content/post/pipotron/$type/$day-$hour/
docker run moul/pipotron "$type" > content/post/pipotron/$type/$day-$hour/$filename
cat > content/post/pipotron/$type/$day-$hour/index.md <<EOF
---
title: "$title"
date: "$date"
tags: ["$type", "pipotron", "image"]
author: m1ch3l
categories: ["generated"]
slug: "$type/$day-$hour"
---
$body
EOF
}
add_br() {
sed 's/.*/&<br>/'
}
append_day() {
sed "s/\$/ $day/"
}
pipotron_run "marabout"
pipotron_run "moijaime"
pipotron_run "fuu"
pipotron_run "insulte-mignone"
pipotron_run "prenom-compose"
pipotron_run "horoscope" "append_day" "add_br"
pipotron_run "reve" "" "add_br"
pipotron_save "image-svg" "image-svg" "image.svg" '![](image.svg)'
## jargon generator
mkdir -p content/post/pipotron/jargon/$day-$hour
body=$(docker run ultreme/jargon-generator)
title="jargon"
type=jargon
cat > content/post/pipotron/jargon/$day-$hour/index.md <<EOF
---
title: "$title"
date: "$date"
tags: ["$type", "pipotron"]
author: m1ch3l
categories: ["generated"]
slug: "$type/$day-$hour"
---
$body
EOF