initial examples of board metadata and files
This commit is contained in:
parent
2c437db68a
commit
cf718e32fc
11 changed files with 147 additions and 245 deletions
|
|
@ -15,3 +15,10 @@ TODO
|
|||
- [x] update header to latest version (different logo)
|
||||
- [x] deploy accounts, and update url to accounts production in download.js
|
||||
- [ ] authenticate github api for newsletter posts
|
||||
|
||||
|
||||
# To add a new board to the site:
|
||||
|
||||
1. Edit _data/metadata.json and add a new object in the array with the board details.
|
||||
2. Commit and push the code. A file will be automatically generated in _downloads/board_id.description_type
|
||||
3. Edit the description and save the file
|
||||
|
|
|
|||
|
|
@ -1,158 +0,0 @@
|
|||
{
|
||||
"data": [{
|
||||
"type": "boards",
|
||||
"id": "Arduino Zero",
|
||||
"attributes": {
|
||||
"manufacturer": "Arduino",
|
||||
"downloads": "5324",
|
||||
"board_url": "https://www.arduino.cc",
|
||||
"board_image": "https://cdn-shop.adafruit.com/970x728/2488-19.jpg",
|
||||
"description": {
|
||||
"en": "Arduino Zero is a board.",
|
||||
"de": "Arduino Zero is a board.",
|
||||
"es": "Arduino Zero is a board.",
|
||||
"fil": "Arduino Zero is a board.",
|
||||
"fr": "Arduino Zero is a board."
|
||||
},
|
||||
"versions": [{
|
||||
"stable": true,
|
||||
"version": "3.7",
|
||||
"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",
|
||||
"fr": "https://github.com/adafruit/circuitpython/releases/download/4.0.0-alpha.1/adafruit-circuitpython-arduino_zero-fr-4.0.0-alpha.1.bin"
|
||||
}
|
||||
},
|
||||
{
|
||||
"stable": false,
|
||||
"version": "4.0.0 Alpha 1",
|
||||
"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",
|
||||
"fr": "https://github.com/adafruit/circuitpython/releases/download/4.0.0-alpha.1/adafruit-circuitpython-arduino_zero-fr-4.0.0-alpha.1.bin"
|
||||
}
|
||||
}]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "boards",
|
||||
"id": "Circuit Playground Express",
|
||||
"attributes": {
|
||||
"manufacturer": "Adafruit",
|
||||
"downloads": "213",
|
||||
"board_url": "https://www.adafruit.com",
|
||||
"board_image": "https://cdn-shop.adafruit.com/970x728/3333-03.jpg",
|
||||
"description": {
|
||||
"en": "Circuit Playground Express is a board.",
|
||||
"de": "Circuit Playground Express is a board.",
|
||||
"es": "Circuit Playground Express is a board.",
|
||||
"fil": "Circuit Playground Express is a board.",
|
||||
"fr": "Circuit Playground Express is a board."
|
||||
},
|
||||
"versions": [{
|
||||
"stable": true,
|
||||
"version": "3.7",
|
||||
"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",
|
||||
"fr": "https://github.com/adafruit/circuitpython/releases/download/4.0.0-alpha.1/adafruit-circuitpython-arduino_zero-fr-4.0.0-alpha.1.bin"
|
||||
}
|
||||
},
|
||||
{
|
||||
"stable": false,
|
||||
"version": "4.0.0 Alpha 1",
|
||||
"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",
|
||||
"fr": "https://github.com/adafruit/circuitpython/releases/download/4.0.0-alpha.1/adafruit-circuitpython-arduino_zero-fr-4.0.0-alpha.1.bin"
|
||||
}
|
||||
}]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "boards",
|
||||
"id": "Arduino Zero",
|
||||
"attributes": {
|
||||
"manufacturer": "Arduino",
|
||||
"downloads": "5324",
|
||||
"board_url": "https://www.arduino.cc",
|
||||
"board_image": "https://cdn-shop.adafruit.com/970x728/2488-19.jpg",
|
||||
"description": {
|
||||
"en": "Arduino Zero is a board.",
|
||||
"de": "Arduino Zero is a board.",
|
||||
"es": "Arduino Zero is a board.",
|
||||
"fil": "Arduino Zero is a board.",
|
||||
"fr": "Arduino Zero is a board."
|
||||
},
|
||||
"versions": [{
|
||||
"stable": true,
|
||||
"version": "3.7",
|
||||
"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",
|
||||
"fr": "https://github.com/adafruit/circuitpython/releases/download/4.0.0-alpha.1/adafruit-circuitpython-arduino_zero-fr-4.0.0-alpha.1.bin"
|
||||
}
|
||||
},
|
||||
{
|
||||
"stable": false,
|
||||
"version": "4.0.0 Alpha 1",
|
||||
"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",
|
||||
"fr": "https://github.com/adafruit/circuitpython/releases/download/4.0.0-alpha.1/adafruit-circuitpython-arduino_zero-fr-4.0.0-alpha.1.bin"
|
||||
}
|
||||
}]
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "boards",
|
||||
"id": "Circuit Playground Express",
|
||||
"attributes": {
|
||||
"manufacturer": "Adafruit",
|
||||
"downloads": "213",
|
||||
"board_url": "https://www.adafruit.com",
|
||||
"board_image": "https://cdn-shop.adafruit.com/970x728/3333-03.jpg",
|
||||
"description": {
|
||||
"en": "Circuit Playground Express is a board.",
|
||||
"de": "Circuit Playground Express is a board.",
|
||||
"es": "Circuit Playground Express is a board.",
|
||||
"fil": "Circuit Playground Express is a board.",
|
||||
"fr": "Circuit Playground Express is a board."
|
||||
},
|
||||
"versions": [{
|
||||
"stable": true,
|
||||
"version": "3.7",
|
||||
"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",
|
||||
"fr": "https://github.com/adafruit/circuitpython/releases/download/4.0.0-alpha.1/adafruit-circuitpython-arduino_zero-fr-4.0.0-alpha.1.bin"
|
||||
}
|
||||
},
|
||||
{
|
||||
"stable": false,
|
||||
"version": "4.0.0 Alpha 1",
|
||||
"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",
|
||||
"fr": "https://github.com/adafruit/circuitpython/releases/download/4.0.0-alpha.1/adafruit-circuitpython-arduino_zero-fr-4.0.0-alpha.1.bin"
|
||||
}
|
||||
}]
|
||||
}
|
||||
}]
|
||||
}
|
||||
27
_data/metadata.json
Normal file
27
_data/metadata.json
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
{
|
||||
"data": [{
|
||||
"type": "boards",
|
||||
"id": "arduino_mkr1300",
|
||||
"attributes": {
|
||||
"name": "Arduino MKR WAN 1300",
|
||||
"manufacturer": "Arduino",
|
||||
"board_url": "https://www.arduino.cc/en/Guide/MKRWAN1300",
|
||||
"board_image": "/assets/images/boards/arduino_mkr1300.jpg",
|
||||
"permalink": "/download/Arduion+MKR+WAN+1300/",
|
||||
"description_type": "html"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "boards",
|
||||
"id": "circuitplayground_express",
|
||||
"attributes": {
|
||||
"name": "Circuit Playground Express",
|
||||
"manufacturer": "Adafruit",
|
||||
"board_url": "https://www.adafruit.com",
|
||||
"board_image": "https://cdn-shop.adafruit.com/970x728/3333-03.jpg",
|
||||
"permalink": "/download/Circuit+Playground+Express/",
|
||||
"description_type": "markdown"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
---
|
||||
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"
|
||||
"fr": "https://github.com/adafruit/circuitpython/releases/download/4.0.0-alpha.1/adafruit-circuitpython-arduino_zero-fr-4.0.0-alpha.1.bin"
|
||||
permalink: "/download/Arduino+Zero/"
|
||||
---
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
---
|
||||
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"
|
||||
"fr": "https://github.com/adafruit/circuitpython/releases/download/4.0.0-alpha.1/adafruit-circuitpython-circuitplayground_express-fr-4.0.0-alpha.1.uf2"
|
||||
permalink: "/download/Circuit+Playground+Express/"
|
||||
---
|
||||
17
_downloads/arduino_mkr1300.html
Normal file
17
_downloads/arduino_mkr1300.html
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
---
|
||||
# NOTE: The front matter in this file is pre-generated with generate_downloads.rake
|
||||
# Do not hand edit any of the front matter. You can change these values
|
||||
# in _data/metadata.json for each respective board
|
||||
layout: download
|
||||
board_id: "arduino_mkr1300"
|
||||
downloads: 0
|
||||
title: "Arduino MKR WAN 1300 Download"
|
||||
name: "Arduino MKR WAN 1300"
|
||||
manufacturer: "Arduino"
|
||||
board_url: "https://www.arduino.cc/en/Guide/MKRWAN1300"
|
||||
board_image: "/assets/images/boards/arduino_mkr1300.jpg"
|
||||
permalink: "/download/Arduion+MKR+WAN+1300/"
|
||||
---
|
||||
|
||||
|
||||
Manually add a description here.
|
||||
17
_downloads/circuitplayground_express.md
Normal file
17
_downloads/circuitplayground_express.md
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
---
|
||||
# NOTE: The front matter in this file is pre-generated with generate_downloads.rake
|
||||
# Do not hand edit any of the front matter. You can change these values
|
||||
# in _data/metadata.json for each respective board
|
||||
layout: download
|
||||
board_id: "circuitplayground_express"
|
||||
downloads: 49
|
||||
title: "Circuit Playground Express Download"
|
||||
name: "Circuit Playground Express"
|
||||
manufacturer: "Adafruit"
|
||||
board_url: "https://www.adafruit.com"
|
||||
board_image: "https://cdn-shop.adafruit.com/970x728/3333-03.jpg"
|
||||
permalink: "/download/Circuit+Playground+Express/"
|
||||
---
|
||||
|
||||
|
||||
Manually add a description here. asdf
|
||||
|
|
@ -9,44 +9,52 @@ layout: default
|
|||
<div class="details">
|
||||
<div class="section">
|
||||
<img src="{{ page.board_image }}">
|
||||
|
||||
<p>
|
||||
{{ page.description }}
|
||||
{{ content }}
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="download">
|
||||
<div class="section">
|
||||
<h3>CircuitPython {{ page.version }}</h3>
|
||||
<p>
|
||||
This is the latest stable release of CircuitPython that will work
|
||||
with the {{ page.name }}
|
||||
</p>
|
||||
<div>
|
||||
<label class="language-select">
|
||||
<select>
|
||||
{% for language in page.files %}
|
||||
<option value="{{ language[1] }}" data-locale={{ language[0] }}>
|
||||
{% case language[0] %}
|
||||
{% when 'en' %}
|
||||
ENGLISH
|
||||
{% when 'de' %}
|
||||
GERMAN
|
||||
{% when 'fil' %}
|
||||
FILIPINO
|
||||
{% when 'fr' %}
|
||||
FRENCH
|
||||
{% when 'es' %}
|
||||
SPANISH
|
||||
{% endcase %}
|
||||
</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</label>
|
||||
<a class="download-button" href="{{ page.files.en }}">DOWNLOAD NOW <i class="fas fa-download"></i></a>
|
||||
<div class="clear"></div>
|
||||
{% for version in site.data.files[page.board_id].versions %}
|
||||
<div class="section">
|
||||
<h3>CircuitPython {{ version.version }}</h3>
|
||||
<p>
|
||||
This is the latest {% if version.stable %}stable{% else %}unstable{% endif %}
|
||||
release of CircuitPython that will work with the {{ page.name }}.
|
||||
</p>
|
||||
<div>
|
||||
<label class="language-select">
|
||||
<select>
|
||||
{% for file in version.files %}
|
||||
<option value="{{ file[1][0] }}" data-files={{ file[1] }} data-locale={{ file[0] | replace: '_', '-' }}>
|
||||
{% case file[0] %}
|
||||
{% when 'en_US' %}
|
||||
ENGLISH
|
||||
{% when 'de_DE' %}
|
||||
GERMAN
|
||||
{% when 'fil' %}
|
||||
FILIPINO
|
||||
{% when 'fr' %}
|
||||
FRENCH
|
||||
{% when 'es' %}
|
||||
SPANISH
|
||||
{% when 'it_IT' %}
|
||||
ITALIAN
|
||||
{% when 'pt_BR' %}
|
||||
PORTUGUESE (BRAZILIAN)
|
||||
{% endcase %}
|
||||
</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</label>
|
||||
{% for file in version.files['en_US'] %}
|
||||
<a class="download-button" href="{{ file }}">DOWNLOAD NOW <i class="fas fa-download"></i></a>
|
||||
{% endfor %}
|
||||
<div class="clear"></div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{% endfor %}
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
|
|
|||
BIN
assets/images/boards/arduino_mkr1300.jpg
Normal file
BIN
assets/images/boards/arduino_mkr1300.jpg
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 29 KiB |
|
|
@ -20,6 +20,7 @@ function setLocale(response) {
|
|||
|
||||
for (var i = 0; i < options.length; i++) {
|
||||
if (languages.includes(options[i].dataset.locale)) {
|
||||
console.log(options[i].dataset.locale);
|
||||
options[i].selected = true;
|
||||
languageSelect.onchange();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,39 +9,58 @@ task :generate_downloads do
|
|||
|
||||
template = <<-EOF
|
||||
---
|
||||
# NOTE: The front matter in this file is pre-generated with generate_downloads.rake
|
||||
# Do not hand edit any of the front matter. You can change these values
|
||||
# in _data/metadata.json for each respective board
|
||||
layout: download
|
||||
title: "<%= id %> Download"
|
||||
name: "<%= id %>"
|
||||
version: "<%= attributes["version"] %>"
|
||||
board_id: "<%= id %>"
|
||||
downloads: <%= downloads %>
|
||||
title: "<%= attributes["name"] %> Download"
|
||||
name: "<%= attributes["name"] %>"
|
||||
manufacturer: "<%= attributes["manufacturer"] %>"
|
||||
downloads: "<%= attributes["downloads"] %>"
|
||||
board_url: "<%= attributes["board_url"] %>"
|
||||
board_image: "<%= attributes["board_image"] %>"
|
||||
description: "<%= attributes["description"] %>"
|
||||
files:
|
||||
<%- attributes["files"].each do |file| -%>
|
||||
"<%= file[0] %>": "<%= file[1] %>"
|
||||
<%- end -%>
|
||||
permalink: "/download/<%= CGI.escape(id) %>/"
|
||||
permalink: "<%= attributes["permalink"] %>"
|
||||
---
|
||||
EOF
|
||||
|
||||
erb = ERB.new(template, nil, '-')
|
||||
|
||||
files = File.read(File.join(File.dirname(__FILE__), '../../_data/files.json'))
|
||||
files = JSON.parse(files)
|
||||
|
||||
|
||||
downloads = File.read(File.join(File.dirname(__FILE__), '../../_data/downloads.json'))
|
||||
downloads = JSON.parse(downloads)
|
||||
metadata = File.read(File.join(File.dirname(__FILE__), '../../_data/metadata.json'))
|
||||
metadata = JSON.parse(metadata)
|
||||
|
||||
path = File.dirname(__FILE__), '../../_downloads/'
|
||||
|
||||
# delete existing files
|
||||
Dir.glob(File.join(path, '/*.md')).each { |file| File.delete(file)}
|
||||
metadata['data'].each do |data|
|
||||
id = data['id']
|
||||
file_path = File.join(path, "#{CGI.escape(id)}.#{extension(data)}")
|
||||
board = files[id]
|
||||
|
||||
downloads["data"].each do |download|
|
||||
file = File.join(path, "#{CGI.escape(download["id"])}.md")
|
||||
File.open(file, 'w') do |f|
|
||||
f.write erb.result_with_hash(download)
|
||||
new_contents = erb.result_with_hash(data.merge(board))
|
||||
new_contents = merge_content(new_contents, file_path)
|
||||
|
||||
File.open(file_path, 'w') do |f|
|
||||
f.write new_contents
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def merge_content(new_contents, file_path)
|
||||
if File.file?(file_path)
|
||||
contents = File.read(file_path)
|
||||
contents.gsub(/---\n(.)+---\n/m, new_contents)
|
||||
else
|
||||
new_contents << "\n\nManually add a description here."
|
||||
end
|
||||
end
|
||||
|
||||
def extension(data)
|
||||
if data['attributes']['description_type'].eql?('markdown')
|
||||
'md'
|
||||
else
|
||||
data['attributes']['description_type']
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Reference in a new issue