Permalink
Browse files

refine README

  • Loading branch information...
1 parent 06fd2d4 commit a3f710460fd09763367c6508c6fb719249818240 Puraumu committed Jul 26, 2012
Showing with 655 additions and 31 deletions.
  1. +75 −3 README.md
  2. +6 −5 client.rb
  3. +35 −5 coffee/reload.coffee
  4. +30 −11 config.ru
  5. +3 −2 en-sql.rb
  6. +2 −1 enclient.rb
  7. +9 −0 public/css/style.min.css
  8. +4 −2 public/index.html
  9. +64 −0 public/js/reload.min.js
  10. +423 −0 public/js/script.min.js
  11. +4 −2 public/reload/index.html
View
@@ -2,12 +2,84 @@
Evernote HeatMap visualizes Evernote metadata using [d3.js](https://github.com/mbostock/d3) and [Evernote Cloud API](http://dev.evernote.com/documentation/cloud/).
+# Overview
+
+* `rake server` - run sinatra server
+* `localhost:9292/` - view heatmap
+* `localhost:9292/reload` - regenerate JSON file via Cloud API
+
+Paste your "Developer Tokens" to config.ru
+
+Evernote HeatMap uses [evernote/evernote-sdk-ruby](https://github.com/evernote/evernote-sdk-ruby) (already in the repository).
+
# Requirements
-To run the server, following libraries, gems or datas will be required:
+To run `rake server`, following libraries, gems or datas will be required:
* [CoffeeScript](http://coffeescript.org/)
* [Sinatra](http://www.sinatrarb.com/)
* [Compass](http://compass-style.org/)
-* [evernote/evernote-sdk-ruby](https://github.com/evernote/evernote-sdk-ruby)
-* [Developer tokens](http://dev.evernote.com/documentation/cloud/chapters/Authentication.php)
+* [Developer Tokens](http://dev.evernote.com/documentation/cloud/chapters/Authentication.php)
+
+# For minimalists
+
+If you would like to view your Evernote data immediately, you need followings:
+
+* Ruby Programming Language
+* Sinatra Gem
+* Developer Token
+
+If you you know and available above, edit config.ru like
+
+ $token = "YOUR-DEVELOPER-TOKEN"
+
+to
+
+ $token = "S=s1:U=279bf:E=13f92f064bf:C=1383b3f38c3:P=1cd:A=en-devtoken:H=725df8b086b2cb08e13a7bf5ca186406"
+
+Then, open [the URL](http://localhost:9292/reload) and skip to [Generating JSON](#generating-json).
+
+This script is written in [Ruby Programming Language](http://www.ruby-lang.org/en/). You need to install Ruby. To install Ruby, read [this](http://www.ruby-lang.org/en/downloads/) page. If you are using Mac, you don't need to install Ruby. You can check whether Ruby is woking by typing the following command in Command-Line (e.g. Terminal):
+
+ ruby -e "puts 'hello, world'"
+
+[Sinatra gem](http://www.sinatrarb.com/) requires [RubyGems](http://docs.rubygems.org/read/chapter/1/). Because RubyGems is a part of Ruby, RubyGems is basically available if Ruby is installed. To get Sinatra gem, type:
+
+ gem install sinatra
+
+To get Developer Token, visit [Evernote developer page](http://dev.evernote.com/documentation/cloud/chapters/Authentication.php#devtoken) and [get a production developer token](https://www.evernote.com/api/DeveloperToken.action). Once you've got developer token,
+
+edit config.ru file using TextEditor, not Word Processor. find the line something like this:
+
+ $token = "YOUR-DEVELOPER-TOKEN"
+
+Change that line like so:
+
+ $token = "S=s1:U=279bf:E=13f92f064bf:C=1383b3f38c3:P=1cd:A=en-devtoken:H=725df8b086b2cb08e13a7af5ca186406"
+
+
+**Make suer you quote Developer token using " (quotation mark).** When you finish editing the file, you can run Rackup Server by typing following command in Command-Line:
+
+ rackup
+
+Then open your browser and go to [the URL](http://localhost:9292/reload):
+
+ http://localhost:9292/reload
+
+## Generating JSON
+
+This page will generate JSON file. But the page does not immediately generate JSON file unless you click "reload" button. So the page seems no error or no warning, click the button.
+
+When you got some error, check out the message or google some words.
+
+# License
+
+(The MIT License)
+
+Copyright (C) 2012 Puraumu
+
+Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
View
@@ -1,17 +1,18 @@
require 'json'
require './enclient'
-require '~/scripts/rubylibs/util'
src = "../personal/evernote-heatmap.json"
out = './public/static/evernote.json'
# out = './out.json'
-obj = JSON.parse Util.read_file(src)
-client = ENClient.new(obj["authToken"])
+obj = JSON.parse File.read(src)
+client = ENClient.new('hoge')
+# client = ENClient.new(obj["authToken"])
# p client
# exit
oo = client.guid_name
# p oo
# exit
-# Util.write_file(out, client.guid_name.to_json)
-Util.write_file(out, oo.to_json)
+f = File.new(out, 'w')
+f.write(oo.to_json)
+f.close
View
@@ -2,15 +2,45 @@ node = (elm, text) ->
"<#{elm}>#{text}</#{elm}>"
btn = $('button')
dis = $('#display')
+token = null
+
+dis.ajaxError (e, jqxhr, settings, exception) ->
+ $('#cal').hide()
+ p = $ node 'p', ''
+ p.append(node 'strong', "#{jqxhr.status}")
+ p.append(": #{jqxhr.responseText}")
+ dis.append p
$.get '/estimate', (d) ->
+ state = d.state
+ n = d.number
$('#cal').hide()
- n = d
- est = Math.round(n / 50)
- dis.append(node 'p', "You have #{n} notes.")
- dis.append(node 'p', "Estimated time to reload Cloud API: #{est} sec")
+
+ if state is "OK"
+ token = true
+ est = Math.round(n / 50)
+ dis.append(node 'p', "You have #{n} notes.")
+ dis.append(node 'p', "Estimated time: #{est} sec")
+
+ if state is "NG"
+ token = false
+ dis.append(node 'strong', "Developer Token is wrong.")
+ dis.append(node 'p', "Did you edit config.ru? Please read README file.")
+
+ unless state is "NG" or state is "OK"
+ dis.append(node 'p', "Server is broken or down")
btn.on 'click', () ->
dis.append(node 'p', "Processing...")
$.get '/do', (d) ->
- dis.append(node 'p', "Done!")
+ if d is "OK"
+ dis.append(node 'p', "Done!")
+
+ if d is "NG" and token is false
+ dis.append(node 'strong', "Cannot authenticate to Evernote Server.")
+ dis.append(node 'p', "Did you edit config.ru? Please read README file.")
+
+ if d is "NG" and token is true
+ dis.append(node 'p', "sdk is out date?")
+ $.get '/check', (ver) ->
+ dis.append(node 'p', "versionOK?: #{ver}")
View
@@ -1,27 +1,38 @@
require 'sinatra/base'
require 'json'
require './enclient'
-require '~/scripts/rubylibs/util'
-# The project root directory
-$root = ::File.dirname(__FILE__)
-$token = JSON.parse(Util.read_file("../personal/evernote-heatmap.json"))["authToken"]
+$token = "YOUR-DEVELOPER-TOKEN"
class SinatraStaticServer < Sinatra::Base
get("/estimate") do
content_type :json
- client = ENClient.new($token)
- client.all_notes_number.to_json
- 1400.to_json
+ out = {"state" => "OK", "number" => 0}
+ begin
+ client = ENClient.new($token)
+ out["number"] = client.all_notes_number
+ rescue Evernote::EDAM::Error::EDAMUserException
+ out["state"] = "NG"
+ end
+ out.to_json
end
get("/do") do
- # content_type :json
- client = ENClient.new($token)
+ begin
+ client = ENClient.new($token)
+ rescue Evernote::EDAM::Error::EDAMUserException
+ return "NG"
+ end
+
oo = client.guid_name
- Util.write_file('./public/static/evernote.json', oo.to_json)
- "done"
+ write_file(oo.to_json)
+ "OK"
+ end
+
+ get ("/check") do
+ client = ENClient.new($token)
+ client.version.to_s
end
get(/.+/) do
@@ -38,6 +49,14 @@ class SinatraStaticServer < Sinatra::Base
File.exist?(file_path) ? send_file(file_path) : missing_file_block.call
end
+ def write_file(out)
+ f = File.new('./public/static/evernote.json', 'w')
+ f.write(out)
+ f.close
+ end
+
end
+$token = JSON.parse(File.read("../personal/evernote-heatmap.json"))["authToken"] if $token == "YOUR-DEVELOPER-TOKEN"
+
run SinatraStaticServer
View
@@ -1,6 +1,5 @@
require 'sqlite3'
require 'csv'
-require '~/scripts/rubylibs/util'
# user settings
csv_out = './evernote.csv'
@@ -135,4 +134,6 @@ def std_stamp(time)
# csv_string = csv_string << row.to_csv
# end
-# Util.write_file(csv_out, csv_string)
+f = File.new(csv_out, 'w')
+f.write(csv_string)
+f.close
View
@@ -18,7 +18,7 @@
require "Evernote/EDAM/limits_constants.rb"
class ENClient
- attr_accessor :token, :noteStore, :tags, :notebooks
+ attr_accessor :token, :noteStore, :tags, :notebooks, :version
# attr_accessor :token, :evernoteHost, :userStoreUrl,
# :userStoreTransport, :userStoreProtocol, :userStore,
# :notesStoreTransport, :notesStoreProtocol, :notesStore
@@ -47,6 +47,7 @@ def initialize(authToken)
versionOK = userStore.checkVersion("Evernote EDAMTest (Ruby)",
Evernote::EDAM::UserStore::EDAM_VERSION_MAJOR,
Evernote::EDAM::UserStore::EDAM_VERSION_MINOR)
+ self.version = versionOK
if (!versionOK)
puts "Is my Evernote API version up to date? #{versionOK}"
exit(1)
View

Large diffs are not rendered by default.

Oops, something went wrong.
View
@@ -5,7 +5,8 @@
<title>DJI</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="http://d3js.org/d3.v2.js"></script>
- <link type="text/css" rel="stylesheet" href="/css/style.css"/>
+ <link type="text/css" rel="stylesheet" href="/css/style.min.css"/>
+ <!-- <link type="text/css" rel="stylesheet" href="/css/style.css"/> -->
<link type="text/css" rel="stylesheet" href="/css/colorbrewer.css"/>
<link type="text/css" rel="stylesheet" href="/css/calendar.css"/>
</head>
@@ -89,7 +90,8 @@
</div><!-- /.container -->
- <script type="text/javascript" src="/js/script.js"></script>
+ <script type="text/javascript" src="/js/script.min.js"></script>
+ <!-- <script type="text/javascript" src="/js/script.js"></script> -->
<!-- <script type="text/javascript" src="/js/d3.scales.js"></script> -->
<!-- <script type="text/javascript" src="/js/dji.js"></script> -->
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
Oops, something went wrong.

0 comments on commit a3f7104

Please sign in to comment.