mirror of
https://github.com/bigchaindb/site.git
synced 2024-11-21 17:26:55 +01:00
grab country data from external API on every build
This commit is contained in:
parent
19f0ab81d5
commit
6b98f19faa
4
Gemfile
4
Gemfile
@ -6,3 +6,7 @@ group :jekyll do
|
||||
gem 'jekyll-redirect-from'
|
||||
gem 'redcarpet'
|
||||
end
|
||||
|
||||
group :jekyll_plugins do
|
||||
gem 'hash-joiner'
|
||||
end
|
||||
|
@ -72,3 +72,8 @@ collections:
|
||||
gems:
|
||||
- jekyll-sitemap
|
||||
- jekyll-redirect-from
|
||||
|
||||
|
||||
jekyll_get:
|
||||
data: countries
|
||||
json: 'https://restcountries.eu/rest/v2/all?fields=name;alpha2Code'
|
||||
|
@ -1,241 +0,0 @@
|
||||
[
|
||||
{"country" : "Aruba", "abbreviation" : "AW"},
|
||||
{"country" : "Afghanistan", "abbreviation" : "AF"},
|
||||
{"country" : "Angola", "abbreviation" : "AO"},
|
||||
{"country" : "Anguilla", "abbreviation" : "AI"},
|
||||
{"country" : "Albania", "abbreviation" : "AL"},
|
||||
{"country" : "Andorra", "abbreviation" : "AD"},
|
||||
{"country" : "Netherlands Antilles", "abbreviation" : "AN"},
|
||||
{"country" : "United Arab Emirates", "abbreviation" : "AE"},
|
||||
{"country" : "Argentina", "abbreviation" : "AR"},
|
||||
{"country" : "Armenia", "abbreviation" : "AM"},
|
||||
{"country" : "American Samoa", "abbreviation" : "AS"},
|
||||
{"country" : "Antarctica", "abbreviation" : "AQ"},
|
||||
{"country" : "French Southern territories", "abbreviation" : "TF"},
|
||||
{"country" : "Antigua and Barbuda", "abbreviation" : "AG"},
|
||||
{"country" : "Australia", "abbreviation" : "AU"},
|
||||
{"country" : "Austria", "abbreviation" : "AT"},
|
||||
{"country" : "Azerbaijan", "abbreviation" : "AZ"},
|
||||
{"country" : "Burundi", "abbreviation" : "BI"},
|
||||
{"country" : "Belgium", "abbreviation" : "BE"},
|
||||
{"country" : "Benin", "abbreviation" : "BJ"},
|
||||
{"country" : "Burkina Faso", "abbreviation" : "BF"},
|
||||
{"country" : "Bangladesh", "abbreviation" : "BD"},
|
||||
{"country" : "Bulgaria", "abbreviation" : "BG"},
|
||||
{"country" : "Bahrain", "abbreviation" : "BH"},
|
||||
{"country" : "Bahamas", "abbreviation" : "BS"},
|
||||
{"country" : "Bosnia and Herzegovina", "abbreviation" : "BA"},
|
||||
{"country" : "Belarus", "abbreviation" : "BY"},
|
||||
{"country" : "Belize", "abbreviation" : "BZ"},
|
||||
{"country" : "Bermuda", "abbreviation" : "BM"},
|
||||
{"country" : "Bolivia", "abbreviation" : "BO"},
|
||||
{"country" : "Brazil", "abbreviation" : "BR"},
|
||||
{"country" : "Barbados", "abbreviation" : "BB"},
|
||||
{"country" : "Brunei", "abbreviation" : "BN"},
|
||||
{"country" : "Bhutan", "abbreviation" : "BT"},
|
||||
{"country" : "Bouvet Island", "abbreviation" : "BV"},
|
||||
{"country" : "Botswana", "abbreviation" : "BW"},
|
||||
{"country" : "Central African Republic", "abbreviation" : "CF"},
|
||||
{"country" : "Canada", "abbreviation" : "CA"},
|
||||
{"country" : "Cocos (Keeling) Islands", "abbreviation" : "CC"},
|
||||
{"country" : "Switzerland", "abbreviation" : "CH"},
|
||||
{"country" : "Chile", "abbreviation" : "CL"},
|
||||
{"country" : "China", "abbreviation" : "CN"},
|
||||
{"country" : "Ivory Coast", "abbreviation" : "CI"},
|
||||
{"country" : "Cameroon", "abbreviation" : "CM"},
|
||||
{"country" : "Congo, The Democratic Republic of the", "abbreviation" : "CD"},
|
||||
{"country" : "Congo", "abbreviation" : "CG"},
|
||||
{"country" : "Cook Islands", "abbreviation" : "CK"},
|
||||
{"country" : "Colombia", "abbreviation" : "CO"},
|
||||
{"country" : "Comoros", "abbreviation" : "KM"},
|
||||
{"country" : "Cape Verde", "abbreviation" : "CV"},
|
||||
{"country" : "Costa Rica", "abbreviation" : "CR"},
|
||||
{"country" : "Cuba", "abbreviation" : "CU"},
|
||||
{"country" : "Christmas Island", "abbreviation" : "CX"},
|
||||
{"country" : "Cayman Islands", "abbreviation" : "KY"},
|
||||
{"country" : "Cyprus", "abbreviation" : "CY"},
|
||||
{"country" : "Czech Republic", "abbreviation" : "CZ"},
|
||||
{"country" : "Germany", "abbreviation" : "DE"},
|
||||
{"country" : "Djibouti", "abbreviation" : "DJ"},
|
||||
{"country" : "Dominica", "abbreviation" : "DM"},
|
||||
{"country" : "Denmark", "abbreviation" : "DK"},
|
||||
{"country" : "Dominican Republic", "abbreviation" : "DO"},
|
||||
{"country" : "Algeria", "abbreviation" : "DZ"},
|
||||
{"country" : "Ecuador", "abbreviation" : "EC"},
|
||||
{"country" : "Egypt", "abbreviation" : "EG"},
|
||||
{"country" : "Eritrea", "abbreviation" : "ER"},
|
||||
{"country" : "Western Sahara", "abbreviation" : "EH"},
|
||||
{"country" : "Spain", "abbreviation" : "ES"},
|
||||
{"country" : "Estonia", "abbreviation" : "EE"},
|
||||
{"country" : "Ethiopia", "abbreviation" : "ET"},
|
||||
{"country" : "Finland", "abbreviation" : "FI"},
|
||||
{"country" : "Fiji Islands", "abbreviation" : "FJ"},
|
||||
{"country" : "Falkland Islands", "abbreviation" : "FK"},
|
||||
{"country" : "France", "abbreviation" : "FR"},
|
||||
{"country" : "Faroe Islands", "abbreviation" : "FO"},
|
||||
{"country" : "Micronesia, Federated States of", "abbreviation" : "FM"},
|
||||
{"country" : "Gabon", "abbreviation" : "GA"},
|
||||
{"country" : "United Kingdom", "abbreviation" : "GB"},
|
||||
{"country" : "Georgia", "abbreviation" : "GE"},
|
||||
{"country" : "Ghana", "abbreviation" : "GH"},
|
||||
{"country" : "Gibraltar", "abbreviation" : "GI"},
|
||||
{"country" : "Guinea", "abbreviation" : "GN"},
|
||||
{"country" : "Guadeloupe", "abbreviation" : "GP"},
|
||||
{"country" : "Gambia", "abbreviation" : "GM"},
|
||||
{"country" : "Guinea-Bissau", "abbreviation" : "GW"},
|
||||
{"country" : "Equatorial Guinea", "abbreviation" : "GQ"},
|
||||
{"country" : "Greece", "abbreviation" : "GR"},
|
||||
{"country" : "Grenada", "abbreviation" : "GD"},
|
||||
{"country" : "Greenland", "abbreviation" : "GL"},
|
||||
{"country" : "Guatemala", "abbreviation" : "GT"},
|
||||
{"country" : "French Guiana", "abbreviation" : "GF"},
|
||||
{"country" : "Guam", "abbreviation" : "GU"},
|
||||
{"country" : "Guyana", "abbreviation" : "GY"},
|
||||
{"country" : "Hong Kong", "abbreviation" : "HK"},
|
||||
{"country" : "Heard Island and McDonald Islands", "abbreviation" : "HM"},
|
||||
{"country" : "Honduras", "abbreviation" : "HN"},
|
||||
{"country" : "Croatia", "abbreviation" : "HR"},
|
||||
{"country" : "Haiti", "abbreviation" : "HT"},
|
||||
{"country" : "Hungary", "abbreviation" : "HU"},
|
||||
{"country" : "Indonesia", "abbreviation" : "ID"},
|
||||
{"country" : "India", "abbreviation" : "IN"},
|
||||
{"country" : "British Indian Ocean Territory", "abbreviation" : "IO"},
|
||||
{"country" : "Ireland", "abbreviation" : "IE"},
|
||||
{"country" : "Iran", "abbreviation" : "IR"},
|
||||
{"country" : "Iraq", "abbreviation" : "IQ"},
|
||||
{"country" : "Iceland", "abbreviation" : "IS"},
|
||||
{"country" : "Israel", "abbreviation" : "IL"},
|
||||
{"country" : "Italy", "abbreviation" : "IT"},
|
||||
{"country" : "Jamaica", "abbreviation" : "JM"},
|
||||
{"country" : "Jordan", "abbreviation" : "JO"},
|
||||
{"country" : "Japan", "abbreviation" : "JP"},
|
||||
{"country" : "Kazakstan", "abbreviation" : "KZ"},
|
||||
{"country" : "Kenya", "abbreviation" : "KE"},
|
||||
{"country" : "Kyrgyzstan", "abbreviation" : "KG"},
|
||||
{"country" : "Cambodia", "abbreviation" : "KH"},
|
||||
{"country" : "Kiribati", "abbreviation" : "KI"},
|
||||
{"country" : "Saint Kitts and Nevis", "abbreviation" : "KN"},
|
||||
{"country" : "South Korea", "abbreviation" : "KR"},
|
||||
{"country" : "Kuwait", "abbreviation" : "KW"},
|
||||
{"country" : "Laos", "abbreviation" : "LA"},
|
||||
{"country" : "Lebanon", "abbreviation" : "LB"},
|
||||
{"country" : "Liberia", "abbreviation" : "LR"},
|
||||
{"country" : "Libyan Arab Jamahiriya", "abbreviation" : "LY"},
|
||||
{"country" : "Saint Lucia", "abbreviation" : "LC"},
|
||||
{"country" : "Liechtenstein", "abbreviation" : "LI"},
|
||||
{"country" : "Sri Lanka", "abbreviation" : "LK"},
|
||||
{"country" : "Lesotho", "abbreviation" : "LS"},
|
||||
{"country" : "Lithuania", "abbreviation" : "LT"},
|
||||
{"country" : "Luxembourg", "abbreviation" : "LU"},
|
||||
{"country" : "Latvia", "abbreviation" : "LV"},
|
||||
{"country" : "Macao", "abbreviation" : "MO"},
|
||||
{"country" : "Morocco", "abbreviation" : "MA"},
|
||||
{"country" : "Monaco", "abbreviation" : "MC"},
|
||||
{"country" : "Moldova", "abbreviation" : "MD"},
|
||||
{"country" : "Madagascar", "abbreviation" : "MG"},
|
||||
{"country" : "Maldives", "abbreviation" : "MV"},
|
||||
{"country" : "Mexico", "abbreviation" : "MX"},
|
||||
{"country" : "Marshall Islands", "abbreviation" : "MH"},
|
||||
{"country" : "Macedonia", "abbreviation" : "MK"},
|
||||
{"country" : "Mali", "abbreviation" : "ML"},
|
||||
{"country" : "Malta", "abbreviation" : "MT"},
|
||||
{"country" : "Myanmar", "abbreviation" : "MM"},
|
||||
{"country" : "Mongolia", "abbreviation" : "MN"},
|
||||
{"country" : "Northern Mariana Islands", "abbreviation" : "MP"},
|
||||
{"country" : "Mozambique", "abbreviation" : "MZ"},
|
||||
{"country" : "Mauritania", "abbreviation" : "MR"},
|
||||
{"country" : "Montserrat", "abbreviation" : "MS"},
|
||||
{"country" : "Martinique", "abbreviation" : "MQ"},
|
||||
{"country" : "Mauritius", "abbreviation" : "MU"},
|
||||
{"country" : "Malawi", "abbreviation" : "MW"},
|
||||
{"country" : "Malaysia", "abbreviation" : "MY"},
|
||||
{"country" : "Mayotte", "abbreviation" : "YT"},
|
||||
{"country" : "Namibia", "abbreviation" : "NA"},
|
||||
{"country" : "New Caledonia", "abbreviation" : "NC"},
|
||||
{"country" : "Niger", "abbreviation" : "NE"},
|
||||
{"country" : "Norfolk Island", "abbreviation" : "NF"},
|
||||
{"country" : "Nigeria", "abbreviation" : "NG"},
|
||||
{"country" : "Nicaragua", "abbreviation" : "NI"},
|
||||
{"country" : "Niue", "abbreviation" : "NU"},
|
||||
{"country" : "Netherlands", "abbreviation" : "NL"},
|
||||
{"country" : "Norway", "abbreviation" : "NO"},
|
||||
{"country" : "Nepal", "abbreviation" : "NP"},
|
||||
{"country" : "Nauru", "abbreviation" : "NR"},
|
||||
{"country" : "New Zealand", "abbreviation" : "NZ"},
|
||||
{"country" : "Oman", "abbreviation" : "OM"},
|
||||
{"country" : "Pakistan", "abbreviation" : "PK"},
|
||||
{"country" : "Panama", "abbreviation" : "PA"},
|
||||
{"country" : "Pitcairn", "abbreviation" : "PN"},
|
||||
{"country" : "Peru", "abbreviation" : "PE"},
|
||||
{"country" : "Philippines", "abbreviation" : "PH"},
|
||||
{"country" : "Palau", "abbreviation" : "PW"},
|
||||
{"country" : "Papua New Guinea", "abbreviation" : "PG"},
|
||||
{"country" : "Poland", "abbreviation" : "PL"},
|
||||
{"country" : "Puerto Rico", "abbreviation" : "PR"},
|
||||
{"country" : "North Korea", "abbreviation" : "KP"},
|
||||
{"country" : "Portugal", "abbreviation" : "PT"},
|
||||
{"country" : "Paraguay", "abbreviation" : "PY"},
|
||||
{"country" : "Palestine", "abbreviation" : "PS"},
|
||||
{"country" : "French Polynesia", "abbreviation" : "PF"},
|
||||
{"country" : "Qatar", "abbreviation" : "QA"},
|
||||
{"country" : "Reunion", "abbreviation" : "RE"},
|
||||
{"country" : "Romania", "abbreviation" : "RO"},
|
||||
{"country" : "Russian Federation", "abbreviation" : "RU"},
|
||||
{"country" : "Rwanda", "abbreviation" : "RW"},
|
||||
{"country" : "Saudi Arabia", "abbreviation" : "SA"},
|
||||
{"country" : "Sudan", "abbreviation" : "SD"},
|
||||
{"country" : "Senegal", "abbreviation" : "SN"},
|
||||
{"country" : "Singapore", "abbreviation" : "SG"},
|
||||
{"country" : "South Georgia and the South Sandwich Islands", "abbreviation" : "GS"},
|
||||
{"country" : "Saint Helena", "abbreviation" : "SH"},
|
||||
{"country" : "Svalbard and Jan Mayen", "abbreviation" : "SJ"},
|
||||
{"country" : "Solomon Islands", "abbreviation" : "SB"},
|
||||
{"country" : "Sierra Leone", "abbreviation" : "SL"},
|
||||
{"country" : "El Salvador", "abbreviation" : "SV"},
|
||||
{"country" : "San Marino", "abbreviation" : "SM"},
|
||||
{"country" : "Somalia", "abbreviation" : "SO"},
|
||||
{"country" : "Saint Pierre and Miquelon", "abbreviation" : "PM"},
|
||||
{"country" : "Sao Tome and Principe", "abbreviation" : "ST"},
|
||||
{"country" : "Suriname", "abbreviation" : "SR"},
|
||||
{"country" : "Slovakia", "abbreviation" : "SK"},
|
||||
{"country" : "Slovenia", "abbreviation" : "SI"},
|
||||
{"country" : "Sweden", "abbreviation" : "SE"},
|
||||
{"country" : "Swaziland", "abbreviation" : "SZ"},
|
||||
{"country" : "Seychelles", "abbreviation" : "SC"},
|
||||
{"country" : "Syria", "abbreviation" : "SY"},
|
||||
{"country" : "Turks and Caicos Islands", "abbreviation" : "TC"},
|
||||
{"country" : "Chad", "abbreviation" : "TD"},
|
||||
{"country" : "Togo", "abbreviation" : "TG"},
|
||||
{"country" : "Thailand", "abbreviation" : "TH"},
|
||||
{"country" : "Tajikistan", "abbreviation" : "TJ"},
|
||||
{"country" : "Tokelau", "abbreviation" : "TK"},
|
||||
{"country" : "Turkmenistan", "abbreviation" : "TM"},
|
||||
{"country" : "East Timor", "abbreviation" : "TP"},
|
||||
{"country" : "Tonga", "abbreviation" : "TO"},
|
||||
{"country" : "Trinidad and Tobago", "abbreviation" : "TT"},
|
||||
{"country" : "Tunisia", "abbreviation" : "TN"},
|
||||
{"country" : "Turkey", "abbreviation" : "TR"},
|
||||
{"country" : "Tuvalu", "abbreviation" : "TV"},
|
||||
{"country" : "Taiwan", "abbreviation" : "TW"},
|
||||
{"country" : "Tanzania", "abbreviation" : "TZ"},
|
||||
{"country" : "Uganda", "abbreviation" : "UG"},
|
||||
{"country" : "Ukraine", "abbreviation" : "UA"},
|
||||
{"country" : "United States Minor Outlying Islands", "abbreviation" : "UM"},
|
||||
{"country" : "Uruguay", "abbreviation" : "UY"},
|
||||
{"country" : "United States", "abbreviation" : "US"},
|
||||
{"country" : "Uzbekistan", "abbreviation" : "UZ"},
|
||||
{"country" : "Holy See (Vatican City State)", "abbreviation" : "VA"},
|
||||
{"country" : "Saint Vincent and the Grenadines", "abbreviation" : "VC"},
|
||||
{"country" : "Venezuela", "abbreviation" : "VE"},
|
||||
{"country" : "Virgin Islands,British", "abbreviation" : "VG"},
|
||||
{"country" : "Virgin Islands,U.S.", "abbreviation" : "VI"},
|
||||
{"country" : "Vietnam", "abbreviation" : "VN"},
|
||||
{"country" : "Vanuatu", "abbreviation" : "VU"},
|
||||
{"country" : "Wallis and Futuna", "abbreviation" : "WF"},
|
||||
{"country" : "Samoa", "abbreviation" : "WS"},
|
||||
{"country" : "Yemen", "abbreviation" : "YE"},
|
||||
{"country" : "Yugoslavia", "abbreviation" : "YU"},
|
||||
{"country" : "South Africa", "abbreviation" : "ZA"},
|
||||
{"country" : "Zambia", "abbreviation" : "ZM"},
|
||||
{"country" : "Zimbabwe", "abbreviation" : "ZW"}
|
||||
]
|
@ -38,7 +38,7 @@
|
||||
<select class="form-control" id="country" name="country" required data-required="true">
|
||||
<option value=""> </option>
|
||||
{% for country in site.data.countries %}
|
||||
<option value="{{ country.abbreviation }}">{{ country.country }}</option>
|
||||
<option value="{{ country.alpha2Code }}">{{ country.name }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
<label class="form-label" for="country">Country</label>
|
||||
|
40
_src/_plugins/jekyll_get.rb
Normal file
40
_src/_plugins/jekyll_get.rb
Normal file
@ -0,0 +1,40 @@
|
||||
require 'json'
|
||||
require 'hash-joiner'
|
||||
require 'open-uri'
|
||||
|
||||
module Jekyll_Get
|
||||
class Generator < Jekyll::Generator
|
||||
safe true
|
||||
priority :highest
|
||||
|
||||
def generate(site)
|
||||
config = site.config['jekyll_get']
|
||||
if !config
|
||||
return
|
||||
end
|
||||
if !config.kind_of?(Array)
|
||||
config = [config]
|
||||
end
|
||||
config.each do |d|
|
||||
begin
|
||||
target = site.data[d['data']]
|
||||
source = JSON.load(open(d['json']))
|
||||
if target
|
||||
HashJoiner.deep_merge target, source
|
||||
else
|
||||
site.data[d['data']] = source
|
||||
end
|
||||
if d['cache']
|
||||
data_source = (site.config['data_source'] || '_data')
|
||||
path = "#{data_source}/#{d['data']}.json"
|
||||
open(path, 'wb') do |file|
|
||||
file << JSON.generate(site.data[d['data']])
|
||||
end
|
||||
end
|
||||
rescue
|
||||
next
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
Loading…
Reference in New Issue
Block a user