add a script for update

This commit is contained in:
kbe
2025-08-19 23:48:30 +02:00
parent 98f639b913
commit ef7951c1e4
38 changed files with 229 additions and 29 deletions

View File

@@ -5,7 +5,7 @@ FROM hugomods/hugo:nightly
RUN apk add --no-cache nodejs npm RUN apk add --no-cache nodejs npm
# Install Sass (Dart Sass) globally # Install Sass (Dart Sass) globally
RUN npm install -g sass RUN npm install -g sass yarn
# Set the working directory inside the container # Set the working directory inside the container
WORKDIR /app WORKDIR /app
@@ -18,7 +18,7 @@ RUN chmod +x scripts/build.sh
# Install Node.js dependencies if any (e.g., for fetch-wordpress.js) # Install Node.js dependencies if any (e.g., for fetch-wordpress.js)
# Assuming package.json exists and has dependencies # Assuming package.json exists and has dependencies
RUN if [ -f package.json ]; then npm install; fi RUN if [ -f package.json ]; then yarn install; fi
# Ensure /usr/local/bin is in PATH for the CMD # Ensure /usr/local/bin is in PATH for the CMD
ENV PATH="/usr/local/bin:$PATH" ENV PATH="/usr/local/bin:$PATH"

View File

@@ -3,6 +3,7 @@ languageCode = 'fr-fr'
title = 'Mistergeek' title = 'Mistergeek'
# theme = "your-theme" # theme = "your-theme"
ignoreLogs = ["warning-goldmark-raw-html"] ignoreLogs = ["warning-goldmark-raw-html"]
enableRobotsTXT = true
# [permalinks] # [permalinks]
# posts = "/:section/:slug/" # posts = "/:section/:slug/"
@@ -32,7 +33,7 @@ ignoreLogs = ["warning-goldmark-raw-html"]
creator = "@mistergeekfrance" creator = "@mistergeekfrance"
# Facebook # Facebook
facebook_page = "mistergeek.fr" facebook_page = "mistergeekfrance"
youtube_channel = "UCXXXXXXXXXXXXXXXXXXX" youtube_channel = "UCXXXXXXXXXXXXXXXXXXX"
# Search Engine Verification # Search Engine Verification
@@ -41,27 +42,27 @@ ignoreLogs = ["warning-goldmark-raw-html"]
# yandex_verification = "your-yandex-verification-code" # yandex_verification = "your-yandex-verification-code"
# Local SEO # Local SEO
[params.seo.local] # [params.seo.local]
enabled = true # enabled = true
country = "FR" # country = "FR"
language = "fr" # language = "fr"
region = "Île-de-France" # region = "Île-de-France"
city = "Paris" # city = "Paris"
latitude = "48.8566" # latitude = "48.8566"
longitude = "2.3522" # longitude = "2.3522"
# Rich snippets # Rich snippets
enable_search_box = true enable_search_box = true
enable_sitelinks_searchbox = true enable_sitelinks_searchbox = true
# Verification codes # Verification codes
[params.seo.verification] # [params.seo.verification]
google = "your-google-verification-code" # google = "your-google-verification-code"
bing = "your-bing-verification-code" # bing = "your-bing-verification-code"
yandex = "your-yandex-verification-code" # yandex = "your-yandex-verification-code"
alexa = "your-alexa-verification-code" # alexa = "your-alexa-verification-code"
pinterest = "your-pinterest-verification-code" # pinterest = "your-pinterest-verification-code"
norton = "your-norton-verification-code" # norton = "your-norton-verification-code"
# Image optimization for SEO # Image optimization for SEO
[imaging] [imaging]

View File

@@ -20,14 +20,12 @@
</ul> </ul>
</div> </div>
<div class="col-6 col-sm-6 col-lg-3"> <div class="col-6 col-sm-6 col-lg-3">
<h6 class="font-small fw-medium uppercase">Toutes les catégories</h6> <h6 class="font-small fw-medium uppercase">Toutes les catégories</h6>
<ul class="list-unstyled"> <ul class="list-unstyled">
{{ if .Site.Data.wordpress }} {{ if .Site.Data.wordpress }}
{{ $count := 0 }}
{{ range $index, $element := .Site.Data.wordpress.categories }} {{ range $index, $element := .Site.Data.wordpress.categories }}
{{ if ne $element.name "Featured" }} {{ if and (ne $element.name "Featured") (gt $element.count 0) }}
<li class="nav-item"> <li class="nav-item">
<a class="nav-link" href="/{{ $element.slug }}">{{ $element.name }}</a> <a class="nav-link" href="/{{ $element.slug }}">{{ $element.name }}</a>
</li> </li>

