Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ app-viewer/apps.json
.claude/settings.local.json
/app-viewer/details/
/app-viewer/authors/
/app-viewer/install/
/app-viewer/cards/
/app-viewer/sitemap.xml
/app-viewer/robots.txt
45 changes: 44 additions & 1 deletion app-viewer/app.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,22 @@

<body>
<div class="container py-4">
<div class="viewer-header mb-4">
<div class="viewer-header d-flex justify-content-between align-items-center mb-4">
<h1 class="main-title mb-0">
<a href="index.html" class="home-link" title="Tronbyt App Viewer home">
<img src="https://avatars.githubusercontent.com/u/200508996?s=48&v=4" alt="">
<span class="title-full">Tronbyt App Viewer</span>
<span class="title-short">App Viewer</span>
</a>
</h1>
<button type="button"
class="btn btn-secondary server-settings-button"
data-bs-toggle="modal"
data-bs-target="#tronbyt-server-modal"
title="Tronbyt Server settings">
<span class="connection-icon" aria-hidden="true"></span>
<span id="tronbyt-settings-label">Add Tronbyt Server</span>
</button>
</div>

<a href="index.html" class="btn btn-secondary mb-3">← Back
Expand All @@ -36,6 +44,41 @@ <h1 class="main-title mb-0">

<div id="app-content"></div>
</div>
<div class="modal fade" id="tronbyt-server-modal" tabindex="-1" aria-labelledby="tronbyt-server-modal-title" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<form id="tronbyt-server-form">
<div class="modal-header">
<h2 class="modal-title fs-5" id="tronbyt-server-modal-title">Tronbyt Server</h2>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<p class="server-intro">Install apps directly to your Tronbyt devices.</p>
<p class="server-requirement">Requires <a href="https://github.com/tronbyt/server/releases/" target="_blank" rel="noopener">Tronbyt Server v2.x.x</a> or later.</p>
<label for="tronbyt-server-url" class="form-label">Server address</label>
<input type="text"
inputmode="url"
class="form-control"
id="tronbyt-server-url"
autocomplete="url"
placeholder="e.g. 192.168.1.20:8000">
<p class="server-help mt-3 mb-2">Enter your Tronbyt Server address above and select Continue. Your server opens in a new tab: sign in if asked, and it comes straight back to the App Viewer.</p>
<div class="connection-primary-actions">
<div>
<button type="button" class="btn btn-secondary" id="clear-tronbyt-server">Clear</button>
<a class="btn btn-secondary" id="open-tronbyt-server" target="_blank" rel="noopener" hidden>Open Server</a>
</div>
<button type="submit" class="btn btn-success">Continue</button>
</div>
<div id="tronbyt-server-error" role="alert" aria-live="polite"></div>
<div id="connection-troubleshooting" class="connection-troubleshooting mt-3" hidden>
<p>Your Tronbyt Server hasn’t come back yet. Check the address is right and that you can sign in. If it showed its home page after you signed in, it needs updating to v2.x.x or later (if you’re not its admin, ask them).</p>
</div>
</div>
</form>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/marked/marked.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/dompurify@3.0.5/dist/purify.min.js"></script>
Expand Down
45 changes: 44 additions & 1 deletion app-viewer/author.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,22 @@

<body>
<div class="container py-4">
<div class="viewer-header mb-4">
<div class="viewer-header d-flex justify-content-between align-items-center mb-4">
<h1 class="main-title mb-0">
<a href="index.html" class="home-link" title="Tronbyt App Viewer home">
<img src="https://avatars.githubusercontent.com/u/200508996?s=48&v=4" alt="">
<span class="title-full">Tronbyt App Viewer</span>
<span class="title-short">App Viewer</span>
</a>
</h1>
<button type="button"
class="btn btn-secondary server-settings-button"
data-bs-toggle="modal"
data-bs-target="#tronbyt-server-modal"
title="Tronbyt Server settings">
<span class="connection-icon" aria-hidden="true"></span>
<span id="tronbyt-settings-label">Add Tronbyt Server</span>
</button>
</div>

<a href="index.html" class="btn btn-secondary mb-3">← Back to Apps</a>
Expand All @@ -35,6 +43,41 @@ <h1 class="main-title mb-0">

