From 6535fbd73f79a015eb12d7468b0b4f86fc5f0648 Mon Sep 17 00:00:00 2001 From: Michael Wallner Date: Tue, 12 May 2015 11:58:59 +0200 Subject: [PATCH] show already uploaded asset --- app/Controller/Github/Repo.php | 3 +++ app/Github/API.php | 5 +++++ app/Github/API/Releases/ListReleaseAssets.php | 13 ++++++++---- app/views/github/repo.phtml | 20 +++++++++++++++++++ 4 files changed, 37 insertions(+), 4 deletions(-) diff --git a/app/Controller/Github/Repo.php b/app/Controller/Github/Repo.php index bf1358a..32fab56 100644 --- a/app/Controller/Github/Repo.php +++ b/app/Controller/Github/Repo.php @@ -44,6 +44,9 @@ class Repo extends Github $tag = $release->tag_name; settype($repo->tags->$tag, "object"); $repo->tags->$tag->release = $release; + $this->github->listReleaseAssets($repo->full_name, $release->id, function($assets) use($release) { + $release->assets = $assets; + }); } }; } diff --git a/app/Github/API.php b/app/Github/API.php index 0f63a60..d6990f2 100644 --- a/app/Github/API.php +++ b/app/Github/API.php @@ -212,4 +212,9 @@ class API $call = new API\Releases\CreateReleaseAsset($this, compact("url", "asset", "type")); return $call($callback); } + + function listReleaseAssets($repo, $id, callable $callback) { + $call = new API\Releases\ListReleaseAssets($this, compact("repo", "id")); + return $call($callback); + } } diff --git a/app/Github/API/Releases/ListReleaseAssets.php b/app/Github/API/Releases/ListReleaseAssets.php index b365183..bde9096 100644 --- a/app/Github/API/Releases/ListReleaseAssets.php +++ b/app/Github/API/Releases/ListReleaseAssets.php @@ -2,17 +2,22 @@ namespace app\Github\API\Releases; -class ListReleaseAssets extends \app\Github\API\Call +use app\Github\API\Call; +use app\Github\Exception\RequestException; +use app\Github\Links; +use http\Client\Request; + +class ListReleaseAssets extends Call { function enqueue(callable $callback) { - $url = $this->url->mod(uri_template("./repos/{+repo}/releases{/release}/assets", $this->args)); - $request = new \http\Client\Request("GET", $url, [ + $url = $this->url->mod(uri_template("./repos/{+repo}/releases{/id}/assets", $this->args)); + $request = new Request("GET", $url, [ "Authorization" => "token ". $this->api->getToken(), "Accept" => $this->config->api->accept, ]); $this->api->getClient()->enqueue($request, function($response) use($callback) { if ($response->getResponseCode() >= 400 || null === ($json = json_decode($response->getBody()))) { - throw new \app\Github\Exception\RequestException($response); + throw new RequestException($response); } $links = new Links($response->getHeader("Link")); $this->saveToCache([$json, $links]); diff --git a/app/views/github/repo.phtml b/app/views/github/repo.phtml index 6000cf7..80b5c8c 100644 --- a/app/views/github/repo.phtml +++ b/app/views/github/repo.phtml @@ -183,6 +183,8 @@
+
+
release)) : ?>

md($v->release->body) ?>

@@ -206,6 +208,24 @@ +
+
+ release->assets)) : ?> + + +
+
-- 2.30.2