17
package-lock.json generated
View File

@@ -9,7 +9,8 @@
"version": "1.0.0", "version": "1.0.0",
"dependencies": { "dependencies": {
"he": "^1.2.0", "he": "^1.2.0",
"node-fetch": "^3.3.2" "node-fetch": "^3.3.2",
"yarn": "^1.22.22"
}, },
"devDependencies": { "devDependencies": {
"sass": "^1.69.5" "sass": "^1.69.5"
@@ -621,6 +622,20 @@
"engines": { "engines": {
"node": ">= 8" "node": ">= 8"
} }
},
"node_modules/yarn": {
"version": "1.22.22",
"resolved": "https://registry.npmjs.org/yarn/-/yarn-1.22.22.tgz",
"integrity": "sha512-prL3kGtyG7o9Z9Sv8IPfBNrWTDmXB4Qbes8A9rEzt6wkJV8mUvoirjU0Mp3GGAU06Y0XQyA3/2/RQFVuK7MTfg==",
"hasInstallScript": true,
"license": "BSD-2-Clause",
"bin": {
"yarn": "bin/yarn.js",
"yarnpkg": "bin/yarn.js"
},
"engines": {
"node": ">=4.0.0"
}
} }
} }
} }

View File

@@ -2,13 +2,12 @@
"name": "hugo-wordpress-blog", "name": "hugo-wordpress-blog",
"version": "1.0.0", "version": "1.0.0",
"description": "Hugo static site with WordPress content", "description": "Hugo static site with WordPress content",
"license": "MIT",
"scripts": { "scripts": {
"fetch-data": "node scripts/fetch-wordpress.js", "fetch-data": "node scripts/fetch-wordpress.js",
"generate-content": "node scripts/generate-content.js", "generate-content": "node scripts/generate-content.js",
"prebuild": "npm run fetch-data && npm run generate-content", "prebuild": "npm run fetch-data && npm run generate-content",
"build": "npm run build:css && hugo --minify",
"build:css": "sass assets/css/scss:static/assets/css", "build:css": "sass assets/css/scss:static/assets/css",
"dev": "npm run fetch-data && npm run generate-content && npm run build:css && hugo server -D",
"clean": "rm -rf data/wordpress content/posts public" "clean": "rm -rf data/wordpress content/posts public"
}, },
"dependencies": { "dependencies": {
@@ -16,6 +15,7 @@
"node-fetch": "^3.3.2" "node-fetch": "^3.3.2"
}, },
"devDependencies": { "devDependencies": {
"yarn": "^1.22.22",
"sass": "^1.69.5" "sass": "^1.69.5"
} }
} }

37
scripts/README.md Normal file
View File

@@ -0,0 +1,37 @@
# Website Update Script
This script triggers the builder container to update the website content using Docker Compose.
## Usage
1. Make the script executable:
```sh
chmod +x scripts/update-website.sh
```
2. Run the script manually to test it:
```sh
./scripts/update-website.sh
```
3. To set up a cron job, add the following line to your crontab (edit with `crontab -e`):
```sh
0 2 * * * /home/acid/Documents/mistergeek/scripts/update-website.sh >> /home/acid/Documents/mistergeek/logs/update-website.log 2>&1
```
This will run the update script every day at 2:00 AM.
Alternatively, you can run the update script every 6 hours:
```sh
0 */6 * * * /home/acid/Documents/mistergeek/scripts/update-website.sh >> /home/acid/Documents/mistergeek/logs/update-website.log 2>&1
```
## Logs
Logs are stored in `/home/acid/Documents/mistergeek/logs/update-website.log`.
## Requirements
- Docker
- Docker Compose
- The `docker` and `docker compose` commands must be available in the system's PATH

View File

