Let user define README file in apps.json. Only show Read More link if one present

pull/240/head
Paul Cockrell 2020-04-06 18:29:34 +01:00
parent f384d01c34
commit 7df6bafdf9
2 changed files with 7 additions and 2 deletions

View File

@ -898,6 +898,7 @@
"tags": "clock,mario,retro",
"type": "clock",
"allow_emulator":true,
"readme": "README.md",
"storage": [
{"name":"marioclock.app.js","url":"marioclock-app.js"},
{"name":"marioclock.img","url":"marioclock-icon.js","evaluate":true}

View File

@ -23,13 +23,17 @@ function showChangeLog(appid) {
httpGet(`apps/${appid}/ChangeLog`).
then(show).catch(()=>show("No Change Log available"));
}
function hasReadme(appid) {
var app = appNameToApp(appid);
return app.readme;
}
function showReadme(appid) {
var app = appNameToApp(appid);
function show(contents) {
if (!contents) return;
showPrompt(app.name + " Documentation", marked(contents), {ok: true}, false).catch(() => {});
}
httpGet(`apps/${appid}/README.md`).then(show).catch(()=>show("No more information available."));
httpGet(`apps/${appid}/${app.readme}`).then(show).catch(()=>show("Failed to load README."));
}
function handleCustomApp(appTemplate) {
// Pops up an IFRAME that allows an app to be customised
@ -190,7 +194,7 @@ function refreshLibrary() {
</div>
<div class="tile-content">
<p class="tile-title text-bold">${escapeHtml(app.name)} ${versionInfo}</p>
<p class="tile-subtitle">${escapeHtml(app.description)}<br/>${readme}</p>
<p class="tile-subtitle">${escapeHtml(app.description)}${hasReadme ? `<br/>${readme}` : ''}</p>
<a href="https://github.com/espruino/BangleApps/tree/master/apps/${app.id}" target="_blank" class="link-github"><img src="img/github-icon-sml.png" alt="See the code on GitHub"/></a>
</div>
<div class="tile-action">