Skip to content

Commit

Permalink
Addon\Detail: dont link php & php extension to packagist [closes #42]
Browse files Browse the repository at this point in the history
  • Loading branch information
f3l1x committed Feb 11, 2016
1 parent 1c15a2f commit 0133519
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 1 deletion.
1 change: 1 addition & 0 deletions app/config/app/latte.neon
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ services:
- addFilter('timeAgo', ['App\Core\Latte\Filters', 'timeAgo'])
- addFilter('datetime', ['App\Core\Latte\Filters', 'datetime'])
- addFilter('shields', ['App\Core\Latte\Filters', 'shields'])
- addFilter('isPhpDependency', ['App\Core\Latte\Filters', 'isPhpDependency'])
21 changes: 21 additions & 0 deletions app/core/latte/Filters.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace App\Core\Latte;

use Nette\Utils\DateTime;
use Nette\Utils\Strings;

final class Filters
{
Expand Down Expand Up @@ -96,4 +97,24 @@ public static function shields($name)
return $name;
}

/**
* @param string $name
* @return bool
*/
public static function isPhpDependency($name)
{
$blacklist = [
'php',
'ext-\w'
];

foreach ($blacklist as $regex) {
if (Strings::match($name, "#$regex#")) {

This comment has been minimized.

Copy link
@Majkl578

Majkl578 Feb 11, 2016

This is incorrect, it will also match e.g. 'some-php-package'.

This comment has been minimized.

Copy link
@f3l1x

f3l1x Feb 11, 2016

Author Member

Thanks, my fault, fixed now, with tests.

return TRUE;
}
}

return FALSE;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,12 @@
<div class="title">Requirements</div>

<ul n:inner-foreach="$composer->getRequire() as $name => $version">
<li><a title="{$name} ({$version})" data-toggle="tooltip" data-placement="left" data-ga="1" data-event="click" data-category="requirements" data-action="{$name}" href="{$addon->github->composer->getPackageUrl($name)}">{$name}</a> ({$version})</li>
<li>
<a n:tag-if="!$template->isPhpDependency($name)" title="{$name} ({$version})" data-toggle="tooltip" data-placement="left" data-ga="1" data-event="click" data-category="requirements" data-action="{$name}" href="{$addon->github->composer->getPackageUrl($name)}">
{$name}
</a>
({$version})
</li>
</ul>
</div>
{/if}
Expand Down

0 comments on commit 0133519

Please sign in to comment.