diff --git a/.github/workflows/jekyll.yml b/.github/workflows/jekyll.yml new file mode 100644 index 0000000..fb57743 --- /dev/null +++ b/.github/workflows/jekyll.yml @@ -0,0 +1,26 @@ +name: Jekyll site CI + +on: + push: + branches: [ main ] + pull_request: + branches: [ main ] + +jobs: + build: + + runs-on: ubuntu-latest + + steps: + - uses: actions/checkout@v3 + - name: Build the site in the jekyll/builder container + run: | + docker run \ + -v ${{ github.workspace }}:/srv/jekyll -v ${{ github.workspace }}/_site:/srv/jekyll/_site \ + jekyll/builder:latest /bin/bash -c "chmod -R 777 /srv/jekyll && jekyll build --future" + + - name: Deploy 🚀 + uses: JamesIves/github-pages-deploy-action@v4.3.3 + with: + branch: gh-pages # The branch the action should deploy to. + folder: _site # The folder the action should deploy. \ No newline at end of file diff --git a/.gitignore b/.gitignore index da94aed..0e1774c 100644 --- a/.gitignore +++ b/.gitignore @@ -4,4 +4,5 @@ _site tmp env vendor -.bundle \ No newline at end of file +.bundle +.jekyll-cache diff --git a/Gemfile b/Gemfile index abc7acf..0117594 100644 --- a/Gemfile +++ b/Gemfile @@ -1,4 +1,6 @@ source 'https://rubygems.org' -gem 'jekyll', '~> 3.6.3' +gem 'jekyll' gem 'jekyll-coffeescript' + +gem "webrick", "~> 1.7" diff --git a/Gemfile.lock b/Gemfile.lock index bea8c53..d3cdeb7 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,60 +1,80 @@ GEM remote: https://rubygems.org/ specs: - addressable (2.7.0) + addressable (2.8.0) public_suffix (>= 2.0.2, < 5.0) coffee-script (2.4.1) coffee-script-source execjs coffee-script-source (1.12.2) colorator (1.1.0) - execjs (2.7.0) - ffi (1.11.3) + concurrent-ruby (1.1.10) + em-websocket (0.5.3) + eventmachine (>= 0.12.9) + http_parser.rb + eventmachine (1.2.7) + execjs (2.8.1) + ffi (1.15.5) + forwardable-extended (2.6.0) - jekyll (3.6.3) + http_parser.rb (0.8.0) + i18n (1.10.0) + concurrent-ruby (>= 1.0) + jekyll (4.2.2) addressable (~> 2.4) colorator (~> 1.0) - jekyll-sass-converter (~> 1.0) - jekyll-watch (~> 1.1) - kramdown (~> 1.14) + em-websocket (~> 0.5) + i18n (~> 1.0) + jekyll-sass-converter (~> 2.0) + jekyll-watch (~> 2.0) + kramdown (~> 2.3) + kramdown-parser-gfm (~> 1.0) liquid (~> 4.0) - mercenary (~> 0.3.3) + mercenary (~> 0.4.0) pathutil (~> 0.9) - rouge (>= 1.7, < 3) + rouge (~> 3.0) safe_yaml (~> 1.0) + terminal-table (~> 2.0) jekyll-coffeescript (2.0.0) coffee-script (~> 2.2) coffee-script-source (~> 1.12) - jekyll-sass-converter (1.5.2) - sass (~> 3.4) - jekyll-watch (1.5.1) + jekyll-sass-converter (2.2.0) + sassc (> 2.0.1, < 3.0) + jekyll-watch (2.2.1) listen (~> 3.0) - kramdown (1.17.0) + kramdown (2.4.0) + rexml + kramdown-parser-gfm (1.1.0) + kramdown (~> 2.0) liquid (4.0.3) - listen (3.2.1) + listen (3.7.1) rb-fsevent (~> 0.10, >= 0.10.3) rb-inotify (~> 0.9, >= 0.9.10) - mercenary (0.3.6) + mercenary (0.4.0) + pathutil (0.16.2) - forwardable-extended (~> 2.6) - public_suffix (4.0.1) - rb-fsevent (0.10.3) - rb-inotify (0.10.0) - ffi (~> 1.0) - rouge (2.2.1) + forwardable-extended (>= 2.6) + public_suffix (4.0.7) + rb-fsevent (0.11.1) + rb-inotify (0.10.1) + ffi (>= 1.0) + rexml (3.2.5) + rouge (3.28.0) safe_yaml (1.0.5) - sass (3.7.4) - sass-listen (~> 4.0.0) - sass-listen (4.0.0) - rb-fsevent (~> 0.9, >= 0.9.4) - rb-inotify (~> 0.9, >= 0.9.7) + sassc (2.4.0) + ffi (~> 1.9) + terminal-table (2.0.0) + unicode-display_width (~> 1.1, >= 1.1.1) + unicode-display_width (1.8.0) + webrick (1.7.0) PLATFORMS - ruby + x86_64-linux DEPENDENCIES - jekyll (~> 3.6.3) + jekyll jekyll-coffeescript + webrick (~> 1.7) BUNDLED WITH - 1.17.3 + 2.3.14 diff --git a/_bin/gobo_scrape.py b/_bin/gobo_scrape.py new file mode 100644 index 0000000..e8c5d4c --- /dev/null +++ b/_bin/gobo_scrape.py @@ -0,0 +1,78 @@ +from unittest import result +import requests +import yaml +from yaml import Loader, Dumper +from bs4 import BeautifulSoup, element +import os.path + + +with open("_data/gobos.yml", "r") as f: + gdata = yaml.load(f, Loader=Loader) + +for gobo in gdata: + gobo_num = ''.join(str(gobo['number']).split()) + print(gobo_num) + if not 'name' in gobo: + filename = '' + if gobo['make'] == 'Goboland': + + # Get gobo information from goboland.com + goboland_search_url = 'https://www.goboland.com/advanced_search_result.php?keywords=' + gobo_num + '&psearch=products&location=United-Kingdom' + goboland_html = requests.get(goboland_search_url) + assert goboland_html.status_code == 200, "Failed to fetch from goboland.com" + + s = BeautifulSoup(goboland_html.text, 'lxml') + name = s.find('span', {'class' : 'searchLinks'}) + if name is None: + pass + + gobo['name'] = name.text + + # Get gobo image + gobo_info = name.parent.parent.parent + imgurl = 'https://www.goboland.com/' + gobo_info.find('img').get('src') + filename = 'goboland-' + gobo_num + '.jpg' + + + + elif gobo['make'] == 'Rosco': + + # Get gobo information from rosco.com + rosco_search_url = 'https://emea.rosco.com/en/products/catalog/gobos?search=' + str(gobo_num) + rosco_html = requests.get(rosco_search_url) + assert rosco_html.status_code == 200, "Failed to fetch from rosco.com" + + s = BeautifulSoup(rosco_html.text, 'lxml') + names = s.find_all('div', {'class' : 'product-item'}) + if names is None: + pass + + for result in names: + number = result.find('span', {'class' : 'name'}).text + if number == gobo_num: + name = result.find('span', {'class' : 'text-box'}).text.strip().split('\n')[0] + image = result.find('img').get('src') + break + + gobo['name'] = name + + + # Get gobo image + imgurl = 'https://emea.rosco.com/' + image + filename = 'rosco-' + gobo_num + '.jpg' + + if filename is not '': + path = 'images/gobos/' + filename + if not os.path.exists(path): + with open(path, 'wb') as f: + f.write(requests.get(imgurl).content) + + gobo['image'] = filename + + + +with open("_data/gobos.yml", "w") as f: + stream = yaml.dump(gdata, Dumper=Dumper, width=720, indent=2) + stream = stream.replace('\n- ', '\n\n- ') + stream = stream.replace('!!python/unicode ', '') + f.write(stream) diff --git a/_bin/lee_scrape.py b/_bin/lee_scrape_legacy.py similarity index 70% rename from _bin/lee_scrape.py rename to _bin/lee_scrape_legacy.py index 6ac47c8..fc73848 100644 --- a/_bin/lee_scrape.py +++ b/_bin/lee_scrape_legacy.py @@ -1,14 +1,15 @@ import requests import yaml +from yaml import Loader, Dumper from bs4 import BeautifulSoup, element -lee_html = requests.get("http://leefilters.com/lighting/colour-list.html") +lee_html = requests.get("http://web.archive.org/web/20210618025008id_/http://leefilters.com/lighting/colour-list.html") assert lee_html.status_code == 200, "Failed to fetch from leefilters.com" s = BeautifulSoup(lee_html.text, 'html.parser') -print "**{}**".format(s.title.string) +print("**{}**".format(s.title.string)) lee_gels = {} @@ -26,10 +27,10 @@ 'description': description, } -print "{} colour refs acquired".format(len(lee_gels)) +print("{} colour refs acquired".format(len(lee_gels))) with open("_data/gels.yml", "r") as f: - gdata = yaml.load(f) + gdata = yaml.load(f, Loader=Loader) for gel in gdata: if gel['code'] in lee_gels: @@ -37,10 +38,10 @@ gel['name'] = str(lee_gels[gel['code']]['name']) gel['description'] = str(lee_gels[gel['code']]['description']) else: - print "Our {} is not present on leefilters.com".format(gel['code']) + print("Our {} is not present on leefilters.com".format(gel['code'])) with open("_data/gels.yml", "w") as f: - stream = yaml.dump(gdata, width=720, indent=2) + stream = yaml.dump(gdata, Dumper=Dumper, width=720, indent=2) stream = stream.replace('\n- ', '\n\n- ') stream = stream.replace('!!python/unicode ', '') f.write(stream) diff --git a/_bin/stocktake.py b/_bin/stocktake.py index 440c51e..abf09c3 100644 --- a/_bin/stocktake.py +++ b/_bin/stocktake.py @@ -1,5 +1,6 @@ import csv import yaml +from yaml import Loader, Dumper igels = {} @@ -28,13 +29,13 @@ def input_colour(code, result, mode='cut'): sheets[row[0]] = 1 # Do sheets -for code, qty in sheets.iteritems(): +for code, qty in sheets.items(): input_colour(code, qty, 'sheet') with open("_data/gels.yml", "r") as f: - ogels = yaml.load(f) + ogels = yaml.load(f, Loader=Loader) -print "{} gels to process, processing all known".format(len(igels)) +print("{} gels to process, processing all known".format(len(igels))) for ogel in ogels: code = ogel['code'] @@ -55,12 +56,12 @@ def input_colour(code, result, mode='cut'): ogel['stock']['cut'] = 'none' ogel['stock']['sheet'] = 0 -print "{} gels to process, processing unknowns".format(len(igels)) +print("{} gels to process, processing unknowns".format(len(igels))) if len(igels) > 0: - print "Gels not known to the catalogue exist! Scrape or manually add data afterwards." + print("Gels not known to the catalogue exist! Scrape or manually add data afterwards.") -for code, stock in igels.iteritems(): +for code, stock in igels.items(): if 'cut' not in stock: stock['cut'] = 'none' if 'sheet' not in stock: @@ -75,9 +76,10 @@ def input_colour(code, result, mode='cut'): }) with open("_data/gels.yml", "w") as f: - stream = yaml.dump(ogels, width=720, indent=2) + stream = yaml.dump(ogels, Dumper=Dumper, width=720, indent=2) stream = stream.replace('\n- ', '\n\n- ') stream = stream.replace('!!python/unicode ', '') f.write(stream) -print "done" +print("done") + diff --git a/_bin/stocktake_gobo.py b/_bin/stocktake_gobo.py new file mode 100644 index 0000000..5a1a3e6 --- /dev/null +++ b/_bin/stocktake_gobo.py @@ -0,0 +1,71 @@ +# update _data/gobos.yml with stock numbers from _stacktake/gobos.txt + +from sqlalchemy import null +import yaml +from operator import itemgetter + + +igobos = {} + +def input_gobo(make, code, size, amount): + if make not in igobos: + igobos[make] = {} + if code not in igobos[make]: + igobos[make][code] = {} + igobos[make][code][size] = amount + +with open('_stocktake/gobos.txt', 'r') as f: + text = f.read().split('\n\n') + +for manufacturer in text: + if manufacturer != '': + manufacturer_name = manufacturer.split('\n')[0] + for line in manufacturer.split('\n')[1:]: + if line != '': + amount = line.split(' ')[0][0:-1] + size = line[-1:].upper() + code = line.split(' ', 1) + print(code) + code = code[1][:-2] + input_gobo(manufacturer_name, code, size, amount) + +with open("_data/gobos.yml", "r") as f: + ogobos = yaml.load(f, Loader=yaml.Loader) + +print("{} gobos to process, processing all known".format(len(igobos))) + +for gobo in ogobos: + make = gobo['make'] + code = gobo['number'] + gobo['stock'] = [] + if make in igobos and code in igobos[make]: + # In input list, add what we have + for size, amount in igobos[make][code].items(): + gobo['stock'].append({'size': size, 'qty': amount}) + + # Done with gel, pop from dict + igobos[make].pop(code) + if len(igobos[make]) == 0: + igobos.pop(make) + +print("{} gobos to process, processing unknowns".format(len(igobos))) + +for make in igobos: + for code, sizes in igobos[make].items(): + gobo = {'make': make, 'number': code, 'stock': None} + stock = [] + for size, amount in sizes.items(): + stock.append({'size': size, 'qty': amount}) + gobo['stock'] = stock + + ogobos.append(gobo) + +ogobos = sorted(ogobos, key=lambda x: (-1*str(x['make']), str(x['number']))) + +with open("_data/gobos.yml", "w") as f: + stream = yaml.dump(ogobos, Dumper=yaml.Dumper, width=720, indent=2) + stream = stream.replace('\n- ', '\n\n- ') + stream = stream.replace('!!python/unicode ', '') + f.write(stream) + +print("done") \ No newline at end of file diff --git a/_includes/head.html b/_includes/head.html index d7b0738..563b56c 100644 --- a/_includes/head.html +++ b/_includes/head.html @@ -9,7 +9,7 @@ - + diff --git a/_stocktake/gobos.txt b/_stocktake/gobos.txt new file mode 100644 index 0000000..65508cd --- /dev/null +++ b/_stocktake/gobos.txt @@ -0,0 +1,34 @@ +Rosco +2x 79144 M +2x 78202 A +5x 78136 B +1x 77811 M +2x 77337 B +2x 77856 B +1x 77702 B +4x 77915 A +7x 77805 A +1x 77805 M +4x 77805 B +1x 77259 B +2x 77808 B +1x 77884 M +1x 77165 A +1x 77501 B +1x 77561 B +1x 71030 B +2x 79203 A +1x 78061 B +2x 77721 A +1x 77920 B + +Goboland +1x 2 102 000 B +1x 2 101 001 B +2x 2 542 012 B +1x 2 431 003 B +1x 2 180 010 B + +Custom +2x WSAF splodge A +1x WSAF glass b diff --git a/gels.html b/gels.html index e9cc0e8..065bc41 100644 --- a/gels.html +++ b/gels.html @@ -7,7 +7,7 @@