ki 0.4.9 → 0.4.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -2,6 +2,8 @@ body
2
2
  padding-top: 20px
3
3
  padding-bottom: 20px
4
4
 
5
+ $text-color: #333
6
+
5
7
  .navbar
6
8
  margin-bottom: 20px
7
9
 
@@ -21,3 +23,25 @@ body
21
23
 
22
24
  .code
23
25
  text-align: justify
26
+
27
+ #parsedJson
28
+ text-align: left
29
+
30
+ .value
31
+ // color: darken($cool, 20%)
32
+ font-weight: bold
33
+
34
+ #playground
35
+ width: 100%
36
+ height: 300px
37
+ color: $text-color
38
+ padding: 15px
39
+ font-family: Menlo,Monaco,Consolas,'Courier New',monospace
40
+ background-color: #f5f5f5
41
+
42
+ input[type="text"], textarea
43
+ outline: none
44
+ box-shadow: none !important
45
+
46
+ .form-control:focus
47
+ border-color: #ccc
@@ -0,0 +1,108 @@
1
+ .row{ 'ng-app' => 'app', 'ng-controller' => 'MainCtrl' }
2
+ .col-xs-6
3
+ .embed-responsive.embed-responsive-16by9
4
+ %youtube-video.embed-responsive-item{ 'video-url' => 'ytVideoUrl', 'player' => 'bestPlayer', 'player-vars' => 'playerVars' }
5
+ .col-xs-6
6
+ %div{ 'ng-show' => 'results.length == 0' }
7
+ %input{ 'ng-model' => 'json.api_key', 'type' => 'text', 'placeholder' => 'api key' }
8
+ %input{ 'ng-model' => 'json.secret', 'type' => 'password', 'placeholder' => 'secret' }
9
+ %i.fa.fa-refresh{ 'ng-click' => 'refresh()' }
10
+ %div{ 'ng-show' => 'results.length > 0' }
11
+ %ul
12
+ %li.text-center{ 'ng-click' => 'playRandom()' }
13
+ %i.fa.fa-random{ 'alt' => 'yes, I know' }
14
+ %li{ 'ng-repeat' => 'result in results', 'ng-click' => 'play(result)', 'ng-class' => '{ selected: isSelected(result) }'}
15
+ %span.pull-right
16
+ %i.fa.fa-edit
17
+ %p
18
+ {{ result.name || result }}
19
+ %li.text-center
20
+ %i.fa.fa-plus
21
+
22
+ <link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/font-awesome/4.4.0/css/font-awesome.min.css">
23
+
24
+ <script src="https://www.youtube.com/iframe_api"></script>
25
+ = js "https://ajax.googleapis.com/ajax/libs/angularjs/1.3.14/angular.min.js"
26
+ = js "/javascripts/music/angular-youtube-embed.js"
27
+
28
+ :css
29
+ .embed-responsive {
30
+ position: relative;
31
+ display: block;
32
+ height: 0;
33
+ padding: 0;
34
+ overflow: hidden;
35
+ }
36
+
37
+ .embed-responsive.embed-responsive-16by9 {
38
+ padding-bottom: 56.25%;
39
+ }
40
+
41
+ .embed-responsive-item {
42
+ position: absolute;
43
+ top: 0;
44
+ bottom: 0;
45
+ left: 0;
46
+ width: 100%;
47
+ height: 100%;
48
+ border: 0;
49
+ }
50
+
51
+ .selected {
52
+ background-color: yellow;
53
+ }
54
+
55
+ li {
56
+ list-style-type: none;
57
+ }
58
+
59
+ :javascript
60
+ var app = angular.module('app', ['youtube-embed']);
61
+
62
+ app.controller('MainCtrl', function ($scope, youtubeEmbedUtils) {
63
+ $scope.results = []
64
+ $scope.refresh = function () {
65
+ jNorthPole.getStorage($scope.json, function (data) {
66
+ if ($scope.json.apiKey != 'guest' && data.error === undefined) {
67
+ localStorage.json = angular.toJson($scope.json)
68
+ }
69
+
70
+ if (data.error === undefined) {
71
+ $scope.results = data;
72
+ $scope.$apply();
73
+ }
74
+ });
75
+ };
76
+ $scope.playerVars = {
77
+ controls: 1,
78
+ autoplay: 1
79
+ };
80
+
81
+ if (localStorage.json === undefined) {
82
+ $scope.json = { 'api_key': 'guest', 'secret': 'quest', 'category': 'music' };
83
+ } else {
84
+ $scope.json = angular.fromJson(localStorage.json);
85
+ $scope.refresh();
86
+ }
87
+
88
+ $scope.play = function (video) {
89
+ $scope.ytVideoUrl = video.url;
90
+ console.log(youtubeEmbedUtils.getIdFromURL($scope.ytVideoUrl));
91
+ }
92
+
93
+ $scope.isSelected = function (video) {
94
+ return $scope.ytVideoUrl == video.url;
95
+ }
96
+
97
+ $scope.playRandom = function() {
98
+ var item = $scope.results[Math.floor(Math.random()*$scope.results.length)];
99
+ $scope.play(item);
100
+ if (player !== undefined) {
101
+ player.seekTo(0);
102
+ }
103
+ }
104
+
105
+ $scope.$on('youtube.player.ended', function ($event, player) {
106
+ $scope.playRandom(player)
107
+ })
108
+ });
@@ -2,20 +2,38 @@
2
2
 
