commit 4b88d144f58812dd554bc27a7eac4d1f13e67a83
parent 82116e684b2f96a2646b30f883e7864de2b5b9b4
Author: Mahdi Mirzade <[email protected]>
Date: Tue, 15 Mar 2022 07:21:23 +0330
Add stuff
Diffstat:
8 files changed, 204 insertions(+), 0 deletions(-)
diff --git a/Kaveh b/Kaveh
@@ -0,0 +1,73 @@
+#!/usr/bin/env bash
+
+# Source config file
+export KVH_CONFIG_FILE="./Kaveh.cfg"
+[[ -f "$KVH_CONFIG_FILE" ]] && source "$KVH_CONFIG_FILE"
+
+# Default configuration
+export KVH_SRC="${KVH_INPUT_DIR:-./src}"
+export KVH_DST="${KVH_OUTPUT_DIR:-./out}"
+export KVH_DATETIME="${KVH_DATETIME:-%d %B %Y %H:%M:%S}"
+
+# Find all pre-existed dirs
+find_dirs(){
+ KVH_DIRS=()
+ while IFS= read -d $'\n' -r dir ; do
+ KVH_DIRS=("${KVH_DIRS[@]}" "$dir")
+ done < <(find "$KVH_SRC" -type d -perm /u=r)
+}
+
+# Prepare all pre-existed dirs to $KVH_DST
+make_dirs(){
+ find_dirs
+ for KVH_DIR in "${KVH_DIRS[@]}"; do
+ export KVH_DIR_NAME="${KVH_DIR/$KVH_SRC/}"
+ mkdir -p "$KVH_DST/$KVH_DIR_NAME"
+ done
+}
+
+# Find all markdown goods
+find_mds(){
+ KVH_MARKDOWNS=()
+ while IFS= read -d $'\n' -r file ; do
+ KVH_MARKDOWNS=("${KVH_MARKDOWNS[@]}" "$file")
+ done < <(find "$KVH_SRC" -type f -perm /u=r -name "*.md")
+}
+
+# Get Markdown comments from file
+parse_md_comments(){
+ sed -n "/<\!---.*KVH.*/,/--->/p" "$@"
+}
+
+# Parse variables from string
+parse_md_variables(){
+ echo "$2" | grep "$1" | sed 's/^.*: //'
+}
+
+# Prepare all html files to $KVH_DST
+make_mds(){
+ find_mds
+ for KVH_FILE in "${KVH_MARKDOWNS[@]}"; do
+ export KVH_FILE_NAME="${KVH_FILE/$KVH_SRC/}"
+ export KVH_FILE_NAME="${KVH_FILE_NAME/%.md/}"
+ #markdown "$KVH_FILE" > "$KVH_DST/$KVH_FILE_NAME.html"
+ POST_COMMENTS=$(parse_md_comments "$KVH_FILE")
+ TITLE=$(parse_md_variables "Title" "$POST_COMMENTS")
+ DESC=$(parse_md_variables "Description" "$POST_COMMENTS")
+ H=$(cat "./tpl/header.html")
+ C=$(markdown "$KVH_FILE")
+ F=$(cat "./tpl/footer.html")
+ D=$(date -r "$KVH_FILE" "+$KVH_DATETIME")
+ KVH_CONTENT="$H
+$C
+$F"
+ KVH_CONTENT=${KVH_CONTENT//\$PAGE_TITLE/$TITLE}
+ KVH_CONTENT=${KVH_CONTENT//\$PAGE_DESC/$DESC}
+ KVH_CONTENT=${KVH_CONTENT//$POST_COMMENTS/}
+ echo "$KVH_CONTENT" > "$KVH_DST/$KVH_FILE_NAME.html"
+ done
+}
+
+# Main program
+make_dirs
+make_mds
diff --git a/out/blog/index.html b/out/blog/index.html
@@ -0,0 +1,27 @@
+<!DOCTYPE html>
+<html lang=en>
+ <head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <meta name="generator" content="Kaveh v1.0.0" />
+ <link rel="icon" href="$PAGE_ICON">
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/water.css@2/out/water.min.css">
+ <title></title>
+ <meta name="description" content="">
+ </head>
+ <body>
+ <div>
+<h1>What is this?</h1>
+
+<p>This is my simple template to create minimal websites.</p>
+
+<h2>How do you use it?</h2>
+
+<p>I write my blog posts like <code>blog/*.md</code>, using Markdown, It’s easier for me to read and write.</p>
+ </div>
+ <footer style="text-align: right;">
+ <p><small>Powered by <a href="https://github.com/MahdyMirzade/Kaveh">Kaveh</a></small></p>
+ </footer>
+ </body>
+</html>
diff --git a/out/index.html b/out/index.html
@@ -0,0 +1,57 @@
+<!DOCTYPE html>
+<html lang=en>
+ <head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <meta name="generator" content="Kaveh v1.0.0" />
+ <link rel="icon" href="$PAGE_ICON">
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/water.css@2/out/water.min.css">
+ <title>Kaveh | Home Page</title>
+ <meta name="description" content="This is about Kaveh.">
+ </head>
+ <body>
+ <div>
+
+
+
+
+
+<div style="text-align: center;"><img src="./logo.png"></div>
+
+
+<h1>What is this?</h1>
+
+<p>This is my simple template to create minimal websites.</p>
+
+<h2>How do you use it?</h2>
+
+<p>I write my blog posts like <code>blog/*.md</code>, using Markdown, It’s easier for me to read and write.</p>
+
+<h2>Team <img src="https://img.shields.io/github/contributors/mahdymirzade/gip" alt="GitHub contributors" /></h2>
+
+<p>This project is maintained by the following people and a bunch of <a href="https://github.com/MahdyMirzade/gip/graphs/contributors">awesome contributors</a>.</p>
+
+<table>
+<thead>
+<tr>
+<th> <a href="https://github.com/mahdymirzade"><img src="https://github.com/mahdymirzade.png?size=100" alt="Mahdy Mirzade" /></a> </th>
+</tr>
+</thead>
+<tbody>
+<tr>
+<td> <a href="https://github.com/mahdymirzade">Mahdy Mirzade</a> </td>
+</tr>
+</tbody>
+</table>
+
+
+<h2>Donate</h2>
+
+<p>You can use <a href="https://git.io/JB2BO">this page</a> to find more about supporting this project.</p>
+ </div>
+ <footer style="text-align: right;">
+ <p><small>Powered by <a href="https://github.com/MahdyMirzade/Kaveh">Kaveh</a></small></p>
+ </footer>
+ </body>
+</html>
diff --git a/out/logo.png b/out/logo.png
Binary files differ.
diff --git a/src/blog/index.md b/src/blog/index.md
@@ -0,0 +1,5 @@
+# What is this?
+This is my simple template to create minimal websites.
+
+## How do you use it?
+I write my blog posts like `blog/*.md`, using Markdown, It's easier for me to read and write.
diff --git a/src/index.md b/src/index.md
@@ -0,0 +1,22 @@
+<!---------------KVH----------------
+Title: Kaveh | Home Page
+Description: This is about Kaveh.
+----------------------------------->
+
+<div style="text-align: center;"><img src="./logo.png"></div>
+
+# What is this?
+This is my simple template to create minimal websites.
+
+## How do you use it?
+I write my blog posts like `blog/*.md`, using Markdown, It's easier for me to read and write.
+
+## Team ![GitHub contributors](https://img.shields.io/github/contributors/mahdymirzade/gip)
+This project is maintained by the following people and a bunch of [awesome contributors](https://github.com/MahdyMirzade/gip/graphs/contributors).
+
+| [![Mahdy Mirzade](https://github.com/mahdymirzade.png?size=100)](https://github.com/mahdymirzade) |
+| --- |
+| [Mahdy Mirzade](https://github.com/mahdymirzade) |
+
+## Donate
+You can use [this page](https://git.io/JB2BO) to find more about supporting this project.
diff --git a/tpl/footer.html b/tpl/footer.html
@@ -0,0 +1,6 @@
+ </div>
+ <footer style="text-align: right;">
+ <p><small>Powered by <a href="https://github.com/MahdyMirzade/Kaveh">Kaveh</a></small></p>
+ </footer>
+ </body>
+</html>
diff --git a/tpl/header.html b/tpl/header.html
@@ -0,0 +1,14 @@
+<!DOCTYPE html>
+<html lang=en>
+ <head>
+ <meta charset="UTF-8">
+ <meta http-equiv="X-UA-Compatible" content="IE=edge">
+ <meta name="viewport" content="width=device-width, initial-scale=1">
+ <meta name="generator" content="Kaveh v1.0.0" />
+ <link rel="icon" href="$PAGE_ICON">
+ <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/water.css@2/out/water.min.css">
+ <title>$PAGE_TITLE</title>
+ <meta name="description" content="$PAGE_DESC">
+ </head>
+ <body>
+ <div>