locomotivecms / coal Goto Github PK
View Code? Open in Web Editor NEWAPI ruby client for LocomotiveCMS
License: MIT License
API ruby client for LocomotiveCMS
License: MIT License
I am trying to get all content entries but I keep on getting the error for missing slug.
I made a tiny script and it keeps on failing with the error above:
Script:
require 'locomotive/coal'
client = Locomotive::Coal::Client.new('...', { email: '...', api_key: '...' })
site_client = client.scope_by('site')
content_type = site_client.contents.news
news = site_client.content_entries(content_type).all
puts news.count
Error:
Traceback (most recent call last):
1: from update_news_entries.rb:6:in `<main>'
/Users/donkoko/.rvm/gems/ruby-2.5.3/gems/locomotivecms_coal-1.6.0.beta1/lib/locomotive/coal/client.rb:44:in `content_entries': undefined method `slug' for #<Locomotive::Coal::Resources::ContentEntries:0x00007fcaeafa4828> (NoMethodError)
Coal version: locomotivecms_coal (1.5.1)
Engine version: gem 'locomotivecms', github: 'locomotivecms/engine', ref: '9ed6083'
The documentation for coal says:
If not logged in, then it's possible to create your account
client = Locomotive::Coal::Client.new('http://www.myengine.dev')
client.my_account.create(name: 'John Doe', email: '[email protected]', password: 'easyone', password_confirmation: 'easyone')
But, when I try that, I get:
ArgumentError (wrong number of arguments (given 1, expected 2..3))
So, at server setup can you create the first account with Coal?
Using the example form the docs trying to read all content types,
site_client.contents.messages.all({})
will raise an exception:
NoMethodError: undefined method `[]' for nil:NilClass
content_entries.rb:23:in `index'
the issue appears when trying to access options which is defaulted with nil hence options[:page] will crash.
PaginatedResources.new(list,
options[:page] || 1,
response.headers[:x_total_pages].to_i,
response.headers[:x_total_entries].to_i)
PR following soon.
refers to locomotivecms/steam#189 and locomotivecms/wagon#392
I'm newbie for locomotivecms. I have a question. I can't pull and deploy the site from engine which installed on my company server to wagon on my machine, the error is "Pulling...\Locomotive::Coal::UnauthorizedError", but i can pull and deploy to locomotivecms demo server as anytime I want, how should I do?
Sorry for my english.
Hi
I have news content_type which has a field posted_at which is required: true
In my data/news.yml file, all the news have a posted_at: field filled in with data of this type
posted_at: '2015-11-11 18:00:00 +0100'
When pushing to the Engine, with the latest version of Coal (locomotivecms_coal (~> 1.0.0.rc3)) and Wagon (locomotivecms_wagon (2.0.0.rc5)), I get the error below.
This error did not occur with the previous versions.
Resource invalid: posted_at can't be blank, formatted_posted_at can't be blank
Resource invalid: posted_at can't be blank, formatted_posted_at can't be blank
/Users/cedriclor/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/locomotivecms_coal-1.0.0.rc3/lib/locomotive/coal/resources/concerns/request.rb:36:in `do_request'
/Users/cedriclor/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/locomotivecms_coal-1.0.0.rc3/lib/locomotive/coal/resources/concerns/request.rb:15:in `put'
/Users/cedriclor/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/locomotivecms_coal-1.0.0.rc3/lib/locomotive/coal/resources/base.rb:35:in `update_with_locale'
/Users/cedriclor/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/locomotivecms_wagon-2.0.0.rc5/lib/locomotive/wagon/commands/push_sub_commands/push_content_entries_command.rb:42:in `persist'
/Users/cedriclor/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/locomotivecms_wagon-2.0.0.rc5/lib/locomotive/wagon/commands/push_sub_commands/push_base_command.rb:34:in `block in _push'
/Users/cedriclor/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/locomotivecms_wagon-2.0.0.rc5/lib/locomotive/wagon/commands/push_sub_commands/push_base_command.rb:30:in `each'
/Users/cedriclor/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/locomotivecms_wagon-2.0.0.rc5/lib/locomotive/wagon/commands/push_sub_commands/push_base_command.rb:30:in `_push'
/Users/cedriclor/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/locomotivecms_wagon-2.0.0.rc5/lib/locomotive/wagon/commands/push_sub_commands/push_content_entries_command.rb:12:in `block in _push'
/Users/cedriclor/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/locomotivecms_wagon-2.0.0.rc5/lib/locomotive/wagon/commands/push_sub_commands/push_content_entries_command.rb:10:in `each'
/Users/cedriclor/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/locomotivecms_wagon-2.0.0.rc5/lib/locomotive/wagon/commands/push_sub_commands/push_content_entries_command.rb:10:in `_push'
/Users/cedriclor/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/locomotivecms_wagon-2.0.0.rc5/lib/locomotive/wagon/commands/push_sub_commands/push_base_command.rb:25:in `block in _push_with_timezone'
/Users/cedriclor/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/activesupport-4.2.5/lib/active_support/core_ext/time/zones.rb:48:in `use_zone'
/Users/cedriclor/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/locomotivecms_wagon-2.0.0.rc5/lib/locomotive/wagon/commands/push_sub_commands/push_base_command.rb:24:in `_push_with_timezone'
/Users/cedriclor/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/locomotivecms_wagon-2.0.0.rc5/lib/locomotive/wagon/commands/push_sub_commands/push_base_command.rb:18:in `block in push'
/Users/cedriclor/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/activesupport-4.2.5/lib/active_support/notifications.rb:166:in `instrument'
/Users/cedriclor/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/locomotivecms_wagon-2.0.0.rc5/lib/locomotive/wagon/commands/push_sub_commands/push_base_command.rb:47:in `instrument'
/Users/cedriclor/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/locomotivecms_wagon-2.0.0.rc5/lib/locomotive/wagon/commands/push_sub_commands/push_base_command.rb:16:in `push'
/Users/cedriclor/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/locomotivecms_wagon-2.0.0.rc5/lib/locomotive/wagon/commands/push_sub_commands/push_base_command.rb:12:in `push'
/Users/cedriclor/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/locomotivecms_wagon-2.0.0.rc5/lib/locomotive/wagon/commands/push_command.rb:54:in `block in _push'
/Users/cedriclor/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/locomotivecms_wagon-2.0.0.rc5/lib/locomotive/wagon/commands/push_command.rb:82:in `block in each_resource'
/Users/cedriclor/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/locomotivecms_wagon-2.0.0.rc5/lib/locomotive/wagon/commands/push_command.rb:75:in `each'
/Users/cedriclor/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/locomotivecms_wagon-2.0.0.rc5/lib/locomotive/wagon/commands/push_command.rb:75:in `each_resource'
/Users/cedriclor/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/locomotivecms_wagon-2.0.0.rc5/lib/locomotive/wagon/commands/push_command.rb:53:in `_push'
/Users/cedriclor/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/locomotivecms_wagon-2.0.0.rc5/lib/locomotive/wagon/commands/push_command.rb:40:in `push'
/Users/cedriclor/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/locomotivecms_wagon-2.0.0.rc5/lib/locomotive/wagon/commands/push_command.rb:30:in `push'
/Users/cedriclor/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/locomotivecms_wagon-2.0.0.rc5/lib/locomotive/wagon.rb:73:in `push'
/Users/cedriclor/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/locomotivecms_wagon-2.0.0.rc5/lib/locomotive/wagon/cli.rb:313:in `deploy'
/Users/cedriclor/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/command.rb:27:in `run'
/Users/cedriclor/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/invocation.rb:126:in `invoke_command'
/Users/cedriclor/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor.rb:359:in `dispatch'
/Users/cedriclor/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/thor-0.19.1/lib/thor/base.rb:440:in `start'
/Users/cedriclor/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/locomotivecms_wagon-2.0.0.rc5/bin/wagon:12:in `<top (required)>'
/Users/cedriclor/.rbenv/versions/2.2.3/bin/wagon:23:in `load'
/Users/cedriclor/.rbenv/versions/2.2.3/bin/wagon:23:in `<main>'
page = 1
while page do
articles = site_client.contents.articles.all({ published: true }, page: page)
articles.each { |article| puts article.title }
page = articles._next_page
end
could also be written like this:
site_client.contents.articles.each({ published: true }, 'en') do |article|
puts article.title
end
Gemnasium declared that there was an security issue in the Unirest gem.
Something like:
client = Locomotive::Coal::Client.new('http://www.myengine.dev', { email: <EMAIL>, api_key: <API KEY> })
client.engine_version # get /locomotive/api/version
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.