Skip to content

Instantly share code, notes, and snippets.

@sobstel
Last active December 2, 2017 22:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sobstel/c9b5cb6f5dc09bd2b12ada7e310c4634 to your computer and use it in GitHub Desktop.
Save sobstel/c9b5cb6f5dc09bd2b12ada7e310c4634 to your computer and use it in GitHub Desktop.
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