aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVitali64 <vitali64pmemail@protonmail.com>2021-12-09 17:15:11 +0100
committerVitali64 <vitali64pmemail@protonmail.com>2021-12-09 17:15:11 +0100
commitb6a9a5566f490a932a2bf10a28c17e9642decfc6 (patch)
tree349f05dc074ccd3bcb8e5656363e6c285d65f567
downloadseen-b6a9a5566f490a932a2bf10a28c17e9642decfc6.tar.gz
seen-b6a9a5566f490a932a2bf10a28c17e9642decfc6.zip
Init
-rw-r--r--README.md28
-rw-r--r--articles/articletext.cfg3
-rw-r--r--articles/articletext.md7
-rwxr-xr-xmain.sh48
-rw-r--r--red.html33
-rw-r--r--templates/article.html5
-rw-r--r--templates/footer.html17
-rw-r--r--templates/header.html8
-rw-r--r--www/articles/articletext.html32
-rw-r--r--www/index.html30
10 files changed, 211 insertions, 0 deletions
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..0151c48
--- /dev/null
+++ b/README.md
@@ -0,0 +1,28 @@
+# seen
+
+*A simple blog generator written in bash*
+
+### How to use
+
+First, install `markdown` because this script uses it heavily.
+
+Put your markdown files on `articles/<name of file>.md`.
+
+You also need to create a config file. Put it in `articles/<name of file>.cfg`. It should use the same name your markdown file uses.
+
+- Example :
+
+<pre><code>
+
+name="Hello World"
+
+desc="Welcome to my blog!"
+
+date="9th December 2021"
+
+</code></pre>
+
+And run the following:
+
+ $ chmod +x main.sh
+ $ ./main.sh
diff --git a/articles/articletext.cfg b/articles/articletext.cfg
new file mode 100644
index 0000000..5038244
--- /dev/null
+++ b/articles/articletext.cfg
@@ -0,0 +1,3 @@
+name="Hello World!"
+desc="Welcome to seen! This is a test article."
+date="9th December 2021"
diff --git a/articles/articletext.md b/articles/articletext.md
new file mode 100644
index 0000000..dbf6405
--- /dev/null
+++ b/articles/articletext.md
@@ -0,0 +1,7 @@
+# Hello
+
+Welcome to `seen` !
+
+It's a simple blog generator.
+
+Please refer to the README.md file for more information.
diff --git a/main.sh b/main.sh
new file mode 100755
index 0000000..b3e4c19
--- /dev/null
+++ b/main.sh
@@ -0,0 +1,48 @@
+#!/bin/sh
+
+# Seen, a simple static blog generator
+#
+# Vitali64 <vitali64pmemail@protonmail.com
+
+# START
+
+# Erase www/index.html and insert the header
+
+cat "templates/header.html" > www/index.html
+
+# Detect articles
+
+articles="$(ls -1 articles/*.md|sed -e 's@.md@@g' -e 's@articles/@@g')"
+
+# Set the defaults
+
+name="(!) no name (!)"
+desc="(!) no description (!)"
+date="1st January 1970"
+
+# In the 'for' loop
+
+for line in ${articles}
+do
+ . "articles/${line}.cfg" # Override the defaults
+ cat "templates/header.html" > "www/articles/${line}.html" # Erase <article>.html and insert the header
+
+ markdown "articles/${line}.md" >> "www/articles/${line}.html" # Convert the markdown text to html
+
+ cat "templates/footer.html" >> "www/articles/${line}.html" # Insert the footer into the article page
+
+ # Add an entry in index.html
+ sed \
+ -e "s@path-of-article@articles/${line}@" \
+ -e "s@name-of-article@${name}@" \
+ -e "s@date-of-article@${date}@" \
+ -e "s@description-of-article@${desc}@" \
+ "templates/article.html">> "www/index.html"
+done
+
+# Insert the footer into the index.html
+
+cat "templates/footer.html" >> "www/index.html"
+
+echo "Enjoy your blog."
+
diff --git a/red.html b/red.html
new file mode 100644
index 0000000..ba88b5e
--- /dev/null
+++ b/red.html
@@ -0,0 +1,33 @@
+<h1>seen</h1>
+
+<p><em>A simple blog generator written in bash</em></p>
+
+<h3>How to use</h3>
+
+<p>First, install <code>markdown</code> because this script uses it heavily.</p>
+
+<p>Put your markdown files on <code>articles/&lt;name of file&gt;.md</code>.</p>
+
+<p>You also need to create a config file. Put it in <code>articles/&lt;name of file&gt;.cfg</code>. It should use the same name your markdown file uses.</p>
+
+<ul>
+<li>Example :</li>
+</ul>
+
+
+<pre><code>
+
+name="Hello World"
+
+desc="Welcome to my blog!"
+
+date="9th December 2021"
+
+</code></pre>
+
+
+<p>And run the following:</p>
+
+<pre><code>$ chmod +x main.sh
+$ ./main.sh
+</code></pre>
diff --git a/templates/article.html b/templates/article.html
new file mode 100644
index 0000000..3087552
--- /dev/null
+++ b/templates/article.html
@@ -0,0 +1,5 @@
+ <div class="article">
+ <a href="path-of-article.html"><h3>name-of-article</h3>date-of-article</a>
+ <p>description-of-article</p>
+ </div>
+
diff --git a/templates/footer.html b/templates/footer.html
new file mode 100644
index 0000000..868f809
--- /dev/null
+++ b/templates/footer.html
@@ -0,0 +1,17 @@
+
+ </div>
+
+ <footer>Generated by `seen`, a static blog generator.</footer>
+
+ </main>
+
+ </body>
+ <style>
+div
+{
+ background-color: #ddd;
+ padding: 4pt;
+}
+ </style>
+
+</html>
diff --git a/templates/header.html b/templates/header.html
new file mode 100644
index 0000000..bbae57f
--- /dev/null
+++ b/templates/header.html
@@ -0,0 +1,8 @@
+<!DOCTYPE html>
+
+<html>
+
+ <body>
+ <h1>Blog</h1>
+ <div>
+
diff --git a/www/articles/articletext.html b/www/articles/articletext.html
new file mode 100644
index 0000000..cd84fa3
--- /dev/null
+++ b/www/articles/articletext.html
@@ -0,0 +1,32 @@
+<!DOCTYPE html>
+
+<html>
+
+ <body>
+ <h1>Blog</h1>
+ <div>
+
+<h1>Hello</h1>
+
+<p>Welcome to <code>seen</code> !</p>
+
+<p>It&rsquo;s a simple blog generator.</p>
+
+<p>Please refer to the README.md file for more information.</p>
+
+ </div>
+
+ <footer>Generated by `seen`, a static blog generator.</footer>
+
+ </main>
+
+ </body>
+ <style>
+div
+{
+ background-color: #ddd;
+ padding: 4pt;
+}
+ </style>
+
+</html>
diff --git a/www/index.html b/www/index.html
new file mode 100644
index 0000000..c7f33dd
--- /dev/null
+++ b/www/index.html
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+
+<html>
+
+ <body>
+ <h1>Blog</h1>
+ <div>
+
+ <div class="article">
+ <a href="articles/articletext.html"><h3>Hello World!</h3>9th December 2021</a>
+ <p>Welcome to seen! This is a test article.</p>
+ </div>
+
+
+ </div>
+
+ <footer>Generated by `seen`, a static blog generator.</footer>
+
+ </main>
+
+ </body>
+ <style>
+div
+{
+ background-color: #ddd;
+ padding: 4pt;
+}
+ </style>
+
+</html>