Skip to content

Instantly share code, notes, and snippets.

@camillebaldock
Last active August 29, 2015 14:17
Show Gist options
  • Save camillebaldock/e7756c5067bc11323aee to your computer and use it in GitHub Desktop.
Save camillebaldock/e7756c5067bc11323aee to your computer and use it in GitHub Desktop.
Dashing Feedly widget

Description

A Dashing widget for displaying the number of unread items in Feedly categories.

See a live demo here.

Usage

Setup the following environment variables:

  • FEEDLY_TOKEN: see instructions here to setup a token
  • FEEDLY_CATEGORY_NAMES: comma-separated list of the names of the Feedly categories that you wish to monitor
<li data-row="1" data-col="1" data-sizex="1" data-sizey="1">
<div data-id="feedly-Reading" data-view="Number" data-title="Reading" style="background-color:#FF8000"></div>
</li>
require "json"
require "uri"
require "net/http"
SCHEDULER.every "30m" do
headers = {
"Authorization" => "OAuth #{ENV["FEEDLY_TOKEN"]}"
}
uri = URI.parse("http://cloud.feedly.com/v3/markers/counts")
http = Net::HTTP.new(uri.host, uri.port)
response = http.get(uri.path, headers)
response_hash = JSON.parse(response.body)
unread_counts = response_hash["unreadcounts"]
ENV["FEEDLY_CATEGORY_NAMES"].split(",").each do |category_name|
reading_count = unread_counts.find do |unread_count|
unread_count["id"].include?("category/#{category_name}")
end
send_event("feedly-#{category_name}", { current: reading_count["count"] })
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment