Instantly share code, notes, and snippets.

@sobstel /Gemfile
Last active Dec 2, 2017

Embed
What would you like to do?
Quick&dirty trello task list
#
# !!! 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
#
require './app'
run Cuba
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