3
3
  %ul#myTab.nav.nav-tabs
4
4
  %li.active
5
- %a{"data-toggle" => "tab", href: "#curl"} curl
5
+ %a{"data-toggle" => "tab", href: "#curl"}
6
+ %img{"src" => "/images/shell.png"}
7
+ curl
6
8
  %li
7
- %a{"data-toggle" => "tab", href: "#ruby"} ruby
9
+ %a{"data-toggle" => "tab", href: "#javascript"}
10
+ %img{"src" => "/images/js.png"}
11
+ javascript
8
12
  %li
9
- %a{"data-toggle" => "tab", href: "#python"} python
13
+ %a{"data-toggle" => "tab", href: "#ruby"}
14
+ %img{"src" => "/images/ruby.png"}
15
+ ruby
10
16
  %li
11
- %a{"data-toggle" => "tab", href: "#php"} php
17
+ %a{"data-toggle" => "tab", href: "#python"}
18
+ %img{"src" => "/images/python.png"}
19
+ python
12
20
  %li
13
- %a{"data-toggle" => "tab", href: "#java"} java
21
+ %a{"data-toggle" => "tab", href: "#php"}
22
+ %img{"src" => "/images/php.png"}
23
+ php
14
24
  %li
15
- %a{"data-toggle" => "tab", href: "#dotnet"} .net
25
+ %a{"data-toggle" => "tab", href: "#java"}
26
+ %img{"src" => "/images/java.png"}
27
+ java
28
+ %li
29
+ %a{"data-toggle" => "tab", href: "#dotnet"}
30
+ %img{"src" => "/images/dotnet.png"}
31
+ \.net
16
32
  .tab-content
17
33
  #curl.tab-pane.fade.in.active
18
34
  = partial 'curl'
35
+ #javascript.tab-pane.fade
36
+ = partial 'javascript'
19
37
  #ruby.tab-pane.fade
20
38
  = partial 'ruby'
21
39
  #python.tab-pane.fade
@@ -1,32 +1,38 @@
1
- %a{'href' => '#what'} What is json.northpole.ro?
1
+ %a{href: '#what'} What is json.northpole.ro?
2
2
  %br
3
- %a{'href' => '#how'} How do I use the API?
3
+ %a{href: '#how'} How do I use the API?
4
4
  %br
5
- %a{'href' => '#storage'} What can I store?
5
+ %a{href: '#storage'} What can I store?
6
6
  %br
7
- %a{'href' => '#where'} Where do I sign up for my free account?
7
+ %a{href: '#why'} Why should I register?
8
8
  %br
9
- %a{'href' => '#question'} I have a question
9
+ %a{href: '#register'} How do I register?
10
10
  %br
11
- %h3#what What is json.northpole.ro
11
+ %h3#what What is json.northpole.ro?
12
12
  %p
13
- json.northpole.ro is a JSON cloud storage service. It is designed to be simple, fast and easy to use. It uses a documented oriented database in the backend to store your objects and provides you with a RESTful http layer to manage the data you store.
13
+ json.northpole.ro is a JSON cloud storage service.
14
+ %p
15
+ It is designed to be simple, fast and easy to use. Use a RESTful HTTP api to manage
16
+ your json objects and access them from anywhere.
14
17
  %h3#how How do I use the API?
15
18
  %p
16
- The API communicates through HTTP. #{NP_URL} has client libraries but you can write your own - if you want to. As long as your device is connected to the internet, you can use the API
19
+ HTTP requests. Read
20
+ %a{href: '/examples'} the docs
21
+ for more info.
17
22
  %p
18
- To get an idea of how the API works, you can
19
- %a{:href => '/try'}
20
- try it in your browser
23
+ To get an idea of how the API works, head to the
24
+ %a{href: '/playground'} playground
25
+ \.
21
26
  %h3#storage What can I store?
22
27
  %p
23
- Any valid json object. The object can contain keys, arrays and hashes. By default, each object will get an id and some extra attributes - like created_at
24
- %h3#where Where do I signup for my free account?
28
+ Any valid json object. The object can contain keys, arrays and hashes.
25
29
  %p
26
- %a{:href => "/signup"} Signing up
27
- is quick and easy. You will get an email containing your api_key and secet.
28
- %h3#question I have a question
30
+ Once the object gets created it will receive a unique id.
31
+ %h3#why Why should I register?
32
+ %p You get your own private storage space under your api_key and secret.
33
+ %h3#register How do I register?
29
34
  %p
30
- If it concerns the API, I suggest you use
31
- %a{'href' => 'http://github.com/northpole-api/northpole.ro/issues'}
32
- github issues
35
+ Create a user in the
36
+ %a{href: '/playground'} playground
37
+ \. If you can't do that, there is a good chance you don't understand
38
+ how the API works. Think of it as a tutorial.
@@ -0,0 +1,7 @@
1
+ %p Open the browser console.
2
+ %p This should get you started:
3
+ %pre.code
4
+ jNorthPole.help
5
+ %p
6
+ The js library can be found
7
+ %a{href: '/javascripts/jnorthpole.js', target: '_blank'} here
@@ -34,6 +34,8 @@
34
34
  %a{href: "/playground"} playground
35
35
  %li.examples
36
36
  %a{href: "/examples"} examples
37
+ %li.faq
38
+ %a{href: "/faq"} faq
37
39
  = yield
38
40
 
39
41
  = js "https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"
@@ -1,12 +1,13 @@
1
1
  .row
2
2
  .col-md-6
3
- %textarea#playground{:style => "width: 100%; height: 300px; color: #333; padding: 15px; font-family: Menlo,Monaco,Consolas,'Courier New',monospace; background-color: #f5f5f5"}
4
- = preserve do
5
- {
6
- \ "api_key":"guest",
7
- \ "secret":"guest"
8
- }
9
- .text-center
3
+ .form-group
4
+ %textarea#playground.form-control
5
+ = preserve do
6
+ {
7
+ \ "api_key":"guest",
8
+ \ "secret":"guest"
9
+ }
10
+ .text-center{style: 'margin-bottom: 14px;'}
10
11
  .btn-group
11
12
  %button.btn.btn-default.dropdown-toggle{"data-toggle" => "dropdown", type: "button"}
12
13
  %span#resource Storage
@@ -32,7 +33,7 @@
32
33
  .btn-group
33
34
  %button#npAction.btn.btn-default Execute Request
34
35
  .col-md-6{:style => 'height: 100%'}
35
- %pre#parsedJson{:style => 'text-align: left;'}
36
+ %pre#parsedJson
36
37
  {}
37
38
  .row
38
39
  .col-md-12
@@ -3,5 +3,4 @@
3
3
  %head
4
4
  %title Hello
5
5
  %body
6
- %p hello world
7
6
  = User.find_or_create({ NP_API_KEY => NP_GUEST_API_KEY, NP_SECRET => NP_GUEST_SECRET })
@@ -81,7 +81,7 @@ describe Ki::Orm do
81
81
  it 'should delete by id' do
82
82
  obj_id = @db.insert 'foo', { 'hello' => 'world' }
83
83
  expect {
84
- @db.delete('foo', obj_id).should == {}
84
+ @db.delete('foo', obj_id).should == { deleted_item_count: 1 }
85
85
  }.to change { @db.count 'foo' }.by(-1)
86
86
  end
87
87
  end
@@ -14,10 +14,6 @@ module Ki
14
14
  def config_file_path
15
15
  config_yml_path = 'spec/config.yml'
16
16
  config_yml_path += '.example' unless File.exist?('spec/config.yml')
17
-
18
- if config_yml_path.end_with?('example')
19
- puts 'WARNING: spec/config.yml.example used'
20
- end
21
17
  config_yml_path
22
18
  end
23
19
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ki
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.9
4
+ version: 0.4.10
5
5
  platform: ruby
6
6
  authors:
7
7
  - Cristian Mircea Messel
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-06-16 00:00:00.000000000 Z
11
+ date: 2015-09-06 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -363,6 +363,7 @@ files:
363
363
  - spec/examples/json.northpole.ro/public/images/ice.png
364
364
  - spec/examples/json.northpole.ro/public/images/java.png
365
365
  - spec/examples/json.northpole.ro/public/images/java_small.png
366
+ - spec/examples/json.northpole.ro/public/images/js.png
366
367
  - spec/examples/json.northpole.ro/public/images/json.png
367
368
  - spec/examples/json.northpole.ro/public/images/json_small.png
368
369
  - spec/examples/json.northpole.ro/public/images/logo.png
@@ -379,25 +380,24 @@ files:
379
380
  - spec/examples/json.northpole.ro/public/javascripts/app.coffee
380
381
  - spec/examples/json.northpole.ro/public/javascripts/docs.min.js
381
382
  - spec/examples/json.northpole.ro/public/javascripts/jnorthpole.coffee
382
- - spec/examples/json.northpole.ro/public/javascripts/util.coffee
383
+ - spec/examples/json.northpole.ro/public/javascripts/music/angular-youtube-embed.js
383
384
  - spec/examples/json.northpole.ro/public/stylesheets/app.sass
384
- - spec/examples/json.northpole.ro/public/stylesheets/application.sass
385
- - spec/examples/json.northpole.ro/public/stylesheets/cover.css
385
+ - spec/examples/json.northpole.ro/views/awsum.haml
386
386
  - spec/examples/json.northpole.ro/views/curl.haml
387
387
  - spec/examples/json.northpole.ro/views/doc.haml
388
388
  - spec/examples/json.northpole.ro/views/doc_table.haml
389
389
  - spec/examples/json.northpole.ro/views/dotnet.haml
390
390
  - spec/examples/json.northpole.ro/views/examples.haml
391
391
  - spec/examples/json.northpole.ro/views/faq.haml
392
- - spec/examples/json.northpole.ro/views/foo.haml
393
392
  - spec/examples/json.northpole.ro/views/index.haml
394
393
  - spec/examples/json.northpole.ro/views/java.haml
394
+ - spec/examples/json.northpole.ro/views/javascript.haml
395
395
  - spec/examples/json.northpole.ro/views/layout.haml
396
396
  - spec/examples/json.northpole.ro/views/php.haml
397
397
  - spec/examples/json.northpole.ro/views/playground.haml
398
398
  - spec/examples/json.northpole.ro/views/python.haml
399
399
  - spec/examples/json.northpole.ro/views/ruby.haml
400
- - spec/examples/json.northpole.ro/views/signup.haml
400
+ - spec/examples/json.northpole.ro/views/seed.haml
401
401
  - spec/examples/json.northpole.ro/views/thanks.haml
402
402
  - spec/examples/tasks-example/.ruby-gemset
403
403
  - spec/examples/tasks-example/.ruby-version
