mirror of https://github.com/captn3m0/outliner.git
Fix import script
This commit is contained in:
parent
f8c659b28b
commit
beed823d63
|
@ -54,7 +54,7 @@ remote_collection_name = ARGV[1]
|
||||||
|
|
||||||
# Create a root collection
|
# Create a root collection
|
||||||
CLIENT = Outliner::Client.new ENV['OUTLINE_BASE_URI']
|
CLIENT = Outliner::Client.new ENV['OUTLINE_BASE_URI']
|
||||||
root_collection_id = find_or_create_collection(CLIENT, remote_collection_name)
|
root_collection_id = CLIENT.find_or_create_collection(remote_collection_name)
|
||||||
|
|
||||||
begin
|
begin
|
||||||
create_documents_recursively(local_directory, root_collection_id)
|
create_documents_recursively(local_directory, root_collection_id)
|
||||||
|
|
|
@ -10,10 +10,20 @@ module Outliner
|
||||||
@token = ENV['OUTLINE_TOKEN']
|
@token = ENV['OUTLINE_TOKEN']
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def find_or_create_collection(name)
|
||||||
|
collections = self.collections_list(limit: 100)['data']
|
||||||
|
collections.filter!{|c|c['name'] == name}
|
||||||
|
if collections.size >= 1
|
||||||
|
collections[0]['id']
|
||||||
|
else
|
||||||
|
self.collections_create(name: name, description: 'Imported Collection')['data']['id']
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def method_missing(method_name, params = {})
|
def method_missing(method_name, params = {})
|
||||||
method_name = '/' + method_name.to_s.sub('_', '.')
|
method_name = '/' + method_name.to_s.sub('_', '.')
|
||||||
body = {token: @token}.merge(params).to_json
|
body = {token: @token}.merge(params).to_json
|
||||||
options = {
|
options = {
|
||||||
body: body,
|
body: body,
|
||||||
headers: {
|
headers: {
|
||||||
'Accept'=>'application/json',
|
'Accept'=>'application/json',
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
module Outliner
|
module Outliner
|
||||||
VERSION = "0.2.0"
|
VERSION = "0.2.1"
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue