diff --git a/README.md b/README.md index 60bbc86..024d821 100644 --- a/README.md +++ b/README.md @@ -93,8 +93,6 @@ gdpsConfig.js - Tweak small settings for GDPS'es here, such as whether to decryp level.json - An array of the official GD tracks, and also difficulty face stuff for level searching -mapPacks.json - The IDs for the levels in map packs. I can't believe I have to hardcode this - secretStuff.json - GJP goes here, needed for level leaderboards. Not included in the repo for obvious reasons sizecheck.js - Excecuted on most pages, used for the 'page isn't wide enough' message, back button, and a few other things diff --git a/api/mappack.js b/api/mappack.js new file mode 100644 index 0000000..4fec6b7 --- /dev/null +++ b/api/mappack.js @@ -0,0 +1,33 @@ +const request = require('request') +const difficulties = ["unrated", "easy", "normal", "hard", "harder", "insane", "demon"] + +let cache = {data: null, indexed: 0} + +module.exports = async (app, req, res) => { + + if (app.offline) return res.send("-1") + else if (app.config.cacheMapPacks && cache.data != null && cache.indexed + 20000000 > Date.now()) return res.send(cache.data) // 6 hour cache + + request.post(app.endpoint + 'getGJMapPacks21.php', req.gdParams({ count: 100 }), function (err, resp, body) { + + if (err || !body || body == '-1' || body.startsWith(" app.parseResponse(x)).filter(x => x[2]) + + let mappacks = packs.map(x => ({ // "packs.map()" laugh now please + id: +x[1], + name: x[2], + levels: x[3].split(","), + stars: +x[4], + coins: +x[5], + difficulty: difficulties[+x[6]], + barColor: x[7], + textColor: x[8] + })) + + if (app.config.cacheMapPacks) cache = {data: mappacks, indexed: Date.now()} + return res.send(mappacks) + + }) + +} \ No newline at end of file diff --git a/api/search.js b/api/search.js index 3ccecc3..3a24bfd 100644 --- a/api/search.js +++ b/api/search.js @@ -1,5 +1,4 @@ const request = require('request') -const mapPacks = require('../misc/mapPacks.json') const levels = require('../misc/level.json').music const Level = require('../classes/Level.js') @@ -38,10 +37,7 @@ module.exports = async (app, req, res) => { count: amount } - let foundPack = mapPacks[req.params.text.toLowerCase()] - if (foundPack) filters.str = `${foundPack[0]},${foundPack[1]},${foundPack[2]}`; - - if (req.query.gauntlet || req.query.hasOwnProperty("mappack") || req.query.type == "saved") filters.type = 10 + if (req.query.gauntlet || req.query.hasOwnProperty("mappack") || req.query.hasOwnProperty("list") || req.query.type == "saved") filters.type = 10 if (req.query.songID && filters.customSong == 0 && levels.find(x => req.query.songID.toLowerCase() == x[0].toLowerCase())) { filters.song = levels.findIndex(x => req.query.songID.toLowerCase() == x[0].toLowerCase()) @@ -67,7 +63,6 @@ module.exports = async (app, req, res) => { if (req.query.hasOwnProperty("creators")) filters.type = 12 if (req.params.text == "*") delete filters.str - else if (req.query.hasOwnProperty("list")) filters.type = 10 request.post(app.endpoint + 'getGJLevels21.php', req.gdParams(filters), async function(err, resp, body) { diff --git a/assets/css/browser.css b/assets/css/browser.css index 01fdb7a..a1bfd27 100644 --- a/assets/css/browser.css +++ b/assets/css/browser.css @@ -544,7 +544,7 @@ input::-webkit-inner-spin-button { .mappack { vertical-align: top; width: 250px; - height: 50px; + height: 60px; margin: 0px 9px 210px 9px; display: inline-block; cursor: pointer; diff --git a/gdpsConfig.js b/gdpsConfig.js index c4eff2f..5828bd1 100644 --- a/gdpsConfig.js +++ b/gdpsConfig.js @@ -12,10 +12,11 @@ module.exports = { binaryVersion: '35', }, - rateLimiting: true, // Enables rate limiting to avoid api spam, feel free to disable for private use - ipForwarding: true, // Forwards 'x-real-ip' to the servers (requested by robtop) + rateLimiting: true, // Enables rate limiting to avoid api spam, feel free to disable for private use. + ipForwarding: true, // Forwards 'x-real-ip' to the servers. (requested by robtop) base64descriptions: true, // Are level descriptions encoded in Base64? xorPasswords: true, // Are level passwords XOR encrypted? + cacheMapPacks: true, // Caches map packs to speed up loading. Useful if they're rarely updated. timestampSuffix: " ago", // Suffix to add after timestamps, if any. // more settings soon diff --git a/html/api.html b/html/api.html index ec050b1..60ab4a2 100644 --- a/html/api.html +++ b/html/api.html @@ -27,6 +27,7 @@
Levels Searching + Map Packs Level Leaderboards
@@ -264,7 +265,7 @@

creators: A comment seperated list of account IDs. Only levels by those players will be returned


-

Params that require anything (e.g. ?mappack=yes or ?mappack)

+

Params that require anything (e.g. ?featured=yes or ?featured)

list: Reads and returns a custom list of levels (search query should be a comma seperated list of IDs)

featured: Only return featured levels

original: Only return non-copied levels

@@ -274,7 +275,6 @@

starred: Only return levels with a star rating

noStar: Only return levels without a star rating

customSong: Reads the 'song' parameter as a custom song ID instead of an official one

-

mappack: Reads the search query as the name of a map pack and returns the 3 levels if pack exists

user: Reads the search query as a player's ID and returns their levels


@@ -371,10 +371,57 @@
+ +
+
+
+

Map Packs

+

/api/mappacks

+ +

Returns the list of map packs

+ +
+

Parameters (0)

+
+

No parameters for this one!

+
+ +
+

Response (8)

+
+

The API will return an array of each map pack with the following information:

+

id: The ID of the map

+

name: The name of the pack

+

levels: An array of level IDs in the map pack. Fetch with /search/ using the ?list parameter

+

stars: The amount of stars rewarded for completing the pack

+

coins: Basically the only reason people play map packs LOL

+

difficulty: The (usually inaccurate) difficulty face of the map pack

+

barColor: The RGB color of the pack's progress bar

+

textColor: The RGB color of the pack's name

+
+ +
+

Example

+
+

Example Request

+

/api/mappacks

+ +
+

Example Response

+

...

+
+ +
+
+ +
+ +
+
-

Level Leaderboards

+

Level Leaderboards (usually broken)

/api/leaderboardLevel/levelID

Returns the leaderboard for a level

@@ -519,7 +566,7 @@
-

Commenting

+

Commenting (usually broken)

POST: /postComment

Leaves a comment on a level. This one is a POST request!

@@ -560,7 +607,7 @@
-

Profile Posting

+

Profile Posting (usually broken)

POST: /postProfileComment

Leaves a profile post. This one is a POST request!

@@ -597,7 +644,7 @@
-

Liking

+

Liking (usually broken)

POST: /like

Likes/dislikes level, comment, or post. This one is a POST request!

@@ -638,7 +685,7 @@
-

Messages

+

Messages (usually broken)

POST:
/messages (fetches messages, includes subject but not actual content. blame robtop)
/messages/messageID (reads a message)
diff --git a/html/filters.html b/html/filters.html index 6c6c697..b0ead7b 100644 --- a/html/filters.html +++ b/html/filters.html @@ -30,7 +30,7 @@

@@ -34,13 +32,15 @@