]> danix's work - danix.xyz.git/commitdiff
add CLAUDE.md and update post-receive hook with detailed logging release_04042026-1231
authorDanilo M. <redacted>
Sat, 4 Apr 2026 10:31:30 +0000 (12:31 +0200)
committerDanilo M. <redacted>
Sat, 4 Apr 2026 10:31:30 +0000 (12:31 +0200)
Co-Authored-By: Claude Sonnet 4.6 <redacted>
CLAUDE.md [new file with mode: 0644]
git-post-receive [new file with mode: 0644]

diff --git a/CLAUDE.md b/CLAUDE.md
new file mode 100644 (file)
index 0000000..095cff1
--- /dev/null
+++ b/CLAUDE.md
@@ -0,0 +1,81 @@
+# CLAUDE.md
+
+This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
+
+## What This Is
+
+A personal blog/website for danix.xyz, built with [Hugo](https://gohugo.io/). It uses a custom theme called **dagreynix** (located at `themes/dagreynix/`) which is developed alongside the site content.
+
+## Common Commands
+
+```bash
+# Serve locally with live reload
+hugo server
+
+# Build the site
+hugo
+
+# Create a new article (uses the articles archetype)
+hugo new articles/my-article-title.md
+```
+
+## Deployment
+
+The site is deployed via a **git post-receive hook** (`git-post-receive`) on a bare Gitolite server. Pushing to `master` triggers an automatic build and deploy. There is no manual deploy step.
+
+### How it works
+
+1. `git push` to the bare repo on the server
+2. Hook detects `master` branch push and the `danix.xyz` repo (via `$GL_REPO`)
+3. Creates a fresh Hugo site at `/tmp/danix.xyz-compile`
+4. Backs up `/var/www/html` → `~/danix.xyz-backup` (trap reverts on failure)
+5. Checks out repo content into the temp dir
+6. **Clones the theme** from `~/repositories/theme-danix.xyz.git` (separate bare repo) into `themes/dagreynix/`
+7. Clears and rebuilds `/var/www/html` with `hugo --minify`
+8. Tags the commit as `release_DDMMYYYY-HHMM`
+
+### Important: two separate repos
+
+The theme (`themes/dagreynix/`) has its **own** git repository, separate from the site content repo. They deploy independently:
+
+- **Content changes** (articles, `hugo.toml`, `assets/uploads/`): commit and push from `/home/danix/Programming/GIT/danix.xyz`
+- **Theme changes** (`themes/dagreynix/`): commit and push from inside the `themes/dagreynix/` submodule directory
+
+Both must be pushed for the full site to reflect all changes. Push the theme first, then the content repo, since the hook clones the theme at build time.
+
+## Architecture
+
+### Content
+- `content/articles/` — main blog posts (English)
+- `content/is/` — "about the site" page
+- Article frontmatter fields: `title`, `date`, `draft`, `type`, `author`, `format`, `excerpt`, `featured_image`, `categories`, `tags`
+
+### Theme (`themes/dagreynix/`)
+The site uses a fully custom theme. Key areas:
+
+- **`layouts/`** — Hugo templates organized by content type (`articles/`, `article/`, `page/`, `_default/`, `partials/`, `shortcodes/`)
+- **`assets/sass/`** — Sass stylesheets compiled by Hugo Pipes. Entry point is `main.scss`, with partials split into `base/`, `components/`, `layout/`, and `libs/`
+- **`assets/js/`** — JavaScript assets
+- **`assets/SVGs/`** and **`assets/img/`** — Theme image assets
+
+### Key Partials (`themes/dagreynix/layouts/partials/`)
+- `head.html` / `head-addition.html` — `<head>` content (addition allows per-page injection)
+- `footer.html` / `footer-addition.html` — footer (addition allows per-page injection)
+- `breadcrumbs.html`, `pagination.html`, `tag-cloud.html`, `prev-next.html`
+- `funcs/` — reusable template functions/helpers
+
+### Shortcodes (`themes/dagreynix/layouts/shortcodes/`)
+Custom shortcodes in use: `img`, `figure`, `gallery`/`gal-img`, `gravatar`, `quote`, `dropcap`, `div`/`div-close`, `em`, `strike`, `svg`, `video`, `contact`, `search`, `actions`
+
+### Site-level Assets
+- `assets/uploads/` — article images, organized by year/month
+- `static/` — files served as-is (GPG key, packages, videos)
+
+### Search
+The site generates a `searchindex.json` via a custom output format defined in `hugo.toml`. The search partial and shortcode handle frontend search.
+
+### hugo.toml Notes
+- `mainSections = ["articles", "article"]` — controls what appears in listings
+- `imageSizes` — used by theme for responsive image processing
+- Privacy settings disable Disqus and Google Analytics; social embeds use privacy-enhanced modes
+- `refLinksErrorLevel = "WARNING"` — broken ref links warn but don't fail the build
diff --git a/git-post-receive b/git-post-receive
new file mode 100644 (file)
index 0000000..f4d5e58
--- /dev/null
@@ -0,0 +1,101 @@
+#!/bin/bash
+
+# theme repository
+THEME_REPO=$HOME/repositories/theme-danix.xyz.git
+# repository logical name
+REPO="danix.xyz"
+# Directory where to work on our site
+TARGET_DIR=/tmp/danix.xyz-compile
+GIT_DIR=$HOME/repositories/${REPO}.git
+# Public dir where to push the site once compiled
+PUBLIC_WWW="/var/www/html"
+BACKUP_WWW=$HOME/danix.xyz-backup
+SITE_DOMAIN=https://danix.xyz
+# Branch that is going to be deployed to server
+BRANCH="master"
+# date to be appended to latest tag
+NOW=$(date +"%d%m%Y-%H%M")
+# Log file
+LOG_DIR=/tmp/hugo-danix-site
+LOG_FILE=$LOG_DIR/post-receive.log
+
+
+set -e
+
+# Ensure log directory exists
+mkdir -p "$LOG_DIR"
+
+# Tee all output (stdout + stderr) to the log file, appending
+exec > >(tee -a "$LOG_FILE") 2>&1
+
+log() {
+       echo "[$(date '+%Y-%m-%d %H:%M:%S')] $*"
+}
+
+log "========================================"
+log "POST-RECEIVE HOOK STARTED"
+log "Repo   : $REPO"
+log "Branch : $BRANCH"
+log "Tag    : release_$NOW"
+log "========================================"
+
+# delete the working directory first
+log "Removing old working directory: $TARGET_DIR"
+rm -rf $TARGET_DIR
+
+# create new temporary site
+log "Creating fresh Hugo site at: $TARGET_DIR"
+/usr/local/bin/hugo new site $TARGET_DIR
+
+# backup public www directory first then setup trap
+log "Backing up $PUBLIC_WWW → $BACKUP_WWW"
+rsync -avz --no-t $PUBLIC_WWW/ $BACKUP_WWW
+trap "log 'A problem occurred. Reverting to backup.'; rsync -avz --no-t --del $BACKUP_WWW/ $PUBLIC_WWW; rm -rf $TARGET_DIR; log 'Revert complete.'" EXIT
+
+while read oldrev newrev ref
+do
+       log "Received ref: $ref (${oldrev:0:8} → ${newrev:0:8})"
+
+       # if TARGET_DIR is empty we don't want deploy for this project
+       if [[ ! $TARGET_DIR == "" ]]; then
+               if [[ "$GL_REPO" == "$REPO" ]]; then
+                       # let's check that we are deploying to the correct branch
+                       if [[ $ref = refs/heads/${BRANCH} ]]; then
+                               log "Deploying '$BRANCH' branch to production..."
+
+                               log "Checking out content into $TARGET_DIR"
+                               git --git-dir=$GIT_DIR --work-tree=. -C "$TARGET_DIR" checkout -f
+
+                               log "Cloning theme from $THEME_REPO"
+                               git clone $THEME_REPO ${TARGET_DIR}/themes/dagreynix
+                               log "Theme cloned at commit: $(git -C ${TARGET_DIR}/themes/dagreynix rev-parse --short HEAD)"
+
+                               log "Clearing $PUBLIC_WWW"
+                               rm -rf $PUBLIC_WWW/*
+
+                               log "Tagging: release_$NOW"
+                               git tag release_$NOW $BRANCH
+
+                               log "Running Hugo build..."
+                               /usr/local/bin/hugo -s $TARGET_DIR -d $PUBLIC_WWW -b "${SITE_DOMAIN}" -t "dagreynix" --noTimes --minify
+                               log "Hugo build complete."
+
+                               log "========================================"
+                               log "DEPLOYMENT COMPLETED - ${REPO}"
+                               log "Target branch : ${BRANCH}"
+                               log "Target folder : ${PUBLIC_WWW}"
+                               log "Tag name      : release_${NOW}"
+                               log "========================================"
+                       else
+                               log "Ref $ref received. Doing nothing: only the ${BRANCH} branch may be deployed on this server."
+                       fi
+               else
+                       log "GL_REPO='$GL_REPO' does not match '$REPO'. Skipping."
+               fi
+       else
+               log "Target directory not declared. Skipping deploy to server."
+       fi
+done
+
+trap - EXIT
+log "Hook finished successfully."