<div id="author-content"></div>
</div>
<div class="modal fade" id="tronbyt-server-modal" tabindex="-1" aria-labelledby="tronbyt-server-modal-title" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<form id="tronbyt-server-form">
<div class="modal-header">
<h2 class="modal-title fs-5" id="tronbyt-server-modal-title">Tronbyt Server</h2>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<p class="server-intro">Install apps directly to your Tronbyt devices.</p>
<p class="server-requirement">Requires <a href="https://github.com/tronbyt/server/releases/" target="_blank" rel="noopener">Tronbyt Server v2.x.x</a> or later.</p>
<label for="tronbyt-server-url" class="form-label">Server address</label>
<input type="text"
inputmode="url"
class="form-control"
id="tronbyt-server-url"
autocomplete="url"
placeholder="e.g. 192.168.1.20:8000">
<p class="server-help mt-3 mb-2">Enter your Tronbyt Server address above and select Continue. Your server opens in a new tab: sign in if asked, and it comes straight back to the App Viewer.</p>
<div class="connection-primary-actions">
<div>
<button type="button" class="btn btn-secondary" id="clear-tronbyt-server">Clear</button>
<a class="btn btn-secondary" id="open-tronbyt-server" target="_blank" rel="noopener" hidden>Open Server</a>
</div>
<button type="submit" class="btn btn-success">Continue</button>
</div>
<div id="tronbyt-server-error" role="alert" aria-live="polite"></div>
<div id="connection-troubleshooting" class="connection-troubleshooting mt-3" hidden>
<p>Your Tronbyt Server hasn’t come back yet. Check the address is right and that you can sign in. If it showed its home page after you signed in, it needs updating to v2.x.x or later (if you’re not its admin, ask them).</p>
</div>
</div>
</form>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
<script type="module" src="main.js"></script>
</body>
Expand Down
20 changes: 20 additions & 0 deletions app-viewer/generate-apps-json.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,20 @@ export function appPageUrl(app) {
return `${SITE_URL}details/${encodeURIComponent(app.name)}`;
}

// "Add to my Tronbyt" link for an app: apps.tronbyt.com/install/<app>. Anyone can share it. It is the app's details
// page, marked so the page carries on to adding the app: straight to the visitor's own Tronbyt Server's install page
// if one is verified in this browser (which only shows the app and asks which device), otherwise it asks for the
// server address first. Search engines are pointed at the details page.
export function installPageUrl(app) {
return `${SITE_URL}install/${encodeURIComponent(app.name)}`;
}

export function markAsInstallPage(detailsHtml) {
return detailsHtml.replace('</head>', ` <meta name="robots" content="noindex">
<meta name="tronbyt-install" content="add">
</head>`);
}

