diff options
author | 2020-06-23 08:31:16 -0700 | |
---|---|---|
committer | 2020-06-23 08:31:16 -0700 | |
commit | 9149e614019b8c5dc59d145d365011b2ed144b34 (patch) | |
tree | e143c4d8073cf5622a382e056452615b71126f23 | |
parent | Fix the news feeds (diff) | |
download | www-9149e614019b8c5dc59d145d365011b2ed144b34.tar.gz www-9149e614019b8c5dc59d145d365011b2ed144b34.tar.bz2 www-9149e614019b8c5dc59d145d365011b2ed144b34.zip |
Fix new packages feed
Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
-rw-r--r-- | _includes/frontpage/packages | 2 | ||||
-rw-r--r-- | _plugins/packages.rb | 61 |
2 files changed, 62 insertions, 1 deletions
diff --git a/_includes/frontpage/packages b/_includes/frontpage/packages index adf87f9..444d15c 100644 --- a/_includes/frontpage/packages +++ b/_includes/frontpage/packages @@ -1,7 +1,7 @@ <table class="table table-striped frontpage-table"> {% for post in site.data.packages.updates limit:5 %} <tr> - <td class="frontpage-table-package-atom"><a href="{{ post.uri }}">{{ post.atom }}</a></td> + <td class="frontpage-table-package-atom"><a href="{{ post.uri }}">{{ post.atom_cpv }}</a></td> <td>{{ post.description }}</td> </tr> {% endfor %} diff --git a/_plugins/packages.rb b/_plugins/packages.rb index 98cb373..5d02178 100644 --- a/_plugins/packages.rb +++ b/_plugins/packages.rb @@ -3,6 +3,52 @@ module Gentoo XML = '_data/packages.xml' def generate(site) + generate_soko(site) + end + def generate_soko(site) + xml = nil + begin + xml = Nokogiri::XML(File.open(XML)) + # atom is mainly one namespace + xml.remove_namespaces! + rescue + # Bail out if it's not valid XML + return [] + end + + #site.data['packages'] ||= { 'updates' => [] } + items = [] + + xml.xpath('/feed/entry').each do |item| + item_data = {} + + entry_by_tagname = {} + item.children.each do |tag| + entry_by_tagname[tag.name] = tag + end + + if entry_by_tagname['id'].text =~ /^tag:packages.gentoo.org,(\d{4}-\d{2}-\d{2}):\/package\/(.*)/ then + item_data['date'] = $1 + item_data['atom'] = $2 + item_data['atom_c'], item_data['atom_pn'] = item_data['atom'].split('/', 2) + item_data['atom_pv'] = nil + if entry_by_tagname['title'].text.start_with?(item_data['atom']) then + item_data['atom_pv'] = entry_by_tagname['title'].text.delete_prefix(item_data['atom']+"-") + end + item_data['description'] = entry_by_tagname['summary'].text + item_data['uri'] = entry_by_tagname['link']['href'] + if item_data['atom_pv'] then + item_data['atom_cpv'] = sprintf('%s:%s-%s', + item_data['atom_c'], + item_data['atom_pn'], + item_data['atom_pv']) + end + items << item_data + end + end + return items + end + def generate_kkuleomi(site) xml = Nokogiri::XML(File.open(XML)) # atom is mainly one namespace xml.remove_namespaces! @@ -30,3 +76,18 @@ module Gentoo end end end + +# Example from kkuleomi +# TODO +# Example from Soko: +# <entry> +# <title>dev-python/requests-unixsocket-0.2.0</title> +# <updated>2020-06-21T10:16:38Z</updated> +# <id>tag:packages.gentoo.org,2020-06-21:/package/dev-python/requests-unixsocket</id> +# <content type="html">dev-python/requests-unixsocket-0.2.0 is now available in Gentoo on these architectures: ~amd64 ~x86. See <a href='https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=cc81527c2dd329d517f9439123d52197968865d1'>Gitweb</a></content> +# <link href="https://packages.gentoo.org/package/dev-python/requests-unixsocket" rel="alternate"></link> +# <summary type="html">Use requests to talk HTTP via a UNIX domain socket</summary> +# <author> +# <name>Michał Górny</name> +# </author> +# </entry> |