Skip to content

Commit

Permalink
Release v1.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
LittleYang0531 committed Feb 14, 2023
1 parent 58813c5 commit 48b4e43
Show file tree
Hide file tree
Showing 29 changed files with 341 additions and 59 deletions.
11 changes: 11 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,17 @@ string levelSearch(map<string, string> $_GET) {
## 更新日志
### v1.2.0 2023.2.14
🎁 情人节特供 💝
所有基础 web 界面已全部完工,目前所有页面及超链接已保持和官方一致。
1. 新增所有组件的 jump 页面。
2. 更新关卡搜索配置。
3. 新增对所有搜索界面状态保存。
4. 修复语言修改只在当前页面生效的问题。
### v1.1.3 2023.2.11
1. 修复当 list 页面没有条目时显示 `{{html.xxx}}` 的错误。
Expand Down
13 changes: 12 additions & 1 deletion README_en.md
Original file line number Diff line number Diff line change
Expand Up @@ -278,9 +278,20 @@ These days, the official wiki website has added an endpoint `/sonolus/authentica
## Upload Log
### v1.2.0 2023.2.14
🎁 Happy Valentine's Day 💝
All basic web interfaces have been completed. At present, all pages and hyperlinks have been consistent with the official ones.
1. Add the jump page of all components.
2. Update the level search configuration.
3. Add the feature to save the status of all search interfaces.
4. Fix the problem that language modification only takes effect on the current page.
### v1.1.3 2023.2.11
1. Fix the error of displaying `{{html. xxx}}` when the list page has no entries.
1. Fix the error of displaying `{{html.xxx}}` when the list page has no entries.
2. Completely repair the memory leak caused by the client's long connection without sending information.
3. Add the display of search criteria on the list page of each component.
4. Fix the problem of stiff animation when the link jumps.
Expand Down
6 changes: 5 additions & 1 deletion i18n/en-us.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,9 @@
"download": "If you do not have Sonolus yet, download it here:",
"searchButton":"Search",
"yes": "OFF",
"no": "ON"
"no": "ON",
"jumpTitle": "Jump to Page",
"pages": "Page",
"pagesPlaceholder": "Enter page number...",
"jump": "Jump"
}
6 changes: 5 additions & 1 deletion i18n/zh-cn.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,9 @@
"download": "如果您还没有 sonolus,请前往下载:",
"searchButton":"搜索",
"yes": "",
"no": ""
"no": "",
"jumpTitle": "跳至页码",
"pages": "页码",
"pagesPlaceholder": "输入页码...",
"jump": "跳至"
}
9 changes: 6 additions & 3 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,9 +90,6 @@ int main(int argc, char** argv) {
app.addRoute("/data/%s", downloader);
app.addRoute("/js/%s", js_import);
app.addRoute("/css/%s", css_import);
app.addRoute("/test", [](client_conn conn, http_request request, param argv){

});

app.addRoute("/sonolus/info", sonolus_info);
app.addRoute("/sonolus/levels/create", sonolus_levels_create);
Expand Down Expand Up @@ -134,6 +131,12 @@ int main(int argc, char** argv) {
app.addRoute("/effects/search", web_effects_search);
app.addRoute("/particles/search", web_particles_search);
app.addRoute("/engines/search", web_engines_search);
app.addRoute("/levels/jump/%d", web_levels_jump);
app.addRoute("/skins/jump/%d", web_skins_jump);
app.addRoute("/backgrounds/jump/%d", web_backgrounds_jump);
app.addRoute("/effects/jump/%d", web_effects_jump);
app.addRoute("/particles/jump/%d", web_particles_jump);
app.addRoute("/engines/jump/%d", web_engines_jump);
app.addRoute("/levels/%s", web_levels);
app.addRoute("/skins/%s", web_skins);
app.addRoute("/backgrounds/%s", web_backgrounds);
Expand Down
6 changes: 4 additions & 2 deletions modules/html.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ H fetchIndexBottom(string searchUrl, string listUrl) {

string disableClass = "router-link-active router-link-exact-active flex select-none space-x-2 p-2 transition-colors sm:space-x-3 sm:p-3 pointer-events-none bg-sonolus-ui-button-disabled text-sonolus-ui-text-disabled";
string enableClass = "router-link-active router-link-exact-active flex select-none space-x-2 p-2 transition-colors sm:space-x-3 sm:p-3 cursor-pointer bg-sonolus-ui-button-normal hover:bg-sonolus-ui-button-highlighted active:bg-sonolus-ui-button-pressed";
H fetchBottomBar(string sonolusUrl, string topUrl, string previousUrl, string nextUrl, string bottomUrl, string searchUrl, int currentPage, int totalPage) {
H fetchBottomBar(string sonolusUrl, string topUrl, string previousUrl, string nextUrl, string bottomUrl, string searchUrl, string jumpUrl, int currentPage, int totalPage) {
string source = readFile("./web/html/components/bottomBar.html");
argvar args;
args["class.previous"] = currentPage > 0 ? enableClass : disableClass;
Expand All @@ -102,18 +102,20 @@ H fetchBottomBar(string sonolusUrl, string topUrl, string previousUrl, string ne
args["url.next"] = nextUrl;
args["url.bottom"] = bottomUrl;
args["url.search"] = searchUrl;
args["url.jump"] = jumpUrl;
args["pages.current"] = to_string(currentPage + 1);
args["pages.all"] = to_string(totalPage);
return str_replace(source, args);
}

H fetchSearchText(string query, string name, string placeholder, bool isMargin) {
H fetchSearchText(string query, string name, string placeholder, string def, bool isMargin) {
string source = readFile("./web/html/components/searchText.html");
argvar args;
args["search.query"] = query;
args["search.name"] = name;
args["search.placeholder"] = placeholder;
args["search.isMargin"] = isMargin ? "style=\"margin-top: 12px;\"" : "";
args["search.default"] = def;
return str_replace(source, args);
}

Expand Down
6 changes: 4 additions & 2 deletions modules/httpd.h
Original file line number Diff line number Diff line change
Expand Up @@ -633,8 +633,10 @@ argvar getParam(http_request request) {
*/
string getStringfy(argvar $_GET) {
string res = "";
for (auto v : $_GET) res += v.first + "=" + v.second + "&";
res.pop_back();
for (auto v : $_GET) {
if (v.first == "" && v.second == "") continue;
res += v.first + "=" + v.second + "&";
} if (res.size()) res.pop_back();
return res;
}

Expand Down
23 changes: 23 additions & 0 deletions web/backgrounds_jump.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using namespace std;

auto web_backgrounds_jump = [](client_conn conn, http_request request, param argv) {
string header = readFile("./web/html/components/header.html");
string body = readFile("./web/html/pages/jump.html");
auto cookie = cookieParam(request);
argvar argList = merge(transfer(appConfig), transfer(i18n[cookie["lang"] == "" ? appConfig["language.default"].asString() : cookie["lang"]], "language."));

// TODO: add the argList here
argList["page.title"] = argList["language.jumpTitle"] + " | " + appConfig["server.title"].asString();
argList["html.navbar"] = fetchNavBar("{{language.jumpTitle}}").output();
argList["pages.current"] = to_string(atoi(argv[0].c_str()) + 1);
argList["url.base"] = "/backgrounds/list?" + getStringfy(getParam(request));

header = str_replace(header, argList);
body = str_replace(body, argList);
H root = H(true, "html");
root.append(header);
root.append(body);
putRequest(conn, 200, __default_response);
send(conn, root.output());
exitRequest(conn);
};
6 changes: 4 additions & 2 deletions web/backgrounds_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ auto web_backgrounds_list = [](client_conn conn, http_request request, param arg
$_GET["page"] = to_string(page - 1); string previousUrl = "/backgrounds/list?" + getStringfy($_GET);
$_GET["page"] = to_string(page + 1); string nextUrl = "/backgrounds/list?" + getStringfy($_GET);
$_GET["page"] = to_string(section.pageCount - 1); string bottomUrl = "/backgrounds/list?" + getStringfy($_GET);
argList["html.backgroundsBottom"] = fetchBottomBar(sonolusUrl, topUrl, previousUrl, nextUrl, bottomUrl, "/backgrounds/search", page, section.pageCount).output();
$_GET.erase("page"); string jumpUrl = "/backgrounds/jump/" + to_string(page) + "?" + getStringfy($_GET);
string searchUrl = "/backgrounds/search?" + getStringfy($_GET);
argList["html.backgroundsBottom"] = fetchBottomBar(sonolusUrl, topUrl, previousUrl, nextUrl, bottomUrl, searchUrl, jumpUrl, page, section.pageCount).output();
argList["html.backgroundsList"] = "";
argList["url.list"] = "/backgrounds/list";
argList["search.display"] = $_GET.size() == 1 && $_GET.find("page") != $_GET.end() ? "style=\"display: none\"" : "";
argList["search.display"] = $_GET.size() == 0 ? "style=\"display: none\"" : "";
argList["search.filterWords"] = "";
for (auto v : $_GET) {
if (v.first == "page") continue;
Expand Down
10 changes: 5 additions & 5 deletions web/backgrounds_search.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ auto web_backgrounds_search = [](client_conn conn, http_request request, param a
// TODO: add the argList here
argList["page.title"] = argList["language.search"] + " | " + appConfig["server.title"].asString();
argList["html.navbar"] = fetchNavBar("{{language.search}}").output();
argList["html.backgroundsSearchOption"] = "";
argList["html.backgroundsSearchOption"] = ""; auto $_GET = getParam(request);
for (int i = 0; i < BackgroundSearch.options.size(); i++) {
auto v = BackgroundSearch.options[i];
if (v.type == "text") argList["html.backgroundsSearchOption"] += fetchSearchText(v.text.query, v.text.name, v.text.placeholder, i != 0).output();
if (v.type == "toggle") argList["html.backgroundsSearchOption"] += fetchSearchToggle(v.toggle.query, v.toggle.name, v.toggle.def, i != 0).output();
if (v.type == "select") argList["html.backgroundsSearchOption"] += fetchSearchSelect(v.select.query, v.select.name, v.select.values, v.select.def, i != 0).output();
if (v.type == "slider") argList["html.backgroundsSearchOption"] += fetchSearchSlider(v.slider.query, v.slider.name, v.slider.def, v.slider.min, v.slider.max, v.slider.step, i != 0).output();
if (v.type == "text") argList["html.backgroundsSearchOption"] += fetchSearchText(v.text.query, v.text.name, v.text.placeholder, $_GET[v.text.query], i != 0).output();
if (v.type == "toggle") argList["html.backgroundsSearchOption"] += fetchSearchToggle(v.toggle.query, v.toggle.name, $_GET[v.toggle.query] == "" ? v.toggle.def : atoi($_GET[v.toggle.query].c_str()), i != 0).output();
if (v.type == "select") argList["html.backgroundsSearchOption"] += fetchSearchSelect(v.select.query, v.select.name, v.select.values, $_GET[v.select.query] == "" ? v.select.def : atoi($_GET[v.select.query].c_str()), i != 0).output();
if (v.type == "slider") argList["html.backgroundsSearchOption"] += fetchSearchSlider(v.slider.query, v.slider.name, $_GET[v.slider.query] == "" ? v.slider.def : atoi($_GET[v.slider.query].c_str()), v.slider.min, v.slider.max, v.slider.step, i != 0).output();
}
argList["json.searchConfig"] = readFile("./config/background_search.json");

Expand Down
23 changes: 23 additions & 0 deletions web/effects_jump.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using namespace std;

auto web_effects_jump = [](client_conn conn, http_request request, param argv) {
string header = readFile("./web/html/components/header.html");
string body = readFile("./web/html/pages/jump.html");
auto cookie = cookieParam(request);
argvar argList = merge(transfer(appConfig), transfer(i18n[cookie["lang"] == "" ? appConfig["language.default"].asString() : cookie["lang"]], "language."));

// TODO: add the argList here
argList["page.title"] = argList["language.jumpTitle"] + " | " + appConfig["server.title"].asString();
argList["html.navbar"] = fetchNavBar("{{language.jumpTitle}}").output();
argList["pages.current"] = to_string(atoi(argv[0].c_str()) + 1);
argList["url.base"] = "/effects/list?" + getStringfy(getParam(request));

header = str_replace(header, argList);
body = str_replace(body, argList);
H root = H(true, "html");
root.append(header);
root.append(body);
putRequest(conn, 200, __default_response);
send(conn, root.output());
exitRequest(conn);
};
6 changes: 4 additions & 2 deletions web/effects_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ auto web_effects_list = [](client_conn conn, http_request request, param argv) {
$_GET["page"] = to_string(page - 1); string previousUrl = "/effects/list?" + getStringfy($_GET);
$_GET["page"] = to_string(page + 1); string nextUrl = "/effects/list?" + getStringfy($_GET);
$_GET["page"] = to_string(section.pageCount - 1); string bottomUrl = "/effects/list?" + getStringfy($_GET);
argList["html.effectsBottom"] = fetchBottomBar(sonolusUrl, topUrl, previousUrl, nextUrl, bottomUrl, "/effects/search", page, section.pageCount).output();
$_GET.erase("page"); string jumpUrl = "/effects/jump/" + to_string(page) + "?" + getStringfy($_GET);
string searchUrl = "/effects/search?" + getStringfy($_GET);
argList["html.effectsBottom"] = fetchBottomBar(sonolusUrl, topUrl, previousUrl, nextUrl, bottomUrl, searchUrl, jumpUrl, page, section.pageCount).output();
argList["html.effectsList"] = "";
argList["url.list"] = "/effects/list";
argList["search.display"] = $_GET.size() == 1 && $_GET.find("page") != $_GET.end() ? "style=\"display: none\"" : "";
argList["search.display"] = $_GET.size() == 0 ? "style=\"display: none\"" : "";
argList["search.filterWords"] = "";
for (auto v : $_GET) {
if (v.first == "page") continue;
Expand Down
10 changes: 5 additions & 5 deletions web/effects_search.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ auto web_effects_search = [](client_conn conn, http_request request, param argv)
// TODO: add the argList here
argList["page.title"] = argList["language.search"] + " | " + appConfig["server.title"].asString();
argList["html.navbar"] = fetchNavBar("{{language.search}}").output();
argList["html.effectsSearchOption"] = "";
argList["html.effectsSearchOption"] = ""; auto $_GET = getParam(request);
for (int i = 0; i < EffectSearch.options.size(); i++) {
auto v = EffectSearch.options[i];
if (v.type == "text") argList["html.effectsSearchOption"] += fetchSearchText(v.text.query, v.text.name, v.text.placeholder, i != 0).output();
if (v.type == "toggle") argList["html.effectsSearchOption"] += fetchSearchToggle(v.toggle.query, v.toggle.name, v.toggle.def, i != 0).output();
if (v.type == "select") argList["html.effectsSearchOption"] += fetchSearchSelect(v.select.query, v.select.name, v.select.values, v.select.def, i != 0).output();
if (v.type == "slider") argList["html.effectsSearchOption"] += fetchSearchSlider(v.slider.query, v.slider.name, v.slider.def, v.slider.min, v.slider.max, v.slider.step, i != 0).output();
if (v.type == "text") argList["html.effectsSearchOption"] += fetchSearchText(v.text.query, v.text.name, v.text.placeholder, $_GET[v.text.query], i != 0).output();
if (v.type == "toggle") argList["html.effectsSearchOption"] += fetchSearchToggle(v.toggle.query, v.toggle.name, $_GET[v.toggle.query] == "" ? v.toggle.def : atoi($_GET[v.toggle.query].c_str()), i != 0).output();
if (v.type == "select") argList["html.effectsSearchOption"] += fetchSearchSelect(v.select.query, v.select.name, v.select.values, $_GET[v.select.query] == "" ? v.select.def : atoi($_GET[v.select.query].c_str()), i != 0).output();
if (v.type == "slider") argList["html.effectsSearchOption"] += fetchSearchSlider(v.slider.query, v.slider.name, $_GET[v.slider.query] == "" ? v.slider.def : atoi($_GET[v.slider.query].c_str()), v.slider.min, v.slider.max, v.slider.step, i != 0).output();
}
argList["json.searchConfig"] = readFile("./config/effect_search.json");

Expand Down
23 changes: 23 additions & 0 deletions web/engines_jump.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using namespace std;

auto web_engines_jump = [](client_conn conn, http_request request, param argv) {
string header = readFile("./web/html/components/header.html");
string body = readFile("./web/html/pages/jump.html");
auto cookie = cookieParam(request);
argvar argList = merge(transfer(appConfig), transfer(i18n[cookie["lang"] == "" ? appConfig["language.default"].asString() : cookie["lang"]], "language."));

// TODO: add the argList here
argList["page.title"] = argList["language.jumpTitle"] + " | " + appConfig["server.title"].asString();
argList["html.navbar"] = fetchNavBar("{{language.jumpTitle}}").output();
argList["pages.current"] = to_string(atoi(argv[0].c_str()) + 1);
argList["url.base"] = "/engines/list?" + getStringfy(getParam(request));

header = str_replace(header, argList);
body = str_replace(body, argList);
H root = H(true, "html");
root.append(header);
root.append(body);
putRequest(conn, 200, __default_response);
send(conn, root.output());
exitRequest(conn);
};
6 changes: 4 additions & 2 deletions web/engines_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,12 @@ auto web_engines_list = [](client_conn conn, http_request request, param argv) {
$_GET["page"] = to_string(page - 1); string previousUrl = "/engines/list?" + getStringfy($_GET);
$_GET["page"] = to_string(page + 1); string nextUrl = "/engines/list?" + getStringfy($_GET);
$_GET["page"] = to_string(section.pageCount - 1); string bottomUrl = "/engines/list?" + getStringfy($_GET);
argList["html.enginesBottom"] = fetchBottomBar(sonolusUrl, topUrl, previousUrl, nextUrl, bottomUrl, "/engines/search", page, section.pageCount).output();
$_GET.erase("page"); string jumpUrl = "/engines/jump/" + to_string(page) + "?" + getStringfy($_GET);
string searchUrl = "/engines/search?" + getStringfy($_GET);
argList["html.enginesBottom"] = fetchBottomBar(sonolusUrl, topUrl, previousUrl, nextUrl, bottomUrl, searchUrl, jumpUrl, page, section.pageCount).output();
argList["html.enginesList"] = "";
argList["url.list"] = "/engines/list";
argList["search.display"] = $_GET.size() == 1 && $_GET.find("page") != $_GET.end() ? "style=\"display: none\"" : "";
argList["search.display"] = $_GET.size() == 0 ? "style=\"display: none\"" : "";
argList["search.filterWords"] = "";
for (auto v : $_GET) {
if (v.first == "page") continue;
Expand Down
10 changes: 5 additions & 5 deletions web/engines_search.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ auto web_engines_search = [](client_conn conn, http_request request, param argv)
// TODO: add the argList here
argList["page.title"] = argList["language.search"] + " | " + appConfig["server.title"].asString();
argList["html.navbar"] = fetchNavBar("{{language.search}}").output();
argList["html.enginesSearchOption"] = "";
argList["html.enginesSearchOption"] = ""; auto $_GET = getParam(request);
for (int i = 0; i < EngineSearch.options.size(); i++) {
auto v = EngineSearch.options[i];
if (v.type == "text") argList["html.enginesSearchOption"] += fetchSearchText(v.text.query, v.text.name, v.text.placeholder, i != 0).output();
if (v.type == "toggle") argList["html.enginesSearchOption"] += fetchSearchToggle(v.toggle.query, v.toggle.name, v.toggle.def, i != 0).output();
if (v.type == "select") argList["html.enginesSearchOption"] += fetchSearchSelect(v.select.query, v.select.name, v.select.values, v.select.def, i != 0).output();
if (v.type == "slider") argList["html.enginesSearchOption"] += fetchSearchSlider(v.slider.query, v.slider.name, v.slider.def, v.slider.min, v.slider.max, v.slider.step, i != 0).output();
if (v.type == "text") argList["html.enginesSearchOption"] += fetchSearchText(v.text.query, v.text.name, v.text.placeholder, $_GET[v.text.query], i != 0).output();
if (v.type == "toggle") argList["html.enginesSearchOption"] += fetchSearchToggle(v.toggle.query, v.toggle.name, $_GET[v.toggle.query] == "" ? v.toggle.def : atoi($_GET[v.toggle.query].c_str()), i != 0).output();
if (v.type == "select") argList["html.enginesSearchOption"] += fetchSearchSelect(v.select.query, v.select.name, v.select.values, $_GET[v.select.query] == "" ? v.select.def : atoi($_GET[v.select.query].c_str()), i != 0).output();
if (v.type == "slider") argList["html.enginesSearchOption"] += fetchSearchSlider(v.slider.query, v.slider.name, $_GET[v.slider.query] == "" ? v.slider.def : atoi($_GET[v.slider.query].c_str()), v.slider.min, v.slider.max, v.slider.step, i != 0).output();
}
argList["json.searchConfig"] = readFile("./config/engine_search.json");

Expand Down
Loading

0 comments on commit 48b4e43

Please sign in to comment.