Skip to content

Commit

Permalink
Dropped defaultUserLanguage from viewer_settings.js
Browse files Browse the repository at this point in the history
  • Loading branch information
veloman-yunkan committed Jan 31, 2024
1 parent e5dab19 commit c697611
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 51 deletions.
3 changes: 1 addition & 2 deletions src/server/internalServer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -767,8 +767,7 @@ std::unique_ptr<Response> InternalServer::handle_viewer_settings(const RequestCo
const kainjow::mustache::object data{
{"enable_toolbar", m_withTaskbar ? "true" : "false" },
{"enable_link_blocking", m_blockExternalLinks ? "true" : "false" },
{"enable_library_button", m_withLibraryButton ? "true" : "false" },
{"default_user_language", request.get_user_language() }
{"enable_library_button", m_withLibraryButton ? "true" : "false" }
};
return ContentResponse::build(RESOURCE::templates::viewer_settings_js, data, "application/javascript; charset=utf-8");
}
Expand Down
3 changes: 1 addition & 2 deletions static/templates/viewer_settings.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
const viewerSettings = {
toolbarEnabled: {{enable_toolbar}},
linkBlockingEnabled: {{enable_link_blocking}},
libraryButtonEnabled: {{enable_library_button}},
defaultUserLanguage: "{{default_user_language}}"
libraryButtonEnabled: {{enable_library_button}}
}
51 changes: 4 additions & 47 deletions test/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2077,8 +2077,7 @@ TEST_F(ServerTest, viewerSettings)
R"(const viewerSettings = {
toolbarEnabled: false,
linkBlockingEnabled: false,
libraryButtonEnabled: false,
defaultUserLanguage: "en"
libraryButtonEnabled: false
}
)");
}
Expand All @@ -2089,8 +2088,7 @@ R"(const viewerSettings = {
R"(const viewerSettings = {
toolbarEnabled: false,
linkBlockingEnabled: true,
libraryButtonEnabled: false,
defaultUserLanguage: "en"
libraryButtonEnabled: false
}
)");
}
Expand All @@ -2101,8 +2099,7 @@ R"(const viewerSettings = {
R"(const viewerSettings = {
toolbarEnabled: true,
linkBlockingEnabled: false,
libraryButtonEnabled: false,
defaultUserLanguage: "en"
libraryButtonEnabled: false
}
)");
}
Expand All @@ -2113,47 +2110,7 @@ R"(const viewerSettings = {
R"(const viewerSettings = {
toolbarEnabled: true,
linkBlockingEnabled: false,
libraryButtonEnabled: true,
defaultUserLanguage: "en"
}
)");
}

{
resetServer(ZimFileServer::WITH_TASKBAR_AND_LIBRARY_BUTTON);
const Headers headers{ {"Accept-Language", "fr"} };
ASSERT_EQ(zfs1_->GET("/ROOT%23%3F/viewer_settings.js", headers)->body,
R"(const viewerSettings = {
toolbarEnabled: true,
linkBlockingEnabled: false,
libraryButtonEnabled: true,
defaultUserLanguage: "fr"
}
)");
}

{
resetServer(ZimFileServer::WITH_TASKBAR_AND_LIBRARY_BUTTON);
const Headers headers{ {"Accept-Language", "test;q=0.2, en;q=0.9"} };
ASSERT_EQ(zfs1_->GET("/ROOT%23%3F/viewer_settings.js", headers)->body,
R"(const viewerSettings = {
toolbarEnabled: true,
linkBlockingEnabled: false,
libraryButtonEnabled: true,
defaultUserLanguage: "en"
}
)");
}

{
resetServer(ZimFileServer::WITH_TASKBAR_AND_LIBRARY_BUTTON);
const Headers headers{ {"Accept-Language", "test;q=0.9, en;q=0.2"} };
ASSERT_EQ(zfs1_->GET("/ROOT%23%3F/viewer_settings.js", headers)->body,
R"(const viewerSettings = {
toolbarEnabled: true,
linkBlockingEnabled: false,
libraryButtonEnabled: true,
defaultUserLanguage: "test"
libraryButtonEnabled: true
}
)");
}
Expand Down

0 comments on commit c697611

Please sign in to comment.