3
0
mirror of https://git.coop/cotech/website.git synced 2025-12-18 20:27:32 +00:00

Remove scripts directory

These scripts have served their purpose and we can recover them from
the git history if we ever need them again.
This commit is contained in:
Chris Lowis
2025-12-16 15:36:47 +00:00
parent ff2441b7b8
commit e79fb6c5d4
12 changed files with 0 additions and 340 deletions

1
scripts/.gitignore vendored
View File

@ -1 +0,0 @@
mirror

View File

@ -1,4 +0,0 @@
source 'https://rubygems.org'
gem 'nokogiri'
gem 'activesupport'

View File

@ -1,28 +0,0 @@
GEM
remote: https://rubygems.org/
specs:
activesupport (5.1.4)
concurrent-ruby (~> 1.0, >= 1.0.2)
i18n (~> 0.7)
minitest (~> 5.1)
tzinfo (~> 1.1)
concurrent-ruby (1.1.1)
i18n (0.9.5)
concurrent-ruby (~> 1.0)
mini_portile2 (2.3.0)
minitest (5.11.3)
nokogiri (1.8.5)
mini_portile2 (~> 2.3.0)
thread_safe (0.3.6)
tzinfo (1.2.5)
thread_safe (~> 0.1)
PLATFORMS
ruby
DEPENDENCIES
activesupport
nokogiri
BUNDLED WITH
1.17.1

View File

