generate download collection files from json downloads file, initial layout

This commit is contained in:
Justin Cooper 2018-11-08 11:13:37 -06:00
parent 5b5cb6ffd6
commit c67564d5f0
6 changed files with 81 additions and 1 deletions

3
README.md Normal file
View file

@ -0,0 +1,3 @@
# CircuitPython organization site
TODO

View file

@ -27,6 +27,11 @@ sass:
sass_dir: assets/sass
style: :compressed
# Collections
collections:
downloads:
output: true
### Exclude from processing.
exclude:
- Gemfile

View file

@ -0,0 +1,17 @@
---
layout: download
title: "Arduino Zero Download"
name: "Arduino Zero"
version: "4.0.0 Alpha 1"
manufacturer: "Arduino"
downloads: "5324"
board_url: "https://www.arduino.cc"
board_image: "https://cdn-shop.adafruit.com/970x728/2488-19.jpg"
description: "Arduino Zero is a board."
files:
"en": "https://github.com/adafruit/circuitpython/releases/download/4.0.0-alpha.1/adafruit-circuitpython-arduino_zero-en_US-4.0.0-alpha.1.bin"
"de": "https://github.com/adafruit/circuitpython/releases/download/4.0.0-alpha.1/adafruit-circuitpython-arduino_zero-de_DE-4.0.0-alpha.1.bin"
"es": "https://github.com/adafruit/circuitpython/releases/download/4.0.0-alpha.1/adafruit-circuitpython-arduino_zero-es-4.0.0-alpha.1.bin"
"fil": "https://github.com/adafruit/circuitpython/releases/download/4.0.0-alpha.1/adafruit-circuitpython-arduino_zero-fil-4.0.0-alpha.1.bin"
permalink: "/download/Arduino+Zero/"
---

View file

@ -0,0 +1,17 @@
---
layout: download
title: "Circuit Playground Express Download"
name: "Circuit Playground Express"
version: "4.0.0 Alpha 1"
manufacturer: "Adafruit"
downloads: "213"
board_url: "https://www.adafruit.com"
board_image: "https://cdn-shop.adafruit.com/970x728/3333-03.jpg"
description: "Circuit Playground Express is a board."
files:
"en": "https://github.com/adafruit/circuitpython/releases/download/4.0.0-alpha.1/adafruit-circuitpython-circuitplayground_express-de_DE-4.0.0-alpha.1.uf2"
"de": "https://github.com/adafruit/circuitpython/releases/download/4.0.0-alpha.1/adafruit-circuitpython-circuitplayground_express-de_DE-4.0.0-alpha.1.uf2"
"es": "https://github.com/adafruit/circuitpython/releases/download/4.0.0-alpha.1/adafruit-circuitpython-circuitplayground_express-es-4.0.0-alpha.1.uf2"
"fil": "https://github.com/adafruit/circuitpython/releases/download/4.0.0-alpha.1/adafruit-circuitpython-circuitplayground_express-fil-4.0.0-alpha.1.uf2"
permalink: "/download/Circuit+Playground+Express/"
---

5
_layouts/download.html Normal file
View file

@ -0,0 +1,5 @@
---
layout: default
---
{{ page.name }}

View file

@ -0,0 +1,33 @@
require 'json'
require 'erb'
require 'cgi'
template = ERB.new <<-EOF
---
layout: download
title: "<%= id %> Download"
name: "<%= id %>"
version: "<%= attributes["version"] %>"
manufacturer: "<%= attributes["manufacturer"] %>"
downloads: "<%= attributes["downloads"] %>"
board_url: "<%= attributes["board_url"] %>"
board_image: "<%= attributes["board_image"] %>"
description: "<%= attributes["description"] %>"
files:
"en": "<%= attributes["files"]["en"] %>"
"de": "<%= attributes["files"]["de"] %>"
"es": "<%= attributes["files"]["es"] %>"
"fil": "<%= attributes["files"]["fil"] %>"
permalink: "/download/<%= CGI.escape(id) %>/"
---
EOF
downloads = File.read('../_data/downloads.json')
downloads = JSON.parse(downloads)
downloads["data"].each do |download|
path = File.join('../_downloads', "#{CGI.escape(download["id"])}.md")
File.open(path, 'w') do |f|
f.write template.result_with_hash(download)
end
end