export function buildAppMetaTags(app, cardPath = SITE_CARD) {
const name = app.displayName || app.name;
const title = `${name} - Tronbyt App`;
Expand Down Expand Up @@ -541,6 +555,12 @@ function generateHtmlFiles(apps, cards) {
</div>`);
writeFileSync(join(detailsDir, `${app.name}.html`), appHtml);
}

const installDir = join(outputDir, 'install');
mkdirSync(installDir, { recursive: true });
for (const app of apps) {
writeFileSync(join(installDir, `${app.name}.html`), markAsInstallPage(readFileSync(join(detailsDir, `${app.name}.html`), 'utf8')));
}
}

function generateAuthorHtmlFiles(profiles, authorCards) {
Expand Down
8 changes: 8 additions & 0 deletions app-viewer/generate-apps-json.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
buildAppMetaTags,
buildAppPrerender,
buildAuthorPrerender,
markAsInstallPage,
buildSitemap,
escapeHtmlAttribute,
buildRobotsTxt,
Expand Down Expand Up @@ -129,3 +130,10 @@ test('repoints a home page card tag from the old site address', () => {
assert.equal(pointHomePageAtCard(html, 'cards/tronbyt-app-viewer-0123456789.png'),
'<meta property="og:image" content="https://apps.tronbyt.com/cards/tronbyt-app-viewer-0123456789.png">');
});

test('install/<app> pages are the details page, marked to carry on to adding the app and kept out of search', () => {
const page = markAsInstallPage('<html><head><title>Clock</title></head><body></body></html>');
assert.match(page, /<meta name="robots" content="noindex">/);
assert.match(page, /<meta name="tronbyt-install" content="add">\s*<\/head>/);
assert.match(page, /<title>Clock<\/title>/);
});
45 changes: 44 additions & 1 deletion app-viewer/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,22 @@

<body>
<div class="container py-4">
<div class="viewer-header mb-4">
<div class="viewer-header d-flex justify-content-between align-items-center mb-4">
<h1 class="main-title mb-0">
<a href="index.html" class="home-link" title="Tronbyt App Viewer home">
<img src="https://avatars.githubusercontent.com/u/200508996?s=48&v=4" alt="">
<span class="title-full">Tronbyt App Viewer</span>
<span class="title-short">App Viewer</span>
</a>
</h1>
<button type="button"
class="btn btn-secondary server-settings-button"
data-bs-toggle="modal"
data-bs-target="#tronbyt-server-modal"
title="Tronbyt Server settings">
<span class="connection-icon" aria-hidden="true"></span>
<span id="tronbyt-settings-label">Add Tronbyt Server</span>
</button>
</div>

<div class="viewer-filters mb-4">
Expand Down Expand Up @@ -91,6 +99,41 @@ <h1 class="main-title mb-0">

<div id="apps-list" class="row g-4"></div>
</div>
<div class="modal fade" id="tronbyt-server-modal" tabindex="-1" aria-labelledby="tronbyt-server-modal-title" aria-hidden="true">
<div class="modal-dialog">
<div class="modal-content">
<form id="tronbyt-server-form">
<div class="modal-header">
<h2 class="modal-title fs-5" id="tronbyt-server-modal-title">Tronbyt Server</h2>
<button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
</div>
<div class="modal-body">
<p class="server-intro">Install apps directly to your Tronbyt devices.</p>
<p class="server-requirement">Requires <a href="https://github.com/tronbyt/server/releases/" target="_blank" rel="noopener">Tronbyt Server v2.x.x</a> or later.</p>
<label for="tronbyt-server-url" class="form-label">Server address</label>
<input type="text"
inputmode="url"
class="form-control"
id="tronbyt-server-url"
autocomplete="url"
placeholder="e.g. 192.168.1.20:8000">
<p class="server-help mt-3 mb-2">Enter your Tronbyt Server address above and select Continue. Your server opens in a new tab: sign in if asked, and it comes straight back to the App Viewer.</p>
<div class="connection-primary-actions">
<div>
<button type="button" class="btn btn-secondary" id="clear-tronbyt-server">Clear</button>
<a class="btn btn-secondary" id="open-tronbyt-server" target="_blank" rel="noopener" hidden>Open Server</a>
</div>
<button type="submit" class="btn btn-success">Continue</button>
</div>
<div id="tronbyt-server-error" role="alert" aria-live="polite"></div>
<div id="connection-troubleshooting" class="connection-troubleshooting mt-3" hidden>
<p>Your Tronbyt Server hasn’t come back yet. Check the address is right and that you can sign in. If it showed its home page after you signed in, it needs updating to v2.x.x or later (if you’re not its admin, ask them).</p>
</div>
</div>
</form>
</div>
</div>
</div>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
<script type="module" src="main.js"></script>
</body>
Expand Down
16 changes: 16 additions & 0 deletions app-viewer/main-navigation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ globalThis.requestAnimationFrame = callback => {
const {
buildAppSourceUrl,
filterAndSortApps,
installLinkUrl,
normalizeCatalogueMetadata,
rememberViewerScroll,
restoreViewerScroll,
Expand Down Expand Up @@ -184,3 +185,18 @@ test('the shared link is the page alone', () => {
'https://apps.tronbyt.com/authors/robert-ison'
);
});

test('builds the install link from an app page address', () => {
assert.equal(
installLinkUrl('https://apps.tronbyt.com/details/uptime_kuma.html?display=wide&scroll=2109#readme'),
'https://apps.tronbyt.com/install/uptime_kuma'
);
assert.equal(
installLinkUrl('https://saltedlolly.github.io/tronbyt-apps/details/birthdays'),
'https://saltedlolly.github.io/tronbyt-apps/install/birthdays'
);
assert.equal(
installLinkUrl('https://apps.tronbyt.com/install/birthdays?add=1'),
'https://apps.tronbyt.com/install/birthdays'
);
});
Loading