Skip to content

Instantly share code, notes, and snippets.

@mickey
Created Sep 4, 2013
Embed
What would you like to do?
Dashing widget to track the number of applications for the dashing widget challenge.

##Description

Dashing widget to track the number of applications for the Dashing widget challenge.

##Preview

##Dependencies

mechanize

Add it to dashing's gemfile:

gem 'mechanize'

and run bundle install.

##Usage

  1. Add the widget HTML to your dashboard
    <li data-row="1" data-col="1" data-sizex="1" data-sizey="1">
      <div data-id="widget-competition" data-view="Number" data-title="Widgets submitted">
      </div>
    </li>
  1. Add widget-competition.rb in your jobs directory.

  2. Enjoy!

require 'mechanize'
SCHEDULER.every '5m', :first_in => 0 do |job|
page = Mechanize.new.get('http://dashing.challengepost.com/submissions')
number_of_widgets_submitted = page.search(".pages").search("b").last.children.text
send_event('widget-competition', { current: number_of_widgets_submitted })
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment