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
|
||||
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
|
||||
create_documents_recursively(local_directory, root_collection_id)
|
||||
|
|
|
@ -10,6 +10,16 @@ module Outliner
|
|||
@token = ENV['OUTLINE_TOKEN']
|
||||
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 = {})
|
||||
method_name = '/' + method_name.to_s.sub('_', '.')
|
||||
body = {token: @token}.merge(params).to_json
|
||||
|
|
|
@ -1,3 +1,3 @@
|
|||
module Outliner
|
||||
VERSION = "0.2.0"
|
||||
VERSION = "0.2.1"
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue