Skip to content

Commit

Permalink
Set consistent whitespace & style
Browse files Browse the repository at this point in the history
* 4-space indentation
* Drop closing PHP tags
* Trim trailing whitespace
* Adhere to PSR-2
  • Loading branch information
jeffbyrnes committed Apr 6, 2018
1 parent 409bcfc commit 1e8c108
Show file tree
Hide file tree
Showing 34 changed files with 1,576 additions and 1,541 deletions.
76 changes: 38 additions & 38 deletions src/Alcatraz.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,44 +6,44 @@

class Alcatraz extends Repo
{
protected $id = 'alcatraz';
protected $url = 'http://alcatraz.io';
protected $has_db = true;

public function search($query)
{
if (!$this->hasMinQueryLength($query)) {
return $this->xml();
}
foreach($this->pkgs as $categories) {
// plugins, color_scheme, project_templates, file_templates
foreach($categories as $category) {
foreach($category as $pkg) {
if ($this->check($pkg, $query)) {
$this->cache->w->result(
$pkg->url,
$this->makeArg($pkg->name, $pkg->url),
$pkg->name,
$pkg->description,
"icon-cache/{$this->id}.png"
);
}

// only search till max return reached
if ( count ( $this->cache->w->results() ) == $this->max_return ) {
break;
}
}
}
}
// The search URL here isn’t quiet right, since Alcatraz doesn't have a
// a web UI for its "repo"
$this->noResults($query, $this->cache->dbs[$this->id]);

return $this->xml();
}
protected $id = 'alcatraz';
protected $url = 'http://alcatraz.io';
protected $has_db = true;

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

foreach ($this->pkgs as $categories) {
// plugins, color_scheme, project_templates, file_templates
foreach ($categories as $category) {
foreach ($category as $pkg) {
if ($this->check($pkg, $query)) {
$this->cache->w->result(
$pkg->url,
$this->makeArg($pkg->name, $pkg->url),
$pkg->name,
$pkg->description,
"icon-cache/{$this->id}.png"
);
}

// only search till max return reached
if (count($this->cache->w->results()) == $this->max_return) {
break;
}
}
}
}

// The search URL here isn’t quiet right, since Alcatraz doesn't have a
// a web UI for its "repo"
$this->noResults($query, $this->cache->dbs[$this->id]);

return $this->xml();
}
}

// Test code, uncomment to debug this script from the command-line
Expand Down
88 changes: 44 additions & 44 deletions src/Apm.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,61 +6,61 @@

class Apm extends Repo
{
protected $id = 'apm';
protected $url = 'https://atom.io';
protected $search_url = 'https://atom.io/packages/search?q=';
protected $id = 'apm';
protected $url = 'https://atom.io';
protected $search_url = 'https://atom.io/packages/search?q=';

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

$data = $this->cache->get_query_regex(
$this->id,
$query,
"{$this->search_url}{$query}",
'/<div class="package-list">([\s\S]*?)<div class="footer-pad">/i'
);
$data = $this->cache->get_query_regex(
$this->id,
$query,
"{$this->search_url}{$query}",
'/<div class="package-list">([\s\S]*?)<div class="footer-pad">/i'
);

$this->pkgs = explode('<div class="grid-cell">', $data[0]);
array_shift($this->pkgs);
$this->pkgs = explode('<div class="grid-cell">', $data[0]);
array_shift($this->pkgs);

foreach($this->pkgs as $pkg) {
// make params
preg_match('/<h4 class="card-name">([\s\S]*?)<\/h4>/i', $pkg, $matches);
$title = trim(strip_tags($matches[1]));
foreach ($this->pkgs as $pkg) {
// make params
preg_match('/<h4 class="card-name">([\s\S]*?)<\/h4>/i', $pkg, $matches);
$title = trim(strip_tags($matches[1]));

preg_match(
'/<span class="css-truncate-target card-description">([\s\S]*?)<\/span>/i',
$pkg,
$matches
);
preg_match(
'/<span class="css-truncate-target card-description">([\s\S]*?)<\/span>/i',
$pkg,
$matches
);

$description = html_entity_decode(trim(strip_tags($matches[1])));
$description = html_entity_decode(trim(strip_tags($matches[1])));

preg_match('/<a href="[\s\S]*?" class="author">([\s\S]*?)<\/a>/i', $pkg, $matches);
$author = trim(strip_tags($matches[1]));
// $version = trim(strip_tags($matches[1]));
preg_match('/<a href="[\s\S]*?" class="author">([\s\S]*?)<\/a>/i', $pkg, $matches);
$author = trim(strip_tags($matches[1]));
// $version = trim(strip_tags($matches[1]));

$this->cache->w->result(
$title,
$this->makeArg($title, "{$this->url}/packages/{$title}"),
"{$title} ~ by {$author}", // "v{$version}"
$description,
"icon-cache/{$this->id}.png"
);
$this->cache->w->result(
$title,
$this->makeArg($title, "{$this->url}/packages/{$title}"),
"{$title} ~ by {$author}", // "v{$version}"
$description,
"icon-cache/{$this->id}.png"
);

// only search till max return reached
if ( count ( $this->cache->w->results() ) == $this->max_return ) {
break;
}
}
// only search till max return reached
if (count($this->cache->w->results()) == $this->max_return) {
break;
}
}

$this->noResults($query, "{$this->search_url}{$query}");
$this->noResults($query, "{$this->search_url}{$query}");

return $this->xml();
}
return $this->xml();
}
}

// Test code, uncomment to debug this script from the command-line
Expand Down
84 changes: 42 additions & 42 deletions src/AptGet.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,48 +6,48 @@

class AptGet extends Repo
{
protected $id = 'apt-get';
protected $url = 'https://apps.ubuntu.com';
protected $search_url = 'https://apps.ubuntu.com/cat/search/?q=';

public function search($query)
{
if (!$this->hasMinQueryLength($query)) {
return $this->xml();
}
$this->pkgs = $this->cache->get_query_regex(
$this->id,
$query,
"{$this->search_url}{$query}",
'/<tr>([\s\S]*?)<\/tr>/i'
);
foreach($this->pkgs as $item) {
preg_match('/<p>(.*?)<\/p>/i', $item, $matches);
$name = trim(strip_tags($matches[1]));
preg_match('/<h3>([\s\S]*?)<\/h3>/i', $item, $matches);
$description = trim(strip_tags($matches[1]));
$this->cache->w->result(
$name,
$this->makeArg($name, "{$this->url}/cat/applications/{$name}"),
$name,
$description,
"icon-cache/{$this->id}.png"
);

// only search till max return reached
if ( count ( $this->cache->w->results() ) == $this->max_return ) {
break;
}
}
$this->noResults($query, "{$this->search_url}{$query}");

return $this->xml();
}
protected $id = 'apt-get';
protected $url = 'https://apps.ubuntu.com';
protected $search_url = 'https://apps.ubuntu.com/cat/search/?q=';

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

$this->pkgs = $this->cache->get_query_regex(
$this->id,
$query,
"{$this->search_url}{$query}",
'/<tr>([\s\S]*?)<\/tr>/i'
);

foreach ($this->pkgs as $item) {
preg_match('/<p>(.*?)<\/p>/i', $item, $matches);
$name = trim(strip_tags($matches[1]));

preg_match('/<h3>([\s\S]*?)<\/h3>/i', $item, $matches);
$description = trim(strip_tags($matches[1]));

$this->cache->w->result(
$name,
$this->makeArg($name, "{$this->url}/cat/applications/{$name}"),
$name,
$description,
"icon-cache/{$this->id}.png"
);

// only search till max return reached
if (count($this->cache->w->results()) == $this->max_return) {
break;
}
}

$this->noResults($query, "{$this->search_url}{$query}");

return $this->xml();
}
}

// Test code, uncomment to debug this script from the command-line
Expand Down
76 changes: 38 additions & 38 deletions src/Bower.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,44 +6,44 @@

class Bower extends Repo
{
protected $id = 'bower';
protected $kind = 'components';
protected $url = 'http://bower.io';
protected $search_url = 'https://bower.herokuapp.com/packages/search/';

public function search($query)
{
if (!$this->hasMinQueryLength($query)) {
return $this->xml();
}
$this->pkgs = $this->cache->get_query_json(
'bower',
$query,
"{$this->search_url}{$query}"
);
foreach($this->pkgs as $pkg) {
$url = str_replace("git://", "https://", $pkg->url);
$version = "*";
$this->cache->w->result(
$pkg->url,
$this->makeArg($pkg->name, $url, "\"{$pkg->name}\": \"{$version}\""),
$pkg->name,
$url,
"icon-cache/{$this->id}.png"
);
// Only show results up to the $max_return
if ( count ( $this->cache->w->results() ) == $this->max_return ) {
break;
}
}

$this->noResults($query, "{$this->url}/search/?q={$query}");

return $this->xml();
}
protected $id = 'bower';
protected $kind = 'components';
protected $url = 'http://bower.io';
protected $search_url = 'https://bower.herokuapp.com/packages/search/';

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

$this->pkgs = $this->cache->get_query_json(
'bower',
$query,
"{$this->search_url}{$query}"
);

foreach ($this->pkgs as $pkg) {
$url = str_replace("git://", "https://", $pkg->url);
$version = "*";
$this->cache->w->result(
$pkg->url,
$this->makeArg($pkg->name, $url, "\"{$pkg->name}\": \"{$version}\""),
$pkg->name,
$url,
"icon-cache/{$this->id}.png"
);

// Only show results up to the $max_return
if (count($this->cache->w->results()) == $this->max_return) {
break;
}
}

$this->noResults($query, "{$this->url}/search/?q={$query}");

return $this->xml();
}
}

// Test code, uncomment to debug this script from the command-line
Expand Down
Loading

0 comments on commit 1e8c108

Please sign in to comment.