From dd193074c36d664ecdfeed8515f713807a7c8978 Mon Sep 17 00:00:00 2001 From: ReenigneArcher <42013603+ReenigneArcher@users.noreply.github.com> Date: Mon, 6 Jan 2025 22:13:58 -0500 Subject: [PATCH] docs(gh-pages): migrate site to jekyll format (#169) --- .github/workflows/update-db.yml | 71 +++---- README.md | 2 +- .../{images => assets/img}/no-logo.png | Bin .../{ => assets}/js/item_loader.js | 33 +-- gh-pages-template/index.html | 188 +++++------------- 5 files changed, 91 insertions(+), 203 deletions(-) rename gh-pages-template/{images => assets/img}/no-logo.png (100%) rename gh-pages-template/{ => assets}/js/item_loader.js (94%) diff --git a/.github/workflows/update-db.yml b/.github/workflows/update-db.yml index 2f5be854d71..6e59effae92 100644 --- a/.github/workflows/update-db.yml +++ b/.github/workflows/update-db.yml @@ -3,10 +3,15 @@ name: Update on: pull_request: - branches: [master] - types: [opened, synchronize, reopened] + branches: + - master + types: + - opened + - synchronize + - reopened push: - branches: [master] + branches: + - master schedule: - cron: '0 0 * * *' # every day at midnight workflow_dispatch: @@ -23,24 +28,12 @@ jobs: - name: Checkout uses: actions/checkout@v4 - - name: Checkout gh-pages - uses: actions/checkout@v4 - with: - ref: gh-pages - path: gh-pages - persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of the personal token - fetch-depth: 0 # otherwise, will fail to push refs to dest repo - - name: Cache id: cache uses: actions/cache@v4 with: path: cache - key: none - - - name: Get current date - id: date - run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT + key: update-${{ github.sha }} - name: Set up Python uses: actions/setup-python@v5 @@ -52,14 +45,6 @@ jobs: python -m pip install --upgrade pip python -m pip install -r requirements.txt - - name: Prepare gh-pages - run: | - # empty contents to ensure deleted igdb are removed - rm -f -r ./gh-pages/* - - # copy template back to pages - cp -f -r ./gh-pages-template/* ./gh-pages/ - - name: Update env: TWITCH_CLIENT_ID: ${{ secrets.TWITCH_CLIENT_ID }} @@ -69,27 +54,29 @@ jobs: - name: Prepare Artifacts # uploading artifacts will fail if not zipped due to very large quantity of files shell: bash - if: ${{ github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' }} run: | - 7z a "./gh-pages.zip" "gh-pages" + 7z a "./build.zip" "gh-pages" - - name: Upload Artifacts - if: ${{ github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' }} + - name: Upload artifact uses: actions/upload-artifact@v4 with: - name: gh-pages - if-no-files-found: error # 'warn' or 'ignore' are also available, defaults to `warn` + name: update path: | - ${{ github.workspace }}/gh-pages.zip + ${{ github.workspace }}/build.zip + gh-pages-template/ + if-no-files-found: error + include-hidden-files: true + retention-days: 1 - - name: Deploy to gh-pages - if: ${{ (github.event_name == 'push' && github.ref == 'refs/heads/master') || (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') }} # yamllint disable-line rule:line-length - uses: actions-js/push@v1.5 - with: - github_token: ${{ secrets.GH_BOT_TOKEN }} - author_email: ${{ secrets.GH_BOT_EMAIL }} - author_name: ${{ secrets.GH_BOT_NAME }} - directory: gh-pages - branch: gh-pages - force: false - message: automatic-update-${{ steps.date.outputs.date }} + call-jekyll-build: + needs: update + uses: LizardByte/LizardByte.github.io/.github/workflows/jekyll-build.yml@master + with: + site_artifact: 'update' + extract_archive: 'build.zip' + target_branch: 'gh-pages' + clean_gh_pages: true + secrets: + GH_BOT_EMAIL: ${{ secrets.GH_BOT_EMAIL }} + GH_BOT_NAME: ${{ secrets.GH_BOT_NAME }} + GH_BOT_TOKEN: ${{ secrets.GH_BOT_TOKEN }} diff --git a/README.md b/README.md index cc19e5c0231..a629a9dc343 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ Information from YouTube API is also added to the database for videos. ## Plans -- [ ] Build with Jekyll +- [x] Build with Jekyll - [ ] Revamp index page - [ ] Provide an item page for each API item - [ ] Remove CNAME after next Sunshine release (> v0.23.1) diff --git a/gh-pages-template/images/no-logo.png b/gh-pages-template/assets/img/no-logo.png similarity index 100% rename from gh-pages-template/images/no-logo.png rename to gh-pages-template/assets/img/no-logo.png diff --git a/gh-pages-template/js/item_loader.js b/gh-pages-template/assets/js/item_loader.js similarity index 94% rename from gh-pages-template/js/item_loader.js rename to gh-pages-template/assets/js/item_loader.js index 88edaa862b4..a5773a50ef1 100644 --- a/gh-pages-template/js/item_loader.js +++ b/gh-pages-template/assets/js/item_loader.js @@ -1,18 +1,12 @@ // setup defaults let org_name = "LizardByte" -let base_url = `https://db.${org_name.toLowerCase()}.dev` - -// scripts to load -let scripts = [ - 'https://app.lizardbyte.dev/js/levenshtein_distance.js', - 'https://app.lizardbyte.dev/js/ranking_sorter.js' -] +let base_url = `https://app.${org_name.toLowerCase()}.dev/GameDB` // get search options, we will append each platform to this list let search_options = document.getElementById("search_type") // get platforms container -platforms_container = document.getElementById("platforms-container") +let platforms_container = document.getElementById("platforms-container") $(document).ready(function(){ @@ -21,16 +15,6 @@ $(document).ready(function(){ cache: false, }) - let script_queue = scripts.map(function(script) { - return $.getScript(script) - }) - - $.when.apply(null, script_queue).done(function() { - get_platform_enums() - get_platform_xref() - initialize() - }) - // get platform enums from json file let platform_enums let get_platform_enums = function() { @@ -134,7 +118,6 @@ $(document).ready(function(){ // Split the string at the end of the last full word const splitIndex = match[1].length; const firstPart = string.slice(0, splitIndex); - // const secondPart = string.slice(splitIndex); return [firstPart, string]; } @@ -168,7 +151,7 @@ $(document).ready(function(){ platforms.push(result[platform]) } - let sorted = platforms.sort(rankingSorter("name", "id")).reverse() + let sorted = platforms.sort(window.rankingSorter("name", "id")).reverse() for(let item in sorted) { // create search option @@ -209,7 +192,7 @@ $(document).ready(function(){ banner.src = sorted[item]['platform_logo']['url'].replace("t_thumb", "t_cover_big") } catch (err) { - banner.src = "images/no-logo.png" + banner.src = "/GameDB/assets/img/no-logo.png" banner.classList.add("bg-dark") banner.classList.add("bg-gradient") banner.classList.add("p-4") @@ -220,7 +203,7 @@ $(document).ready(function(){ banner_link.append(banner) let card_body = document.createElement("div") - card_body.className = "bg-dark text-white card-body p-4 rounded-0" + card_body.className = "card-body text-white p-4 rounded-0" card.appendChild(card_body) let card_title_link = document.createElement("a") @@ -246,7 +229,7 @@ $(document).ready(function(){ card_paragraph_div.appendChild(card_paragraph) let card_footer = document.createElement("div") - card_footer.className = "card-footer p-2 pt-0 bg-dark text-white border-0 rounded-0" + card_footer.className = "card-footer p-2 pt-0 border-0 rounded-0" card.appendChild(card_footer) // get first or last version depending on "category" @@ -350,4 +333,8 @@ $(document).ready(function(){ } }) } + + get_platform_enums() + get_platform_xref() + initialize() }) diff --git a/gh-pages-template/index.html b/gh-pages-template/index.html index 6faa5e84c4d..d341d8acdf2 100644 --- a/gh-pages-template/index.html +++ b/gh-pages-template/index.html @@ -1,143 +1,57 @@ - - - - LizardByte - db - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
- - - -
-
- - -
- - - - + +
+ - - - - - - - - - - + +