blob: a459319539c6ee755b92e6b979c79c36cbf30e8e (
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
51
52
53
|
# frozen_string_literal: true
# Display package version data acording to PyPI
# Simple API: https://warehouse.pypa.io/api-reference/legacy/#simple-project-api
module Packages
module Pypi
class SimplePresenterBase
include API::Helpers::RelatedResourcesHelpers
def initialize(packages, project_or_group)
@packages = packages
@project_or_group = project_or_group
end
def body
<<-HTML
<!DOCTYPE html>
<html>
<head>
<title>Links for #{escape(body_name)}</title>
</head>
<body>
<h1>Links for #{escape(body_name)}</h1>
#{links}
</body>
</html>
HTML
end
private
def package_link(url, required_python, name)
"<a href=\"#{url}\" data-requires-python=\"#{escape(required_python)}\">#{name}</a>"
end
def escape(str)
ERB::Util.html_escape(str)
end
def project?
@project_or_group.is_a?(::Project)
end
def group?
@project_or_group.is_a?(::Group)
end
def available_packages
@packages.not_pending_destruction
end
end
end
end
|