copy newsletter posts rake tasks, rework structure
This commit is contained in:
parent
bfca38a16d
commit
40388cfe84
9 changed files with 105 additions and 70 deletions
8
.travis.yml
Normal file
8
.travis.yml
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
language: ruby
|
||||
rvm:
|
||||
- 2.5.3
|
||||
install:
|
||||
- gem install git
|
||||
script:
|
||||
- ruby _scripts/generate_downloads.rb
|
||||
- ruby _scripts/copy_newsletter_posts.rb
|
||||
|
|
@ -8,6 +8,7 @@ TODO
|
|||
- [x] layout of Downloads
|
||||
- [ ] responsive sizes
|
||||
- [x] download details pages
|
||||
- [x] landing page
|
||||
- [ ] news page?
|
||||
- [ ] help page
|
||||
- [ ] setup travis for generate_downloads.rb
|
||||
|
|
|
|||
1
Rakefile
Normal file
1
Rakefile
Normal file
|
|
@ -0,0 +1 @@
|
|||
Dir.glob('lib/tasks/*.rake').each { |r| load r}
|
||||
|
|
@ -1,18 +1,18 @@
|
|||
---
|
||||
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/"
|
||||
---
|
||||
---
|
||||
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 +1,18 @@
|
|||
---
|
||||
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/"
|
||||
---
|
||||
---
|
||||
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/"
|
||||
---
|
||||
|
|
|
|||
|
|
@ -1,34 +0,0 @@
|
|||
require 'json'
|
||||
require 'erb'
|
||||
require 'cgi'
|
||||
|
||||
template = <<-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:
|
||||
<%- attributes["files"].each do |file| -%>
|
||||
"<%= file[0] %>": "<%= file[1] %>"
|
||||
<%- end -%>
|
||||
permalink: "/download/<%= CGI.escape(id) %>/"
|
||||
---
|
||||
EOF
|
||||
|
||||
erb = ERB.new(template, nil, '-')
|
||||
|
||||
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 erb.result_with_hash(download)
|
||||
end
|
||||
end
|
||||
20
lib/tasks/copy_newsletter_posts.rake
Executable file
20
lib/tasks/copy_newsletter_posts.rake
Executable file
|
|
@ -0,0 +1,20 @@
|
|||
#!/usr/bin/env ruby
|
||||
|
||||
require 'rubygems'
|
||||
require 'open-uri'
|
||||
require 'json'
|
||||
require 'base64'
|
||||
|
||||
desc 'Copy files from the newsletter repository'
|
||||
task :copy_newsletter_posts do
|
||||
file = open('https://api.github.com/repos/adafruit/circuitpython-weekly-newsletter/contents/_posts').read
|
||||
|
||||
posts = JSON.parse(file)
|
||||
|
||||
posts.each do |post|
|
||||
response = JSON.parse(open(post["url"]).read)
|
||||
content = Base64.decode64(response["content"])
|
||||
File.write File.join(File.dirname(__FILE__), '../../_posts/', post["name"]), content
|
||||
sleep 2
|
||||
end
|
||||
end
|
||||
39
lib/tasks/generate_downloads.rake
Executable file
39
lib/tasks/generate_downloads.rake
Executable file
|
|
@ -0,0 +1,39 @@
|
|||
#!/usr/bin/env ruby
|
||||
|
||||
require 'json'
|
||||
require 'erb'
|
||||
require 'cgi'
|
||||
|
||||
desc 'Generate download pages from the downloads json file'
|
||||
task :generate_downloads do
|
||||
template = <<-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:
|
||||
<%- attributes["files"].each do |file| -%>
|
||||
"<%= file[0] %>": "<%= file[1] %>"
|
||||
<%- end -%>
|
||||
permalink: "/download/<%= CGI.escape(id) %>/"
|
||||
---
|
||||
EOF
|
||||
|
||||
erb = ERB.new(template, nil, '-')
|
||||
|
||||
downloads = File.read(File.join(File.dirname(__FILE__), '../../_data/downloads.json'))
|
||||
downloads = JSON.parse(downloads)
|
||||
|
||||
downloads["data"].each do |download|
|
||||
path = File.join(File.dirname(__FILE__), '../../_downloads/', "#{CGI.escape(download["id"])}.md")
|
||||
File.open(path, 'w') do |f|
|
||||
f.write erb.result_with_hash(download)
|
||||
end
|
||||
end
|
||||
end
|
||||
0
lib/tasks/travis.rake
Normal file
0
lib/tasks/travis.rake
Normal file
Loading…
Reference in a new issue