blob: ffe4eeb9585bb522f6e79fc979d5dd6a4df7b492 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
# frozen_string_literal: true
# Display package repository index acording to PyPI
# Simple API: https://peps.python.org/pep-0503/
module Packages
module Pypi
class SimpleIndexPresenter < SimplePresenterBase
private
def links
refs = []
available_packages.each_batch do |batch|
batch.each do |package|
url = build_pypi_package_path(package)
refs << package_link(url, package.pypi_metadatum.required_python, package.name)
end
end
refs.join
end
def build_pypi_package_path(package)
params = {
id: @project_or_group.id,
package_name: package.normalized_pypi_name
}
if project?
expose_url(
api_v4_projects_packages_pypi_simple_package_name_path(
params, true
)
)
elsif group?
expose_url(
api_v4_groups___packages_pypi_simple_package_name_path(
params, true
)
)
end
end
def body_name
@project_or_group.name
end
end
end
end
|