@@ -3,18 +3,33 @@
# Exit immediately if a command exits with a non-zero status. # Exit immediately if a command exits with a non-zero status.
set -e set -e
# Log the start of the build process
echo "Starting build process..."
# Log the beginning of CSS compilation
echo "Building CSS..." echo "Building CSS..."
# Assuming sass is installed and available in the environment or Docker image # Assuming sass is installed and available in the environment or Docker image
# Compile theme.scss to theme.css # Compile theme.scss to theme.css
echo "Compiling SASS to CSS..."
sass assets/css/scss/theme.scss static/assets/css/theme.css sass assets/css/scss/theme.scss static/assets/css/theme.css
echo "CSS compilation completed successfully."
# Log the beginning of data fetching from WordPress
echo "Fetching content from WordPress..." echo "Fetching content from WordPress..."
# Assuming Node.js is installed and available in the environment or Docker image # Assuming Node.js and Yarn are installed and available in the environment or Docker image
node scripts/fetch-wordpress.js yarn run fetch-data
echo "Content fetched successfully from WordPress."
# Log the beginning of content generation for Hugo
echo "Generating content for Hugo..."
yarn run generate-content
echo "Content generation for Hugo completed successfully."
# Log the beginning of Hugo production build
echo "Generating production build with Hugo..." echo "Generating production build with Hugo..."
# Assuming Hugo is installed and available in the environment or Docker image # Assuming Hugo is installed and available in the environment or Docker image
hugo --minify --environment production --config hugo.toml hugo --minify --environment production --config hugo.toml
echo "Hugo production build completed successfully."
# Log the successful completion of the build process
echo "Build process completed successfully!" echo "Build process completed successfully!"

View File

@@ -2,7 +2,7 @@ const fs = require('fs');
const path = require('path'); const path = require('path');
const fetch = (...args) => import('node-fetch').then(({default: fetch}) => fetch(...args)); const fetch = (...args) => import('node-fetch').then(({default: fetch}) => fetch(...args));
const WORDPRESS_API = 'https://www.mistergeek.net/wp-json/wp/v2'; const WORDPRESS_API = 'https://wp.mistergeek.net/wp-json/wp/v2';
const OUTPUT_DIR = path.join(__dirname, '..', 'data', 'wordpress'); const OUTPUT_DIR = path.join(__dirname, '..', 'data', 'wordpress');
const HUGO_DATA_DIR = path.join(__dirname, '..', 'data'); const HUGO_DATA_DIR = path.join(__dirname, '..', 'data');

View File

@@ -0,0 +1,7 @@
# Crontab file for updating the website
# Run the update script every day at 2:00 AM
0 2 * * * /home/acid/Documents/mistergeek/scripts/update-website.sh >> /home/acid/Documents/mistergeek/logs/update-website.log 2>&1
# Alternatively, run the update script every 6 hours
# 0 */6 * * * /home/acid/Documents/mistergeek/scripts/update-website.sh >> /home/acid/Documents/mistergeek/logs/update-website.log 2>&1

24
scripts/update-website.sh Executable file
View File

@@ -0,0 +1,24 @@
#!/bin/sh
# Exit immediately if a command exits with a non-zero status.
set -e
# Log the start of the update process
echo "Starting website update process..."
# Navigate to the project directory
cd "$(dirname "$0")/.."
# Build the Docker image if it doesn't exist
echo "Checking for Docker image..."
if ! docker compose ls | grep -q "builder"; then
echo "Docker image not found. Building image..."
docker compose build
fi
# Start the builder container
echo "Starting builder container..."
docker compose run --rm builder
# Log the successful completion of the update process
echo "Website update process completed successfully!"

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 35 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 32 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 5.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 8.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 36 KiB

View File

@@ -0,0 +1,2 @@
<?xml version="1.0" encoding="utf-8"?>
<browserconfig><msapplication><tile><square70x70logo src="/ms-icon-70x70.png"/><square150x150logo src="/ms-icon-150x150.png"/><square310x310logo src="/ms-icon-310x310.png"/><TileColor>#ffffff</TileColor></tile></msapplication></browserconfig>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.8 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 12 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

View File

