Skip to content

Commit 82a8a61

Browse files
docs(gh-pages): migrate site to jekyll format
1 parent 0b966ad commit 82a8a61

File tree

5 files changed

+91
-203
lines changed

5 files changed

+91
-203
lines changed

.github/workflows/update-db.yml

Lines changed: 29 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,15 @@ name: Update
33

44
on:
55
pull_request:
6-
branches: [master]
7-
types: [opened, synchronize, reopened]
6+
branches:
7+
- master
8+
types:
9+
- opened
10+
- synchronize
11+
- reopened
812
push:
9-
branches: [master]
13+
branches:
14+
- master
1015
schedule:
1116
- cron: '0 0 * * *' # every day at midnight
1217
workflow_dispatch:
@@ -23,24 +28,12 @@ jobs:
2328
- name: Checkout
2429
uses: actions/checkout@v4
2530

26-
- name: Checkout gh-pages
27-
uses: actions/checkout@v4
28-
with:
29-
ref: gh-pages
30-
path: gh-pages
31-
persist-credentials: false # otherwise, the token used is the GITHUB_TOKEN, instead of the personal token
32-
fetch-depth: 0 # otherwise, will fail to push refs to dest repo
33-
3431
- name: Cache
3532
id: cache
3633
uses: actions/cache@v4
3734
with:
3835
path: cache
39-
key: none
40-
41-
- name: Get current date
42-
id: date
43-
run: echo "date=$(date +'%Y-%m-%d')" >> $GITHUB_OUTPUT
36+
key: update-${{ github.sha }}
4437

