Skip to content

Commit 143bd80

Browse files
author
[ビルドしてる人の名前/ニックネーム]
committed
Merge branch 'main' of github.com:okaitslinblog/BlogWriter into main
2 parents 77f9f80 + 4e147a5 commit 143bd80

File tree

1 file changed

+80
-0
lines changed

1 file changed

+80
-0
lines changed

write.sh

+80
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
#!/bin/bash
2+
echo "Blog Writer Started."
3+
echo 'By okaits#7534'
4+
echo "okaitslinblogに投稿します。"
5+
read -p "日付(yyyy-mm-dd, 例: 2021-08-23(2021年8月23日)> " date
6+
fn=$date
7+
read -p "タイトル> " title
8+
fn=${fn}-${title}.md
9+
read -p "カテゴリー> " categories
10+
read -p "筆者のDiscordのユーザー名(例:okaits#7534)> " author
11+
echo "記事をHTMLまたはMarkDownで書いてください。"
12+
read -p "説明を聞きますか?(yes/no)> " s
13+
if [ $s = yes ]
14+
then
15+
echo "HTMLで書く時もMarkDownで書く時も、brタグを入れないと改行できません。注意してください。"
16+
echo 'また、記事の中にプログラムやコードなどを入れるには、コードの始めに「blogwriter.commands.code.start」、終わりに「blogwriter.commands.code.end」をいれてください。'
17+
echo 'また、blogwriter.commands.code.endだけを書くと「</pre></code>」という文字例になります。'
18+
echo '逆にblogwriter.commands.code.startだけを書くとこのコマンド以降全てがコードとして認識され、表示が崩れてしまいます。くれぐれもご注意ください。'
19+
echo 'なお、scriptタグもOKです。'
20+
echo '目次をいれる場所に、{% include toc.html html=content sanitize=true %}と入れて下さい。'
21+
echo '終了するには改行してから「blogwriter.commands.EOF」と入力してEnterキーを押してください。'
22+
fi
23+
echo "書き始めて下さい。"
24+
echo "---" > $fn
25+
echo "layout: post" >> $fn
26+
echo "title: $title" >> $fn
27+
echo "categories: $categories" >> $fn
28+
echo "disqus: true" >> $fn
29+
echo "author: $author" >> $fn
30+
while true
31+
do
32+
read -p "> " b
33+
if [ "$b" = "blogwriter.commands.EOF" ]
34+
then
35+
echo "入力が終わりました。"
36+
break
37+
fi
38+
if [ "$b" = "blogwriter.commands.code.start" ]
39+
then
40+
echo "コードが挿入されます。"
41+
echo "言語はどれにしますか?"
42+
echo "1) Bash"
43+
echo "2) Html"
44+
echo "3) CSS"
45+
echo "4) Python"
46+
echo "5) その他(自動認識)"
47+
read -p "言語(1-5)> " lang
48+
case "$lang" in
49+
1) lang=" lang-bash" ;;
50+
2) lang=" lang-html" ;;
51+
3) lang=" lang-css" ;;
52+
4) lang=" lang-python" ;;
53+
5) lang="" ;;
54+
esac
55+
echo -n '<pre class="prettyprint><code class="prettyprint'${lang}'>' >> $fn
56+
fi
57+
if [ "$b" = "blogwriter.commands.code.end" ]
58+
then
59+
echo "コードが終了しました。"
60+
echo '</code></pre>' >> $fn
61+
fi
62+
echo $b >> $fn
63+
done
64+
echo "アップロードします。"
65+
if ls okaitslinblog > /dev/null 2>&1
66+
then
67+
echo "okaitslinblogを発見しました。cloneをキャンセルします。"
68+
else
69+
echo "okaitslinblogがありません。cloneします。"
70+
git clone https://github.com/okaitslinblog/okaitslinblog.github.io
71+
echo "cloneが終わりました。"
72+
fi
73+
cd okaitslinblog
74+
git checkout gh-pages
75+
mv ../${fn} ./_posts/
76+
echo "アップロード処理を開始します。"
77+
echo "もし選択肢がでたら、絶対にokaitslinblog/okaitslinblog.github.ioを選んでください。"
78+
gh pr create --title "[add] Post" --body "Automaticaly created by blogwriter"
79+
echo "アップロード処理が完了しました。"
80+
exit

0 commit comments

Comments
 (0)