|
1 | 1 | <script> |
2 | 2 | import { onMount } from "svelte"; |
3 | 3 | import { page } from "$app/stores"; |
4 | | - import { browser } from '$app/environment'; |
| 4 | + import { browser } from "$app/environment"; |
5 | 5 |
|
6 | 6 | import { PUBLIC_API_URL, PUBLIC_STUDIO_URL } from "$env/static/public"; |
7 | 7 |
|
|
35 | 35 |
|
36 | 36 | const isAprilFools = () => { |
37 | 37 | if (!browser) return false; |
38 | | - |
| 38 | +
|
39 | 39 | const date = new Date(Date.now()); |
40 | 40 | const urlParams = $page.url.searchParams; |
41 | 41 | const isAprilFools = date.getMonth() === 3 && date.getDate() === 1; // month is 0 indexed for literally no reason |
|
152 | 152 | } |
153 | 153 |
|
154 | 154 | const getAndUpdateMyFeed = async () => { |
155 | | - console.log("update feed"); |
156 | 155 | const feed = await ProjectClient.getMyFeed(0); |
157 | 156 | if (feed.length <= 0) { |
158 | 157 | feedIsEmpty = true; |
|
204 | 203 | Language.forceUpdate(); |
205 | 204 | let username = localStorage.getItem("username"); |
206 | 205 | const token = localStorage.getItem("token"); |
| 206 | +
|
| 207 | + const setFrontPage = () => |
| 208 | + ProjectClient.getFrontPage() |
| 209 | + .then((results) => { |
| 210 | + projects.today = results.latest; |
| 211 | + projects.featured = results.featured; |
| 212 | + projects.voted = results.voted; |
| 213 | + projects.viewed = results.viewed; |
| 214 | + projects.tagged = results.tagged; |
| 215 | + if (results.suggested) |
| 216 | + projects.suggested = results.suggested; |
| 217 | + tagForProjects = results.selectedTag; |
| 218 | + projectsLoaded = true; |
| 219 | +
|
| 220 | + if (results.blocked) { |
| 221 | + const blocked = results.blocked; |
| 222 | +
|
| 223 | + const remove_blocked = (projects) => |
| 224 | + projects.filter((p) => |
| 225 | + blocked.every((b) => p.author.id != b), |
| 226 | + ); |
| 227 | +
|
| 228 | + projects.today = remove_blocked(projects.today); |
| 229 | + projects.featured = remove_blocked(results.featured); |
| 230 | + projects.voted = remove_blocked(results.voted); |
| 231 | + projects.viewed = remove_blocked(results.viewed); |
| 232 | + projects.tagged = remove_blocked(results.tagged); |
| 233 | + if (results.suggested) |
| 234 | + projects.suggested = remove_blocked( |
| 235 | + results.suggested, |
| 236 | + ); |
| 237 | + } |
| 238 | + }) |
| 239 | + .catch((err) => { |
| 240 | + projectsFailed = true; |
| 241 | + if (err === 429) { |
| 242 | + projectsRateLimited = true; |
| 243 | + } |
| 244 | + }); |
| 245 | +
|
207 | 246 | if (!token || !username) { |
208 | 247 | loggedIn = false; |
209 | 248 | loggedInAdminOrMod = false; |
| 249 | + setFrontPage(); |
210 | 250 | } else { |
211 | 251 | Authentication.usernameFromCode(username, token) |
212 | 252 | .then(({ username: usernameActual, isAdmin, isApprover }) => { |
|
220 | 260 | loggedIn = true; |
221 | 261 | loggedInAdminOrMod = isAdmin || isApprover; |
222 | 262 | getAndUpdateMyFeed(); |
| 263 | +
|
| 264 | + setFrontPage(); |
223 | 265 | }) |
224 | 266 | .catch((err) => { |
225 | 267 | loggedIn = false; |
226 | 268 | loggedInAdminOrMod = false; |
| 269 | +
|
| 270 | + setFrontPage(); |
227 | 271 | }); |
228 | 272 | } |
229 | 273 |
|
|
253 | 297 | updates = [updatess]; |
254 | 298 | }); |
255 | 299 | }); |
256 | | -
|
257 | | - ProjectClient.getFrontPage() |
258 | | - .then((results) => { |
259 | | - projects.today = results.latest; |
260 | | - projects.featured = results.featured; |
261 | | - projects.voted = results.voted; |
262 | | - projects.viewed = results.viewed; |
263 | | - projects.tagged = results.tagged; |
264 | | - if (results.suggested) projects.suggested = results.suggested; |
265 | | - tagForProjects = results.selectedTag; |
266 | | - projectsLoaded = true; |
267 | | - }) |
268 | | - .catch((err) => { |
269 | | - projectsFailed = true; |
270 | | - if (err === 429) { |
271 | | - projectsRateLimited = true; |
272 | | - } |
273 | | - }); |
274 | 300 | }); |
275 | 301 |
|
276 | 302 | // login code below |
|
279 | 305 | Authentication.onLogout(() => { |
280 | 306 | loggedIn = false; |
281 | 307 | myFeed = []; |
| 308 | +
|
| 309 | + getFrontPage(); |
282 | 310 | }); |
283 | 311 | Authentication.onAuthentication((username, token) => { |
284 | 312 | loggedInUsername = username; |
285 | 313 | ProjectClient.setUsername(username); |
286 | 314 | ProjectClient.setToken(token); |
287 | 315 | loggedIn = true; |
288 | 316 | getAndUpdateMyFeed(); |
| 317 | + getFrontPage(); |
289 | 318 | return; |
290 | 319 | }); |
291 | 320 |
|
|
715 | 744 | <!-- NOTE: This section is entirely hard-coded for time-relevant stuff, but avoid making new classes for a topic. --> |
716 | 745 | <div class="category-news"> |
717 | 746 | <div class="category-news-content"> |
718 | | - <h2 style="margin-block:4px;">Spring PenguinJam has ended!</h2> |
| 747 | + <h2 style="margin-block:4px;"> |
| 748 | + Spring PenguinJam has ended! |
| 749 | + </h2> |
719 | 750 | <div style="width:100%"> |
720 | 751 | <p> |
721 | | - Time's up everyone, the 2026 Spring PenguinJam has ended! |
| 752 | + Time's up everyone, the 2026 Spring PenguinJam |
| 753 | + has ended! |
722 | 754 | <br /> |
723 | 755 | Thanks for submitting your projects this year! |
724 | 756 | <br /> |
725 | | - We're going to start ranking your projects now. |
726 | | - Please wait until we are done with ranking! |
| 757 | + We're going to start ranking your projects now. Please |
| 758 | + wait until we are done with ranking! |
727 | 759 | </p> |
728 | 760 | <img |
729 | 761 | src="/events/news/penguinjamspring2026.webp" |
|
1105 | 1137 | lang={currentLang} |
1106 | 1138 | html={true} |
1107 | 1139 | replace={{ |
1108 | | - "{{LINK}}": "<a href='https://scratch.org/'>https://scratch.org/</a>" |
| 1140 | + "{{LINK}}": |
| 1141 | + "<a href='https://scratch.org/'>https://scratch.org/</a>", |
1109 | 1142 | }} |
1110 | 1143 | /> |
1111 | 1144 | </p> |
|
1287 | 1320 | :global(body.dark-mode) .main { |
1288 | 1321 | color: white; |
1289 | 1322 | } |
1290 | | - |
| 1323 | +
|
1291 | 1324 | .main[data-aprilfools="true"] { |
1292 | 1325 | filter: brightness(0.7) contrast(1.8) sepia(1); |
1293 | 1326 | } |
1294 | 1327 | .main[data-aprilfools="true"] :global(*) { |
1295 | | - font-family: 'Times New Roman', Times, serif !important; |
| 1328 | + font-family: "Times New Roman", Times, serif !important; |
1296 | 1329 | } |
1297 | 1330 | .main[data-aprilfools="true"] p, |
1298 | 1331 | .main[data-aprilfools="true"] span, |
|
0 commit comments