This commit is contained in:
Shish
2023-11-11 21:49:12 +00:00
parent 848797030e
commit fd1bb21f9d
235 changed files with 1551 additions and 1591 deletions

View File

@@ -10,7 +10,7 @@ class DanbooruApiInfo extends ExtensionInfo
public string $key = self::KEY;
public string $name = "Danbooru Client API";
public array $authors = ["JJS"=>"jsutinen@gmail.com"];
public array $authors = ["JJS" => "jsutinen@gmail.com"];
public string $description = "Allow Danbooru apps like Danbooru Uploader for Firefox to communicate with Shimmie";
public ?string $documentation =
"<b>Notes</b>:

View File

@@ -99,7 +99,7 @@ class DanbooruApi extends Extension
foreach ($idlist as $id) {
$sqlresult = $database->get_all(
"SELECT id,tag,count FROM tags WHERE id = :id",
['id'=>$id]
['id' => $id]
);
foreach ($sqlresult as $row) {
$results[] = [$row['count'], $row['tag'], $row['id']];
@@ -110,7 +110,7 @@ class DanbooruApi extends Extension
foreach ($namelist as $name) {
$sqlresult = $database->get_all(
"SELECT id,tag,count FROM tags WHERE LOWER(tag) = LOWER(:tag)",
['tag'=>$name]
['tag' => $name]
);
foreach ($sqlresult as $row) {
$results[] = [$row['count'], $row['tag'], $row['id']];
@@ -129,7 +129,7 @@ class DanbooruApi extends Extension
$start = isset($_GET['after_id']) ? int_escape($_GET['offset']) : 0;
$sqlresult = $database->get_all(
"SELECT id,tag,count FROM tags WHERE count > 0 AND id >= :id ORDER BY id DESC",
['id'=>$start]
['id' => $start]
);
foreach ($sqlresult as $row) {
$results[] = [$row['count'], $row['tag'], $row['id']];
@@ -205,7 +205,7 @@ class DanbooruApi extends Extension
// Now we have the array $results filled with Image objects
// Let's display them
$xml = POSTS(["count"=>$count, "offset"=>$start]);
$xml = POSTS(["count" => $count, "offset" => $start]);
foreach ($results as $img) {
// Sanity check to see if $img is really an image object
// If it isn't (e.g. someone requested an invalid md5 or id), break out of the this

View File

@@ -13,13 +13,13 @@ class DanbooruApiTest extends ShimmiePHPUnitTestCase
$image_id = $this->post_image("tests/bedroom_workshop.jpg", "data");
$this->get_page("api/danbooru/find_posts");
$this->get_page("api/danbooru/find_posts", ["id"=>$image_id]);
$this->get_page("api/danbooru/find_posts", ["md5"=>"17fc89f372ed3636e28bd25cc7f3bac1"]);
$this->get_page("api/danbooru/find_posts", ["tags"=>"*"]);
$this->get_page("api/danbooru/find_posts", ["id" => $image_id]);
$this->get_page("api/danbooru/find_posts", ["md5" => "17fc89f372ed3636e28bd25cc7f3bac1"]);
$this->get_page("api/danbooru/find_posts", ["tags" => "*"]);
$this->get_page("api/danbooru/find_tags");
$this->get_page("api/danbooru/find_tags", ["id"=>1]);
$this->get_page("api/danbooru/find_tags", ["name"=>"data"]);
$this->get_page("api/danbooru/find_tags", ["id" => 1]);
$this->get_page("api/danbooru/find_tags", ["name" => "data"]);
$page = $this->get_page("api/danbooru/post/show/$image_id");
$this->assertEquals(302, $page->code);