diff --git a/scripts/games/app.js b/scripts/games/app.js index aafb7d9..39fa0a6 100644 --- a/scripts/games/app.js +++ b/scripts/games/app.js @@ -6,6 +6,7 @@ const logger = require('winston'); const sanitizeHtml = require('sanitize-html'); +const toml = require('toml'); const blackfriday = require('./blackfriday.js'); const del = require('delete'); @@ -27,9 +28,11 @@ function url(title) { function gitPull(directory, repository) { if (fs.existsSync(directory)) { logger.info(`Fetching latest from Github : ${directory}`); - exec(`cd ${directory} && git pull && cd -`); + logger.info(`git --git-dir=${directory} pull`); + exec(`git --git-dir=${directory} pull`); } else { logger.info(`Cloning repository from Github : ${directory}`); + logger.info(`git clone ${repository}`); exec(`git clone ${repository}`); } } @@ -39,17 +42,6 @@ function getDirectories (srcpath) { .filter(file => fs.lstatSync(path.join(srcpath, file)).isDirectory()) } -String.prototype.trimNewline = function() { - let string = this.toString(); - if (string.endsWith('\r\n')) { - return string.slice(0, -2); - } else if (string.endsWith('\r') || string.endsWith('\n')) { - return string.slice(0, -1); - } else { - return string; - } -} - // Fetch game information stored in Github repository. gitPull(inputDirectoryGame, 'https://github.com/citra-emu/citra-games-wiki.git'); @@ -119,10 +111,7 @@ try { fsextra.copySync(`${inputDirectorySavefilesGame}/${file}`, `${outputDirectorySavefilesGame}/${file.replace('.zip', '.zip')}`); } else if (path.extname(file) == '.dat') { // Store the contents of the file in memory for adding it into the markdown later. - savefileMetadataContents.push({ - filename: file.replace('.dat', '.zip'), - contents: fs.readFileSync(`${inputDirectorySavefilesGame}/${file}`, 'utf8').trimNewline() - }); + savefileMetadataContents.push({ filename: file.replace('.dat', '.zip'), contents: fs.readFileSync(`${inputDirectorySavefilesGame}/${file}`, 'utf8') }); } }); } @@ -150,14 +139,28 @@ try { var stats = fs.statSync(`${inputDirectoryGame}/${game}/game.dat`); let modified = new Date(util.inspect(stats.mtime)); - let datContents = fs.readFileSync(`${inputDirectoryGame}/${game}/game.dat`, 'utf8').trimNewline(); + let datContents = fs.readFileSync(`${inputDirectoryGame}/${game}/game.dat`, 'utf8'); + datContents = `date = "${modified.toISOString()}"\r\n` + datContents; + + // Parse testcase information out of the dat to reinject as shortcut values. + try { + var dat = toml.parse(datContents); + if (dat.testcases == null || dat.testcases.length == 0) { + datContents = `compatibility = 99"\r\ntestcase_date = "2000-01-01"\r\n` + datContents; + } else { + let recent = dat.testcases[0]; + datContents = `compatibility = ${recent.compatibility}\r\ntestcase_date = "${recent.date}"\r\n` + datContents; + } + } catch (e) { + console.error(`Parsing dat file error on line ${e.line}, column ${e.column}: ${e.message}`); + } var wikiContents = ""; let wikiPathGame = `${inputDirectoryWiki}/${game}.md`; if (fs.existsSync(wikiPathGame)) { - wikiContents = fs.readFileSync(wikiPathGame, 'utf8').trimNewline(); + wikiContents = fs.readFileSync(wikiPathGame, 'utf8'); } else { - wikiContents = "## No wiki exists yet for this game."; + wikiContents = "No wiki exists yet for this game."; } // Fix Blackfriday markdown rendering differences. @@ -167,14 +170,13 @@ try { // Read all savefiles from array and copy them into the markdown. savefileMetadataContents.forEach(function(savefile) { let modified = new Date(util.inspect(stats.mtime)); - datContents += `\r\n\r\n[[ savefiles ]]\r\nfilename = "${savefile.filename}"\r\ndate = "${modified.toISOString()}"\r\n${savefile.contents}`; + datContents += `\r\n\r\n[[ savefiles ]]\r\n${savefile.contents}\r\nfilename = "${savefile.filename}"\r\ndate = "${modified.toISOString()}"\r\n`; }); - let output = `+++\r\ndate = "${modified.toISOString()}"\r\n${datContents}\r\n+++\r\n\r\n${wikiContents}\r\n`; + let output = `+++\r\n${datContents}\r\n+++\r\n\r\n${wikiContents}\r\n`; fs.writeFileSync(`${outputDirectoryMd}/${game}.md`, output); } catch (ex) { logger.error(`${game} failed to generate: ${ex}`); - logger.error(ex); } }); } catch (ex) { diff --git a/scripts/games/package.json b/scripts/games/package.json index 49e98ba..f5e3ad8 100644 --- a/scripts/games/package.json +++ b/scripts/games/package.json @@ -11,6 +11,7 @@ "rimraf": "^2.6.1", "sanitize-html": "^1.14.1", "sync-exec": "^0.6.2", + "toml": "^2.3.2", "winston": "^2.2.0" }, "preferGlobal": false, diff --git a/site/data/compatibility.json b/site/data/compatibility.json index 45ad2d4..97b609a 100644 --- a/site/data/compatibility.json +++ b/site/data/compatibility.json @@ -4,5 +4,6 @@ "2": { "name": "Okay", "color": "#94b242", "description": "Game functions with major graphical or audio glitches, but game is playable from start to finish with workarounds." }, "3": { "name": "Bad", "color": "#f2d624", "description": "Game functions, but with major graphical or audio glitches. Unable to progress in specific areas due to glitches even with workarounds." }, "4": { "name": "Intro/Menu", "color": "red", "description": "Game is completely unplayable due to major graphical or audio glitches. Unable to progress past the Start Screen." }, - "5": { "name": "Won't Boot", "color": "#828282", "description": "The game crashes when attempting to startup." } + "5": { "name": "Won't Boot", "color": "#828282", "description": "The game crashes when attempting to startup." }, + "99": { "name": "Not Tested", "color": "black", "description": "This game has not yet been tested." } } diff --git a/site/themes/citra-bs-theme/layouts/_default/baseof.html b/site/themes/citra-bs-theme/layouts/_default/baseof.html index 29045da..bcd6011 100755 --- a/site/themes/citra-bs-theme/layouts/_default/baseof.html +++ b/site/themes/citra-bs-theme/layouts/_default/baseof.html @@ -5,6 +5,10 @@ + + + + {{ .Render "meta" }} {{ .Hugo.Generator }} @@ -17,38 +21,7 @@ {{ end }} - {{ if .IsHome }}Homepage{{ else }}{{ .Title }}{{ end }} | {{ .Site.Title }} | Nintendo 3DS Emulator - - - - - {{ if (eq .Section "game") }} - {{ $rating := index .Site.Data.compatibility ( string .Params.compatibility | default "0" ) }} - - - {{ else }} - - - {{ end }} - -   - -     - {{ if (eq .Section "entry") | or (eq .Section "wiki") | or (eq .Section "game") }} -   - {{ if (eq .Section "entry") }} - - {{ else if (eq .Section "game") }} - - {{ end }} - -     {{ range .Params.tags }} -     -     {{ end }} -    {{ else }} - -    {{ end }} - + {{- if .IsHome }}Homepage{{- else }}{{ .Title }}{{- end }} | {{ .Site.Title }} | Nintendo 3DS Emulator {{ if eq (getenv "GULP") "true" }} diff --git a/site/themes/citra-bs-theme/layouts/_default/meta.html b/site/themes/citra-bs-theme/layouts/_default/meta.html new file mode 100644 index 0000000..d50230e --- /dev/null +++ b/site/themes/citra-bs-theme/layouts/_default/meta.html @@ -0,0 +1,3 @@ + + + diff --git a/site/themes/citra-bs-theme/layouts/entry/meta.html b/site/themes/citra-bs-theme/layouts/entry/meta.html new file mode 100644 index 0000000..c89c850 --- /dev/null +++ b/site/themes/citra-bs-theme/layouts/entry/meta.html @@ -0,0 +1,8 @@ + + + + + +{{- range .Params.tags }} + +{{- end }} diff --git a/site/themes/citra-bs-theme/layouts/game/list.html b/site/themes/citra-bs-theme/layouts/game/list.html index b7ea199..ac0a103 100644 --- a/site/themes/citra-bs-theme/layouts/game/list.html +++ b/site/themes/citra-bs-theme/layouts/game/list.html @@ -24,15 +24,15 @@ - {{ range .Data.Pages }} - {{ $rating := index .Site.Data.compatibility ( string .Params.compatibility | default "0" ) }} - - - {{ .Params.title }} -
{{ $rating.name }} - {{ dateFormat "January 2, 2006" .Params.tested_date }} - - {{ end }} + {{ range .Data.Pages }} + {{- $rating := index .Site.Data.compatibility ( string .Params.compatibility | default "99" ) }} + + + {{ .Params.title }} +
{{ $rating.name }} + {{ dateFormat "January 2, 2006" .Params.testcase_date }} + + {{ end }} {{ end }} diff --git a/site/themes/citra-bs-theme/layouts/game/meta.html b/site/themes/citra-bs-theme/layouts/game/meta.html new file mode 100644 index 0000000..011d68b --- /dev/null +++ b/site/themes/citra-bs-theme/layouts/game/meta.html @@ -0,0 +1,10 @@ +{{- $rating := index .Site.Data.compatibility ( string .Params.compatibility | default "99" ) }} + + + + + + +{{- range .Params.tags }} + +{{- end }} diff --git a/site/themes/citra-bs-theme/layouts/game/single.html b/site/themes/citra-bs-theme/layouts/game/single.html index ddc5d5d..cd6ec52 100644 --- a/site/themes/citra-bs-theme/layouts/game/single.html +++ b/site/themes/citra-bs-theme/layouts/game/single.html @@ -1,7 +1,6 @@ {{ define "main" }} {{ $BaseURL := .Site.BaseURL }} {{ $gameName := .File.BaseFileName }} - {{ $rating := index .Site.Data.compatibility ( string .Params.compatibility | default "0" ) }}
@@ -36,6 +35,7 @@ + {{- $rating := index .Site.Data.compatibility ( string .Params.compatibility | default "99" ) }} @@ -65,32 +65,40 @@

{{ .Params.Description }}

+ {{ .Content }} -
-
-

Compatibility

-
Status
{{ $rating.name }}

{{ $rating.description }}
- - - - - - - - - - - - - - - - -
DateTested ByCitra VersionRating
{{ dateFormat "January 2, 2006" .Params.tested_date }}{{ .Params.tested_by }}{{ .Params.tested_version }}
{{ $rating.name }}
-
-
+ {{ if isset .Params "testcases" }} + {{ $siteCompatibility := .Site.Data.compatibility }} + {{ range .Params.testcases }} + {{ $testcase := . }} + {{ $rating := index $siteCompatibility ( string $testcase.compatibility | default "0" ) }} +
+
+

Compatibility

+ + + + + + + + + + + + + + + + + +
DateTested ByCitra VersionRating
{{ dateFormat "January 2, 2006" $testcase.date }}{{ $testcase.author }}{{ $testcase.version }}
{{ $rating.name }}
+
+
+ {{ end }} + {{ end }} {{ if (where (readDir "/static/savefiles") "Name" .File.BaseFileName) }}