aboutsummaryrefslogtreecommitdiff
path: root/gen
blob: 44fa700db91d4dac9c3c6aef1bd7e30e59a9cb74 (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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/usr/bin/env ruby
# Creates the overlays.gentoo.org webpage
# Alex Legler <a3li@gentoo.org>

require 'erb'
require 'nokogiri'
require 'open-uri'

REPOSITORIES_XML = 'https://api.gentoo.org/overlays/repositories.xml'.freeze
$xml = Nokogiri::XML(open(REPOSITORIES_XML))

def render_table
  r = ''
  $xml.xpath('//repo').each do |repo|
    repo_name = repo.xpath('./name/text()').first.content

    repo_uri  = nil
    xpath = repo.xpath('./homepage/text()')
    if xpath.length > 0
      repo_uri  = repo.xpath('./homepage/text()').first.content
    end

    repo_desc = repo.xpath('./description/text()').first.content
    repo_qual = repo['quality']
    repo_stat = repo['status']

    repo_ownr = nil
    xpath = repo.xpath('./owner/name/text()')
    if xpath.length > 0
      repo_ownr = xpath.first.content
    end

    repo_mail = repo.xpath('./owner/email/text()').first.content.gsub('@', '(at)')

    r += '<tr>'
    r += '<th>'

    if repo_stat == 'official'
      r += '<span class="fa fa-fw fa-institution" title="Official repository"></span> '
    else
      r += '<span class="fa fa-fw fa-group" title="Unofficial repository"></span> '
    end

    if repo_uri
      r += "<a href='%s'>%s</a>" % [repo_uri, repo_name]
    else
      r += repo_name
    end

    r += '</th>'

    r += '<td>' + repo_desc + '</td>'
    r += '<td>'
    r += "<a href='mailto:%s'>%s</a>" % [repo_mail, repo_ownr ? repo_ownr : repo_mail]
    r += '</td>'

    r += "</tr>\n"
  end

  r 
end

renderer = ERB.new(DATA.read)
puts renderer.result

__END__
<h1 class="first-header">Gentoo repositories</h1>

<p>
  <a href="https://wiki.gentoo.org/wiki/Overlay">Ebuild repositories</a> contain additional packages for your Gentoo system.
  Gentoo maintains a list of repositories for use in tools such as <code>layman</code>. You can find them below.
</p>

<div class="alert alert-info">
  <strong>Using these repositories:</strong>
  You can enable these repositories in your system using <a href="https://wiki.gentoo.org/wiki/Layman"><kbd>layman</kbd></a>.
  They appear by the same name as on this page.
  <br><br>
  <strong>Adding your own repository:</strong>
  Please see the <a href="https://wiki.gentoo.org/wiki/Project:Overlays/Overlays_guide" class="alert-link">Overlays guide</a>
  to either request a Git repository on git.gentoo.org and/or add your repository to the list.
</div>

<div class="alert alert-danger">
  <strong>Repository URL changes</strong>
  <br><br>
  We recently restructured the way you can access repositories hosted by Gentoo.<br>
  Any overlays from <code>git.overlays.gentoo.org</code> or <code>overlays.gentoo.org</code> need to be changed to a new URL.
  You can find more information in the <a href="https://www.gentoo.org/news/2015/04/25/anongit-overlays.html" class="alert-link">news item</a>.
</div>

<table class="table">
  <tr>
    <th>Repository name</th>
    <th>Description</th>
    <th>Contact</th>
  </tr>
  <%= render_table %>
</table>