landing page - use correct gitworkshop link

This commit is contained in:
DanConwayDev
2025-12-02 13:59:08 +00:00
parent 774d237fec
commit 96a75dedee
2 changed files with 28 additions and 3 deletions
+14 -2
View File
@@ -51,7 +51,6 @@ pub fn get_html(config: &Config) -> String {
base_css = get_base_css(),
relay_name = config.relay_name,
relay_description = config.relay_description,
domain = config.domain,
)
}
@@ -323,7 +322,7 @@ pub fn get_repo_html(config: &Config, npub: &str, identifier: &str) -> String {
<span class="client-name">gitworkshop.dev</span>
<span class="client-desc">Web-based repository browser</span>
</div>
<a href="https://gitworkshop.dev" target="_blank">Visit &rarr;</a>
<a id="gitworkshop-link" href="https://gitworkshop.dev" target="_blank">Visit &rarr;</a>
</div>
<div class="card client-card">
<div class="client-info">
@@ -342,6 +341,19 @@ pub fn get_repo_html(config: &Config, npub: &str, identifier: &str) -> String {
</div>
<div class="footer">Powered by <strong>ngit-grasp</strong></div>
</div>
<script>
// Detect protocol and construct gitworkshop link
const protocol = window.location.protocol; // 'http:' or 'https:'
const host = window.location.host; // 'domain.com' or 'domain.com:port'
// For http, use ws:// prefix and URL encode; for https, just use host (implies wss://)
let relayref = host;
if (protocol === 'http:') relayref = encodeURIComponent("ws://" + host);
// Construct gitworkshop link: gitworkshop.dev/npub/relayref/identifier
const gitworkshopLink = document.getElementById('gitworkshop-link');
gitworkshopLink.setAttribute('href', 'https://gitworkshop.dev/{npub}/' + relayref + '/{identifier}');
</script>
</body>
</html>"##,
base_css = get_base_css(),
+14 -1
View File
@@ -220,7 +220,7 @@
<p class="subtitle">{relay_description}</p>
<a href="https://gitworkshop.dev/relay/{domain}" class="browse-link" target="_blank">
<a id="browse-link" href="https://gitworkshop.dev" class="browse-link" target="_blank">
Browse Repositories on GitWorkshop.dev &rarr;
</a>
@@ -295,5 +295,18 @@
Powered by <strong>ngit-grasp</strong>
</div>
</main>
<script>
// Detect protocol and construct gitworkshop relay link
const protocol = window.location.protocol; // 'http:' or 'https:'
const host = window.location.host; // 'domain.com' or 'domain.com:port'
// For http, use ws:// prefix and URL encode; for https, just use host (implies wss://)
let relayref = host;
if (protocol === 'http:') relayref = encodeURIComponent("ws://" + host);
// Update the browse link to point to the relay on gitworkshop
const browseLink = document.getElementById('browse-link');
browseLink.setAttribute('href', 'https://gitworkshop.dev/relay/' + relayref);
</script>
</body>
</html>