Storyblok ruby client for easy access of the content delivery api
Switch branches/tags
Nothing to show
Clone or download
Latest commit 3c53d37 Oct 16, 2018
Permalink
Failed to load latest commit information.
examples fixes cache issue Feb 7, 2018
lib Updates docs Oct 16, 2018
.editorconfig init Feb 19, 2017
.gitignore init Feb 19, 2017
Gemfile adds query_string instead of query Feb 19, 2017
README.md Fix README Oct 16, 2018
storyblok.gemspec Allow usage of rest-client > 1.99 Feb 7, 2018

README.md

About

This is the Storyblok ruby client for easy access of the content delivery api.

Install

gem 'storyblok'

Usage

Load a Story

# Without cache
client = Storyblok::Client.new(token: 'YOUR_TOKEN')

# Optionally set a cache client
redis = Redis.new(url: 'redis://localhost:6379')
cache = Storyblok::Cache::Redis.new(redis: Redis.current)
client = Storyblok::Client.new(cache: cache, token: 'YOUR_TOKEN')

# Get a story
client.story('home')

Load a list of Stories

# Get all Stories that start with news
client.stories({
  :starts_with => 'news'
})

Load a list of datasource entries

# Get all label datasource entries
client.datasource_entries({
  :datasource => 'labels'
})

Load a list of tags

# Get all Tags that within the folder news
client.tags({
  :starts_with => 'news'
})

Generate a navigation tree

tree = client.tree

puts '<ul>'
tree.each do |key, item|
  puts '<li>' + item['item']['name']

  if !item['children'].empty?
    puts '<ul>'
    item['children'].each do |key, inner_item|
      puts '<li>' + inner_item['item']['name'] + '</li>'
    end
    puts '</ul>'
  end

  puts '</li>'
end
puts '</ul>'

License

This project is open-sourced software licensed under the MIT license