Blog Posts

1 - Nextcloud Collectives and Hugo SSG

Result #

All the errors were were corrected and the site is working just fine now! Here are the results of the Workflow:

1. Front Matter #

FRONTMATTER START  
title: "Nextcloud Collectives and Hugo SSG"  
description: "My experience with using Nextcloud Collectives and Hugo Static Site Generator."  
draft: false  
tags:  
 - "Go"  
 - "Nextcloud"  
 - "Collectives"  
 - "Hugo"  
 - "Static Site Generator"  
date: "2024-12-27"  
categories:   
 - "Hugo"  
 - "Nextcloud"  
menu: "main"  
author: "Vincent Maule"  
type: posts  
FRONTMATTER END

2. Copy Files from Nextcloud Collective #

#! /run/current-system/sw/bin/bash
cd ..
git submodule init
git submodule update
cd themes/hugo-book
git checkout e104a11f42fbd069aa15606c5f01631b07d7528c
cd ../..
rm -rf content/*
echo "Copying Files..."
cp -r ~/Nextcloud/Collectives/tech_fish-maule_com/* content
echo "Moving to Content Directory: " && pwd
cd content
echo "Renaming all Readme.md files..."
find . -depth -name "Readme.md" -exec sh -c 'f="{}"; mv -- "$f" "${f%Readme.md}_index.md"';
echo "Replacing Front Matter for all files where applicable..."
# Function to replace frontmatter
replace_frontmatter() {
    local file="$1"
    # Read the file content
    local content=$(cat "$file")
    
    # Check if the old frontmatter format exists
    if [[ "$content" =~ "FRONTMATTER START" && "$content" =~ "FRONTMATTER END" ]]; then
        # Replace the old format with the new one
        content="${content/FRONTMATTER START/---}"
        content="${content/FRONTMATTER END/---}"
        
        # Write the modified content back to the file
        echo "$content" > "$file"
        echo "Updated frontmatter in $file"
    fi
}

# Find all .md files in the current directory and its subdirectories
find . -type f -name "*.md" | while read -r file; do
    replace_frontmatter "$file"
done

echo "Frontmatter conversion process completed."

3. Git Push #

#!/run/current-system/sw/bin/bash
cd ..
rm tech_fish-maule_com.tar.gz
rm -rf public
git add .
git commit -a -m "Perform Initial Commit attempt 7."
git push

4. Generate Sites #

#! /run/current-system/sw/bin/bash
cd ..
hugo --gc --minify
tar -czf tech_fish-maule_com.tar.gz public/*

Experience #

Timeline: December 24, 2024 - January 1, 2025

...

2 - Presenting Git Changes

Result #

#! /run/current-system/sw/bin/bash

cd ..

# Get the total number of commits
commit_count=$(git rev-list --count HEAD)

# Loop through each commit in reverse order (last to first)
for (( i=1; i<=$commit_count; i++ )); do
    # Calculate commit hash for the current iteration
    commit_hash=$(git rev-list --max-count=1 --skip=$((commit_count - i)) HEAD)
    
    # Get the hash of the previous commit (or an empty string if it's the first commit)
    if [ $i -eq 1 ]; then
        previous_commit=""
    else
        previous_commit=$(git rev-list --max-count=1 --skip=$((commit_count - i + 1)) HEAD)
    fi

    # Generate the diff, using the empty tree for the initial commit if necessary
    if [ -z "$previous_commit" ]; then
        git diff 4b825dc642cb6eb9a060e54bf8d69288fbee4904 $commit_hash > "commit_$(printf "%03d" $i)_$(git rev-parse --short $commit_hash).diff"
    else
        git diff $previous_commit $commit_hash > "commit_$(printf "%03d" $i)_$(git rev-parse --short $commit_hash).diff"
    fi
done

echo "Diff files for all commits have been created."

Current Date: December 29, 2024

...

3 - Yubikey

Result #

1. Update Yubikey Firmware #

It is not possible to update any Yubikey’s to the latest version: YubiKey Firmware is Not Upgradeable.

It is possible to find the current version using this guide: Where to find YubiKey Firmware Version.

Note: Quick and dirty command; assuming you have yubikey-manager installed: ykman info.

2. Factory Reset YubiKey #

I compiled all the information within this documentation: Factory Reset Components.

Note: Non-Resident SSH Keys will be stored in FIDO Component.

...

7 - Testing and Building Nix!

Excerpt #

As I’ve been experiencing (what feels like circles) Skarabox, I noticed that some friends would be dropping hints here and there with how to use Nix more effeciently; those days of just doing some cowboy building was driving me insane, constantly asking myself if there was a more efficient way and feeling the scope creep getting to me. That’s what the Testing and Building sections are meant to capture, this post is to capture my first experience using these tools.

...