Skip to content

Commit

Permalink
Updated docker script to use the same index api as the docker client.
Browse files Browse the repository at this point in the history
  • Loading branch information
tavisto committed Sep 23, 2015
1 parent c383256 commit 106a148
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 22 deletions.
Binary file modified Package Managers.alfredworkflow
Binary file not shown.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Package Managers ([Download v3.03](https://github.com/willfarrell/alfred-pkgman-workflow/releases/download/3.03/Package.Managers.alfredworkflow))
# Package Managers ([Download v3.04](https://github.com/willfarrell/alfred-pkgman-workflow/releases/download/3.04/Package.Managers.alfredworkflow))

Package Repo Search

Expand Down
4 changes: 2 additions & 2 deletions current-version.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": 3.03,
"download_url": "https://github.com/willfarrell/alfred-pkgman-workflow/releases/download/3.02/Package.Managers.alfredworkflow",
"version": 3.04,
"download_url": "https://github.com/willfarrell/alfred-pkgman-workflow/releases/download/3.04/Package.Managers.alfredworkflow",
"description": "Package Repo Search"
}
30 changes: 11 additions & 19 deletions src/Docker.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,41 +8,33 @@ class Docker extends Repo
{
protected $id = 'docker';
protected $kind = 'images';
protected $url = 'https://registry.hub.docker.com';
protected $search_url = 'https://registry.hub.docker.com/search?q=';
protected $url = 'https://hub.docker.com';
protected $search_url = 'https://index.docker.io/v1/search?q=';

public function search($query)
{
if (!$this->hasMinQueryLength($query)) {
return $this->xml();
}

$this->pkgs = $this->cache->get_query_regex(
$this->pkgs = $this->cache->get_query_json(
$this->id,
$query,
"{$this->search_url}{$query}",
'/(<a href="\/(_|u)\/.*"><div class="repo-list-item box">[\s\S]*?<\/a>)/i',
1
);
"{$this->search_url}{$query}"
);

foreach($this->pkgs as $pkg) {
foreach($this->pkgs->results as $pkg) {

// make params
preg_match('/<a href="(.*?)">[\s\S]*?<h2>([\s\S]*?)<[\s\S]*<\/h2>([\s\S]*?)<\/div>/i', $pkg, $matches);
$title = trim(preg_replace('/\s+/', '', $matches[2]));
$url = $this->url . trim(preg_replace('/\s+/', '', $matches[1]));
$description = trim(preg_replace('/\s+/', ' ', $matches[3]));
if (!$description || trim(preg_replace('/\s+/', '', $matches[3])) == '') {
$description = $url;
}
$title = $pkg->name;
$repository = ($pkg->is_official ) ? '_' : 'r';
$url = $this->url . '/'. $repository . '/'. $pkg->name;
$description = $pkg->description;

preg_match('/<span class="timesince" data-time=".*">\s?([\s\S]*?)\s?<\/span>/i', $pkg, $matches);
$updated = trim(preg_replace('/\s+/', ' ', $matches[1]));

$this->cache->w->result(
$title,
$this->makeArg($title, $url),
$title.' ~ '.$updated,
$title.' ~ '.$pkg->star_count,
$description,
"icon-cache/{$this->id}.png"
);
Expand Down

0 comments on commit 106a148

Please sign in to comment.