aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobin H. Johnson <robbat2@gentoo.org>2022-01-22 21:06:49 -0800
committerRobin H. Johnson <robbat2@gentoo.org>2022-01-22 21:09:38 -0800
commitedeeea48b837944e8ce7ac25a446b1c731638863 (patch)
tree1afb54c71f16470322276c538626602731f1cee4 /_plugins
parentFix some broken download links (diff)
downloadwww-edeeea48b837944e8ce7ac25a446b1c731638863.tar.gz
www-edeeea48b837944e8ce7ac25a446b1c731638863.tar.bz2
www-edeeea48b837944e8ce7ac25a446b1c731638863.zip
_plugins/mirrors.rb: move country names to seperate file
Reference: https://bugs.gentoo.org/831807 Signed-off-by: Robin H. Johnson <robbat2@gentoo.org>
Diffstat (limited to '_plugins')
-rw-r--r--_plugins/mirrors.rb12
1 files changed, 10 insertions, 2 deletions
diff --git a/_plugins/mirrors.rb b/_plugins/mirrors.rb
index c1bf17b..9683a9e 100644
--- a/_plugins/mirrors.rb
+++ b/_plugins/mirrors.rb
@@ -1,25 +1,33 @@
+require 'yaml'
module Gentoo
class StaticMirrorDataGenerator < Jekyll::Generator
DISTFILES_XML = '_data/mirrors-distfiles.xml'
RSYNC_XML = '_data/mirrors-rsync.xml'
+ ISO3166 = '_data/iso3166-sort-of.yaml'
def generate(site)
site.data['mirrors'] ||= { 'rsync' => {}, 'distfiles' => {} }
+ load_countries(site, ISO3166)
load_mirrors(site, DISTFILES_XML, 'distfiles')
load_mirrors(site, RSYNC_XML, 'rsync')
end
+ def load_countries(site, yaml_file)
+ countryinfo = YAML.load(File.read(yaml_file))
+ site.data['countries'] = countryinfo
+ end
+
def load_mirrors(site, xml, key)
mirrorinfo = Nokogiri::XML(File.open(xml))
mirrorinfo.xpath('/mirrors/mirrorgroup').each do |mirrorgroup|
region = mirrorgroup['region']
- country = mirrorgroup['countryname']
country_code = mirrorgroup['country']
+ country_name = site.data&.dig('countries', country_code, 'country-name') || "Unknown-country-name:"+country_code
site.data['mirrors'][key][region] ||= {}
- site.data['mirrors'][key][region][country_code] ||= { 'name' => country, 'mirrors' => [] }
+ site.data['mirrors'][key][region][country_code] ||= { 'name' => country_name, 'mirrors' => [] }
mirrorgroup.children.each do |mirror|
mirror_data = { 'uris' => [] }