Quick&dirty trello task list
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# !!! EXPERIMENTAL !!! | |
# | |
require 'cuba' | |
require 'json' | |
require 'open-uri' | |
KEY = '!!!KEY!!!'.freeze | |
TOKEN = '!!!TOKEN!!!'.freeze | |
# require 'cuba/safe' | |
# Cuba.plugin Cuba::Safe | |
def read(resource) | |
JSON.parse open("https://trello.com/1/#{resource}?key=#{KEY}&token=#{TOKEN}").read | |
end | |
Cuba.define do | |
on get do | |
on root do | |
res.write '<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet" />' | |
res.write '<table class="table"><tbody>' | |
read('boards/RJWQg37w/lists').last(3).each do |list| | |
read("lists/#{list['id']}/cards").each do |card| | |
res.write '<tr>' | |
res.write "<th scope='row'>#{list['name']}</th>" | |
res.write "<td><a href='#{card['url']}'>#{card['name']}</a></td>" | |
res.write "<td><small>#{card['labels'].collect { |l| l['name'] }.join(', ')}</small></td>" | |
res.write '</td>' | |
res.write "<td>#{card['due'] ? card['due'].slice(0..9) : ''}</td>" | |
res.write '</tr>' | |
end | |
end | |
res.write '</tbody></table>' | |
end | |
end | |
end | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require './app' | |
run Cuba |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
source 'https://rubygems.org' | |
ruby '~> 2.3.1' | |
gem 'cuba' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment