Added gameInfo page using markdown, removed old game sub-pages and directories
This commit is contained in:
parent
351a5b87bf
commit
11245462f0
|
@ -88,16 +88,10 @@ def player_settings(game):
|
||||||
return render_template(f"player-settings.html", game=game)
|
return render_template(f"player-settings.html", game=game)
|
||||||
|
|
||||||
|
|
||||||
# Game sub-pages
|
# Game Info Pages
|
||||||
@app.route('/games/<string:game>/<string:page>')
|
@app.route('/games/<string:game>/info/<string:lang>')
|
||||||
def game_pages(game, page):
|
def game_page(game, lang):
|
||||||
return render_template(f"/games/{game}/{page}.html")
|
return render_template('gameInfo.html', game=game, lang=lang)
|
||||||
|
|
||||||
|
|
||||||
# Game landing pages
|
|
||||||
@app.route('/games/<game>')
|
|
||||||
def game_page(game):
|
|
||||||
return render_template(f"/games/{game}/{game}.html")
|
|
||||||
|
|
||||||
|
|
||||||
# List of supported games
|
# List of supported games
|
||||||
|
@ -107,7 +101,7 @@ def games():
|
||||||
for game, world in AutoWorldRegister.world_types.items():
|
for game, world in AutoWorldRegister.world_types.items():
|
||||||
if not world.hidden:
|
if not world.hidden:
|
||||||
worlds[game] = world.__doc__ if world.__doc__ else "No description provided."
|
worlds[game] = world.__doc__ if world.__doc__ else "No description provided."
|
||||||
return render_template("games/games.html", worlds=worlds)
|
return render_template("supportedGames.html", worlds=worlds)
|
||||||
|
|
||||||
|
|
||||||
@app.route('/tutorial/<string:game>/<string:file>/<string:lang>')
|
@app.route('/tutorial/<string:game>/<string:file>/<string:lang>')
|
||||||
|
|
|
@ -0,0 +1,54 @@
|
||||||
|
window.addEventListener('load', () => {
|
||||||
|
const gameInfo = document.getElementById('game-info');
|
||||||
|
new Promise((resolve, reject) => {
|
||||||
|
const ajax = new XMLHttpRequest();
|
||||||
|
ajax.onreadystatechange = () => {
|
||||||
|
if (ajax.readyState !== 4) { return; }
|
||||||
|
if (ajax.status === 404) {
|
||||||
|
reject("Sorry, this game's info page is not available in that language yet.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (ajax.status !== 200) {
|
||||||
|
reject("Something went wrong while loading the info page.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
resolve(ajax.responseText);
|
||||||
|
};
|
||||||
|
ajax.open('GET', `${window.location.origin}/static/assets/gameInfo/` +
|
||||||
|
`${gameInfo.getAttribute('data-lang')}_${gameInfo.getAttribute('data-game')}.md`, true);
|
||||||
|
ajax.send();
|
||||||
|
}).then((results) => {
|
||||||
|
// Populate page with HTML generated from markdown
|
||||||
|
showdown.setOption('tables', true);
|
||||||
|
showdown.setOption('strikethrough', true);
|
||||||
|
showdown.setOption('simpleLineBreaks', true);
|
||||||
|
showdown.setOption('literalMidWordUnderscores', true);
|
||||||
|
gameInfo.innerHTML += (new showdown.Converter()).makeHtml(results);
|
||||||
|
adjustHeaderWidth();
|
||||||
|
|
||||||
|
// Reset the id of all header divs to something nicer
|
||||||
|
const headers = Array.from(document.querySelectorAll('h1, h2, h3, h4, h5, h6'));
|
||||||
|
const scrollTargetIndex = window.location.href.search(/#[A-z0-9-_]*$/);
|
||||||
|
for (let i=0; i < headers.length; i++){
|
||||||
|
const headerId = headers[i].innerText.replace(/[ ]/g,'-').toLowerCase()
|
||||||
|
headers[i].setAttribute('id', headerId);
|
||||||
|
headers[i].addEventListener('click', () =>
|
||||||
|
window.location.href = window.location.href.substring(0, scrollTargetIndex) + `#${headerId}`);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Manually scroll the user to the appropriate header if anchor navigation is used
|
||||||
|
if (scrollTargetIndex > -1) {
|
||||||
|
try{
|
||||||
|
const scrollTarget = window.location.href.substring(scrollTargetIndex + 1);
|
||||||
|
document.getElementById(scrollTarget).scrollIntoView({ behavior: "smooth" });
|
||||||
|
} catch(error) {
|
||||||
|
console.error(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}).catch((error) => {
|
||||||
|
console.error(error);
|
||||||
|
gameInfo.innerHTML =
|
||||||
|
`<h2>This page is out of logic!</h2>
|
||||||
|
<h3>Click <a href="${window.location.origin}">here</a> to return to safety.</h3>`;
|
||||||
|
});
|
||||||
|
});
|
|
@ -0,0 +1 @@
|
||||||
|
# Link to the Past Game Info
|
|
@ -0,0 +1 @@
|
||||||
|
# Factorio Game Info
|
|
@ -0,0 +1 @@
|
||||||
|
# Subnautica Game Info
|
|
@ -0,0 +1,14 @@
|
||||||
|
{% extends 'pageWrapper.html' %}
|
||||||
|
|
||||||
|
{% block head %}
|
||||||
|
<title>{{ game }} Info</title>
|
||||||
|
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename="styles/markdown.css") }}" />
|
||||||
|
<script type="application/ecmascript" src="{{ url_for('static', filename="assets/gameInfo.js") }}"></script>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
{% block body %}
|
||||||
|
{% include 'header/grassHeader.html' %}
|
||||||
|
<div id="game-info" class="markdown" data-game="{{ game }}">
|
||||||
|
<!-- Populated my JS / MD -->
|
||||||
|
</div>
|
||||||
|
{% endblock %}
|
|
@ -1,15 +0,0 @@
|
||||||
{% extends 'pageWrapper.html' %}
|
|
||||||
|
|
||||||
{% block head %}
|
|
||||||
<title>A Link to the Past</title>
|
|
||||||
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename="styles/zelda3/zelda3.css") }}" />
|
|
||||||
<script type="application/ecmascript" src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
|
|
||||||
<script type="application/ecmascript" src="{{ url_for('static', filename="assets/js-yaml.min.js") }}"></script>
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block body %}
|
|
||||||
{% include 'header/grassHeader.html' %}
|
|
||||||
<div id="zelda3">
|
|
||||||
Coming Soon™
|
|
||||||
</div>
|
|
||||||
{% endblock %}
|
|
|
@ -1,15 +0,0 @@
|
||||||
{% extends 'pageWrapper.html' %}
|
|
||||||
|
|
||||||
{% block head %}
|
|
||||||
<title>Factorio</title>
|
|
||||||
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename="styles/factorio/factorio.css") }}" />
|
|
||||||
<script type="application/ecmascript" src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
|
|
||||||
<script type="application/ecmascript" src="{{ url_for('static', filename="assets/js-yaml.min.js") }}"></script>
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block body %}
|
|
||||||
{% include 'header/grassHeader.html' %}
|
|
||||||
<div id="factorio">
|
|
||||||
Coming Soon™
|
|
||||||
</div>
|
|
||||||
{% endblock %}
|
|
|
@ -1,15 +0,0 @@
|
||||||
{% extends 'pageWrapper.html' %}
|
|
||||||
|
|
||||||
{% block head %}
|
|
||||||
<title>Minecraft</title>
|
|
||||||
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename="styles/minecraft/minecraft.css") }}" />
|
|
||||||
<script type="application/ecmascript" src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
|
|
||||||
<script type="application/ecmascript" src="{{ url_for('static', filename="assets/js-yaml.min.js") }}"></script>
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block body %}
|
|
||||||
{% include 'header/grassHeader.html' %}
|
|
||||||
<div id="minecraft">
|
|
||||||
Coming Soon™
|
|
||||||
</div>
|
|
||||||
{% endblock %}
|
|
|
@ -1,15 +0,0 @@
|
||||||
{% extends 'pageWrapper.html' %}
|
|
||||||
|
|
||||||
{% block head %}
|
|
||||||
<title>Subnautica</title>
|
|
||||||
<link rel="stylesheet" type="text/css" href="{{ url_for('static', filename="styles/subnautica/subnautica.css") }}" />
|
|
||||||
<script type="application/ecmascript" src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
|
|
||||||
<script type="application/ecmascript" src="{{ url_for('static', filename="assets/js-yaml.min.js") }}"></script>
|
|
||||||
{% endblock %}
|
|
||||||
|
|
||||||
{% block body %}
|
|
||||||
{% include 'header/grassHeader.html' %}
|
|
||||||
<div id="subnautica">
|
|
||||||
Coming Soon™
|
|
||||||
</div>
|
|
||||||
{% endblock %}
|
|
Loading…
Reference in New Issue