Added [[testcases]] that are stored in game dat file, instead of single variables. Split metadata out into a template file for easier modification.
This commit is contained in:
parent
672696155d
commit
13e6155ed1
|
@ -6,6 +6,7 @@ const logger = require('winston');
|
||||||
|
|
||||||
const sanitizeHtml = require('sanitize-html');
|
const sanitizeHtml = require('sanitize-html');
|
||||||
|
|
||||||
|
const toml = require('toml');
|
||||||
const blackfriday = require('./blackfriday.js');
|
const blackfriday = require('./blackfriday.js');
|
||||||
|
|
||||||
const del = require('delete');
|
const del = require('delete');
|
||||||
|
@ -27,9 +28,11 @@ function url(title) {
|
||||||
function gitPull(directory, repository) {
|
function gitPull(directory, repository) {
|
||||||
if (fs.existsSync(directory)) {
|
if (fs.existsSync(directory)) {
|
||||||
logger.info(`Fetching latest from Github : ${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 {
|
} else {
|
||||||
logger.info(`Cloning repository from Github : ${directory}`);
|
logger.info(`Cloning repository from Github : ${directory}`);
|
||||||
|
logger.info(`git clone ${repository}`);
|
||||||
exec(`git clone ${repository}`);
|
exec(`git clone ${repository}`);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -39,17 +42,6 @@ function getDirectories (srcpath) {
|
||||||
.filter(file => fs.lstatSync(path.join(srcpath, file)).isDirectory())
|
.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.
|
// Fetch game information stored in Github repository.
|
||||||
gitPull(inputDirectoryGame, 'https://github.com/citra-emu/citra-games-wiki.git');
|
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')}`);
|
fsextra.copySync(`${inputDirectorySavefilesGame}/${file}`, `${outputDirectorySavefilesGame}/${file.replace('.zip', '.zip')}`);
|
||||||
} else if (path.extname(file) == '.dat') {
|
} else if (path.extname(file) == '.dat') {
|
||||||
// Store the contents of the file in memory for adding it into the markdown later.
|
// Store the contents of the file in memory for adding it into the markdown later.
|
||||||
savefileMetadataContents.push({
|
savefileMetadataContents.push({ filename: file.replace('.dat', '.zip'), contents: fs.readFileSync(`${inputDirectorySavefilesGame}/${file}`, 'utf8') });
|
||||||
filename: file.replace('.dat', '.zip'),
|
|
||||||
contents: fs.readFileSync(`${inputDirectorySavefilesGame}/${file}`, 'utf8').trimNewline()
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -150,14 +139,28 @@ try {
|
||||||
var stats = fs.statSync(`${inputDirectoryGame}/${game}/game.dat`);
|
var stats = fs.statSync(`${inputDirectoryGame}/${game}/game.dat`);
|
||||||
let modified = new Date(util.inspect(stats.mtime));
|
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 = "";
|
var wikiContents = "";
|
||||||
let wikiPathGame = `${inputDirectoryWiki}/${game}.md`;
|
let wikiPathGame = `${inputDirectoryWiki}/${game}.md`;
|
||||||
if (fs.existsSync(wikiPathGame)) {
|
if (fs.existsSync(wikiPathGame)) {
|
||||||
wikiContents = fs.readFileSync(wikiPathGame, 'utf8').trimNewline();
|
wikiContents = fs.readFileSync(wikiPathGame, 'utf8');
|
||||||
} else {
|
} else {
|
||||||
wikiContents = "## No wiki exists yet for this game.";
|
wikiContents = "No wiki exists yet for this game.";
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fix Blackfriday markdown rendering differences.
|
// Fix Blackfriday markdown rendering differences.
|
||||||
|
@ -167,14 +170,13 @@ try {
|
||||||
// Read all savefiles from array and copy them into the markdown.
|
// Read all savefiles from array and copy them into the markdown.
|
||||||
savefileMetadataContents.forEach(function(savefile) {
|
savefileMetadataContents.forEach(function(savefile) {
|
||||||
let modified = new Date(util.inspect(stats.mtime));
|
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);
|
fs.writeFileSync(`${outputDirectoryMd}/${game}.md`, output);
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
logger.error(`${game} failed to generate: ${ex}`);
|
logger.error(`${game} failed to generate: ${ex}`);
|
||||||
logger.error(ex);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
} catch (ex) {
|
} catch (ex) {
|
||||||
|
|
|
@ -11,6 +11,7 @@
|
||||||
"rimraf": "^2.6.1",
|
"rimraf": "^2.6.1",
|
||||||
"sanitize-html": "^1.14.1",
|
"sanitize-html": "^1.14.1",
|
||||||
"sync-exec": "^0.6.2",
|
"sync-exec": "^0.6.2",
|
||||||
|
"toml": "^2.3.2",
|
||||||
"winston": "^2.2.0"
|
"winston": "^2.2.0"
|
||||||
},
|
},
|
||||||
"preferGlobal": false,
|
"preferGlobal": false,
|
||||||
|
|
|
@ -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." },
|
"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." },
|
"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." },
|
"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." }
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,10 @@
|
||||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||||
<meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
|
<meta name="viewport" content="width=device-width,minimum-scale=1,initial-scale=1">
|
||||||
<meta name="theme-color" content="#FF8E03">
|
<meta name="theme-color" content="#FF8E03">
|
||||||
|
<meta property="og:title" content="{{ if ne .URL "/" }}{{ .Title }} · {{ end }}{{ .Site.Title }}" />
|
||||||
|
<meta property="og:site_name" content="{{ .Site.Title }}" />
|
||||||
|
<meta property="og:url" content="{{ .Permalink }}" />
|
||||||
|
{{ .Render "meta" }}
|
||||||
|
|
||||||
{{ .Hugo.Generator }}
|
{{ .Hugo.Generator }}
|
||||||
|
|
||||||
|
@ -17,38 +21,7 @@
|
||||||
<link href="{{ .Site.BaseURL }}index.xml" rel="feed" type="application/rss+xml" title="{{ .Site.Title }}" />
|
<link href="{{ .Site.BaseURL }}index.xml" rel="feed" type="application/rss+xml" title="{{ .Site.Title }}" />
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
||||||
<title>{{ if .IsHome }}Homepage{{ else }}{{ .Title }}{{ end }} | {{ .Site.Title }} | Nintendo 3DS Emulator</title>
|
<title>{{- if .IsHome }}Homepage{{- else }}{{ .Title }}{{- end }} | {{ .Site.Title }} | Nintendo 3DS Emulator</title>
|
||||||
|
|
||||||
<!-- Meta Properties -->
|
|
||||||
<meta property="og:title" content="{{ if ne .URL "/" }} {{ .Title }} · {{ end }} {{ .Site.Title }}" />
|
|
||||||
|
|
||||||
{{ if (eq .Section "game") }}
|
|
||||||
{{ $rating := index .Site.Data.compatibility ( string .Params.compatibility | default "0" ) }}
|
|
||||||
<meta property="og:description" content="{{ $rating.name }} - {{ $rating.description }}" />
|
|
||||||
<meta name="description" content="{{ $rating.name }} - {{ $rating.description }}">
|
|
||||||
{{ else }}
|
|
||||||
<meta property="og:description" content="{{ with .Description }}{{ . }}{{ else }}{{ .Summary }}{{ end }}" />
|
|
||||||
<meta name="description" content="{{ with .Description }}{{ . }}{{ else }}{{ .Summary }}{{ end }}">
|
|
||||||
{{ end }}
|
|
||||||
|
|
||||||
<meta property="og:site_name" content="{{ .Site.Title }}" />
|
|
||||||
<meta property="og:url" content="{{ .Permalink }}" />
|
|
||||||
|
|
||||||
{{ if (eq .Section "entry") | or (eq .Section "wiki") | or (eq .Section "game") }}
|
|
||||||
<meta property="og:type" content="article" />
|
|
||||||
{{ if (eq .Section "entry") }}
|
|
||||||
<meta property="og:image" content="{{ .Site.BaseURL }}images/banners/{{ .Params.Banner | default (print .File.BaseFileName ".png") }}" />
|
|
||||||
{{ else if (eq .Section "game") }}
|
|
||||||
<meta property="og:image" content="{{ .Site.BaseURL }}images/game/icons/{{ .File.BaseFileName }}.png" />
|
|
||||||
{{ end }}
|
|
||||||
<meta property="og:article:published_time" content="{{ .Date.Format "2006-01-02T15:04:05Z07:00" | safeHTML }}" />
|
|
||||||
{{ range .Params.tags }}
|
|
||||||
<meta property="og:article:tag" content="{{ . }}" />
|
|
||||||
{{ end }}
|
|
||||||
{{ else }}
|
|
||||||
<meta property="og:type" content="website" />
|
|
||||||
{{ end }}
|
|
||||||
<!-- End Meta Properties -->
|
|
||||||
|
|
||||||
{{ if eq (getenv "GULP") "true" }}
|
{{ if eq (getenv "GULP") "true" }}
|
||||||
<link rel="stylesheet" href="/css/main.css"/>
|
<link rel="stylesheet" href="/css/main.css"/>
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
<meta property="og:description" content="{{ with .Description }}{{ . }}{{ else }}{{ .Summary }}{{ end }}" />
|
||||||
|
<meta name="description" content="{{ with .Description }}{{ . }}{{ else }}{{ .Summary }}{{ end }}" />
|
||||||
|
<meta property="og:type" content="website" />
|
|
@ -0,0 +1,8 @@
|
||||||
|
<meta property="og:description" content="{{ with .Description }}{{ . }}{{ else }}{{ .Summary }}{{ end }}" />
|
||||||
|
<meta name="description" content="{{ with .Description }}{{ . }}{{ else }}{{ .Summary }}{{ end }}" />
|
||||||
|
<meta property="og:type" content="article" />
|
||||||
|
<meta property="og:image" content="{{ .Site.BaseURL }}images/banners/{{ .Params.Banner | default (print .File.BaseFileName ".png") }}" />
|
||||||
|
<meta property="og:article:published_time" content="{{ .Date.Format "2006-01-02T15:04:05Z07:00" | safeHTML }}" />
|
||||||
|
{{- range .Params.tags }}
|
||||||
|
<meta property="og:article:tag" content="{{ . }}" />
|
||||||
|
{{- end }}
|
|
@ -24,15 +24,15 @@
|
||||||
</tr>
|
</tr>
|
||||||
</thead>
|
</thead>
|
||||||
<tbody>
|
<tbody>
|
||||||
{{ range .Data.Pages }}
|
{{ range .Data.Pages }}
|
||||||
{{ $rating := index .Site.Data.compatibility ( string .Params.compatibility | default "0" ) }}
|
{{- $rating := index .Site.Data.compatibility ( string .Params.compatibility | default "99" ) }}
|
||||||
<tr>
|
<tr>
|
||||||
<td style="width: 55px;"><img class="img-responsive game-icon-list" src="{{ .Site.BaseURL }}images/game/icons/{{ default (print .File.BaseFileName ".png") }}" /></td>
|
<td style="width: 55px;"><img class="img-responsive game-icon-list" src="{{ .Site.BaseURL }}images/game/icons/{{ default (print .File.BaseFileName ".png") }}" /></td>
|
||||||
<td><a href="{{ .Permalink }}">{{ .Params.title }}</a></td>
|
<td><a href="{{ .Permalink }}">{{ .Params.title }}</a></td>
|
||||||
<td class="compatibility-row"><div class="square-icon compatibility-{{ replace ($rating.name | urlize) "/" "" }}" style="background-color: {{ $rating.color }}"></div> {{ $rating.name }}</td>
|
<td class="compatibility-row"><div class="square-icon compatibility-{{ replace ($rating.name | urlize) "/" "" }}" style="background-color: {{ $rating.color }}"></div> {{ $rating.name }}</td>
|
||||||
<td>{{ dateFormat "January 2, 2006" .Params.tested_date }}</td>
|
<td>{{ dateFormat "January 2, 2006" .Params.testcase_date }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</tbody>
|
</tbody>
|
||||||
</table>
|
</table>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
|
|
|
@ -0,0 +1,10 @@
|
||||||
|
{{- $rating := index .Site.Data.compatibility ( string .Params.compatibility | default "99" ) }}
|
||||||
|
<meta property="og:description" content="{{ $rating.name }} - {{ $rating.description }}" />
|
||||||
|
<meta name="description" content="{{ $rating.name }} - {{ $rating.description }}" />
|
||||||
|
|
||||||
|
<meta property="og:type" content="article" />
|
||||||
|
<meta property="og:image" content="{{ .Site.BaseURL }}images/game/icons/{{ .File.BaseFileName }}.png" />
|
||||||
|
<meta property="og:article:published_time" content="{{ .Date.Format "2006-01-02T15:04:05Z07:00" | safeHTML }}" />
|
||||||
|
{{- range .Params.tags }}
|
||||||
|
<meta property="og:article:tag" content="{{ . }}" />
|
||||||
|
{{- end }}
|
|
@ -1,7 +1,6 @@
|
||||||
{{ define "main" }}
|
{{ define "main" }}
|
||||||
{{ $BaseURL := .Site.BaseURL }}
|
{{ $BaseURL := .Site.BaseURL }}
|
||||||
{{ $gameName := .File.BaseFileName }}
|
{{ $gameName := .File.BaseFileName }}
|
||||||
{{ $rating := index .Site.Data.compatibility ( string .Params.compatibility | default "0" ) }}
|
|
||||||
|
|
||||||
<div class="alert alert-info">
|
<div class="alert alert-info">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
@ -36,6 +35,7 @@
|
||||||
<table class="table table-responsive table-striped table-bordered">
|
<table class="table table-responsive table-striped table-bordered">
|
||||||
<tbody>
|
<tbody>
|
||||||
<tr>
|
<tr>
|
||||||
|
{{- $rating := index .Site.Data.compatibility ( string .Params.compatibility | default "99" ) }}
|
||||||
<td style="width: 100px;">Status</td>
|
<td style="width: 100px;">Status</td>
|
||||||
<td><b><div class="square-icon" style="background-color: {{ $rating.color }}"></div> {{ $rating.name }}</b><br />{{ $rating.description }}</td>
|
<td><b><div class="square-icon" style="background-color: {{ $rating.color }}"></div> {{ $rating.name }}</b><br />{{ $rating.description }}</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -65,32 +65,40 @@
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p>{{ .Params.Description }}</p>
|
<p>{{ .Params.Description }}</p>
|
||||||
|
|
||||||
{{ .Content }}
|
{{ .Content }}
|
||||||
|
|
||||||
<!-- Compatibility -->
|
<!-- Compatibility -->
|
||||||
<div class="row">
|
{{ if isset .Params "testcases" }}
|
||||||
<div class="col-md-12">
|
{{ $siteCompatibility := .Site.Data.compatibility }}
|
||||||
<h2>Compatibility</h2>
|
{{ range .Params.testcases }}
|
||||||
<table class="table table-responsive table-striped">
|
{{ $testcase := . }}
|
||||||
<thead>
|
{{ $rating := index $siteCompatibility ( string $testcase.compatibility | default "0" ) }}
|
||||||
<tr>
|
<div class="row">
|
||||||
<th>Date</th>
|
<div class="col-md-12">
|
||||||
<th>Tested By</th>
|
<h2>Compatibility</h2>
|
||||||
<th>Citra Version</th>
|
<table class="table table-responsive table-striped">
|
||||||
<th>Rating</th>
|
<thead>
|
||||||
</tr>
|
<tr>
|
||||||
</thead>
|
<th>Date</th>
|
||||||
<tbody>
|
<th>Tested By</th>
|
||||||
<tr>
|
<th>Citra Version</th>
|
||||||
<td>{{ dateFormat "January 2, 2006" .Params.tested_date }}</td>
|
<th>Rating</th>
|
||||||
<td><a href="https://community.citra-emu.org/u/{{ .Params.tested_by }}/summary">{{ .Params.tested_by }}</a></td>
|
</tr>
|
||||||
<td>{{ .Params.tested_version }}</td>
|
</thead>
|
||||||
<td><b><div class="square-icon" style="background-color: {{ $rating.color }}"></div> {{ $rating.name }}</b></td>
|
<tbody>
|
||||||
</tr>
|
<tr>
|
||||||
</tbody>
|
<td>{{ dateFormat "January 2, 2006" $testcase.date }}</td>
|
||||||
</table>
|
<td><a href="https://community.citra-emu.org/u/{{ $testcase.owner }}/summary">{{ $testcase.author }}</a></td>
|
||||||
</div>
|
<td>{{ $testcase.version }}</td>
|
||||||
</div>
|
<td><b><div class="square-icon" style="background-color: {{ $rating.color }}"></div> {{ $rating.name }}</b></td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
{{ end }}
|
||||||
|
{{ end }}
|
||||||
|
|
||||||
{{ if (where (readDir "/static/savefiles") "Name" .File.BaseFileName) }}
|
{{ if (where (readDir "/static/savefiles") "Name" .File.BaseFileName) }}
|
||||||
<div class="row">
|
<div class="row">
|
||||||
|
|
Reference in New Issue