mirror of
https://git.lolcat.ca/lolcat/4get.git
synced 2024-11-14 03:49:48 +01:00
Compare commits
3 commits
85246cc7ec
...
12d5b4ade8
Author | SHA1 | Date | |
---|---|---|---|
12d5b4ade8 | |||
c422abbdc6 | |||
6eabc3edf4 |
|
@ -353,26 +353,17 @@ class qwant{
|
|||
"related" => []
|
||||
];
|
||||
|
||||
if($json["status"] != "success"){
|
||||
if(
|
||||
$json["status"] != "success" &&
|
||||
$json["data"]["error_code"] === 5
|
||||
){
|
||||
|
||||
if($json["data"]["error_code"] === 5){
|
||||
|
||||
return $out;
|
||||
}
|
||||
|
||||
if(isset($json["data"]["error_code"])){
|
||||
|
||||
switch($json["data"]["error_code"]){
|
||||
|
||||
case 27:
|
||||
throw new Exception("Qwant returned a captcha");
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
throw new Exception("Qwant returned an error code: " . $json["data"]["error_code"]);
|
||||
// no results
|
||||
return $out;
|
||||
}
|
||||
|
||||
$this->detect_errors($json);
|
||||
|
||||
if(!isset($json["data"]["result"]["items"]["mainline"])){
|
||||
|
||||
throw new Exception("Server did not return a result object");
|
||||
|
@ -654,10 +645,7 @@ class qwant{
|
|||
throw new Exception("Failed to decode JSON");
|
||||
}
|
||||
|
||||
if($json["status"] != "success"){
|
||||
|
||||
throw new Exception("Qwant returned an API error");
|
||||
}
|
||||
$this->detect_errors($json);
|
||||
|
||||
if(isset($json["data"]["result"]["items"]["mainline"])){
|
||||
|
||||
|
@ -754,10 +742,7 @@ class qwant{
|
|||
throw new Exception("Could not parse JSON");
|
||||
}
|
||||
|
||||
if($json["status"] != "success"){
|
||||
|
||||
throw new Exception("Qwant returned an API error");
|
||||
}
|
||||
$this->detect_errors($json);
|
||||
|
||||
if(isset($json["data"]["result"]["items"]["mainline"])){
|
||||
|
||||
|
@ -861,10 +846,7 @@ class qwant{
|
|||
throw new Exception("Could not parse JSON");
|
||||
}
|
||||
|
||||
if($json["status"] != "success"){
|
||||
|
||||
throw new Exception("Qwant returned an API error");
|
||||
}
|
||||
$this->detect_errors($json);
|
||||
|
||||
if(isset($json["data"]["result"]["items"]["mainline"])){
|
||||
|
||||
|
@ -906,6 +888,28 @@ class qwant{
|
|||
return $out;
|
||||
}
|
||||
|
||||
private function detect_errors($json){
|
||||
|
||||
if(
|
||||
isset($json["status"]) &&
|
||||
$json["status"] == "error"
|
||||
){
|
||||
|
||||
if(isset($json["data"]["error_data"]["captchaUrl"])){
|
||||
|
||||
throw new Exception("Qwant returned a captcha");
|
||||
}elseif(isset($json["data"]["error_data"]["error_code"])){
|
||||
|
||||
throw new Exception(
|
||||
"Qwant returned an API error: " .
|
||||
$json["data"]["error_data"]["error_code"]
|
||||
);
|
||||
}
|
||||
|
||||
throw new Exception("Qwant returned an API error");
|
||||
}
|
||||
}
|
||||
|
||||
private function limitstrlen($text){
|
||||
|
||||
return explode("\n", wordwrap($text, 300, "\n"))[0];
|
||||
|
|
40
static/themes/Wine.css
Normal file
40
static/themes/Wine.css
Normal file
|
@ -0,0 +1,40 @@
|
|||
:root
|
||||
{
|
||||
--accent : #f79e98;
|
||||
--1d2021 : #180d0c;
|
||||
--282828 : #180d0c;
|
||||
--3c3836 : #251615;
|
||||
--504945 : #251615;
|
||||
--928374 : var(--accent);
|
||||
--a89984 : #d8c5c4;
|
||||
--bdae93 : #d8c5c4;
|
||||
--8ec07c : var(--accent);
|
||||
--ebdbb2 : #d8c5c4;
|
||||
--comment: #928374;
|
||||
--default: #DCC9BC;
|
||||
--keyword: #F07342;
|
||||
--string : var(--accent);
|
||||
--green : #959A6B;
|
||||
--yellow : #E39C45;
|
||||
--red : #CF223E;
|
||||
--white : var(--a89984);
|
||||
--black : var(--1d2021);
|
||||
--hover : #b18884
|
||||
}
|
||||
|
||||
a.link, a { color: var(--accent); text-decoration: none; }
|
||||
.searchbox { width: 23%; }
|
||||
.filters filter select { color: #E39C45; }
|
||||
.web .separator::before { color: var(--white) }
|
||||
.searchbox input[type="text"]::placeholder { color: var(--white); }
|
||||
a.link:hover
|
||||
{
|
||||
color: var(--hover);
|
||||
text-shadow: 0 0 .2rem var(--hover);
|
||||
}
|
||||
.code-inline
|
||||
{ border-color: var(--default); font-family: monospace;}
|
||||
.home #center a
|
||||
{ color: var(--accent); }
|
||||
.home .subtext
|
||||
{ color: var(--white); }
|
Loading…
Reference in a new issue