aboutsummaryrefslogtreecommitdiff
path: root/priv/discord_activity.html.eex
blob: 5cb8a68adcd745ae84b19dbaa9d9abb948f0d55c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<% home_url="/.proxy/?#{Mediasync.Constants.query_param_discord_activity_inner()}" %>
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="robots" content="noindex, nofollow">
    <title>discord activity | mediasync</title>
    <style>
        :root {
            /* Based on https://discord.com/developers/docs/activities/development-guides#mobile-safe-areas */
            --sait: var(--discord-safe-area-inset-top, env(safe-area-inset-top, 0px));
            --sair: var(--discord-safe-area-inset-right, env(safe-area-inset-right, 0px));
            --saib: var(--discord-safe-area-inset-bottom, env(safe-area-inset-bottom, 0px));
            --sail: var(--discord-safe-area-inset-left, env(safe-area-inset-left, 0px));

            --saiv: calc(var(--sait) + var(--saib));
            --saih: calc(var(--sair) + var(--sail));

            --instance-room-info-height: 20%;
            --instance-room-info-remainder: calc(100% - var(--instance-room-info-height));

            box-sizing: border-box;
            height: calc(100% - var(--saiv));
            width: calc(100% - var(--saih));
        }

        *,
        *::before,
        *::after {
            box-sizing: inherit;
        }

        body {
            background-color: black;
            color: white;
            font-family: monospace;
            height: 100%;
            margin: var(--sait) var(--sair) var(--saib) var(--sail);
            overflow: hidden;
            width: 100%;
        }

        iframe {
            border: none;
            height: 100%;
            width: 100%;
        }

        iframe.at-home {
            height: var(--instance-room-info-remainder);
        }

        div#instance-room-info {
            border-bottom: 1px solid white;
            display: none;
            height: var(--instance-room-info-height);
            overflow: auto;
            padding: 8px 8px 0px 8px;
            width: 100%;
        }

        body:has(> iframe.at-home) > div#instance-room-info {
            display: block;
        }
    </style>
</head>

<body data-csrf-token="<%= Plug.CSRFProtection.get_csrf_token() %>">
    <div id="instance-room-info">
        <span style="font-weight: bold;">currently hosting:</span>
        <div id="instance-room-info-content"></div>
    </div>
    </div>
    <iframe src="<%= home_url %>" style="display: none;" class="at-home" name="activity-inner-iframe"></iframe>
    <script>
        const QUERY_PARAM_DISCORD_ACTIVITY_INNER = "<%= Mediasync.Constants.query_param_discord_activity_inner() %>";
        const DISCORD_CLIENT_ID = "<%= Application.fetch_env!(:mediasync, :discord_client_id) %>";
        const ACCESS_TOKEN_URL = `/.proxy/discord_activity/access_token?${QUERY_PARAM_DISCORD_ACTIVITY_INNER}`;
        const HOME_URL = "<%= home_url %>";
        const roomsForInstanceUrl = (instanceId) => {
            return `/.proxy/discord_activity/rooms_for_instance?${QUERY_PARAM_DISCORD_ACTIVITY_INNER}&instance_id=${instanceId}`;
        };
        const roomUrl = (roomId) => {
            return `/.proxy/room/${roomId}?${QUERY_PARAM_DISCORD_ACTIVITY_INNER}`;
        };
    </script>
    <script src="/static/discord-embedded-app-sdk/Discord.js" type="module"></script>
    <script src="/static/discordActivity.js" type="module"></script>
</body>

</html>