storyblok 3.0.1 → 3.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +282 -0
- data/.rubocop_strict.yml +30 -0
- data/.rubocop_todo.yml +405 -0
- data/Gemfile +8 -3
- data/Gemfile.lock +92 -20
- data/README.md +72 -32
- data/coverage/.last_run.json +5 -0
- data/coverage/.resultset.json +547 -0
- data/coverage/.resultset.json.lock +0 -0
- data/coverage/assets/0.10.2/application.css +799 -0
- data/coverage/assets/0.10.2/application.js +1707 -0
- data/coverage/assets/0.10.2/colorbox/border.png +0 -0
- data/coverage/assets/0.10.2/colorbox/controls.png +0 -0
- data/coverage/assets/0.10.2/colorbox/loading.gif +0 -0
- data/coverage/assets/0.10.2/colorbox/loading_background.png +0 -0
- data/coverage/assets/0.10.2/favicon_green.png +0 -0
- data/coverage/assets/0.10.2/favicon_red.png +0 -0
- data/coverage/assets/0.10.2/favicon_yellow.png +0 -0
- data/coverage/assets/0.10.2/loading.gif +0 -0
- data/coverage/assets/0.10.2/magnify.png +0 -0
- data/coverage/assets/0.10.2/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/coverage/assets/0.10.2/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/coverage/assets/0.10.2/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/coverage/assets/0.10.2/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/coverage/assets/0.10.2/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/coverage/assets/0.10.2/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/coverage/assets/0.10.2/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/coverage/assets/0.10.2/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/coverage/assets/0.10.2/smoothness/images/ui-icons_222222_256x240.png +0 -0
- data/coverage/assets/0.10.2/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
- data/coverage/assets/0.10.2/smoothness/images/ui-icons_454545_256x240.png +0 -0
- data/coverage/assets/0.10.2/smoothness/images/ui-icons_888888_256x240.png +0 -0
- data/coverage/assets/0.10.2/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/coverage/index.html +3380 -0
- data/examples/cache.rb +5 -6
- data/examples/example_queries.rb +6 -6
- data/examples/management_api.rb +2 -4
- data/examples/renderer.rb +11 -12
- data/examples/tree.rb +12 -12
- data/lib/storyblok/cache/redis.rb +0 -1
- data/lib/storyblok/client.rb +135 -131
- data/lib/storyblok/links.rb +16 -17
- data/lib/storyblok/version.rb +1 -1
- data/lib/storyblok.rb +3 -3
- metadata +38 -13
- data/.DS_Store +0 -0
- data/.ruby-version +0 -1
- data/lib/.DS_Store +0 -0
- data/lib/storyblok/.DS_Store +0 -0
data/README.md
CHANGED
@@ -1,19 +1,35 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
1
|
+
<div align="center">
|
2
|
+
<a href="https://www.storyblok.com?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-ruby" align="center">
|
3
|
+
<img src="https://a.storyblok.com/f/88751/1776x360/95e296dafa/sb-ruby.png" alt="Storyblok Logo">
|
4
|
+
</a>
|
5
|
+
<h1 align="center">Storyblok Ruby Client</h1>
|
6
|
+
<p align="center">This is the official <a href="http://www.storyblok.com?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-ruby" target="_blank">Storyblok</a> ruby client for easy access of the management and content delivery api.</p>
|
7
|
+
</div>
|
8
|
+
|
9
|
+
<p align="center">
|
10
|
+
<a href="https://codeclimate.com/github/storyblok/storyblok-ruby/test_coverage">
|
11
|
+
<img src="https://api.codeclimate.com/v1/badges/76e7fcc8524d4fadeeee/test_coverage" alt="Test Coverage" />
|
12
|
+
</a>
|
13
|
+
<a href="https://discord.gg/jKrbAMz">
|
14
|
+
<img src="https://img.shields.io/discord/700316478792138842?label=Join%20Our%20Discord%20Community&style=appveyor&logo=discord&color=09b3af">
|
15
|
+
</a>
|
16
|
+
<a href="https://twitter.com/intent/follow?screen_name=storyblok">
|
17
|
+
<img src="https://img.shields.io/badge/Follow-%40storyblok-09b3af?style=appveyor&logo=twitter" alt="Follow @Storyblok" />
|
18
|
+
</a><br/>
|
19
|
+
<a href="https://app.storyblok.com/#!/signup?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-ruby">
|
20
|
+
<img src="https://img.shields.io/badge/Try%20Storyblok-Free-09b3af?style=appveyor&logo=data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAB4AAAAeCAYAAAA7MK6iAAAABGdBTUEAALGPC/xhBQAAADhlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAAqACAAQAAAABAAAAHqADAAQAAAABAAAAHgAAAADpiRU/AAACRElEQVRIDWNgGGmAEd3D3Js3LPrP8D8WXZwSPiMjw6qvPoHhyGYwIXNAbGpbCjbzP0MYuj0YFqMroBV/wCxmIeSju64eDNzMBJUxvP/9i2Hnq5cM1devMnz984eQsQwETeRhYWHgIcJiXqC6VHlFBjUeXgav40cIWkz1oLYXFmGwFBImaDFBHyObcOzdW4aSq5eRhRiE2dgYlpuYoYSKJi8vw3GgWnyAJIs/AuPu4scPGObd/fqVQZ+PHy7+6udPOBsXgySLDfn5GRYYmaKYJcXBgWLpsx8/GPa8foWiBhuHJIsl2DkYQqWksZkDFgP5PObcKYYff//iVAOTIDlx/QPqRMb/YSYBaWlOToZIaVkGZmAZSQiQ5OPtwHwacuo4iplMQEu6tXUZMhSUGDiYmBjylFQYvv/7x9B04xqKOnQOyT5GN+Df//8M59ASXKyMHLoyDD5JPtbj42OYrm+EYgg70JfuYuIoYmLs7AwMjIzA+uY/zjAnyWJpDk6GOFnCvrn86SOwmsNtKciVFAc1ileBHFDC67lzG10Yg0+SjzF0ownsf/OaofvOLYaDQJoQIGix94ljv1gIZI8Pv38zPvj2lQWYf3HGKbpDCFp85v07NnRN1OBTPY6JdRSGxcCw2k6sZuLVMZ5AV4s1TozPnGGFKbz+/PE7IJsHmC//MDMyhXBw8e6FyRFLv3Z0/IKuFqvFyIqAzd1PwBzJw8jAGPfVx38JshwlbIygxmYY43/GQmpais0ODDHuzevLMARHBcgIAQAbOJHZW0/EyQAAAABJRU5ErkJggg==" alt="Follow @Storyblok" />
|
21
|
+
</a>
|
22
|
+
</p>
|
23
|
+
|
24
|
+
## 🚀 Usage
|
25
|
+
|
26
|
+
### Install
|
11
27
|
|
12
28
|
```bash
|
13
29
|
gem 'storyblok'
|
14
30
|
```
|
15
31
|
|
16
|
-
|
32
|
+
### Usage for the content delivery api
|
17
33
|
|
18
34
|
By default the client loads the "draft" version of the Story. Be sure to set the version to "published" to get the published content only.
|
19
35
|
|
@@ -25,7 +41,15 @@ Storyblok::Client.new(version: 'draft')
|
|
25
41
|
Storyblok::Client.new(version: 'published')
|
26
42
|
```
|
27
43
|
|
28
|
-
|
44
|
+
#### Using the APIs on other regions
|
45
|
+
|
46
|
+
You should use the space access token AND `api_region: 'us'` whenever your space was created under `US` Server Location.
|
47
|
+
|
48
|
+
```ruby
|
49
|
+
client = Storyblok::Client.new(token: 'YOUR_TOKEN', api_region: 'us')
|
50
|
+
```
|
51
|
+
|
52
|
+
#### Load a story
|
29
53
|
|
30
54
|
```ruby
|
31
55
|
# Without cache
|
@@ -40,7 +64,7 @@ client = Storyblok::Client.new(cache: cache, token: 'YOUR_TOKEN')
|
|
40
64
|
client.story('home')
|
41
65
|
```
|
42
66
|
|
43
|
-
|
67
|
+
#### Load a list of stories
|
44
68
|
|
45
69
|
```ruby
|
46
70
|
# Get all Stories that start with news
|
@@ -49,7 +73,7 @@ client.stories({
|
|
49
73
|
})
|
50
74
|
```
|
51
75
|
|
52
|
-
|
76
|
+
#### Load a list of datasource entries
|
53
77
|
|
54
78
|
```ruby
|
55
79
|
# Get all label datasource entries
|
@@ -59,7 +83,7 @@ client.datasource_entries({
|
|
59
83
|
|
60
84
|
```
|
61
85
|
|
62
|
-
|
86
|
+
#### Load a list of tags
|
63
87
|
|
64
88
|
```ruby
|
65
89
|
# Get all Tags that within the folder news
|
@@ -69,13 +93,13 @@ client.tags({
|
|
69
93
|
|
70
94
|
```
|
71
95
|
|
72
|
-
|
96
|
+
#### Load a list of links
|
73
97
|
|
74
98
|
```ruby
|
75
99
|
client.links
|
76
100
|
```
|
77
101
|
|
78
|
-
|
102
|
+
### Generate a navigation tree
|
79
103
|
|
80
104
|
```ruby
|
81
105
|
tree = client.tree
|
@@ -97,13 +121,13 @@ end
|
|
97
121
|
puts '</ul>'
|
98
122
|
```
|
99
123
|
|
100
|
-
|
124
|
+
#### Get the space info
|
101
125
|
|
102
126
|
```ruby
|
103
127
|
client.space
|
104
128
|
```
|
105
129
|
|
106
|
-
|
130
|
+
### How to flush the cache
|
107
131
|
|
108
132
|
Following an example of how to flush the client cache:
|
109
133
|
|
@@ -118,9 +142,9 @@ client.story('home')
|
|
118
142
|
client.flush
|
119
143
|
```
|
120
144
|
|
121
|
-
|
145
|
+
### Usage for the management api
|
122
146
|
|
123
|
-
|
147
|
+
#### Initialize the client and load spaces
|
124
148
|
|
125
149
|
```ruby
|
126
150
|
client = Storyblok::Client.new(oauth_token: 'YOUR_OAUTH_TOKEN')
|
@@ -129,35 +153,35 @@ client = Storyblok::Client.new(oauth_token: 'YOUR_OAUTH_TOKEN')
|
|
129
153
|
client.get('spaces/')
|
130
154
|
```
|
131
155
|
|
132
|
-
|
156
|
+
#### Create a story
|
133
157
|
|
134
158
|
```ruby
|
135
159
|
client.post("spaces/{space_id}/stories", {story: {name: 'new', slug: "new"}})
|
136
160
|
```
|
137
161
|
|
138
|
-
|
162
|
+
#### Update a story
|
139
163
|
|
140
164
|
```ruby
|
141
165
|
client.put("spaces/{space_id}/stories/{story_id}", {story: {name: 'new', slug: "new"}})
|
142
166
|
```
|
143
167
|
|
144
|
-
|
168
|
+
#### Delete a story
|
145
169
|
|
146
170
|
```ruby
|
147
171
|
client.delete("spaces/{space_id}/stories/{story_id}")
|
148
172
|
```
|
149
173
|
|
150
|
-
|
174
|
+
### Rendering of richtext fields
|
151
175
|
|
152
176
|
This SDK comes with a rendering service for richtext fields of Storyblok to get html output.
|
153
177
|
|
154
|
-
|
178
|
+
#### Rendering a richtext field
|
155
179
|
|
156
180
|
```ruby
|
157
181
|
client.render(data.richtext_field)
|
158
182
|
```
|
159
183
|
|
160
|
-
|
184
|
+
#### Define a component renderer
|
161
185
|
|
162
186
|
Storyblok's richtext field also let's you insert content blocks. To render these blocks you can define a Lambda.
|
163
187
|
|
@@ -180,7 +204,7 @@ client.set_component_resolver(->(component, data) {
|
|
180
204
|
})
|
181
205
|
```
|
182
206
|
|
183
|
-
|
207
|
+
#### Contribute
|
184
208
|
|
185
209
|
How to build a gem file.
|
186
210
|
|
@@ -189,10 +213,10 @@ gem build storyblok.gemspec
|
|
189
213
|
gem push storyblok-2.0.X.gem
|
190
214
|
~~~
|
191
215
|
|
192
|
-
|
216
|
+
#### Running Tests
|
193
217
|
We use [RSpec](http://rspec.info/) for testing.
|
194
218
|
|
195
|
-
|
219
|
+
###### To run the whole test suite you will need export the environment variables, ATTENTION when running the test suit with the variable `REDIS_URL` exported, the test suite will remove the keys with this pattern `storyblok:*` from the redis database defined by `REDIS_URL`
|
196
220
|
|
197
221
|
```bash
|
198
222
|
export REDIS_URL="redis://localhost:6379"
|
@@ -216,6 +240,22 @@ To run tests without redis cache tests (for when you don't have redis, or to avo
|
|
216
240
|
rspec --tag ~redis_cache:true
|
217
241
|
```
|
218
242
|
|
219
|
-
|
243
|
+
## 🔗 Related Links
|
244
|
+
|
245
|
+
* **[Storyblok & Ruby on GitHub](https://github.com/search?q=org%3Astoryblok+topic%3Aruby)**: Check all of our Ruby open source repos;
|
246
|
+
* **[Storyblok & Ruby 5 minutes tutorial](https://www.storyblok.com/tp/ruby-on-rails-cms?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-ruby)**: will show you how you can use the API-based CMS Storyblok in combination with the Framework “Ruby on Rails”;
|
247
|
+
* **[Technology Hub](https://www.storyblok.com/technologies?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-ruby)**: We prepared technology hubs so that you can find selected beginner tutorials, videos, boilerplates, and even cheatsheets all in one place;
|
248
|
+
* **[Storyblok CLI](https://github.com/storyblok/storyblok)**: A simple CLI for scaffolding Storyblok projects and fieldtypes.
|
249
|
+
|
250
|
+
## ℹ️ More Resources
|
251
|
+
|
252
|
+
### Support
|
253
|
+
|
254
|
+
* Bugs or Feature Requests? [Submit an issue](../../../issues/new);
|
255
|
+
|
256
|
+
* Do you have questions about Storyblok or you need help? [Join our Discord Community](https://discord.gg/jKrbAMz).
|
257
|
+
|
258
|
+
### Contributing
|
220
259
|
|
221
|
-
|
260
|
+
Please see our [contributing guidelines](https://github.com/storyblok/.github/blob/master/contributing.md) and our [code of conduct](https://www.storyblok.com/trust-center#code-of-conduct?utm_source=github.com&utm_medium=readme&utm_campaign=storyblok-ruby).
|
261
|
+
This project use [semantic-release](https://semantic-release.gitbook.io/semantic-release/) for generate new versions by using commit messages and we use the Angular Convention to naming the commits. Check [this question](https://semantic-release.gitbook.io/semantic-release/support/faq#how-can-i-change-the-type-of-commits-that-trigger-a-release) about it in semantic-release FAQ.
|