4538
- name: Set up Python
4639
uses: actions/setup-python@v5
@@ -52,14 +45,6 @@ jobs:
5245
python -m pip install --upgrade pip
5346
python -m pip install -r requirements.txt
5447
55-
- name: Prepare gh-pages
56-
run: |
57-
# empty contents to ensure deleted igdb are removed
58-
rm -f -r ./gh-pages/*
59-
60-
# copy template back to pages
61-
cp -f -r ./gh-pages-template/* ./gh-pages/
62-
6348
- name: Update
6449
env:
6550
TWITCH_CLIENT_ID: ${{ secrets.TWITCH_CLIENT_ID }}
@@ -69,27 +54,29 @@ jobs:
6954

7055
- name: Prepare Artifacts # uploading artifacts will fail if not zipped due to very large quantity of files
7156
shell: bash
72-
if: ${{ github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' }}
7357
run: |
74-
7z a "./gh-pages.zip" "gh-pages"
58+
7z a "./build.zip" "gh-pages"
7559
76-
- name: Upload Artifacts
77-
if: ${{ github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch' }}
60+
- name: Upload artifact
7861
uses: actions/upload-artifact@v4
7962
with:
80-
name: gh-pages
81-
if-no-files-found: error # 'warn' or 'ignore' are also available, defaults to `warn`
63+
name: update
8264
path: |
83-
${{ github.workspace }}/gh-pages.zip
65+
${{ github.workspace }}/build.zip
66+
gh-pages-template/
67+
if-no-files-found: error
68+
include-hidden-files: true
69+
retention-days: 1
8470

85-
- name: Deploy to gh-pages
86-
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
87-
uses: actions-js/[email protected]
88-
with:
89-
github_token: ${{ secrets.GH_BOT_TOKEN }}
90-
author_email: ${{ secrets.GH_BOT_EMAIL }}
91-
author_name: ${{ secrets.GH_BOT_NAME }}
92-
directory: gh-pages
93-
branch: gh-pages
94-
force: false
95-
message: automatic-update-${{ steps.date.outputs.date }}
71+
call-jekyll-build:
72+
needs: update
73+
uses: LizardByte/LizardByte.github.io/.github/workflows/jekyll-build.yml@master
74+
with:
75+
site_artifact: 'update'
76+
extract_archive: 'build.zip'
77+
target_branch: 'gh-pages'
78+
clean_gh_pages: true
79+
secrets:
80+
GH_BOT_EMAIL: ${{ secrets.GH_BOT_EMAIL }}
81+
GH_BOT_NAME: ${{ secrets.GH_BOT_NAME }}
82+
GH_BOT_TOKEN: ${{ secrets.GH_BOT_TOKEN }}

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Information from YouTube API is also added to the database for videos.
88

99
## Plans
1010

11-
- [ ] Build with Jekyll
11+
- [x] Build with Jekyll
1212
- [ ] Revamp index page
1313
- [ ] Provide an item page for each API item
1414
- [ ] Remove CNAME after next Sunshine release (> v0.23.1)
File renamed without changes.

gh-pages-template/js/item_loader.js renamed to gh-pages-template/assets/js/item_loader.js

Lines changed: 10 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,12 @@
11
// setup defaults
22
let org_name = "LizardByte"
3-
let base_url = `https://db.${org_name.toLowerCase()}.dev`
4-
5-
// scripts to load
6-
let scripts = [
7-
'https://app.lizardbyte.dev/js/levenshtein_distance.js',
8-
'https://app.lizardbyte.dev/js/ranking_sorter.js'
9-
]
3+
let base_url = `https://app.${org_name.toLowerCase()}.dev/GameDB`
104

115
// get search options, we will append each platform to this list
126
let search_options = document.getElementById("search_type")
137

148
// get platforms container
15-
platforms_container = document.getElementById("platforms-container")
9+
let platforms_container = document.getElementById("platforms-container")
1610

1711

1812
$(document).ready(function(){
@@ -21,16 +15,6 @@ $(document).ready(function(){
2115
cache: false,
2216
})
2317

24-
let script_queue = scripts.map(function(script) {
25-
return $.getScript(script)
26-
})
27-
28-
$.when.apply(null, script_queue).done(function() {
29-
get_platform_enums()
30-
get_platform_xref()
31-
initialize()
32-
})
33-
3418
// get platform enums from json file
3519
let platform_enums
3620
let get_platform_enums = function() {
@@ -134,7 +118,6 @@ $(document).ready(function(){
134118
// Split the string at the end of the last full word
135119
const splitIndex = match[1].length;
136120
const firstPart = string.slice(0, splitIndex);
137-
// const secondPart = string.slice(splitIndex);
138121

139122
return [firstPart, string];
140123
}
@@ -168,7 +151,7 @@ $(document).ready(function(){
168151
platforms.push(result[platform])
169152
}
170153

171-
let sorted = platforms.sort(rankingSorter("name", "id")).reverse()
154+
let sorted = platforms.sort(window.rankingSorter("name", "id")).reverse()
172155

173156
for(let item in sorted) {
174157
// create search option
@@ -209,7 +192,7 @@ $(document).ready(function(){
209192
banner.src = sorted[item]['platform_logo']['url'].replace("t_thumb", "t_cover_big")
210193
}
211194
catch (err) {
212-
banner.src = "images/no-logo.png"
195+
banner.src = "/GameDB/assets/img/no-logo.png"
213196
banner.classList.add("bg-dark")
214197
banner.classList.add("bg-gradient")
215198
banner.classList.add("p-4")
@@ -220,7 +203,7 @@ $(document).ready(function(){
220203
banner_link.append(banner)
221204

222205
let card_body = document.createElement("div")
223-
card_body.className = "bg-dark text-white card-body p-4 rounded-0"
206+
card_body.className = "card-body text-white p-4 rounded-0"
224207
card.appendChild(card_body)
225208

226209
let card_title_link = document.createElement("a")
@@ -246,7 +229,7 @@ $(document).ready(function(){
246229
card_paragraph_div.appendChild(card_paragraph)
247230

248231
let card_footer = document.createElement("div")
249-
card_footer.className = "card-footer p-2 pt-0 bg-dark text-white border-0 rounded-0"
232+
card_footer.className = "card-footer p-2 pt-0 border-0 rounded-0"
250233
card.appendChild(card_footer)
251234

252235
// get first or last version depending on "category"
@@ -350,4 +333,8 @@ $(document).ready(function(){
350333
}
351334
})
352335
}
336+
337+
get_platform_enums()
338+
get_platform_xref()
339+
initialize()
353340
})

0 commit comments

Comments
 (0)