@@ -0,0 +1,41 @@
{
"name": "App",
"icons": [
{
"src": "\/android-icon-36x36.png",
"sizes": "36x36",
"type": "image\/png",
"density": "0.75"
},
{
"src": "\/android-icon-48x48.png",
"sizes": "48x48",
"type": "image\/png",
"density": "1.0"
},
{
"src": "\/android-icon-72x72.png",
"sizes": "72x72",
"type": "image\/png",
"density": "1.5"
},
{
"src": "\/android-icon-96x96.png",
"sizes": "96x96",
"type": "image\/png",
"density": "2.0"
},
{
"src": "\/android-icon-144x144.png",
"sizes": "144x144",
"type": "image\/png",
"density": "3.0"
},
{
"src": "\/android-icon-192x192.png",
"sizes": "192x192",
"type": "image\/png",
"density": "4.0"
}
]
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 23 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 69 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 7.7 KiB

View File

@@ -2,6 +2,46 @@
# yarn lockfile v1 # yarn lockfile v1
"@parcel/watcher-android-arm64@2.5.1":
version "2.5.1"
resolved "https://registry.npmjs.org/@parcel/watcher-android-arm64/-/watcher-android-arm64-2.5.1.tgz"
integrity sha512-KF8+j9nNbUN8vzOFDpRMsaKBHZ/mcjEjMToVMJOhTozkDonQFFrRcfdLWn6yWKCmJKmdVxSgHiYvTCef4/qcBA==
"@parcel/watcher-darwin-arm64@2.5.1":
version "2.5.1"
resolved "https://registry.npmjs.org/@parcel/watcher-darwin-arm64/-/watcher-darwin-arm64-2.5.1.tgz"
integrity sha512-eAzPv5osDmZyBhou8PoF4i6RQXAfeKL9tjb3QzYuccXFMQU0ruIc/POh30ePnaOyD1UXdlKguHBmsTs53tVoPw==
"@parcel/watcher-darwin-x64@2.5.1":
version "2.5.1"
resolved "https://registry.npmjs.org/@parcel/watcher-darwin-x64/-/watcher-darwin-x64-2.5.1.tgz"
integrity sha512-1ZXDthrnNmwv10A0/3AJNZ9JGlzrF82i3gNQcWOzd7nJ8aj+ILyW1MTxVk35Db0u91oD5Nlk9MBiujMlwmeXZg==
"@parcel/watcher-freebsd-x64@2.5.1":
version "2.5.1"
resolved "https://registry.npmjs.org/@parcel/watcher-freebsd-x64/-/watcher-freebsd-x64-2.5.1.tgz"
integrity sha512-SI4eljM7Flp9yPuKi8W0ird8TI/JK6CSxju3NojVI6BjHsTyK7zxA9urjVjEKJ5MBYC+bLmMcbAWlZ+rFkLpJQ==
"@parcel/watcher-linux-arm-glibc@2.5.1":
version "2.5.1"
resolved "https://registry.npmjs.org/@parcel/watcher-linux-arm-glibc/-/watcher-linux-arm-glibc-2.5.1.tgz"
integrity sha512-RCdZlEyTs8geyBkkcnPWvtXLY44BCeZKmGYRtSgtwwnHR4dxfHRG3gR99XdMEdQ7KeiDdasJwwvNSF5jKtDwdA==
"@parcel/watcher-linux-arm-musl@2.5.1":
version "2.5.1"
resolved "https://registry.npmjs.org/@parcel/watcher-linux-arm-musl/-/watcher-linux-arm-musl-2.5.1.tgz"
integrity sha512-6E+m/Mm1t1yhB8X412stiKFG3XykmgdIOqhjWj+VL8oHkKABfu/gjFj8DvLrYVHSBNC+/u5PeNrujiSQ1zwd1Q==
"@parcel/watcher-linux-arm64-glibc@2.5.1":
version "2.5.1"
resolved "https://registry.npmjs.org/@parcel/watcher-linux-arm64-glibc/-/watcher-linux-arm64-glibc-2.5.1.tgz"
integrity sha512-LrGp+f02yU3BN9A+DGuY3v3bmnFUggAITBGriZHUREfNEzZh/GO06FF5u2kx8x+GBEUYfyTGamol4j3m9ANe8w==
"@parcel/watcher-linux-arm64-musl@2.5.1":
version "2.5.1"
resolved "https://registry.npmjs.org/@parcel/watcher-linux-arm64-musl/-/watcher-linux-arm64-musl-2.5.1.tgz"
integrity sha512-cFOjABi92pMYRXS7AcQv9/M1YuKRw8SZniCDw0ssQb/noPkRzA+HBDkwmyOJYp5wXcsTrhxO0zq1U11cK9jsFg==
"@parcel/watcher-linux-x64-glibc@2.5.1": "@parcel/watcher-linux-x64-glibc@2.5.1":
version "2.5.1" version "2.5.1"
resolved "https://registry.npmjs.org/@parcel/watcher-linux-x64-glibc/-/watcher-linux-x64-glibc-2.5.1.tgz" resolved "https://registry.npmjs.org/@parcel/watcher-linux-x64-glibc/-/watcher-linux-x64-glibc-2.5.1.tgz"
@@ -12,6 +52,21 @@
resolved "https://registry.npmjs.org/@parcel/watcher-linux-x64-musl/-/watcher-linux-x64-musl-2.5.1.tgz" resolved "https://registry.npmjs.org/@parcel/watcher-linux-x64-musl/-/watcher-linux-x64-musl-2.5.1.tgz"
integrity sha512-n0E2EQbatQ3bXhcH2D1XIAANAcTZkQICBPVaxMeaCVBtOpBZpWJuf7LwyWPSBDITb7In8mqQgJ7gH8CILCURXg== integrity sha512-n0E2EQbatQ3bXhcH2D1XIAANAcTZkQICBPVaxMeaCVBtOpBZpWJuf7LwyWPSBDITb7In8mqQgJ7gH8CILCURXg==
"@parcel/watcher-win32-arm64@2.5.1":
version "2.5.1"
resolved "https://registry.npmjs.org/@parcel/watcher-win32-arm64/-/watcher-win32-arm64-2.5.1.tgz"
integrity sha512-RFzklRvmc3PkjKjry3hLF9wD7ppR4AKcWNzH7kXR7GUe0Igb3Nz8fyPwtZCSquGrhU5HhUNDr/mKBqj7tqA2Vw==
"@parcel/watcher-win32-ia32@2.5.1":
version "2.5.1"
resolved "https://registry.npmjs.org/@parcel/watcher-win32-ia32/-/watcher-win32-ia32-2.5.1.tgz"
integrity sha512-c2KkcVN+NJmuA7CGlaGD1qJh1cLfDnQsHjE89E60vUEMlqduHGCdCLJCID5geFVM0dOtA3ZiIO8BoEQmzQVfpQ==
"@parcel/watcher-win32-x64@2.5.1":
version "2.5.1"
resolved "https://registry.npmjs.org/@parcel/watcher-win32-x64/-/watcher-win32-x64-2.5.1.tgz"
integrity sha512-9lHBdJITeNR++EvSQVUcaZoWupyHfXe1jZvGZ06O/5MflPcuPLtEphScIBL+AiCWBO46tDSHzWyD0uDmmZqsgA==
"@parcel/watcher@^2.4.1": "@parcel/watcher@^2.4.1":
version "2.5.1" version "2.5.1"
resolved "https://registry.npmjs.org/@parcel/watcher/-/watcher-2.5.1.tgz" resolved "https://registry.npmjs.org/@parcel/watcher/-/watcher-2.5.1.tgz"
@@ -173,3 +228,8 @@ web-streams-polyfill@^3.0.3:
version "3.3.3" version "3.3.3"
resolved "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.3.3.tgz" resolved "https://registry.npmjs.org/web-streams-polyfill/-/web-streams-polyfill-3.3.3.tgz"
integrity sha512-d2JWLCivmZYTSIoge9MsgFCZrt571BikcWGYkjC1khllbTeDlGqZ2D8vD8E/lJa8WGWbb7Plm8/XJYV7IJHZZw== integrity sha512-d2JWLCivmZYTSIoge9MsgFCZrt571BikcWGYkjC1khllbTeDlGqZ2D8vD8E/lJa8WGWbb7Plm8/XJYV7IJHZZw==
yarn@^1.22.22:
version "1.22.22"
resolved "https://registry.npmjs.org/yarn/-/yarn-1.22.22.tgz"
integrity sha512-prL3kGtyG7o9Z9Sv8IPfBNrWTDmXB4Qbes8A9rEzt6wkJV8mUvoirjU0Mp3GGAU06Y0XQyA3/2/RQFVuK7MTfg==