-
Notifications
You must be signed in to change notification settings - Fork 1.2k
[AlpinePackages] New alpine packages bridge #4781
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+192
−0
Merged
Changes from 2 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
5d73744
New Alpine Packages bridge
rsd76 d0e64b2
Merge branch 'RSS-Bridge:master' into alpine-packages-bridge
rsd76 4c71099
Redesign and fix comments.
rsd76 e383970
Fix name.
rsd76 a2fe6ae
Fixes for more comments
rsd76 97126d0
[AlpinePackages] Reword strings
Mynacol 3f6a751
Make architecture a list.
rsd76 684c21c
Set defaultValue architecture to 'all'.
rsd76 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| <?php | ||
|
|
||
| class AlpinePackagesBridge extends BridgeAbstract | ||
| { | ||
| const NAME = 'Alpine Packages Bridge'; | ||
Mynacol marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| const MAINTAINER = 'rsd76'; | ||
| const URI = 'https://pkgs.alpinelinux.org'; | ||
| const DESCRIPTION = 'Bridge for getting Alpine packages'; | ||
| const CACHE_TIMEOUT = 15; | ||
|
|
||
| const PARAMETERS = [ | ||
| 'Alpine package' => [ | ||
| 'branch' => [ | ||
| 'type' => 'text', | ||
| 'name' => 'Package branch', | ||
| 'exampleValue' => 'v3.22' | ||
| ], | ||
| 'repository' => [ | ||
| 'type' => 'text', | ||
| 'name' => 'Apline repository', | ||
| 'exampleValue' => 'All' | ||
| ], | ||
| 'architecture' => [ | ||
| 'type' => 'text', | ||
| 'name' => 'Achitecture', | ||
| 'exampleValue' => 'aarch64' | ||
| ], | ||
| 'package' => [ | ||
| 'type' => 'text', | ||
| 'name' => 'Package', | ||
| 'exampleValue' => 'curl' | ||
| ] | ||
| ] | ||
| ]; | ||
|
|
||
| private function getPackageUri() | ||
| { | ||
| if (!is_null($this->getInput('branch')) && !is_null($this->getInput('repository')) && !is_null($this->getInput('architecture')) && !is_null($this->getInput('package'))) { | ||
| return $this->getUri(); | ||
| } else { | ||
| return self::URI . '/packages?name=curl&branch=v3.22&repo=&arch=aarch64&origin=&flagged=&maintainer='; | ||
rsd76 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| } | ||
|
|
||
| public function collectData() | ||
| { | ||
| $dom = getSimpleHTMLDOM($this->getPackageUri()); | ||
| $divs = $dom->find('div[class=table-responsive]'); | ||
| foreach ($divs as $div) { | ||
| $packages = $div->find('td[class=package]'); | ||
| $titles = []; | ||
| $links = []; | ||
| $versions = []; | ||
| $i = 0; | ||
| foreach ($packages as $package) { | ||
| $ahrefs = $package->find('a'); | ||
| foreach ($ahrefs as $ahref) { | ||
| $titles[$i] = trim($ahref->plaintext); | ||
| $links[$i] = trim($ahref->href); | ||
| $i++; | ||
| } | ||
| } | ||
| $maxi = $i; | ||
| $i = 0; | ||
| $versions = $div->find('td[class=version]'); | ||
| foreach ($versions as $version) { | ||
| $strongs = $version->find('strong[class=hint--right hint--rounded text-success]'); | ||
| foreach ($strongs as $strong) { | ||
| $versions[$i] = trim($strong->plaintext); | ||
| $i++; | ||
| } | ||
| } | ||
| for ($i = 0; $i < $maxi; $i++) { | ||
| $this->items[] = [ | ||
| 'title' => $titles[$i] . '-' . $versions[$i], | ||
| 'uri' => self::URI . $links[$i], | ||
| 'uid' => $titles[$i] . '-' . $versions[$i] | ||
| ]; | ||
| } | ||
| } | ||
| } | ||
|
|
||
| public function getName() | ||
| { | ||
| if ($this->getInput('package')) { | ||
| $package = $this->getInput('package'); | ||
| return 'Alpine package - ' . $package; | ||
rsd76 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| return parent::getName(); | ||
| } | ||
|
|
||
| public function getUri() | ||
| { | ||
| $name = urlencode($this->getInput('package')); | ||
| $branch = urlencode($this->GetInput('branch')); | ||
| $repo = urlencode($this->GetInput('repository')); | ||
| $arch = urlencode($this->GetInput('architecture')); | ||
rsd76 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| if ($repo == 'All') { | ||
| $repo = ''; | ||
| } | ||
| if ($name && $branch && $arch) { | ||
| return self::URI . '/packages?name=' . $name . '&branch=' . $branch . '&repo=' . $repo . '&arch=' . $arch . '&origin=&flagged=&maintainer='; | ||
rsd76 marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
| } | ||
| return self::URI . '/packages'; | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.