Skip to content

Commit

Permalink
Merge pull request #163 from ssb-ngi-pointer/ssb-uri-tmpl
Browse files Browse the repository at this point in the history
refactor templates that have ssb uri links
  • Loading branch information
staltz authored Apr 19, 2021
2 parents 951711d + 0f11956 commit 0e5b2f3
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 22 deletions.
File renamed without changes.
9 changes: 5 additions & 4 deletions web/assets/autoredirect.js → web/assets/invite-uri.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,12 @@ window.addEventListener('focus', () => {
const waitingElem = document.getElementById('waiting');
const anchorElem = document.getElementById('join-room-uri');
anchorElem.onclick = function handleURI(ev) {
const ssbUri = ev.target.dataset.href;
const fallbackUrl = ev.target.dataset.hrefFallback;
ev.preventDefault();
const ssbUri = anchorElem.href;
const fallbackUrl = anchorElem.dataset.hrefFallback;
waitingElem.classList.remove('hidden');
setTimeout(function () {
if (hasFocus) window.location = fallbackUrl;
if (hasFocus) window.location.replace(fallbackUrl);
}, 5000);
window.location = ssbUri;
window.location.replace(ssbUri);
};
2 changes: 1 addition & 1 deletion web/handlers/auth_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -424,7 +424,7 @@ func TestAuthWithSSBServerInitHappyPath(t *testing.T) {

jsFile, has := html.Find("script").Attr("src")
a.True(has, "should have client code")
a.Equal("/assets/login-events.js", jsFile)
a.Equal("/assets/auth-withssb-uri.js", jsFile)

serverChallenge, has := html.Find("#challenge").Attr("data-sc")
a.True(has, "should have server challenge")
Expand Down
9 changes: 2 additions & 7 deletions web/handlers/invites_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,20 +76,15 @@ func TestInviteShowAcceptForm(t *testing.T) {
{"title", "InviteFacadeTitle"},
})

// Empty href
joinHref, ok := doc.Find("#join-room-uri").Attr("href")
a.Equal("#", joinHref)
a.True(ok)

// Fallback URL in data-href-fallback
fallbackURL := ts.URLTo(router.CompleteInviteFacadeFallback, "token", testToken)
want := fallbackURL.Path + "?" + fallbackURL.RawQuery
joinDataHrefFallback, ok := doc.Find("#join-room-uri").Attr("data-href-fallback")
a.Equal(want, joinDataHrefFallback)
a.True(ok)

// ssb-uri in data-href
joinDataHref, ok := doc.Find("#join-room-uri").Attr("data-href")
// ssb-uri in href
joinDataHref, ok := doc.Find("#join-room-uri").Attr("href")
a.True(ok)
joinURI, err := url.Parse(joinDataHref)
r.NoError(err)
Expand Down
10 changes: 7 additions & 3 deletions web/i18n/defaults/active.en.toml
Original file line number Diff line number Diff line change
Expand Up @@ -152,18 +152,22 @@ InviteFacadeTitle = "Join Room"
InviteFacadeWelcome = "You have permission to become a member of this room because someone has shared this invite with you."
InviteFacadeInstruct = "To claim the invite, press the button below which will open a compatible SSB app, if it's installed."
InviteFacadeJoin = "Join this room"
InviteFacadeWaiting = "Opening SSB app"
InviteFacadeInstructQR = "If your SSB app is on another device, you can scan the following QR code to claim your invite on that device:"

InviteFacadeFallbackWelcome = "Are you new to SSB? It seems you don't have an SSB app capable of understanding that link. You can install one of these apps:"
InviteFacadeFallbackManyverse = "Install Manyverse"
InviteFacadeFallbackInsertID = "Insert SSB ID"

InviteInsertWelcome = "You can claim your invite by inserting your SSB ID below. After that, you'll be able to connect to the room in your SSB app."

InviteConsumedTitle = "Invite accepted!"
InviteConsumedWelcome = "You are now a member of this room. If you need a multiserver address to connect to the room, you can copy-paste the one below:"

# ssb uri links
###############

SSBURIOpening = "Opening SSB app"
SSBURIFailureWelcome = "Are you new to SSB? It seems you don't have an SSB app capable of understanding that link. You can install one of these apps:"
SSBURIFailureInstallManyverse = "Install Manyverse"

# notices (mini-CMS)
####################

Expand Down
2 changes: 1 addition & 1 deletion web/templates/auth/withssb_server_start.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@

{{if not .IsSolvingRemotely}}
<div id="challenge" class="hidden" data-sc="{{.ServerChallenge}}"></div>
<script src="/assets/login-events.js"></script>
<script src="/assets/auth-withssb-uri.js"></script>
{{end}}
{{end}}
4 changes: 2 additions & 2 deletions web/templates/invite/facade-fallback.tmpl
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
{{ define "title" }}{{ i18n "InviteFacadeTitle" }}{{ end }}
{{ define "content" }}
<div class="flex flex-col justify-center items-center self-center max-w-lg">
<p class="text-center mt-8">{{i18n "InviteFacadeFallbackWelcome"}}</p>
<p class="text-center mt-8">{{i18n "SSBURIFailureWelcome"}}</p>

<div class="flex flex-col sm:flex-row items-center mt-8">
<a
href="https://manyver.se"
class="shadow rounded flex flex-row justify-center items-center px-4 h-8 text-gray-100 bg-purple-500 hover:bg-purple-600 focus:outline-none focus:ring-2 focus:ring-purple-600 focus:ring-opacity-50"
>{{i18n "InviteFacadeFallbackManyverse"}}</a>
>{{i18n "SSBURIFailureInstallManyverse"}}</a>
</div>

<hr class="mt-8 w-64 h-px bg-gray-200"></hr>
Expand Down
7 changes: 3 additions & 4 deletions web/templates/invite/facade.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,12 @@

<a
id="join-room-uri"
href="#"
data-href="{{.JoinRoomURI}}"
href="{{.JoinRoomURI}}"
data-href-fallback="{{.FallbackURL}}"
class="shadow rounded flex flex-row justify-center items-center mt-8 px-4 h-8 text-gray-100 bg-purple-500 hover:bg-purple-600 focus:outline-none focus:ring-2 focus:ring-purple-600 focus:ring-opacity-50"
>{{i18n "InviteFacadeJoin"}}</a>

<p id="waiting" class="hidden mt-8 animate-pulse text-green-500">{{i18n "InviteFacadeWaiting"}}</p>
<p id="waiting" class="hidden mt-8 animate-pulse text-green-500">{{i18n "SSBURIOpening"}}</p>

<hr class="mt-8 w-64 h-px bg-gray-200"></hr>

Expand All @@ -27,6 +26,6 @@
class="mt-8"
/>

<script src="/assets/autoredirect.js"></script>
<script src="/assets/invite-uri.js"></script>
</div>
{{ end }}

0 comments on commit 0e5b2f3

Please sign in to comment.