ki 0.3.3 → 0.4.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.rspec +1 -1
- data/.ruby-gemset +1 -0
- data/.ruby-version +1 -0
- data/Gemfile +2 -21
- data/Gemfile.lock +60 -100
- data/Guardfile +1 -1
- data/LICENSE.md +21 -0
- data/README.md +63 -0
- data/Rakefile +3 -45
- data/bin/ki +1 -1
- data/ki.gemspec +31 -137
- data/lib/ki.rb +21 -21
- data/lib/ki/api_error.rb +28 -0
- data/lib/ki/base_request.rb +34 -0
- data/lib/ki/helpers.rb +55 -0
- data/lib/ki/ki.rb +40 -0
- data/lib/ki/ki_cli.rb +46 -0
- data/lib/ki/ki_config.rb +20 -0
- data/lib/ki/middleware.rb +155 -0
- data/lib/ki/model.rb +70 -0
- data/lib/{modules → ki/modules}/callbacks.rb +0 -0
- data/lib/ki/modules/format_of.rb +10 -0
- data/lib/{modules → ki/modules}/model_helpers.rb +0 -12
- data/lib/ki/modules/public_file_helper.rb +13 -0
- data/lib/ki/modules/query_interface.rb +36 -0
- data/lib/{modules → ki/modules}/restrictions.rb +0 -30
- data/lib/ki/modules/view_helper.rb +13 -0
- data/lib/ki/orm.rb +65 -0
- data/lib/ki/version.rb +3 -0
- data/spec/examples/base/.ruby-gemset +1 -0
- data/spec/examples/base/.ruby-version +1 -0
- data/spec/examples/base/Gemfile +4 -0
- data/spec/examples/base/app.rb +1 -0
- data/{examples → spec/examples}/base/config.ru +0 -3
- data/spec/examples/base/config.yml +17 -0
- data/spec/examples/base/public/favicon.ico +0 -0
- data/spec/examples/base/public/javascripts/.gitkeep +0 -0
- data/spec/examples/base/public/stylesheets/.gitkeep +0 -0
- data/spec/examples/base/views/index.haml +6 -0
- data/spec/examples/couch-lock/.ruby-gemset +1 -0
- data/spec/examples/couch-lock/.ruby-version +1 -0
- data/spec/examples/couch-lock/Gemfile +4 -0
- data/spec/examples/couch-lock/Gemfile.lock +48 -0
- data/spec/examples/couch-lock/app.rb +42 -0
- data/spec/examples/couch-lock/config.ru +3 -0
- data/spec/examples/couch-lock/config.yml +17 -0
- data/spec/examples/couch-lock/install.sh +3 -0
- data/spec/examples/couch-lock/public/favicon.ico +0 -0
- data/spec/examples/couch-lock/public/javascripts/.gitkeep +0 -0
- data/spec/examples/couch-lock/public/stylesheets/.gitkeep +0 -0
- data/spec/examples/couch-lock/views/index.haml +18 -0
- data/spec/examples/json.northpole.ro/.ruby-gemset +1 -0
- data/spec/examples/json.northpole.ro/.ruby-version +1 -0
- data/spec/examples/json.northpole.ro/Capfile +25 -0
- data/spec/examples/json.northpole.ro/Gemfile +6 -0
- data/spec/examples/json.northpole.ro/Gemfile.lock +68 -0
- data/spec/examples/json.northpole.ro/app.rb +79 -0
- data/spec/examples/json.northpole.ro/client.rb +25 -0
- data/spec/examples/json.northpole.ro/config.ru +3 -0
- data/spec/examples/json.northpole.ro/config.yml +17 -0
- data/spec/examples/json.northpole.ro/config/deploy.rb +59 -0
- data/spec/examples/json.northpole.ro/config/deploy/production.rb +39 -0
- data/spec/examples/json.northpole.ro/foo.rb +10 -0
- data/spec/examples/json.northpole.ro/public/JNorthPole.jar +0 -0
- data/spec/examples/json.northpole.ro/public/favicon.ico +0 -0
- data/spec/examples/json.northpole.ro/public/font/FontAwesome.otf +0 -0
- data/spec/examples/json.northpole.ro/public/font/fontawesome-webfont.eot +0 -0
- data/spec/examples/json.northpole.ro/public/font/fontawesome-webfont.svg +284 -0
- data/spec/examples/json.northpole.ro/public/font/fontawesome-webfont.ttf +0 -0
- data/spec/examples/json.northpole.ro/public/font/fontawesome-webfont.woff +0 -0
- data/spec/examples/json.northpole.ro/public/images/bear.png +0 -0
- data/spec/examples/json.northpole.ro/public/images/bg.png +0 -0
- data/spec/examples/json.northpole.ro/public/images/cloud.png +0 -0
- data/spec/examples/json.northpole.ro/public/images/dotnet.png +0 -0
- data/spec/examples/json.northpole.ro/public/images/dotnet_small.png +0 -0
- data/spec/examples/json.northpole.ro/public/images/footer.png +0 -0
- data/spec/examples/json.northpole.ro/public/images/glyphicons-halflings-white.png +0 -0
- data/spec/examples/json.northpole.ro/public/images/glyphicons-halflings.png +0 -0
- data/spec/examples/json.northpole.ro/public/images/ice.png +0 -0
- data/spec/examples/json.northpole.ro/public/images/java.png +0 -0
- data/spec/examples/json.northpole.ro/public/images/java_small.png +0 -0
- data/spec/examples/json.northpole.ro/public/images/json.png +0 -0
- data/spec/examples/json.northpole.ro/public/images/json_small.png +0 -0
- data/spec/examples/json.northpole.ro/public/images/logo.png +0 -0
- data/spec/examples/json.northpole.ro/public/images/mobile.png +0 -0
- data/spec/examples/json.northpole.ro/public/images/php.png +0 -0
- data/spec/examples/json.northpole.ro/public/images/php_small.png +0 -0
- data/spec/examples/json.northpole.ro/public/images/python.png +0 -0
- data/spec/examples/json.northpole.ro/public/images/python_small.png +0 -0
- data/spec/examples/json.northpole.ro/public/images/ruby.png +0 -0
- data/spec/examples/json.northpole.ro/public/images/ruby_small.png +0 -0
- data/spec/examples/json.northpole.ro/public/images/shell.png +0 -0
- data/spec/examples/json.northpole.ro/public/images/shell_small.png +0 -0
- data/spec/examples/json.northpole.ro/public/javascripts/analytics.js +9 -0
- data/spec/examples/json.northpole.ro/public/javascripts/app.coffee +133 -0
- data/spec/examples/json.northpole.ro/public/javascripts/docs.min.js +16 -0
- data/spec/examples/json.northpole.ro/public/javascripts/jnorthpole.coffee +34 -0
- data/spec/examples/json.northpole.ro/public/javascripts/util.coffee +31 -0
- data/spec/examples/json.northpole.ro/public/stylesheets/app.sass +23 -0
- data/spec/examples/json.northpole.ro/public/stylesheets/application.sass +222 -0
- data/spec/examples/json.northpole.ro/public/stylesheets/cover.css +154 -0
- data/spec/examples/json.northpole.ro/views/curl.haml +19 -0
- data/spec/examples/json.northpole.ro/views/doc.haml +16 -0
- data/spec/examples/json.northpole.ro/views/doc_table.haml +45 -0
- data/spec/examples/json.northpole.ro/views/dotnet.haml +24 -0
- data/spec/examples/json.northpole.ro/views/examples.haml +28 -0
- data/spec/examples/json.northpole.ro/views/faq.haml +32 -0
- data/spec/examples/json.northpole.ro/views/foo.haml +7 -0
- data/spec/examples/json.northpole.ro/views/index.haml +4 -0
- data/spec/examples/json.northpole.ro/views/java.haml +0 -0
- data/spec/examples/json.northpole.ro/views/layout.haml +42 -0
- data/spec/examples/json.northpole.ro/views/php.haml +37 -0
- data/spec/examples/json.northpole.ro/views/playground.haml +38 -0
- data/spec/examples/json.northpole.ro/views/python.haml +17 -0
- data/spec/examples/json.northpole.ro/views/ruby.haml +12 -0
- data/spec/examples/json.northpole.ro/views/signup.haml +2 -0
- data/spec/examples/json.northpole.ro/views/thanks.haml +12 -0
- data/spec/functional_spec.rb +4 -0
- data/spec/lib/ki/base_request_spec.rb +88 -0
- data/spec/lib/ki/helpers_spec.rb +12 -0
- data/spec/lib/ki/ki_config_spec.rb +7 -0
- data/spec/lib/ki/middleware_spec.rb +11 -0
- data/spec/lib/ki/model_spec.rb +100 -0
- data/spec/lib/ki/modules/format_of_spec.rb +15 -0
- data/spec/lib/ki/orm_spec.rb +83 -0
- data/spec/spec_helper.rb +18 -5
- data/spec/util_spec.rb +7 -36
- metadata +269 -193
- data/.document +0 -5
- data/.rvmrc +0 -1
- data/LICENSE.txt +0 -20
- data/README.rdoc +0 -3
- data/VERSION +0 -1
- data/examples/base/Gemfile +0 -3
- data/examples/base/Gemfile.lock +0 -24
- data/examples/base/app.rb +0 -4
- data/examples/base/config.yml +0 -16
- data/gfx/colors.xcf +0 -0
- data/gfx/ki3.eps +0 -0
- data/gfx/logo.png +0 -0
- data/ki_wrap.rb +0 -35
- data/lib/conf.rb +0 -28
- data/lib/db.rb +0 -73
- data/lib/helpers.rb +0 -34
- data/lib/ki_cli.rb +0 -76
- data/lib/mockreq.rb +0 -45
- data/lib/model.rb +0 -110
- data/lib/modules/email.rb +0 -51
- data/lib/modules/query_interface.rb +0 -42
- data/lib/req.rb +0 -57
- data/lib/resp.rb +0 -70
- data/lib/static_file.rb +0 -68
- data/lib/util.rb +0 -114
- data/lib/views/404.haml +0 -1
- data/lib/views/406.haml +0 -1
- data/lib/views/index.haml +0 -7
- data/lib/views/layout.haml +0 -1
- data/spec/conf_spec.rb +0 -6
- data/spec/db_spec.rb +0 -93
- data/spec/integration/integration_spec.rb +0 -114
- data/spec/ki_spec.rb +0 -7
- data/spec/model_spec.rb +0 -91
- data/spec/modules/callbacks_spec.rb +0 -25
- data/spec/modules/email_spec.rb +0 -19
- data/spec/modules/query_interface_spec.rb +0 -93
- data/spec/modules/restrictions_spec.rb +0 -110
- data/spec/performance/performance.sh +0 -1
- data/spec/req_spec.rb +0 -29
@@ -0,0 +1,154 @@
|
|
1
|
+
/*
|
2
|
+
* Globals
|
3
|
+
*/
|
4
|
+
|
5
|
+
/* Links */
|
6
|
+
a,
|
7
|
+
a:focus,
|
8
|
+
a:hover {
|
9
|
+
color: #fff;
|
10
|
+
}
|
11
|
+
|
12
|
+
|
13
|
+
/*
|
14
|
+
* Base structure
|
15
|
+
*/
|
16
|
+
|
17
|
+
html,
|
18
|
+
body {
|
19
|
+
height: 100%;
|
20
|
+
background-color: #333;
|
21
|
+
}
|
22
|
+
body {
|
23
|
+
text-align: center;
|
24
|
+
text-shadow: 0 1px 3px rgba(0,0,0,.5);
|
25
|
+
box-shadow: inset 0 0 100px rgba(0,0,0,.5);
|
26
|
+
}
|
27
|
+
|
28
|
+
/* Extra markup and styles for table-esque vertical and horizontal centering */
|
29
|
+
.site-wrapper {
|
30
|
+
display: table;
|
31
|
+
width: 100%;
|
32
|
+
height: 100%; /* For at least Firefox */
|
33
|
+
min-height: 100%;
|
34
|
+
}
|
35
|
+
.site-wrapper-inner {
|
36
|
+
display: table-cell;
|
37
|
+
vertical-align: top;
|
38
|
+
}
|
39
|
+
.cover-container {
|
40
|
+
margin-right: auto;
|
41
|
+
margin-left: auto;
|
42
|
+
}
|
43
|
+
|
44
|
+
/* Padding for spacing */
|
45
|
+
.inner {
|
46
|
+
padding: 30px;
|
47
|
+
}
|
48
|
+
|
49
|
+
|
50
|
+
/*
|
51
|
+
* Header
|
52
|
+
*/
|
53
|
+
.masthead-brand {
|
54
|
+
margin-top: 10px;
|
55
|
+
margin-bottom: 10px;
|
56
|
+
}
|
57
|
+
|
58
|
+
.masthead-brand > a:hover {
|
59
|
+
text-decoration: none;
|
60
|
+
}
|
61
|
+
|
62
|
+
.masthead-nav > li {
|
63
|
+
display: inline-block;
|
64
|
+
}
|
65
|
+
.masthead-nav > li + li {
|
66
|
+
margin-left: 20px;
|
67
|
+
}
|
68
|
+
.masthead-nav > li > a {
|
69
|
+
padding-right: 0;
|
70
|
+
padding-left: 0;
|
71
|
+
font-size: 16px;
|
72
|
+
font-weight: bold;
|
73
|
+
color: #fff; /* IE8 proofing */
|
74
|
+
color: rgba(255,255,255,.75);
|
75
|
+
border-bottom: 2px solid transparent;
|
76
|
+
}
|
77
|
+
.masthead-nav > li > a:hover,
|
78
|
+
.masthead-nav > li > a:focus {
|
79
|
+
background-color: transparent;
|
80
|
+
border-bottom-color: rgba(255,255,255,.25);
|
81
|
+
}
|
82
|
+
.masthead-nav > .active > a,
|
83
|
+
.masthead-nav > .active > a:hover,
|
84
|
+
.masthead-nav > .active > a:focus {
|
85
|
+
color: #fff;
|
86
|
+
border-bottom-color: #fff;
|
87
|
+
}
|
88
|
+
|
89
|
+
@media (min-width: 768px) {
|
90
|
+
.masthead-brand {
|
91
|
+
float: left;
|
92
|
+
}
|
93
|
+
.masthead-nav {
|
94
|
+
float: right;
|
95
|
+
}
|
96
|
+
}
|
97
|
+
|
98
|
+
|
99
|
+
/*
|
100
|
+
* Cover
|
101
|
+
*/
|
102
|
+
|
103
|
+
.cover {
|
104
|
+
padding: 0 20px;
|
105
|
+
}
|
106
|
+
.cover .btn-lg {
|
107
|
+
padding: 10px 20px;
|
108
|
+
font-weight: bold;
|
109
|
+
}
|
110
|
+
|
111
|
+
|
112
|
+
/*
|
113
|
+
* Footer
|
114
|
+
*/
|
115
|
+
|
116
|
+
.mastfoot {
|
117
|
+
color: #999; /* IE8 proofing */
|
118
|
+
color: rgba(255,255,255,.5);
|
119
|
+
}
|
120
|
+
|
121
|
+
|
122
|
+
/*
|
123
|
+
* Affix and center
|
124
|
+
*/
|
125
|
+
|
126
|
+
@media (min-width: 768px) {
|
127
|
+
/* Pull out the header and footer */
|
128
|
+
.masthead {
|
129
|
+
position: fixed;
|
130
|
+
top: 0;
|
131
|
+
}
|
132
|
+
.mastfoot {
|
133
|
+
position: fixed;
|
134
|
+
bottom: 0;
|
135
|
+
}
|
136
|
+
/* Start the vertical centering */
|
137
|
+
.site-wrapper-inner {
|
138
|
+
vertical-align: middle;
|
139
|
+
}
|
140
|
+
/* Handle the widths */
|
141
|
+
.masthead,
|
142
|
+
.mastfoot,
|
143
|
+
.cover-container {
|
144
|
+
width: 100%; /* Must be percentage or pixels for horizontal alignment */
|
145
|
+
}
|
146
|
+
}
|
147
|
+
|
148
|
+
@media (min-width: 992px) {
|
149
|
+
.masthead,
|
150
|
+
.mastfoot,
|
151
|
+
.cover-container {
|
152
|
+
width: 700px;
|
153
|
+
}
|
154
|
+
}
|
@@ -0,0 +1,19 @@
|
|
1
|
+
%pre.code
|
2
|
+
= preserve do
|
3
|
+
:escaped
|
4
|
+
curl -X POST -d '{"api_key":"#{NP_GUEST_API_KEY}","secret":"#{NP_GUEST_SECRET}","storage":["milk","eggs","bacon"]}' '#{NP_URL}/storage.json'
|
5
|
+
|
6
|
+
%pre.code
|
7
|
+
= preserve do
|
8
|
+
:escaped
|
9
|
+
curl -X GET -d '{"api_key":"#{NP_GUEST_API_KEY}","secret":"#{NP_GUEST_SECRET}","storage":["milk","eggs","bacon"]}' '#{NP_URL}/storage.json'
|
10
|
+
|
11
|
+
%pre.code
|
12
|
+
= preserve do
|
13
|
+
:escaped
|
14
|
+
curl -X PUT -d '{"api_key":"#{NP_GUEST_API_KEY}","secret":"#{NP_GUEST_SECRET}","storage":["milk","eggs"],"id": "OBJECT_ID"}' '#{NP_URL}/storage.json'
|
15
|
+
|
16
|
+
%pre.code
|
17
|
+
= preserve do
|
18
|
+
:escaped
|
19
|
+
curl -X DELETE -d '{"api_key":"#{NP_GUEST_API_KEY}","secret":"#{NP_GUEST_SECRET}","storage":["milk","eggs"]}' '#{NP_URL}/storage.json'
|
@@ -0,0 +1,16 @@
|
|
1
|
+
%p Create
|
2
|
+
%pre.code
|
3
|
+
= preserve do
|
4
|
+
curl -X <b>POST</b> -d <b>'{"api_key":"#{NP_GUEST_API_KEY}","secret":"#{NP_GUEST_SECRET}","namespace":"shopping_list","storage":["milk","eggs","bacon"]}'</b> '#{NP_URL}/storage.json'
|
5
|
+
%br
|
6
|
+
%p Read
|
7
|
+
%p.code{:style => 'text-align: left; background-color: #f5f5f5; color: #333; padding: 9.5px; font-family: Menlo,Monaco,Consolas,"Courier New",monospace;'}
|
8
|
+
curl -X <b>GET</b> -d <b>'{"api_key":"#{NP_GUEST_API_KEY}","secret":"#{NP_GUEST_API_KEY}","id":"534569007047d56e11000002"}'</b> '#{NP_URL}/storage.json'
|
9
|
+
%br
|
10
|
+
%p Update
|
11
|
+
%pre.code.shell
|
12
|
+
curl -X <b>PUT</b> -d <b>'{"api_key":"#{NP_GUEST_API_KEY}","secret":"#{NP_GUEST_SECRET}","food":[],"id":"534569007047d56e11000002"}'</b> '#{NP_URL}/storage.json'
|
13
|
+
%br
|
14
|
+
%p Delete
|
15
|
+
%pre.code.shell
|
16
|
+
curl -X <b>DELETE</b> -d <b>'{"api_key":"#{NP_GUEST_API_KEY}","secret":"#{NP_GUEST_SECRET}","id":"534569007047d56e11000002"}'</b> '#{NP_URL}/storage.json'
|
@@ -0,0 +1,45 @@
|
|
1
|
+
%table.table.table-striped
|
2
|
+
%thead
|
3
|
+
%tr
|
4
|
+
%th Resource
|
5
|
+
%th HTTP Verb
|
6
|
+
%th Content-Type
|
7
|
+
%th Required Params
|
8
|
+
%th{'style' => 'width: 50%'} Description
|
9
|
+
%tbody
|
10
|
+
%tr
|
11
|
+
%td /user
|
12
|
+
%td GET, SEARCH
|
13
|
+
%td application/json
|
14
|
+
%td api_key, secret
|
15
|
+
%td Finds a user and any info related to the user json object
|
16
|
+
%tr
|
17
|
+
%td /user
|
18
|
+
%td POST
|
19
|
+
%td application/json
|
20
|
+
%td api_key, secret
|
21
|
+
%td Creates a new user
|
22
|
+
%tr
|
23
|
+
%td /storage
|
24
|
+
%td GET, SEARCH
|
25
|
+
%td application/json
|
26
|
+
%td api_key, secret
|
27
|
+
%td Finds stored json objects. Results are always returned in an array
|
28
|
+
%tr
|
29
|
+
%td /storage
|
30
|
+
%td POST
|
31
|
+
%td application/json
|
32
|
+
%td api_key, secret
|
33
|
+
%td Creates a new json object
|
34
|
+
%tr
|
35
|
+
%td /storage
|
36
|
+
%td PUT
|
37
|
+
%td application/json
|
38
|
+
%td api_key, secret, id
|
39
|
+
%td Updates a json object. All attributes of the json object are replaced with the json found in the body of the request
|
40
|
+
%tr
|
41
|
+
%td /storage
|
42
|
+
%td DELETE
|
43
|
+
%td application/json
|
44
|
+
%td api_key, secret
|
45
|
+
%td Deletes json objects
|
@@ -0,0 +1,24 @@
|
|
1
|
+
%p
|
2
|
+
Thank you Rares for contributing with the
|
3
|
+
%a{:href => 'https://github.com/northpole-api/NorthPoleNetWrapper/'} .net wrapper
|
4
|
+
\.
|
5
|
+
%p
|
6
|
+
If you would like to dive in code imediatley, I suggest you take a look at the
|
7
|
+
%a{:href => 'https://github.com/northpole-api/NorthPoleNetWrapper/blob/master/NorthPoleNetWrapperTest/StorageTestSuite.cs'} tests
|
8
|
+
\.
|
9
|
+
%pre.code.dotnet
|
10
|
+
= preserve do
|
11
|
+
:escaped
|
12
|
+
JObject jsonObject = new JObject();
|
13
|
+
jsonObject.Add("#{NP_API_KEY}", "#{NP_GUEST_API_KEY}");
|
14
|
+
jsonObject.Add("#{NP_SECRET}", "#{NP_GUEST_SECRET}");
|
15
|
+
|
16
|
+
JArray items = new JArray();
|
17
|
+
items.Add("milk");
|
18
|
+
items.Add("eggs");
|
19
|
+
items.Add("sugar");
|
20
|
+
|
21
|
+
jsonObject.Add("list", items);
|
22
|
+
|
23
|
+
Storage storage = new Storage(jsonObject);
|
24
|
+
JObject result = storage.Create();
|
@@ -0,0 +1,28 @@
|
|
1
|
+
= partial "doc_table"
|
2
|
+
|
3
|
+
%ul#myTab.nav.nav-tabs
|
4
|
+
%li.active
|
5
|
+
%a{"data-toggle" => "tab", href: "#curl"} curl
|
6
|
+
%li
|
7
|
+
%a{"data-toggle" => "tab", href: "#ruby"} ruby
|
8
|
+
%li
|
9
|
+
%a{"data-toggle" => "tab", href: "#python"} python
|
10
|
+
%li
|
11
|
+
%a{"data-toggle" => "tab", href: "#php"} php
|
12
|
+
%li
|
13
|
+
%a{"data-toggle" => "tab", href: "#java"} java
|
14
|
+
%li
|
15
|
+
%a{"data-toggle" => "tab", href: "#dotnet"} .net
|
16
|
+
.tab-content
|
17
|
+
#curl.tab-pane.fade.in.active
|
18
|
+
= partial 'curl'
|
19
|
+
#ruby.tab-pane.fade
|
20
|
+
= partial 'ruby'
|
21
|
+
#python.tab-pane.fade
|
22
|
+
= partial 'python'
|
23
|
+
#php.tab-pane.fade
|
24
|
+
= partial 'php'
|
25
|
+
#java.tab-pane.fade
|
26
|
+
= partial 'java'
|
27
|
+
#dotnet.tab-pane.fade
|
28
|
+
= partial 'dotnet'
|
@@ -0,0 +1,32 @@
|
|
1
|
+
%a{'href' => '#what'} What is json.northpole.ro?
|
2
|
+
%br
|
3
|
+
%a{'href' => '#how'} How do I use the API?
|
4
|
+
%br
|
5
|
+
%a{'href' => '#storage'} What can I store?
|
6
|
+
%br
|
7
|
+
%a{'href' => '#where'} Where do I sign up for my free account?
|
8
|
+
%br
|
9
|
+
%a{'href' => '#question'} I have a question
|
10
|
+
%br
|
11
|
+
%h3#what What is json.northpole.ro
|
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.
|
14
|
+
%h3#how How do I use the API?
|
15
|
+
%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
|
17
|
+
%p
|
18
|
+
To get an idea of how the API works, you can
|
19
|
+
%a{:href => '/try'}
|
20
|
+
try it in your browser
|
21
|
+
%h3#storage What can I store?
|
22
|
+
%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?
|
25
|
+
%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
|
29
|
+
%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
|
File without changes
|
@@ -0,0 +1,42 @@
|
|
1
|
+
!!!
|
2
|
+
%html{lang: "en"}
|
3
|
+
%head
|
4
|
+
%meta{charset: "utf-8"}/
|
5
|
+
%meta{content: "IE=edge", "http-equiv" => "X-UA-Compatible"}/
|
6
|
+
%meta{content: "width=device-width, initial-scale=1", name: "viewport"}/
|
7
|
+
%meta{content: "", name: "description"}/
|
8
|
+
%meta{content: "", name: "author"}/
|
9
|
+
|
10
|
+
%link{href: "/favicon.ico", rel: "shortcut icon"}/
|
11
|
+
|
12
|
+
%title json cloud storage
|
13
|
+
|
14
|
+
%link{href: "//netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css", rel: "stylesheet"}/
|
15
|
+
= css "/stylesheets/app.css"
|
16
|
+
/ HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries
|
17
|
+
/[if lt IE 9]
|
18
|
+
<script src="https://oss.maxcdn.com/libs/html5shiv/3.7.0/html5shiv.js"></script>
|
19
|
+
<script src="https://oss.maxcdn.com/libs/respond.js/1.4.2/respond.min.js"></script>
|
20
|
+
%body
|
21
|
+
.container
|
22
|
+
.navbar.navbar-default{role: "navigation"}
|
23
|
+
.container-fluid
|
24
|
+
.navbar-header
|
25
|
+
%button.navbar-toggle{"data-target" => ".navbar-collapse", "data-toggle" => "collapse", type: "button"}
|
26
|
+
%span.sr-only Toggle navigation
|
27
|
+
%span.icon-bar
|
28
|
+
%span.icon-bar
|
29
|
+
%span.icon-bar
|
30
|
+
%a.navbar-brand{href: "/"} {"json": ["cloud", "storage"]}
|
31
|
+
.navbar-collapse.collapse
|
32
|
+
%ul.nav.navbar-nav.navbar-right
|
33
|
+
%li.playground
|
34
|
+
%a{href: "/playground"} playground
|
35
|
+
%li.examples
|
36
|
+
%a{href: "/examples"} examples
|
37
|
+
= yield
|
38
|
+
|
39
|
+
= js "https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"
|
40
|
+
= js "//netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js"
|
41
|
+
= js "/javascripts/jnorthpole.js"
|
42
|
+
= js "/javascripts/app.js"
|
@@ -0,0 +1,37 @@
|
|
1
|
+
%pre.code.php
|
2
|
+
= preserve do
|
3
|
+
:escaped
|
4
|
+
<?php
|
5
|
+
|
6
|
+
$apiKey = '#{NP_GUEST_API_KEY}';
|
7
|
+
$secret = '#{NP_GUEST_SECRET}';
|
8
|
+
$url = '#{NP_URL}/storage.json';
|
9
|
+
|
10
|
+
$curlPost = curl_init();
|
11
|
+
curl_setopt($curlPost, CURLOPT_URL, $url);
|
12
|
+
curl_setopt($curlPost, CURLOPT_RETURNTRANSFER, 1);
|
13
|
+
curl_setopt($curlPost, CURLOPT_POSTFIELDS, '{"#{NP_API_KEY}":"' . $apiKey . '","#{NP_SECRET}":"' . $secret . '","food":"pizza"}');
|
14
|
+
$response = curl_exec($curlPost);
|
15
|
+
|
16
|
+
$resource = json_decode($response);
|
17
|
+
$resourceId = $resource->{'id'};
|
18
|
+
|
19
|
+
$curlGet = curl_init();
|
20
|
+
curl_setopt($curlGet, CURLOPT_URL, $url . '?#{NP_API_KEY}=' . $apiKey . '&#{NP_SECRET}='. $secret .'&id=' . $resourceId);
|
21
|
+
curl_setopt($curlGet, CURLOPT_RETURNTRANSFER, 1);
|
22
|
+
$response = curl_exec($curlGet);
|
23
|
+
|
24
|
+
$curlPut = curl_init();
|
25
|
+
curl_setopt($curlPut, CURLOPT_URL, $url . '?#{NP_API_KEY}=' . $apiKey . '&#{NP_SECRET}='. $secret .'&id=' . $resourceId . '&food=salad');
|
26
|
+
curl_setopt($curlPut, CURLOPT_RETURNTRANSFER, 1);
|
27
|
+
curl_setopt($curlPut, CURLOPT_CUSTOMREQUEST, "PUT");
|
28
|
+
$response = curl_exec($curlPut);
|
29
|
+
var_dump($response);
|
30
|
+
|
31
|
+
$curlDelete = curl_init();
|
32
|
+
curl_setopt($curlDelete, CURLOPT_URL, $url . '?#{NP_API_KEY}=' . $apiKey . '&#{NP_SECRET}=' . $secret . '&id=' . $resourceId);
|
33
|
+
curl_setopt($curlDelete, CURLOPT_RETURNTRANSFER, 1);
|
34
|
+
curl_setopt($curlDelete, CURLOPT_CUSTOMREQUEST, "DELETE");
|
35
|
+
$response = curl_exec($curlDelete);
|
36
|
+
|
37
|
+
?>
|
@@ -0,0 +1,38 @@
|
|
1
|
+
.row
|
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
|
10
|
+
.btn-group
|
11
|
+
%button.btn.btn-default.dropdown-toggle{"data-toggle" => "dropdown", type: "button"}
|
12
|
+
%span#resource Storage
|
13
|
+
%span.caret
|
14
|
+
%ul.dropdown-menu{role: "menu"}
|
15
|
+
%li
|
16
|
+
%a{href: "#"} Storage
|
17
|
+
%li
|
18
|
+
%a{href: "#"} User
|
19
|
+
.btn-group
|
20
|
+
%button.btn.btn-default.dropdown-toggle{"data-toggle" => "dropdown", type: "button"}
|
21
|
+
%span#verb GET
|
22
|
+
%span.caret
|
23
|
+
%ul.dropdown-menu{role: "menu"}
|
24
|
+
%li
|
25
|
+
%a{href: "#"} GET
|
26
|
+
%li
|
27
|
+
%a{href: "#"} POST
|
28
|
+
%li
|
29
|
+
%a{href: "#"} PUT
|
30
|
+
%li
|
31
|
+
%a{href: "#"} DELETE
|
32
|
+
.btn-group
|
33
|
+
%button#npAction.btn.btn-default Execute Request
|
34
|
+
.col-md-6{:style => 'height: 100%'}
|
35
|
+
%pre#parsedJson{:style => 'text-align: left;'}
|
36
|
+
{}
|
37
|
+
.row
|
38
|
+
.col-md-12
|