@@ -536,6 +536,7 @@ test_files:
536
536
  - spec/examples/json.northpole.ro/public/images/ice.png
537
537
  - spec/examples/json.northpole.ro/public/images/java.png
538
538
  - spec/examples/json.northpole.ro/public/images/java_small.png
539
+ - spec/examples/json.northpole.ro/public/images/js.png
539
540
  - spec/examples/json.northpole.ro/public/images/json.png
540
541
  - spec/examples/json.northpole.ro/public/images/json_small.png
541
542
  - spec/examples/json.northpole.ro/public/images/logo.png
@@ -552,25 +553,24 @@ test_files:
552
553
  - spec/examples/json.northpole.ro/public/javascripts/app.coffee
553
554
  - spec/examples/json.northpole.ro/public/javascripts/docs.min.js
554
555
  - spec/examples/json.northpole.ro/public/javascripts/jnorthpole.coffee
555
- - spec/examples/json.northpole.ro/public/javascripts/util.coffee
556
+ - spec/examples/json.northpole.ro/public/javascripts/music/angular-youtube-embed.js
556
557
  - spec/examples/json.northpole.ro/public/stylesheets/app.sass
557
- - spec/examples/json.northpole.ro/public/stylesheets/application.sass
558
- - spec/examples/json.northpole.ro/public/stylesheets/cover.css
558
+ - spec/examples/json.northpole.ro/views/awsum.haml
559
559
  - spec/examples/json.northpole.ro/views/curl.haml
560
560
  - spec/examples/json.northpole.ro/views/doc.haml
561
561
  - spec/examples/json.northpole.ro/views/doc_table.haml
562
562
  - spec/examples/json.northpole.ro/views/dotnet.haml
563
563
  - spec/examples/json.northpole.ro/views/examples.haml
564
564
  - spec/examples/json.northpole.ro/views/faq.haml
565
- - spec/examples/json.northpole.ro/views/foo.haml
566
565
  - spec/examples/json.northpole.ro/views/index.haml
567
566
  - spec/examples/json.northpole.ro/views/java.haml
567
+ - spec/examples/json.northpole.ro/views/javascript.haml
568
568
  - spec/examples/json.northpole.ro/views/layout.haml
569
569
  - spec/examples/json.northpole.ro/views/php.haml
570
570
  - spec/examples/json.northpole.ro/views/playground.haml
571
571
  - spec/examples/json.northpole.ro/views/python.haml
572
572
  - spec/examples/json.northpole.ro/views/ruby.haml
573
- - spec/examples/json.northpole.ro/views/signup.haml
573
+ - spec/examples/json.northpole.ro/views/seed.haml
574
574
  - spec/examples/json.northpole.ro/views/thanks.haml
575
575
  - spec/examples/tasks-example/.ruby-gemset
576
576
  - spec/examples/tasks-example/.ruby-version
@@ -1,31 +0,0 @@
1
- window.notify = (text, label) ->
2
- $("#signup-info")
3
- .text(text)
4
- .removeClass()
5
- .addClass(label)
6
-
7
- window.syntaxHighlight = (json) ->
8
- json = json.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;")
9
- json.replace /("(\\u[a-zA-Z0-9]{4}|\\[^u]|[^\\"])*"(\s*:)?|\b(true|false|null)\b|-?\d+(?:\.\d*)?(?:[eE][+\-]?\d+)?)/g, (match) ->
10
- cls = "number"
11
- if /^"/.test(match)
12
- if /:$/.test(match)
13
- cls = "key"
14
- else
15
- cls = "string"
16
- else if /true|false/.test(match)
17
- cls = "boolean"
18
- else cls = "null" if /null/.test(match)
19
- "<span class=\"" + cls + "\">" + match + "</span>"
20
-
21
- window.getDataFromTable = () ->
22
- obj = {}
23
- # :gt(0) skips the header
24
- $('#tryNowTable tr:gt(0)').each (index) ->
25
- elements = $(this).find('input');
26
- key = $(elements[0]).val()
27
- val = $(elements[1]).val()
28
- if (key != '' && val != '')
29
- obj[key]=val
30
- obj
31
-