@ -1,19 +0,0 @@
# Scripts
This directory contains scripts for migrating data from wordpress to jekyll.
It relies on a local mirror of the [archived CoTech website](https://coops.tech.archived.website/) which you can create by running
mkdir mirror
cd mirror
httrack https://coops.tech.archived.website/
`httrack` is available via `homebrew` on MacOS.
You then need to install dependencies from rubygems by running
bundle install
## Creating data files in `_coops`
ruby migrate_coop_pages.rb

View File

@ -1,26 +0,0 @@
---
title: <%= title %>
name: <%= name %>
website: <%= website %>
email: <%= email %>
twitter: <%= twitter %>
github: <%= github %>
telephone: <%= telephone %>
address: <%= address %>
latitude: <%= latitude %>
longitude: <%= longitude %>
clients:
<% clients.each do |client| %>
- <%= client %>
<% end %>
services:
<% services.each do |service| %>
- <%= service %>
<% end %>
technologies:
<% technologies.each do |technology| %>
- <%= technology %>
<% end %>
---
<%= body %>

View File

@ -1,141 +0,0 @@
require 'nokogiri'
require 'active_support/inflector'
class Coop
attr_reader :doc
def initialize(fn)
html = File.read(fn)
@fn = fn
@doc = Nokogiri::HTML(html)
end
def slug
File.basename(@fn, '.html')
end
def name
doc.xpath('//*[@id="page-banner"]/div/div/h2').text
end
alias title name
def website
doc.xpath('//*[@id="page-banner"]/div/div/a[2]').text.strip
end
def email
doc.xpath('/html/body/div/div[2]/div/div/div[1]/section/div[2]/p/a').text.strip
end
def twitter
url = doc.xpath('/html/body/div/div[2]/div/div/div[1]/section/div[1]/ul/li[2]/a/@href').text
URI.parse(url).path.split('/').last
end
def github
url = doc.xpath('/html/body/div/div[2]/div/div/div[1]/section/div[1]/ul/li[3]/a/@href').text
URI.parse(url).path.split('/').last
end
def telephone
doc.xpath('/html/body/div/div[2]/div/div/div[1]/section/div[3]/p').text
end
def address
doc.xpath('/html/body/div/div[2]/div/div/div[1]/section/div[4]/p').text
end
def latitude
script = doc.xpath('/html/body/div/section/script').text
match = /var latitude = '(.+)';/.match(script)
match[1] if match
end
def longitude
script = doc.xpath('/html/body/div/section/script').text
match = /var longitude = '(.+)';/.match(script)
match[1] if match
end
def services
doc.css('a.service-thumb').map do |node|
url = node.xpath('@href').text
url.split('/')[2]
end
end
def clients
doc.css('div.client-thumb-container').map do |node|
style = node.xpath('div/@style')
{
title: node.xpath('h5').text,
slug: node.xpath('h5').text&.parameterize,
logo: style.text.match(/background-image: url\((.*)\)/)[1]
}
end
end
def technologies
doc.css('a.technology-thumb').map do |node|
url = node.xpath('@href').text
url.split('/')[2]
end
end
def body
doc.xpath('/html/body/div/div[2]/div/div/div[2]/section[1]').text.strip
end
def logo
doc.xpath('//*[@id="page-banner"]/div/div/a[1]/img/@src').text
end
def erb_binding
binding
end
def self.all
%w(
agile-collective.html
alpha-communication.html
animorph.html
aptivate.html
autonomic.html
blake-house-filmmakers-co-op.html
calverts.html
cbn.html
cetis-llp.html
chapel-street-studio.html
co-operative-web.html
creative-coop.html
dev-the-developers-society.html
digital-liberties.html
dot-project.html
dtc-innovation.html
fairmondo-uk.html
founders-and-coders.html
gildedsplinters.html
glowbox-design.html
go-free-range.html
graphics-coop.html
mc3.html
media-coop.html
mediablaze-hosts.html
netuxo.html
open-data-services.html
open-ecommerce.html
outlandish.html
secure-active-c-i-c.html
small-axe.html
tableflip.html
wave.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

View File

@ -1,19 +0,0 @@
require_relative 'coop'
require 'fileutils'
Coop.all.each do |coop|
coop.clients.each do |client|
current_logo_path = File.join(File.dirname(__FILE__), 'mirror', 'coops.tech.archived.website', 'co-op', client[:logo])
new_logo_path = File.join(File.dirname(__FILE__), '..', 'images', 'clients', client[:slug] + File.extname(current_logo_path))
FileUtils.cp(current_logo_path, new_logo_path)
client_md_path = File.join(File.dirname(__FILE__), '..', '_clients', client[:slug] + '.md')
File.open(client_md_path, 'w') do |file|
file.write("---\n")
file.write("title: #{client[:title]}\n")
file.write("---\n")
end
end
end

View File

@ -1,11 +0,0 @@
require_relative 'coop'
require 'fileutils'
base_dir = File.join(File.dirname(__FILE__), 'mirror', 'coops.tech.archived.website', 'co-op')
Coop.all.each do |coop|
current_fn = File.join(base_dir, coop.logo)
ext = File.extname(current_fn)
new_fn = File.join(File.dirname(__FILE__), '..', 'images', 'coops', coop.slug + ext)
FileUtils.cp(current_fn, new_fn)
end

View File

@ -1,10 +0,0 @@
require_relative 'coop'
require 'erb'
Coop.all.each do |coop|
output_fn = File.join(File.dirname(__FILE__), '..', '_coops', coop.slug + '.md')
renderer = ERB.new(File.read('coop.erb.md'), nil, '<>')
result = renderer.result(coop.erb_binding)
File.open(output_fn, 'w') { |file| file.write(result) }
end

View File

@ -1,35 +0,0 @@
require 'nokogiri'
require 'fileutils'
fn = File.join(File.dirname(__FILE__), 'mirror', 'coops.tech.archived.website', 'index.html')
html = File.read(fn)
doc = Nokogiri::HTML(html)
doc.css('a.service-thumb').each do |node|
url = node.xpath('@href').text
service_slug = url.split('/')[1]
style = node.xpath('div/@style')
current_logo = style.text.match(/background-image: url\((.*)\)/)[1]
current_logo.gsub!('%40', '@')
service_name = node.xpath('h5').text
p [service_name, service_slug, current_logo]
current_logo_path = File.join(File.dirname(__FILE__), 'mirror', 'coops.tech.archived.website', current_logo)
new_logo_path = File.join(File.dirname(__FILE__), '..', 'images', 'services', service_slug + File.extname(current_logo_path))
FileUtils.cp(current_logo_path, new_logo_path)
services_md_path = File.join(File.dirname(__FILE__), '..', '_services', service_slug + '.md')
File.open(services_md_path, 'w') do |file|
file.write("---\n")
file.write("title: #{service_name}\n")
file.write("name: #{service_name}\n")
file.write("---\n")
end
end
# File.open(output_fn, 'w') { |file| file.write(result) }

View File

@ -1,34 +0,0 @@
require 'nokogiri'
require 'fileutils'
fn = File.join(File.dirname(__FILE__), 'mirror', 'coops.tech.archived.website', 'index.html')
html = File.read(fn)
doc = Nokogiri::HTML(html)
doc.css('a.technology-thumb').each do |node|
url = node.xpath('@href').text
technology_slug = url.split('/')[1]
style = node.xpath('div/@style')
current_logo = style.text.match(/background-image: url\((.*)\)/)[1]
technology_name = node.xpath('h5').text
p [technology_name, technology_slug, current_logo]
current_logo_path = File.join(File.dirname(__FILE__), 'mirror', 'coops.tech.archived.website', current_logo)
new_logo_path = File.join(File.dirname(__FILE__), '..', 'images', 'technologies', technology_slug + File.extname(current_logo_path))
FileUtils.cp(current_logo_path, new_logo_path)
technology_md_path = File.join(File.dirname(__FILE__), '..', '_technologies', technology_slug + '.md')
File.open(technology_md_path, 'w') do |file|
file.write("---\n")
file.write("title: #{technology_name}\n")
file.write("name: #{technology_name}\n")
file.write("---\n")
end
end
# File.open(output_fn, 'w') { |file| file.write(result) }

View File

@ -1,12 +0,0 @@
require 'bundler/setup'
require 'yaml'
root_path = Pathname.new(__dir__).join('..')
Dir[root_path.join('_coops/*.md')].each do |path|
content = File.read(path)
body = content.split("\n").reverse.take_while { |l| l != "---" }.reverse.join("\n")
metadata = YAML.safe_load(content)
frontmatter = YAML.dump(metadata)
File.write(path, frontmatter + "---" + "\n" + body)
end