new genblog script, remove old gen scripts new blog layout

This commit is contained in:
2023-07-15 04:41:40 -04:00
parent 224a8f7594
commit 81e150fbd8
7 changed files with 98 additions and 73 deletions

View File

@ -7,32 +7,33 @@
<meta name="viewport" content="width=device-width, initial-scale=1.0">
</head>
<style type="text/css">
p {
font-size: 2.5vw;
#bloglist {
text-align: left;
font-size: 2ch;
}
#date {
font-size: 1.5vw;
p#bloglist span {
float: right;
color: white;
}
#svg {
display: block;
margin-left: auto;
margin-right: auto;
width: 50%;
max-height: 1.5em;
max-width: 1.5em;
}
</style>
<body>
<div class="master">
<body style="background-color: #161617;">
<div id="master">
<header>
<h1 id="font"><a href="https://squi.bid">Squibid's</a> Blog</h1>
<h1 id="font", style="margin-bottom: 0">
<a href="https://squi.bid">Squibid's</a> Blog
</h1>
</header>
<hr style="color: #f7f7f7;">
<p> <!-- script marker blog -->
</p> <!-- script marker blog -->
<a href="https://squi.bid/blog/rss.xml"><img id="svg" src="pics/rss.svg" alt="rss feed"></a>
<p id="bloglist">
<!-- b script marker blog -->
<a href="/blog/librex-and-dots"> librex and dots</a><span>2023/06/27</span><br>
<a href="/blog/It's-Alive!"> It's Alive!</a><span>2023/05/01</span><br>
<a href="/blog/state-of-the-site"> state of the site</a><span>2023/03/11</span><br>
<!-- e script marker blog -->
</p>
<h2 id="font" style="text-align: center; margin-top: 0;">
<a href="/blog/rss.xml", title="rss">subscribe</a>
</h2>
</div>
</body>
</html>

View File

@ -3,6 +3,21 @@
read -p "Enter name of blog: " name
filename="$(echo $name | sed 's/ /-/g').html"
printf "<title>$name</title>\n<link rel="stylesheet" href="style.css">\n<body>\n<p>\n</p>\n</body>" > $filename
# make sure we don't overwrite an existent file
[ -f $filename ] &&
printf "File already exists! Please choose a different filename.\n"; exit 1
printf '<!DOCTYPE HTML>
<html lang="en">
<meta name="date" content="2023/07/15"><title>'$name'</title>
<link rel=stylesheet href=style.css>
<body style="background-color: #161617;">
<p>
</p>
</body>
</html>
' > $filename
$EDITOR $filename
echo "Make sure to run sup to add to rss feed!"

4
gen
View File

@ -1,4 +0,0 @@
#!/bin/sh
./scripts/gengit
./scripts/genblog

51
genblog Executable file
View File

@ -0,0 +1,51 @@
#!/bin/sh
#
# genblog is a script to take data from my blogs and format it into html for
# my website
#
# by: Squibid
#
#
# Helper variables and functions
#
bloglist=$(ls -t1 blog/*.html | grep -oP '(?<=\/).*?(?=\.)')
top5=$(printf "$bloglist\n" | head -5)
blogdate() {
grep -oP '(?<=\<meta name="date" content=").*(?="\>)' "blog/$1.html"
}
blogtitle() { grep -oP '(?<=\<title\>).*(?=\<\/title\>)' "blog/$1.html"; }
htmlline() {
printf "<a href=\"/blog/$1\">\ $(blogtitle $1)</a>\
<span>$(blogdate $1)</span><br>\n"
}
# set file dates properly
for i in $bloglist; do
if $(touch -cd "$(blogdate $i)T00:00:00" /tmp/file); then
touch -amt "$(blogdate $i | sed 's/\///g')0000" "blog/$i.html"
fi
done
#
# Start modifing our files
#
# delete old bloglist
sed -i -n '1,/.*<!-- b script marker blog -->/p;/.*<!-- e script marker blog -->/,$p' index.html
sed -i -n '1,/.*<!-- b script marker blog -->/p;/.*<!-- e script marker blog -->/,$p' blog.html
# top 5 blogs
for i in $top5; do
line=$(htmlline $i)
# add new bloglist
sed -i "/.*<!-- e script marker blog -->/i $line" index.html
done
# generate the full blog list
for i in $bloglist; do
line=$(htmlline $i)
# add new bloglist
sed -i "/.*<!-- e script marker blog -->/i $line" blog.html
done

View File

@ -32,19 +32,19 @@
</div>
</div>
<div id="right">
<div> <!-- Blog Section -->
<h2 id="font"><a href="https://squi.bid/blog/rss.xml"><img id="svg" src="pics/rss.svg" alt="rss feed"></a> My Blog</h2>
<p> <!-- script marker blog -->
</p> <!-- script marker blog -->
<a href="blog">more...</a>
</div>
<div> <!-- Reasoning Section -->
<h2 id="font"> Why Tho?</h2>
<p> Idk I felt like it. Most of the useful stuff
will be over at the <a href="https://git.squi.bid">git</a>
subdomain. Or you can find a shortened list under the
"Git Repos" section.
<div id="group"> <!-- Blog Section -->
<hgroup>
<h2 id="font", style="margin-bottom: 0;">My Blog</h2>
<p style="text-align: center; margin-top: 0;">
<a href="/blog/rss.xml", title="rss">subscribe</a>
</p>
</hgroup>
<p id="blogpreview">
<!-- b script marker blog -->
If this is here I forgot to generate the blog list.
<!-- e script marker blog -->
</p>
<a href="/blog">more...</a>
</div>
</div>
</div>

View File

@ -1,25 +0,0 @@
#!/bin/sh
blogs=$(ls -ct1 blog/*.html)
blogs5=$(ls -ct1 blog/*.html | head -5)
date() {
ls -ct1l --time-style=+'%Y %b %d' $1 | cut -d ' ' -f 6-8
}
# delete old bloglist
sed -i -n '1,/ <p> <!-- script marker blog -->/p;/ <\/p> <!-- script marker blog -->/,$p' index.html
sed -i -n '1,/ <p> <!-- script marker blog -->/p;/ <\/p> <!-- script marker blog -->/,$p' blog.html
# top 5 blogs
for i in $blogs5; do
name=$(echo $i | sed 's/blog\///' | sed 's/\..*//' | sed 's/-/ /g')
line="<a href=\"https://squi.bid/$(echo $i | sed 's/\.html//')\">$name</a> [$(date $i)]<br>"
# add new bloglist
sed -i "/\ <\/p> <!-- script marker blog -->/i $line" index.html
done
# full blog
for i in $blogs; do
name=$(echo $i | sed 's/blog\///' | sed 's/\..*//' | sed 's/-/ /g')
line="<a href=\"https://squi.bid/$(echo $i | sed 's/\.html//')\">$name<span id=\"date\">$(date $i)</span></a><br>"
# add new bloglist
sed -i "/ <\/p> <!-- script marker blog -->/i $line" blog.html
done

View File

@ -1,13 +0,0 @@
#!/bin/sh
repos=$(ls -1 /var/git | grep -o '.*\.git' | head -5)
# delete old list
sed -i -n '1,/ <p> <!-- script marker git -->/p;/ <\/p> <!-- script marker git -->/,$p' index.html
for i in $repos ; do
name=$(echo $i | sed 's/\.git//')
line="<a href=\"https://git.squi.bid/$name\">$name</a><br>"
# add new repo
sed -i "/ <\/p> <!-- script marker git -->/i $line" index.html
done