GDColon / GDBrowser

A website that lets you browse all of Geometry Dash's online features, and more!
https://gdbrowser.com
MIT License
334 stars 160 forks source link

GDBrowser PWA! (need help) #247

Closed fgclue closed 2 years ago

fgclue commented 2 years ago

Ok, Ok.. I'm just a GD Player and a coder.. but I've decided to contribute to this project! I just remembered GDBrowser existed, and decided to contribute by making a PWA (Progressive Web App), but I need some help. So, because I'm lazy, I decided to not put everything there is in the assets in the Service Worker (in this case sw.js), which means, it doens't cache everything, so the PWA will not work when offline. Like, just look:

const assets = [
    "/" // please someone make this list not only have the index
]

Yea...

fgclue commented 2 years ago

I have added some stuff to the assets list in the service worker, but I still didn't put in the png's and plist's, there's A LOT of plist's and png's.

They're in /assets/ and /iconkit/.

Also here's the assets list right now:

const assets = [
    "/",
    "/html/",
    "/api/",
    "/assets/",
    "/classes/",
    "/iconkit/",
    "/misc/",
    "/misc/achievements.json",
    "/misc/achievementTypes.json",
    "/misc/credits.json",
    "/misc/dragscroll.js",
    "/misc/global.js",
    "/misc/music.json",
    "/misc/sampleIcons.json",
    "/misc/secretStuff.json",
    "/misc/analysis/blocks.json",
    "/misc/analysis/colorProperties.json",
    "/misc/analysis/initialProperties.json",
    "/misc/analysis/objectProperties.json",
    "/misc/analysis/objects.json",
    "/misc/manual parsers/parseAchievementPlist.js",
    "/misc/manual parsers/parseIconPlist.js",
    "/misc/manual parsers/parseRobotPlist.js",
    "/index.js",
    "/settings.js",
    "/servers.json",
    "/iconkit/extradata/colorOrder.json",
    "/iconkit/extradata/hardcodedUnlocks.json",
    "/iconkit/extradata/iconCredits.json",
    "/iconkit/extradata/shops.json",
    "/iconkit/libs/ag-psd.js",
    "/iconkit/libs/imagesloaded.js",
    "/iconkit/libs/pixi-ease.js",
    "/iconkit/sacredtexts/colors.json",
    "/iconkit/sacredtexts/forms.json",
    "/iconkit/sacredtexts/gameSheet.json",
    "/iconkit/sacredtexts/robotAnimations.json",
    "/iconkit/icon.js",
    "/classes/Level.js",
    "/classes/Player.js",
    "/classes/XOR.js",
    "/api/leaderboards/accurate.js",
    "/api/leaderboards/boomlings.js",
    "/api/leaderboards/leaderboardLevel.js",
    "/api/leaderboards/scores.js",
    "/api/messages/countMessages.js",
    "/api/messages/deleteMessage.js",
    "/api/messages/fetchMessage.js",
    "/api/messages/getMessage.js",
    "/api/post/like.js",
    "/api/post/postComment.js",
    "/api/post/postProfileComment.js",
    "/api/analyze.js",
    "/api/comments.js",
    "/api/download.js",
    "/api/gauntlets.js",
    "/api/level.js",
    "/api/mappacks.js",
    "/api/profile.js",
    "/api/search.js",
    "/api/song.js",
    "/html/achievements.html",
    "/html/analyze.html",
    "/html/api_old.html",
    "/html/api.html",
    "/html/assets.html",
    "/html/boomlings.html",
    "/html/comingsoon.html",
    "/html/comments.html",
    "/html/demon.html",
    "/html/filters.html",
    "/html/gauntlets.html",
    "/html/gdps.html",
    "/html/home.html",
    "/html/iconkit.html",
    "/html/leaderboard.html",
    "/html/level.html",
    "/html/levelboard.html",
    "/html/mappacks.html",
    "/html/messages.html",
    "/html/offline.html",
    "/html/profile.html",
    "/html/search.html"
]
fgclue commented 2 years ago

BTW, these are gonna be what gets cached, which means they can be loaded offline, which is kinda useless, the only reason I will make so they are cached, is because I don't want the website to just break when you disable internet, I want it to show when you are offline.

I recommend that a mobile version of GDBrowser is made, as PWAs are mainly used for Mobile so Native Apps aren't needed.


Regards, fgclue

Rudxain commented 2 years ago

I like this concept, but I don't know if it will be useful enough to justify adding it.

I also don't know if it's actually necessary to 📋copy-paste HTML headers and add specific paths to the assets array. There may be some way of putting the header in home.html and let the browser know that it should be used in all other HTML files. And about the paths, have you tried using glob patterns? If they're supported, you don't need to specify all paths manually.

And I agree with you, if GDB is made into an app, it shouldn't be native. It makes no sense right now, because there aren't any features that would take advantage of being an installable native app. A PWA is a better option.

Edit: BTW, if the PR is WIP/Beta/incomplete, it's good practice to explicitly specify it by converting to "draft". Don't worry, your PR will still be visible in the "open PRs" tab, just marked as "Draft"

Rudxain commented 2 years ago

@fgclue I think there's an easy way to add all needed files to the assets array. You can write a shell script that recursively lists files in whatever directory you want. Windows tree command does this, but the data structure isn't flat. POSIX shells have a ls -r command that does it better, but you need to convert the CSV to JSON (replace \n by ,, and add quotes to both ends of all strings). Maybe someone already wrote a Python or Node.js script to do this exact thing. After you create a file containing the list of paths, you can 📋copy-paste the list into the assets

fgclue commented 2 years ago

I will close this pull request now.

For some reason, the PWA doens't work.

Also PWAs are targeted for phones (so native apps aren't needed), but GDBrowser doesn't work on phones.

So yea, I'm closing this pull request.

Rudxain commented 2 years ago

PWAs are targeted for phones, but GDBrowser doesn't work on phones

Actually, PWAs are targeted to all kinds of devices, it's just more popular for phones. And GDBrowser DOES work on phones, but only in "landscape" (horizontal) layout mode.

Please don't give up that fast, I'll try to help you. But we need to wait for @GDColon 's opinion 1st

GDColon commented 2 years ago

imo this is pretty pointless

gonna rewrite the site in the future so debating archiving the repo since it sucks

Rudxain commented 2 years ago

Oh... ok then