Skip to content

Instantly share code, notes, and snippets.

@tonyedwardspz
Forked from mordonez/Readme.md
Last active September 9, 2015 13:44
Show Gist options
  • Save tonyedwardspz/b806dfb0b2a99ab49d6a to your computer and use it in GitHub Desktop.
Save tonyedwardspz/b806dfb0b2a99ab49d6a to your computer and use it in GitHub Desktop.
Trello Job for Dashing

#Preview# test

#Description#

Simple Dashing Job to display Trello info about your boards. Uses Trello API.

#Dependencies# ruby-trello

Add it to dashing's gemfile:

gem 'ruby-trello' and run bundle install. Everything should work now :)

#Usage# To use this widget, put the trello.rb file in your /jobs folder.

To include the widget in a dashboard, add the following snippet to the dashboard layout

<li data-row="1" data-col="1" data-sizex="1" data-sizey="1">
  <div data-id="my-trello-board" data-view="List" data-title="Trello Board"></div>
  <i class="icon-trello icon-background"></i>
</li>
require 'trello'
include Trello
Trello.configure do |config|
config.developer_public_key = 'YOUR_DEVELOPER_KEY'
config.member_token = 'YOUR_MEMBER_TOKEN'
end
boards = {
"my-trello-board" => "YOUR_TRELLO_BOARD_ID",
}
class MyTrello
def initialize(widget_id, board_id)
@widget_id = widget_id
@board_id = board_id
end
def widget_id()
@widget_id
end
def board_id()
@board_id
end
def status_list()
status = Array.new
Board.find(@board_id).lists.each do |list|
status.push({label: list.name, value: list.cards.size})
end
status
end
end
@MyTrello = []
boards.each do |widget_id, board_id|
begin
@MyTrello.push(MyTrello.new(widget_id, board_id))
rescue Exception => e
puts e.to_s
end
end
SCHEDULER.every '5m', :first_in => 0 do |job|
@MyTrello.each do |board|
status = board.status_list()
send_event(board.widget_id, { :items => status })
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment