Commit fee9055
committed
JS: Refactor link & badge generation, use URLs (not string) for base URLs
This is two changes that were easier to make together
- BASE_URL and BADGE_BASE_URL are now URL objects rather than strings
that are manipulated. With this done, we no longer use string
manipulation for URLs anywhere!
- Both BASE_URL and BADGE_BASE_URL are now always set, as we had a
bunch of code that was using BADGE_BASE_URL if available but
falls back to BASE_URL + origin if it was not set. This fallback
is now implemented globally, and correctly.
- BASE_URL is also now always fully qualified, and we document that
the python code ensures it has a trailing slash always.
- The function to make links and generate badge markup is moved into
`@jupyterhub/binderhub-client` as it is reasonably generic and
not super specific to our frontend alone. This also involves them
not reading BASE_URL and BADGE_BASE_URL globally, but having that
information be passed in. Tests are also added here to catch any
future issues that may arise.
- Note for future fix - BADGE_BASE_URL is really PUBLIC_BASE_URL or
similar, as it is used both for the location of the badge image
(original intent) but also for the links we generate to share. This
is relevant only for federation, where we want shared links to
point to mybinder.org even though the API call itself may go to
a specific member of the federation. I will do this deprecation +
rename in a future PR so as to not make this PR bigger.
Ref #7741 parent 451eba4 commit fee9055
File tree
8 files changed
+204
-106
lines changed- binderhub/static/js
- src
- js/packages/binderhub-client
- lib
- tests
8 files changed
+204
-106
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
18 | 18 | | |
19 | 19 | | |
20 | 20 | | |
21 | | - | |
| 21 | + | |
22 | 22 | | |
23 | 23 | | |
24 | 24 | | |
25 | 25 | | |
26 | | - | |
| 26 | + | |
27 | 27 | | |
28 | 28 | | |
29 | 29 | | |
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
42 | | - | |
43 | | - | |
44 | | - | |
45 | | - | |
46 | | - | |
47 | | - | |
48 | | - | |
| 42 | + | |
49 | 43 | | |
50 | 44 | | |
51 | 45 | | |
| |||
82 | 76 | | |
83 | 77 | | |
84 | 78 | | |
85 | | - | |
| 79 | + | |
86 | 80 | | |
87 | 81 | | |
88 | 82 | | |
| |||
96 | 90 | | |
97 | 91 | | |
98 | 92 | | |
99 | | - | |
| 93 | + | |
100 | 94 | | |
101 | 95 | | |
102 | 96 | | |
| |||
127 | 121 | | |
128 | 122 | | |
129 | 123 | | |
130 | | - | |
| 124 | + | |
131 | 125 | | |
132 | 126 | | |
133 | 127 | | |
134 | 128 | | |
135 | 129 | | |
136 | 130 | | |
137 | 131 | | |
138 | | - | |
| 132 | + | |
139 | 133 | | |
140 | 134 | | |
141 | 135 | | |
| |||
145 | 139 | | |
146 | 140 | | |
147 | 141 | | |
148 | | - | |
| 142 | + | |
149 | 143 | | |
150 | 144 | | |
151 | 145 | | |
152 | 146 | | |
153 | 147 | | |
154 | | - | |
| 148 | + | |
155 | 149 | | |
156 | 150 | | |
157 | 151 | | |
158 | | - | |
| 152 | + | |
159 | 153 | | |
160 | 154 | | |
161 | 155 | | |
162 | | - | |
| 156 | + | |
163 | 157 | | |
164 | 158 | | |
165 | 159 | | |
| |||
180 | 174 | | |
181 | 175 | | |
182 | 176 | | |
183 | | - | |
| 177 | + | |
184 | 178 | | |
185 | 179 | | |
186 | 180 | | |
| |||
This file was deleted.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | | - | |
3 | | - | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
4 | 6 | | |
5 | | - | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
6 | 11 | | |
| 12 | + | |
7 | 13 | | |
8 | | - | |
9 | | - | |
| 14 | + | |
| 15 | + | |
10 | 16 | | |
11 | | - | |
| 17 | + | |
| 18 | + | |
12 | 19 | | |
13 | | - | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | 3 | | |
4 | | - | |
| 4 | + | |
5 | 5 | | |
6 | 6 | | |
7 | 7 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
26 | 26 | | |
27 | 27 | | |
28 | 28 | | |
29 | | - | |
| 29 | + | |
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
2 | 1 | | |
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 | | - | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
43 | 6 | | |
44 | 7 | | |
45 | 8 | | |
46 | 9 | | |
47 | | - | |
| 10 | + | |
48 | 11 | | |
49 | 12 | | |
50 | 13 | | |
51 | | - | |
52 | | - | |
53 | | - | |
54 | | - | |
55 | | - | |
56 | | - | |
57 | | - | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
58 | 23 | | |
59 | | - | |
60 | 24 | | |
61 | 25 | | |
62 | 26 | | |
63 | 27 | | |
64 | | - | |
65 | | - | |
66 | | - | |
67 | | - | |
| 28 | + | |
68 | 29 | | |
| 30 | + | |
69 | 31 | | |
70 | 32 | | |
71 | 33 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
149 | 149 | | |
150 | 150 | | |
151 | 151 | | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
0 commit comments