diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 00000000..ba8c2b04 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,51 @@ +name: Deploy repository to Github Pages + +on: + push: + branches: [ main, stable ] + + # Allows you to run this workflow manually from the Actions tab + workflow_dispatch: + +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages +permissions: + contents: read + pages: write + id-token: write + +jobs: + build: + runs-on: ubuntu-22.04 + steps: + - name: Checkout main + uses: actions/checkout@v2 + with: + path: main + ref: main + fetch-depth: '0' + - run: | + cd main + ./build_site.sh ../_site/develop + # uncomment this once we have a stable branch + # - name: Checkout Stable + # uses: actions/checkout@v2 + # with: + # path: stable + # ref: stable + # fetch-depth: '0' + # - run: | + # cd stable + # ../master/build_site.sh ../_site/stable + - uses: actions/upload-pages-artifact@v2 + + deploy: + environment: + name: github-pages + url: ${{ steps.deployment.outputs.page_url }} + runs-on: ubuntu-22.04 + needs: build + steps: + - name: Deploy to GitHub Pages + id: deployment + uses: actions/deploy-pages@v2 + diff --git a/.gitignore b/.gitignore new file mode 100644 index 00000000..16182c5d --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/_site \ No newline at end of file diff --git a/build_site.sh b/build_site.sh new file mode 100755 index 00000000..1c9a59ad --- /dev/null +++ b/build_site.sh @@ -0,0 +1,67 @@ +#!/bin/bash + +# builds a repository of scrapers +# outputs to _site with the following structure: +# index.yml +# .zip +# Each zip file contains the scraper.yml file and any other files in the same directory + +outdir="$1" +if [ -z "$outdir" ]; then + outdir="_site" +fi + +rm -rf "$outdir" +mkdir -p "$outdir" + +buildPlugin() +{ + f=$1 + # get the scraper id from the directory + dir=$(dirname "$f") + plugin_id=$(basename "$f" .yml) + + echo "Processing $plugin_id" + + # create a directory for the version + version=$(git log -n 1 --pretty=format:%h -- "$dir"/*) + updated=$(TZ=UTC0 git log -n 1 --date="format-local:%F %T" --pretty=format:%ad -- "$dir"/*) + + # create the zip file + # copy other files + zipfile=$(realpath "$outdir/$plugin_id.zip") + + pushd "$dir" > /dev/null + zip -r "$zipfile" . > /dev/null + popd > /dev/null + + name=$(grep "^name:" "$f" | head -n 1 | cut -d' ' -f2- | sed -e 's/\r//' -e 's/^"\(.*\)"$/\1/') + description=$(grep "^description:" "$f" | head -n 1 | cut -d' ' -f2- | sed -e 's/\r//' -e 's/^"\(.*\)"$/\1/') + ymlVersion=$(grep "^version:" "$f" | head -n 1 | cut -d' ' -f2- | sed -e 's/\r//' -e 's/^"\(.*\)"$/\1/') + version="$ymlVersion-$version" + dep=$(grep "^# requires:" "$f" | cut -c 12- | sed -e 's/\r//') + + # write to spec index + echo "- id: $plugin_id + name: $name + metadata: + description: $description + version: $version + date: $updated + path: $plugin_id.zip + sha256: $(sha256sum "$zipfile" | cut -d' ' -f1)" >> "$outdir"/index.yml + + # handle dependencies + if [ ! -z "$dep" ]; then + echo " requires:" >> "$outdir"/index.yml + for d in ${dep//,/ }; do + echo " - $d" >> "$outdir"/index.yml + done + fi + + echo "" >> "$outdir"/index.yml +} + +find ./plugins -mindepth 1 -name *.yml | while read file; do + buildPlugin "$file" +done diff --git a/plugins/4. CropperJS/CropperJS.yml b/plugins/CropperJS/CropperJS.yml similarity index 100% rename from plugins/4. CropperJS/CropperJS.yml rename to plugins/CropperJS/CropperJS.yml diff --git a/plugins/4. CropperJS/cropper.css b/plugins/CropperJS/cropper.css similarity index 100% rename from plugins/4. CropperJS/cropper.css rename to plugins/CropperJS/cropper.css diff --git a/plugins/4. CropperJS/cropper.js b/plugins/CropperJS/cropper.js similarity index 100% rename from plugins/4. CropperJS/cropper.js rename to plugins/CropperJS/cropper.js diff --git a/plugins/3. Stash Batch Result Toggle/stashBatchResultToggle.js b/plugins/StashBatchResultToggle/stashBatchResultToggle.js similarity index 100% rename from plugins/3. Stash Batch Result Toggle/stashBatchResultToggle.js rename to plugins/StashBatchResultToggle/stashBatchResultToggle.js diff --git a/plugins/3. Stash Batch Result Toggle/stashBatchResultToggle.yml b/plugins/StashBatchResultToggle/stashBatchResultToggle.yml similarity index 80% rename from plugins/3. Stash Batch Result Toggle/stashBatchResultToggle.yml rename to plugins/StashBatchResultToggle/stashBatchResultToggle.yml index 45c47492..a07558f7 100644 --- a/plugins/3. Stash Batch Result Toggle/stashBatchResultToggle.yml +++ b/plugins/StashBatchResultToggle/stashBatchResultToggle.yml @@ -1,6 +1,9 @@ name: Stash Batch Result Toggle. +# requires: StashUserscriptLibrary description: In Scene Tagger, adds button to toggle all stashdb scene match result fields. Saves clicks when you only want to save a few metadata fields. Instead of turning off every field, you batch toggle them off, then toggle on the ones you want version: 1.0 ui: + requires: + - StashUserscriptLibrary javascript: - stashBatchResultToggle.js diff --git a/plugins/sceneCoverCropper/sceneCoverCropper.yml b/plugins/sceneCoverCropper/sceneCoverCropper.yml index 735cf4a3..53f71118 100644 --- a/plugins/sceneCoverCropper/sceneCoverCropper.yml +++ b/plugins/sceneCoverCropper/sceneCoverCropper.yml @@ -1,7 +1,10 @@ name: Scene Cover Cropper +# requires: CropperJS description: Crop Scene Cover Images version: 1.0 ui: + requires: + - CropperJS css: javascript: - sceneCoverCropper.js \ No newline at end of file diff --git a/plugins/1. stashUserscriptLibrary/StashUserscriptLibrary.yml b/plugins/stashUserscriptLibrary/StashUserscriptLibrary.yml similarity index 100% rename from plugins/1. stashUserscriptLibrary/StashUserscriptLibrary.yml rename to plugins/stashUserscriptLibrary/StashUserscriptLibrary.yml diff --git a/plugins/1. stashUserscriptLibrary/stashUserscriptLibrary.js b/plugins/stashUserscriptLibrary/stashUserscriptLibrary.js similarity index 100% rename from plugins/1. stashUserscriptLibrary/stashUserscriptLibrary.js rename to plugins/stashUserscriptLibrary/stashUserscriptLibrary.js diff --git a/plugins/2. stats/stats.js b/plugins/stats/stats.js similarity index 100% rename from plugins/2. stats/stats.js rename to plugins/stats/stats.js diff --git a/plugins/2. stats/stats.yml b/plugins/stats/stats.yml similarity index 56% rename from plugins/2. stats/stats.yml rename to plugins/stats/stats.yml index f86e6a14..255ca988 100644 --- a/plugins/2. stats/stats.yml +++ b/plugins/stats/stats.yml @@ -1,6 +1,9 @@ name: Extended Stats +# requires: StashUserscriptLibrary description: Adds new stats to the stats page version: 1.0 ui: + requires: + - StashUserscriptLibrary javascript: - stats.js