Attention ! Gitlab fournissant maintenant nativement des certificats Let’s Encrypt aux domaines personnalisés des Gitlab Pages, nous avons coupé notre service qui le faisait automatiquement pour vous.

Il est impératif, pour que votre domaine personnalisé continue à avoir un certificat Let’s Encrypt à jour, d’activer la fonctionnalité native dans les paramètres de votre projet. Cette activation remplacera votre certificat actuel par un nouveau certificat Let’s Encrypt géré par Gitlab.

Voir les détails sur https://docs.framasoft.org/fr/gitlab/gitlab-pages-le.html

Commit b5fd8c1c authored by hellekin's avatar hellekin

Import Dewey Maps data

parent 218a8df4
[
{
"id": 8,
"name": "Housing and Dwelling",
"subcategories": [
{
"id": 148,
"name": "Campings"
},
{
"id": 158,
"name": "Care home"
},
{
"id": 130,
"name": "Community land trust"
},
{
"id": 198,
"name": "Community living (for the homeless)"
},
{
"id": 150,
"name": "Homeless shelters (by night)"
},
{
"id": 149,
"name": "Hostels"
},
{
"id": 165,
"name": "Housing cooperatives"
},
{
"id": 131,
"name": "Legalized squat"
},
{
"id": 168,
"name": "Participatory housing, cohousing"
},
{
"id": 164,
"name": "Renters cooperatives"
},
{
"id": 114,
"name": "Right to housing"
}
],
"color": "BCBCBC"
},
{
"id": 6,
"name": "Drinking and Eating",
"subcategories": [
{
"id": 155,
"name": "Aromatic plants"
},
{
"id": 27,
"name": "Community-Supported Agriculture (groups)"
},
{
"id": 185,
"name": "Community-Supported Agriculture (producers)"
},
{
"id": 180,
"name": "Cooking Classes"
},
{
"id": 115,
"name": "Drinkable water"
},
{
"id": 182,
"name": "Food advise"
},
{
"id": 154,
"name": "Free lunches"
},
{
"id": 170,
"name": "Market"
},
{
"id": 28,
"name": "Recuperation of food products"
},
{
"id": 123,
"name": "Small Breweries"
},
{
"id": 135,
"name": "Social Grocery Stores"
},
{
"id": 118,
"name": "Social Restaurants"
}
],
"color": "95A5A6"
},
{
"id": 11,
"name": "Getting Clean and Clothed",
"subcategories": [
{
"id": 46,
"name": "Give-away shops"
},
{
"id": 210,
"name": "Give Boxes"
},
{
"id": 144,
"name": "Public showers"
},
{
"id": 207,
"name": "Public toilets"
},
{
"id": 104,
"name": "Second-hand clothes"
},
{
"id": 156,
"name": "Social Clothing Store"
}
],
"color": "848482"
},
{
"id": 12,
"name": "Lighting Up and Warming Up",
"subcategories": [
{
"id": 122,
"name": "Energy advisors"
},
{
"id": 195,
"name": "Homeless booths"
},
{
"id": 176,
"name": "Solar techniques"
},
{
"id": 134,
"name": "Support for renovation"
}
],
"color": "948279"
},
{
"id": 10,
"name": "Healing and Caring",
"subcategories": [
{
"id": 18,
"name": "Community health center"
},
{
"id": 192,
"name": "Control of addictions"
},
{
"id": 199,
"name": "Defibrillators (free access)"
},
{
"id": 145,
"name": "Health networks"
},
{
"id": 157,
"name": "Health services for the homeless"
},
{
"id": 190,
"name": "Mental health associations"
},
{
"id": 143,
"name": "Palliative care associations"
},
{
"id": 208,
"name": "Public hospitals"
},
{
"id": 191,
"name": "Therapeutic communities"
}
],
"color": "59706a"
},
{
"id": 1,
"name": "Recycling and Repairing",
"subcategories": [
{
"id": 50,
"name": "Book boxes"
},
{
"id": 132,
"name": "Community composting"
},
{
"id": 120,
"name": "Flea market"
},
{
"id": 205,
"name": "Glass recycling"
},
{
"id": 42,
"name": "Repair cafés"
},
{
"id": 113,
"name": "Reused building materials"
},
{
"id": 47,
"name": "Reused computer material"
},
{
"id": 136,
"name": "Reusing inkcartridges"
},
{
"id": 206,
"name": "Used clothes bins"
},
{
"id": 138,
"name": "Woodworking workshops"
}
],
"color": "16A085"
},
{
"id": 7,
"name": "Breathing and Going Green",
"subcategories": [
{
"id": 127,
"name": "Beekeeping associations"
},
{
"id": 121,
"name": "Community composting"
},
{
"id": 194,
"name": "Naturalist association"
},
{
"id": 133,
"name": "Natural reserves"
},
{
"id": 129,
"name": "Public parcs"
},
{
"id": 125,
"name": "Seed exchange"
},
{
"id": 128,
"name": "Support for gardeners"
},
{
"id": 116,
"name": "Vegetable gardens"
}
],
"color": "27AE60"
},
{
"id": 3,
"name": "Meeting and Helping Each Other",
"subcategories": [
{
"id": 202,
"name": "Associations for gender equality"
},
{
"id": 204,
"name": "Community centers NL"
},
{
"id": 211,
"name": "Complementary currency"
},
{
"id": 209,
"name": "International cooperation and solidarity"
},
{
"id": 184,
"name": "Local exchange trading system"
},
{
"id": 102,
"name": "Neighborhood Committees"
},
{
"id": 10,
"name": "Neighborhood houses"
},
{
"id": 197,
"name": "Recent immigrants welcoming"
},
{
"id": 188,
"name": "Refugees welcome"
},
{
"id": 119,
"name": "School Support Associations"
},
{
"id": 14,
"name": "Support for family and children"
},
{
"id": 16,
"name": "Support for people with disabilities"
},
{
"id": 19,
"name": "Support for seniors"
},
{
"id": 193,
"name": "Support for the homeless"
},
{
"id": 201,
"name": "Transition initiatives"
},
{
"id": 15,
"name": "Women's association"
},
{
"id": 17,
"name": "Youth House"
}
],
"color": "2980B9"
},
{
"id": 2,
"name": "Learning and Training",
"subcategories": [
{
"id": 187,
"name": "Adapted work companies"
},
{
"id": 13,
"name": "Adult and continuing education"
},
{
"id": 87,
"name": "Coworking, shared offices"
},
{
"id": 91,
"name": "Defense of cultural heritage"
},
{
"id": 92,
"name": "Public libraries"
},
{
"id": 12,
"name": "Support fo local economy"
},
{
"id": 103,
"name": "Training centres"
},
{
"id": 90,
"name": "Urban ecology associations"
}
],
"color": "34495E"
},
{
"id": 13,
"name": "Expressing Yourself and Communicating",
"subcategories": [
{
"id": 124,
"name": "Free Internet access"
},
{
"id": 174,
"name": "Free Software Associations"
},
{
"id": 43,
"name": "Hackerspaces"
},
{
"id": 109,
"name": "Independent media"
},
{
"id": 177,
"name": "Scrivener"
}
],
"color": "BD3525"
},
{
"id": 9,
"name": "Transportation and Hauling",
"subcategories": [
{
"id": 212,
"name": "Bicycle pumps"
},
{
"id": 140,
"name": "Bike deliveries"
},
{
"id": 179,
"name": "Bike lessons"
},
{
"id": 147,
"name": "Bikessharing"
},
{
"id": 71,
"name": "Bike workshops"
},
{
"id": 141,
"name": "Carsharing"
},
{
"id": 196,
"name": "Taxisharing"
}
],
"color": "D35400"
},
{
"id": 4,
"name": "Going Out and Hobbies",
"subcategories": [
{
"id": 171,
"name": "'Art Deco’ walks"
},
{
"id": 173,
"name": "'Art Nouvau’ walks"
},
{
"id": 200,
"name": "'Comic strips’ walks"
},
{
"id": 110,
"name": "Concert places"
},
{
"id": 117,
"name": "Dance schools"
},
{
"id": 186,
"name": "Holiday for all"
},
{
"id": 139,
"name": "Independant cinemas"
},
{
"id": 100,
"name": "Literary walks"
},
{
"id": 111,
"name": "Museums and exhibitions"
},
{
"id": 203,
"name": "Music classes for all"
},
{
"id": 96,
"name": "Sport clubs and infrastructures"
},
{
"id": 183,
"name": "'Street Art’ walks"
},
{
"id": 98,
"name": "Theatres"
}
],
"color": "EEAD0E"
}
]
This diff is collapsed.
{"148":1,"158":2,"130":3,"198":4,"150":5,"149":6,"165":7,"131":8,"168":9,"164":10,"114":11,"155":12,"27":13,"185":14,"180":15,"115":16,"182":17,"154":18,"170":19,"28":20,"123":21,"135":22,"118":23,"46":24,"210":25,"144":26,"207":27,"104":28,"156":29,"122":30,"195":31,"176":32,"134":33,"18":34,"192":35,"199":36,"145":37,"157":38,"190":39,"143":40,"208":41,"191":42,"50":43,"132":44,"120":45,"205":46,"42":47,"113":48,"47":49,"136":50,"206":51,"138":52,"127":53,"121":54,"194":55,"133":56,"129":57,"125":58,"128":59,"116":60,"202":61,"204":62,"211":63,"209":64,"184":65,"102":66,"10":67,"197":68,"188":69,"119":70,"14":71,"16":72,"19":73,"193":74,"201":75,"15":76,"17":77,"187":78,"13":79,"87":80,"91":81,"92":82,"12":83,"103":84,"90":85,"124":86,"174":87,"43":88,"109":89,"177":90,"212":91,"140":92,"179":93,"147":94,"71":95,"141":96,"196":97,"171":98,"173":99,"200":100,"110":101,"117":102,"186":103,"139":104,"100":105,"111":106,"203":107,"96":108,"183":109,"98":110}
# frozen_string_literal: true
require_relative '../../config/application'
require_relative '../../config/environment'
if taxonomy = Taxonomy.find_by(name: 'Dewey Maps')
raise ArgumentError, 'Dewey Maps Taxonomy already exists: aborted.'
end
require 'json'
ins = Rails.root.join('doc', 'import', 'dewey-maps-categories-en.json')
out = Rails.root.join('doc', 'import', 'dewey-maps-sections.json')
cats = JSON.parse(File.read(ins))
## Agent
agent = AgentCreator.create(
name: 'Dewey Maps', email: 'maps@dewey.be', uri: 'https://maps.dewey.be',
email_validated: true, uri_is_origin: true
).agent
raise ArgumentError, "Dewey Maps Agent cannot be created!\n#{agent&.errors&.inspect}\n#{e.message}" unless agent
dewey = Taxonomy.create!(name: 'Dewey Maps', agent_id: agent.id, summary: 'The original IN COMMON classification.')
subcat = {}
cats.each do |entry|
mycat = Category.create!(
name: entry['name'],
taxonomy_id: dewey.id,
color: "##{entry['color']}"
)
entry['subcategories'].each do |sub|
sec = mycat.sections.find_by(name: sub['name']) ||
Section.create!(
name: sub['name'],
category_id: mycat.id,
color: "##{entry['color']}"
)
subcat[sub['id']] = sec.id unless subcat.key?(sub['id'])
end
end
File.open(out, 'w+') { |f| f.puts JSON.dump(subcat) }
# frozen_string_literal: true
require_relative '../../config/application'
require_relative '../../config/environment'
require 'json'
logger = Rails.logger
## Agent
agent = Agent.find_by(name: 'Dewey Maps')
unless agent
raise ArgumentError,
'Dewey ASBL Agent does not exist!' \
' Please run ./import_dewey_maps_categories.rb first.'
end
## Classification
taxonomy = Taxonomy.find_by(name: 'Dewey Maps')
unless taxonomy
raise ArgumentError,
'Dewey Maps Taxonomy does not exist!' \
' Please run ./import_dewey_maps_categories.rb first.'
end
Rails.logger.info 'Importing points...'
entries = JSON.parse File.read(Rails.root.join('doc', 'import', 'dewey-maps-markers.json'))
subcat = JSON.parse File.read(Rails.root.join('doc', 'import', 'dewey-maps-sections.json'))
# rubocop:disable Metrics/BlockLength
entries.each do |ent|
print '.'
pos = Position.find_or_create_by(geometry: ent['fields']['position'], geo_type: 'Point')
# Extra properties
xtr = {
pk: ent['pk'],
manager_type: ent['fields']['manager_type'],
source: 'Dewey Maps',
}
link = nil
url = ent['fields']['web'].strip
link = Link.with_uri!(url) if url.present?
phone = nil
phnum = ent['fields']['phone'].gsub(/[^\d]/, '').strip
begin
unless phnum.nil?
phone = Phone.find_or_create_by(
number: PhonyRails.normalize_number(phnum, add_plus: true, country_code: 'BE')
)
end
rescue StandardError => e
logger.warn "Phone creation failed for #{phnum}: #{e.message}"
xtr[:phone_number] = phnum if phnum.present?
end
xtr[:phone_number] = phnum unless phone.valid? || xtr.key?(:phone_number)
# address
xtr[:address] = ent['fields']['adress'] # sic
Regexp.new(/\A(.+)\s(\d+)\s([\w-]+)\z/).match(xtr[:address])
street = Regexp.last_match(1)
postal_code = Regexp.last_match(2)
locality = Regexp.last_match(3)
if postal_code && locality
adr = Address.create(
street: street,
postal_code: postal_code,
locality: locality,
country: 'BE'
)
xtr.delete(:address) if adr.valid?
end
email = nil
if ent['fields']['email'].present?
email_address = ent['fields']['email'].delete(' ').strip
email = Email.with_address!(email_address) unless email_address.nil?
end
res = Resource.create(name: ent['fields']['name'],
description: ent['fields']['comment'],
public: (ent['fields']['public'] == true),
created_at: ent['fields']['created'],
updated_at: ent['fields']['last_modified'],
agent_id: agent.id,
meta: xtr)
if res&.valid?
ResourceAddress.create(address: adr, resource: res) if adr&.valid?
ResourcePhone.create(phone: phone, resource: res) if phone&.valid?
ResourceLink.create(link: link, resource: res) if link&.valid?
ResourceEmail.create(email: email, resource: res) if email&.valid?
Location.create(position: pos, locatable: res)
res.save
msg = "[**] Entry saved #{ent['pk']} -> #{res.id} : #{res.name}"
Rails.logger.info msg
ent['fields']['subcategories'].each do |sec_id|
sec = Section.find_by(id: subcat[sec_id.to_s])
if sec
res.save
sec.save
else
msg = "[!!] Missing section for sec_id '#{sec_id}'"
res.meta[:missing_subcat] = sec_id
res.save
Rails.logger.warn msg
end
end
else
logger.warn "[!!] Entry failed to save:\n#{res.errors.inspect}"
sleep 3
end
end
# rubocop:enable Metrics/BlockLength
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment