Allow access to opensearch-description when not logged in, and make opsearch description use search-redirect

This commit is contained in:
Starbeamrainbowlabs 2017-06-28 11:21:42 +01:00
parent 60ebd1340c
commit 4ea4315c5a
4 changed files with 11 additions and 9 deletions

View File

@ -1689,7 +1689,7 @@ if(!isset($pageindex->{$env->page}) and isset($_GET["search-redirect"]))
// Note we use $_GET here because $env->action isn't populated at this point
if($settings->require_login_view === true && // If this site requires a login in order to view pages
!$env->is_logged_in && // And the user isn't logged in
!in_array($_GET["action"], [ "login", "checklogin" ])) // And the user isn't trying to login
!in_array($_GET["action"], [ "login", "checklogin", "opensearch-description" ])) // And the user isn't trying to login, or get the opensearch description
{
// Redirect the user to the login page
http_response_code(307);
@ -3347,7 +3347,8 @@ register_module([
<InputEncoding>UTF-8</InputEncoding>
<OutputEncoding>UTF-8</OutputEncoding>
<Url type=\"text/html\" method=\"get\" template=\"$siteRoot?action=search&amp;query={searchTerms}&amp;offset={startIndex?}&amp;count={count}\" />
<Url type=\"text/html\" method=\"get\" template=\"$siteRoot?action=view&search-redirect=yes&amp;page={searchTerms}&amp;offset={startIndex?}&amp;count={count}\" />
<Url type=\"application/x-suggestions+json\" template=\"$siteRoot?action=suggest-pages&amp;query={searchTerms}&amp;type=opensearch\" />
</OpenSearchDescription>");
});
@ -3367,8 +3368,8 @@ register_module([
if($settings->dynamic_page_suggestion_count === 0)
{
header("content-type: application/json");
header("content-length: 2");
exit("[]");
header("content-length: 3");
exit("[]\n");
}
if(empty($_GET["query"])) {

View File

@ -1336,7 +1336,7 @@ if(!isset($pageindex->{$env->page}) and isset($_GET["search-redirect"]))
// Note we use $_GET here because $env->action isn't populated at this point
if($settings->require_login_view === true && // If this site requires a login in order to view pages
!$env->is_logged_in && // And the user isn't logged in
!in_array($_GET["action"], [ "login", "checklogin" ])) // And the user isn't trying to login
!in_array($_GET["action"], [ "login", "checklogin", "opensearch-description" ])) // And the user isn't trying to login, or get the opensearch description
{
// Redirect the user to the login page
http_response_code(307);

View File

@ -104,7 +104,7 @@
"author": "Starbeamrainbowlabs",
"description": "Adds proper search functionality to Pepperminty Wiki using an inverted index to provide a full text search engine. If pages don't show up, then you might have hit a stop word. If not, try requesting the `invindex-rebuild` action to rebuild the inverted index from scratch.",
"id": "feature-search",
"lastupdate": 1498643008,
"lastupdate": 1498645080,
"optional": false
},
{

View File

@ -273,7 +273,8 @@ register_module([
<InputEncoding>UTF-8</InputEncoding>
<OutputEncoding>UTF-8</OutputEncoding>
<Url type=\"text/html\" method=\"get\" template=\"$siteRoot?action=search&amp;query={searchTerms}&amp;offset={startIndex?}&amp;count={count}\" />
<Url type=\"text/html\" method=\"get\" template=\"$siteRoot?action=view&search-redirect=yes&amp;page={searchTerms}&amp;offset={startIndex?}&amp;count={count}\" />
<Url type=\"application/x-suggestions+json\" template=\"$siteRoot?action=suggest-pages&amp;query={searchTerms}&amp;type=opensearch\" />
</OpenSearchDescription>");
});
@ -293,8 +294,8 @@ register_module([
if($settings->dynamic_page_suggestion_count === 0)
{
header("content-type: application/json");
header("content-length: 2");
exit("[]");
header("content-length: 3");
exit("[]\n");
}
if(empty($_GET["query"])) {