Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

simple client, /reload

  • Loading branch information...
commit 06fd2d4522707806648b0316e08f287cb7722729 1 parent ab8ba3b
Puraumu authored
View
2  .gitignore
@@ -5,3 +5,5 @@ public/css/bootstrap/responsive.css
public/js/script.js
public/static/evernote.csv
public/static/evernote.json
+public/js/reload.js
+
View
16 coffee/reload.coffee
@@ -0,0 +1,16 @@
+node = (elm, text) ->
+ "<#{elm}>#{text}</#{elm}>"
+btn = $('button')
+dis = $('#display')
+
+$.get '/estimate', (d) ->
+ $('#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")
+
+btn.on 'click', () ->
+ dis.append(node 'p', "Processing...")
+ $.get '/do', (d) ->
+ dis.append(node 'p', "Done!")
View
19 config.ru
@@ -1,10 +1,29 @@
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"]
class SinatraStaticServer < Sinatra::Base
+ get("/estimate") do
+ content_type :json
+ client = ENClient.new($token)
+ client.all_notes_number.to_json
+ 1400.to_json
+ end
+
+ get("/do") do
+ # content_type :json
+ client = ENClient.new($token)
+ oo = client.guid_name
+ Util.write_file('./public/static/evernote.json', oo.to_json)
+ "done"
+ end
+
get(/.+/) do
send_sinatra_file(request.path) {404}
end
View
12 public/reload/index.html
@@ -4,22 +4,22 @@
<meta http-equiv="content-type" content="text/html;charset=utf-8">
<title>DJI</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
- <script src="http://d3js.org/d3.v2.js"></script>
+ <script src="http://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js"></script>
<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>
<body>
<div class="container">
<h1>Reload Cloud API</h1>
+ <button class="btn" type="">Reload!</button>
+ <hr />
+ <p id="cal">Calculating estimate time...</p>
+ <div id="display"></div>
</div><!-- /.container -->
- <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> -->
+ <script type="text/javascript" src="/js/reload.js"></script>
</body>
</html>
Please sign in to comment.
Something went wrong with that request. Please try again.