Compare commits
	
		
			No commits in common. "b5129139f5fbb82ad47a0d120599820f23569e7c" and "c40f060791a7fd7a42a0c506f73f97f71c8f0bd2" have entirely different histories.
		
	
	
		
			b5129139f5
			...
			c40f060791
		
	
		
							
								
								
									
										121
									
								
								make.sh
									
									
									
									
									
								
							
							
						
						
									
										121
									
								
								make.sh
									
									
									
									
									
								
							@ -1,76 +1,71 @@
 | 
				
			|||||||
#!/bin/bash
 | 
					#!/bin/bash
 | 
				
			||||||
 | 
					
 | 
				
			||||||
set -e
 | 
					set -e
 | 
				
			||||||
 | 
					
 | 
				
			||||||
# global
 | 
					 | 
				
			||||||
pd=/usr/bin/pandoc
 | 
					pd=/usr/bin/pandoc
 | 
				
			||||||
g=/bin/grep
 | 
					g=/bin/grep
 | 
				
			||||||
tr=/usr/bin/tr
 | 
					 | 
				
			||||||
sed=/bin/sed
 | 
					 | 
				
			||||||
postDir=/home/vilmibm/blog/posts
 | 
					postDir=/home/vilmibm/blog/posts
 | 
				
			||||||
 | 
					
 | 
				
			||||||
htmlDir=/home/vilmibm/public_html/blog
 | 
					# TODO generalize into one loop
 | 
				
			||||||
htmlIndexTmpl=/home/vilmibm/blog/index.tmpl.html
 | 
					 | 
				
			||||||
htmlIndex=/home/vilmibm/public_html/blog/index.html
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
gopherPath=/home/vilmibm/public_gopher/blog
 | 
					function makeHTML() {
 | 
				
			||||||
gopherIndex="${gopherPath}/gophermap"
 | 
					  htmlDir=/home/vilmibm/public_html/blog
 | 
				
			||||||
 | 
					  htmlIndexTmpl=/home/vilmibm/blog/index.tmpl.html
 | 
				
			||||||
 | 
					  htmlIndex=/home/vilmibm/public_html/blog/index.html
 | 
				
			||||||
 | 
					
 | 
				
			||||||
geminiPath=/home/vilmibm/public_gemini/blog
 | 
					 | 
				
			||||||
geminiIndex="${geminiPath}/index.gmi"
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
cd $postDir > /dev/null
 | 
					  if [ -e "${htmlIndex}" ]
 | 
				
			||||||
 | 
					 | 
				
			||||||
# backup HTML index
 | 
					 | 
				
			||||||
if [ -e "${htmlIndex}" ]
 | 
					 | 
				
			||||||
then
 | 
					 | 
				
			||||||
  cp $htmlIndex "${htmlIndex}.bak"
 | 
					 | 
				
			||||||
fi
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
cp $htmlIndexTmpl $htmlIndex
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Remove old gopher posts
 | 
					 | 
				
			||||||
rm ${gopherPath}/*
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Initialize blog gophermap
 | 
					 | 
				
			||||||
echo "!the phlog of vilmibm as it were" > $gopherIndex
 | 
					 | 
				
			||||||
echo >> $gopherIndex
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
# Initialize blog index for gemini
 | 
					 | 
				
			||||||
echo "the gemblog of vilmibm as it were" > $geminiIndex
 | 
					 | 
				
			||||||
echo >> $geminiIndex
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
for p in $(ls *.md)
 | 
					 | 
				
			||||||
do
 | 
					 | 
				
			||||||
  pubdate=$($g "pubdate:" $p | $sed 's/pubdate: //')
 | 
					 | 
				
			||||||
  title=$($g "title:" $p | $sed 's/title: //')
 | 
					 | 
				
			||||||
  slug=$($g "slug:" $p | $sed 's/slug: //' | $tr -d \[:blank:\])
 | 
					 | 
				
			||||||
  if [ -z "$pubdate" ] || [ -z "$title" ] || [ -z "$slug" ]
 | 
					 | 
				
			||||||
  then
 | 
					  then
 | 
				
			||||||
    echo "warning: missing at least one of: pubdate, slug, title in ${p}"
 | 
					    cp $htmlIndex "${htmlIndex}.bak"
 | 
				
			||||||
  else
 | 
					 | 
				
			||||||
    # HTML
 | 
					 | 
				
			||||||
    echo "<h2 class=\"title\">${title}</h2>" >> $htmlIndex
 | 
					 | 
				
			||||||
    echo "<a class=\"pubdate\" name=\"${slug}\" href=\"https://tilde.town/~vilmibm/blog#${slug}\">${pubdate}</a>" >> $htmlIndex
 | 
					 | 
				
			||||||
    echo "<div class=\"post\">" >> $htmlIndex
 | 
					 | 
				
			||||||
    $g -v "pubdate:" $p | $g -v "title:" | $g -v "slug:" |$pd -fmarkdown -thtml >> $htmlIndex
 | 
					 | 
				
			||||||
    echo "</div>" >> $htmlIndex
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    # Gopher
 | 
					 | 
				
			||||||
    echo "0${title}	${slug}.txt" >> $gopherIndex
 | 
					 | 
				
			||||||
    gopherPostPath="${gopherPath}/${slug}.txt"
 | 
					 | 
				
			||||||
    echo "# ${title}" > $gopherPostPath
 | 
					 | 
				
			||||||
    echo >> $gopherPostPath
 | 
					 | 
				
			||||||
    echo "_published ${pubdate}_" >> $gopherPostPath
 | 
					 | 
				
			||||||
    $g -v "pubdate:" $p | $g -v "title:" | $g -v "slug:" >> $gopherPostPath
 | 
					 | 
				
			||||||
 | 
					 | 
				
			||||||
    # Gemini
 | 
					 | 
				
			||||||
    echo "=> gemini://tilde.town/~vilmibm/blog/${slug}.gmi ${title}" >> $geminiIndex
 | 
					 | 
				
			||||||
    geminiPostPath="${geminiPath}/${slug}.gmi"
 | 
					 | 
				
			||||||
    echo "# ${title}" > $geminiPostPath
 | 
					 | 
				
			||||||
    echo >> $geminiPostPath
 | 
					 | 
				
			||||||
    echo "_published ${pubdate}_" >> $geminiPostPath
 | 
					 | 
				
			||||||
    $g -v "pubdate:" $p | $g -v "title:" | $g -v "slug:" >> $geminiPostPath
 | 
					 | 
				
			||||||
  fi
 | 
					  fi
 | 
				
			||||||
done
 | 
					 | 
				
			||||||
 | 
					
 | 
				
			||||||
echo "</body></html>" >> $htmlIndex
 | 
					  cp $htmlIndexTmpl $htmlIndex
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  cd $postDir > /dev/null
 | 
				
			||||||
 | 
					  for p in $(ls *.md)
 | 
				
			||||||
 | 
					  do
 | 
				
			||||||
 | 
					    pubdate=$($g "pubdate:" $p | sed 's/pubdate://')
 | 
				
			||||||
 | 
					    title=$($g "title:" $p | sed 's/title://')
 | 
				
			||||||
 | 
					    slug=$($g "slug:" $p | sed 's/slug://' | tr -d \[:blank:\])
 | 
				
			||||||
 | 
					    if [ -z "$pubdate" ] || [ -z "$title" ] || [ -z "$slug" ]
 | 
				
			||||||
 | 
					    then
 | 
				
			||||||
 | 
					      echo "warning: missing at least one of: pubdate, slug, title in ${p}"
 | 
				
			||||||
 | 
					    else
 | 
				
			||||||
 | 
					      echo "<h2 class=\"title\">${title}</h2>" >> $htmlIndex
 | 
				
			||||||
 | 
					      echo "<a class=\"pubdate\" name=\"${slug}\" href=\"https://tilde.town/~vilmibm/blog#${slug}\">${pubdate}</a>" >> $htmlIndex
 | 
				
			||||||
 | 
					      echo "<div class=\"post\">" >> $htmlIndex
 | 
				
			||||||
 | 
					      $g -v "pubdate:" $p | $g -v "title:" | $g -v "slug:" |$pd -fmarkdown -thtml >> $htmlIndex
 | 
				
			||||||
 | 
					      echo "</div>" >> $htmlIndex
 | 
				
			||||||
 | 
					    fi
 | 
				
			||||||
 | 
					  done
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  echo "</body></html>" >> $htmlIndex
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					function makeGopher() {
 | 
				
			||||||
 | 
					  gopherPath=/home/vilmibm/public_gopher/blog
 | 
				
			||||||
 | 
					  cd $postDir > /dev/null
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  for p in $(ls *.md)
 | 
				
			||||||
 | 
					  do
 | 
				
			||||||
 | 
					    pubdate=$($g "pubdate:" $p | sed 's/pubdate://')
 | 
				
			||||||
 | 
					    title=$($g "title:" $p | sed 's/title://')
 | 
				
			||||||
 | 
					    slug=$($g "slug:" $p | sed 's/slug://' | tr -d \[:blank:\])
 | 
				
			||||||
 | 
					    if [ -z "$pubdate" ] || [ -z "$title" ] || [ -z "$slug" ]
 | 
				
			||||||
 | 
					    then
 | 
				
			||||||
 | 
					      echo "warning: missing at least one of: pubdate, slug, title in ${p}"
 | 
				
			||||||
 | 
					    else
 | 
				
			||||||
 | 
					      postPath="${gopherPath}/${slug}.md"
 | 
				
			||||||
 | 
					      echo "# ${title}" > postPath
 | 
				
			||||||
 | 
					      $g -v "pubdate:" $p | $g -v "title:" | $g -v "slug:" >> $postPath
 | 
				
			||||||
 | 
					    fi
 | 
				
			||||||
 | 
					  done
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#
 | 
				
			||||||
 | 
					#function makeGemini() {
 | 
				
			||||||
 | 
					#  # TODO
 | 
				
			||||||
 | 
					#}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					makeHTML
 | 
				
			||||||
 | 
					makeGopher
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user