Add Coop.all method to return all co-ops for migration
This commit is contained in:
parent
5ca9d98343
commit
23251e7ba2
@ -4,10 +4,16 @@ require 'active_support/inflector'
|
|||||||
class Coop
|
class Coop
|
||||||
attr_reader :doc
|
attr_reader :doc
|
||||||
|
|
||||||
def initialize(html)
|
def initialize(fn)
|
||||||
|
html = File.read(fn)
|
||||||
|
@fn = fn
|
||||||
@doc = Nokogiri::HTML(html)
|
@doc = Nokogiri::HTML(html)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def slug
|
||||||
|
File.basename(@fn, '.html')
|
||||||
|
end
|
||||||
|
|
||||||
def name
|
def name
|
||||||
doc.xpath('//*[@id="page-banner"]/div/div/h2').text
|
doc.xpath('//*[@id="page-banner"]/div/div/h2').text
|
||||||
end
|
end
|
||||||
@ -79,53 +85,56 @@ class Coop
|
|||||||
def erb_binding
|
def erb_binding
|
||||||
binding
|
binding
|
||||||
end
|
end
|
||||||
end
|
|
||||||
|
|
||||||
source_pages = %w(
|
def self.all
|
||||||
agile-collective.html
|
%w(
|
||||||
alpha-communication.html
|
agile-collective.html
|
||||||
animorph.html
|
alpha-communication.html
|
||||||
aptivate.html
|
animorph.html
|
||||||
autonomic.html
|
aptivate.html
|
||||||
blake-house-filmmakers-co-op.html
|
autonomic.html
|
||||||
calverts.html
|
blake-house-filmmakers-co-op.html
|
||||||
cbn.html
|
calverts.html
|
||||||
cetis-llp.html
|
cbn.html
|
||||||
chapel-street-studio.html
|
cetis-llp.html
|
||||||
co-operative-web.html
|
chapel-street-studio.html
|
||||||
creative-coop.html
|
co-operative-web.html
|
||||||
dev-the-developers-society.html
|
creative-coop.html
|
||||||
digital-liberties.html
|
dev-the-developers-society.html
|
||||||
dtc-innovation.html
|
digital-liberties.html
|
||||||
fairmondo-uk.html
|
dtc-innovation.html
|
||||||
founders-and-coders.html
|
fairmondo-uk.html
|
||||||
gildedsplinters.html
|
founders-and-coders.html
|
||||||
glowbox-design.html
|
gildedsplinters.html
|
||||||
go-free-range.html
|
glowbox-design.html
|
||||||
graphics-coop.html
|
go-free-range.html
|
||||||
mc3.html
|
graphics-coop.html
|
||||||
media-coop.html
|
mc3.html
|
||||||
mediablaze-hosts.html
|
media-coop.html
|
||||||
netuxo.html
|
mediablaze-hosts.html
|
||||||
open-data-services.html
|
netuxo.html
|
||||||
open-ecommerce.html
|
open-data-services.html
|
||||||
outlandish.html
|
open-ecommerce.html
|
||||||
secure-active-c-i-c.html
|
outlandish.html
|
||||||
small-axe.html
|
secure-active-c-i-c.html
|
||||||
tableflip.html
|
small-axe.html
|
||||||
the-dot-project.html
|
tableflip.html
|
||||||
wave.html
|
the-dot-project.html
|
||||||
we-are-open.html
|
wave.html
|
||||||
webarchitects.html
|
we-are-open.html
|
||||||
)
|
webarchitects.html
|
||||||
|
).map do |page|
|
||||||
|
|
||||||
|
fn = File.join(File.dirname(__FILE__), 'mirror', 'coops.tech.archived.website', 'co-op', page)
|
||||||
|
new(fn)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
require 'erb'
|
require 'erb'
|
||||||
|
|
||||||
source_pages.each do |page|
|
Coop.all.each do |coop|
|
||||||
fn = File.join(File.dirname(__FILE__), 'mirror', 'coops.tech.archived.website', 'co-op', page)
|
output_fn = File.join(File.dirname(__FILE__), '..', '_coops', coop.slug + '.md')
|
||||||
output_fn = File.join(File.dirname(__FILE__), '..', '_coops', page.gsub('.html','.md'))
|
|
||||||
|
|
||||||
coop = Coop.new(File.read(fn))
|
|
||||||
|
|
||||||
renderer = ERB.new(File.read('coop.erb.md'), nil, '<>')
|
renderer = ERB.new(File.read('coop.erb.md'), nil, '<>')
|
||||||
result = renderer.result(coop.erb_binding)
|
result = renderer.result(coop.erb_binding)
|
||||||
|
Loading…
Reference in New Issue
Block a user