outliner 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 78468e90b9cfa5b4edbddc88991a2a3bf9abf7def91fa7e9c370179838947bb2
4
- data.tar.gz: 5bc469b0dd84226362ea76da9a343cdc569361c39aae188b3b8d5ada30957ce5
3
+ metadata.gz: 965c6e37c5f452ee902a235cf5eaaa73375894dbf1244cca2065f338ab12badd
4
+ data.tar.gz: 84533e4c6617795ee3a50181c6e78b178709caa356730cdcc93d26c89a99d5cc
5
5
  SHA512:
6
- metadata.gz: fe63570fb9585c14326f045d8819d31ac9539e9cb4e561cbd2b8280babb21811af0f5d0090b221b41047c3f2af1747a42029606964103eb451fca3e74d8788f8
7
- data.tar.gz: d58622b22451ea9b1e738b2e3686b4f4cc21b475f380448cbe9e26a555133cd788607710c7bb1287d5869856d95aadc27ba0340e572c95e3bb0eea2b23f2b4ea
6
+ metadata.gz: 29c1e5c613d50fae1337ba041c1203d4d2e5ce82987997e59a83e21875a925c5ed3c0b730513de6a5efa9254997c04c79c4ea8ba26e9925db1019987c888da16
7
+ data.tar.gz: 0c08dec404bffea65a5b00647770fb761725db0a2d5445830d401a22a26abbd77768a9336635913dca195486faf1b39e9becaef2ef7865cceca6d6064079b9a9
data/CHANGELOG.md CHANGED
@@ -7,7 +7,11 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
- - Dockerfile
10
+ ## 0.2.0 - 2019-08-12
11
+
12
+ - Adds export command (See [#1013](https://github.com/outline/outline/pull/1013) for corresponding Outline PR)
13
+ - Adds support for running import|export via Docker
14
+ - Sets up `outline-export` and `outline-import` as rubygem executables
11
15
 
12
16
  ## 0.1.1 - 2019-07-24
13
17
 
@@ -18,5 +22,3 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
18
22
  ### Added
19
23
 
20
24
  - Initial release
21
-
22
- [unreleased]: https://github.com/olivierlacan/keep-a-changelog/compare/v0.1.0...HEAD
data/Dockerfile ADDED
@@ -0,0 +1,9 @@
1
+ FROM ruby:2.6-alpine
2
+
3
+ WORKDIR /outliner
4
+ COPY . /outliner/
5
+
6
+ RUN gem install bundler && \
7
+ bundle install
8
+
9
+ ENTRYPOINT ["/outliner/entrypoint.sh"]
data/Gemfile.lock ADDED
@@ -0,0 +1,42 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ outliner (0.1.1)
5
+ httparty (~> 0.17)
6
+
7
+ GEM
8
+ remote: https://rubygems.org/
9
+ specs:
10
+ addressable (2.6.0)
11
+ public_suffix (>= 2.0.2, < 4.0)
12
+ crack (0.4.3)
13
+ safe_yaml (~> 1.0.0)
14
+ hashdiff (1.0.0)
15
+ httparty (0.17.0)
16
+ mime-types (~> 3.0)
17
+ multi_xml (>= 0.5.2)
18
+ mime-types (3.2.2)
19
+ mime-types-data (~> 3.2015)
20
+ mime-types-data (3.2019.0331)
21
+ minitest (5.8.5)
22
+ multi_xml (0.6.0)
23
+ public_suffix (3.1.1)
24
+ rake (10.5.0)
25
+ safe_yaml (1.0.5)
26
+ webmock (3.6.0)
27
+ addressable (>= 2.3.6)
28
+ crack (>= 0.3.2)
29
+ hashdiff (>= 0.4.0, < 2.0.0)
30
+
31
+ PLATFORMS
32
+ ruby
33
+
34
+ DEPENDENCIES
35
+ bundler (~> 2.0)
36
+ minitest (~> 5.8.4)
37
+ outliner!
38
+ rake (~> 10.0)
39
+ webmock (~> 3.6.0)
40
+
41
+ BUNDLED WITH
42
+ 2.0.2
data/README.md CHANGED
@@ -1,6 +1,6 @@
1
- # Outliner [![Gem Version](https://badge.fury.io/rb/outliner.svg)](https://badge.fury.io/rb/outliner)
1
+ # Outliner [![Gem Version](https://badge.fury.io/rb/outliner.svg)](https://badge.fury.io/rb/outliner) [![](https://images.microbadger.com/badges/version/captn3m0/outliner:v0.2.0.svg)](https://microbadger.com/images/captn3m0/outliner:v0.2.0 'Get your own version badge on microbadger.com') [![](https://images.microbadger.com/badges/version/captn3m0/outliner:latest.svg)](https://microbadger.com/images/captn3m0/outliner:latest 'Get your own version badge on microbadger.com')
2
2
 
3
- A simple HTTParty based wrapper for the [Outline API](https://www.getoutline.com/developers). It also offers a one-line import option to let you migrate an existing set of Markdown files to Outline.
3
+ A simple HTTParty based wrapper for the [Outline API](https://www.getoutline.com/developers). It also offers a one-line import option to let you migrate an existing set of Markdown files to Outline. For quickly running export/import commands, you can use the Docker Image as well.
4
4
 
5
5
  ## Installation
6
6
 
@@ -32,7 +32,7 @@ pp client.collections_list(offset: 0, limit: 10)
32
32
 
33
33
  ### Import
34
34
 
35
- `outliner` can be used to import an existing collection of documents into Outline. To do this run:
35
+ `outliner` can be used to import an existing collection of documents into Outline. To do this, run:
36
36
 
37
37
  ```bash
38
38
  export OUTLINE_BASE_URI="https://kb.example.com"
@@ -40,12 +40,50 @@ export OUTLINE_TOKEN="PUT YOUR TOKEN HERE"
40
40
  export SOURCE_DIRECTORY="/home/user/wiki"
41
41
  export DESTINATION_COLLECTION_NAME="Archive"
42
42
  bundle install outliner
43
- bundle exec bin/import "$SOURCE_DIRECTORY" "$DESTINATION_COLLECTION_NAME"
43
+ outliner-import "$SOURCE_DIRECTORY" "$DESTINATION_COLLECTION_NAME"
44
+ ```
45
+
46
+ ### Export
47
+
48
+ `outliner` can be used to run a one-time export of all documents in Outline to a local directory. To do this, run:
49
+
50
+ ```bash
51
+ export OUTLINE_BASE_URI="https://kb.example.com"
52
+ export OUTLINE_TOKEN="PUT YOUR TOKEN HERE"
53
+ # Ensure that this exists and is writable
54
+ export DESTINATION_DIRECTORY="/data"
55
+ bundle install outliner
56
+ outliner-export "$DESTINATION_DIRECTORY"
57
+ ```
58
+
59
+ ## Docker
60
+
61
+ You can use the pre-built docker image to run the above commands as well. See the following commands for examples:
62
+
63
+ ### Export
64
+
65
+ ```bash
66
+ docker run --env OUTLINE_BASE_URI="https://kb.example.com" \
67
+ --env OUTLINE_TOKEN="PUT YOUR TOKEN HERE" \
68
+ --volume /tmp:/data \
69
+ captn3m0/outliner \
70
+ export \
71
+ /data
72
+ ```
73
+
74
+ ### Import
75
+
76
+ ```bash
77
+ docker run --env OUTLINE_BASE_URI="https://kb.example.com" \
78
+ --env OUTLINE_TOKEN="PUT YOUR TOKEN HERE" \
79
+ --volume /path/to/wiki:/data \
80
+ captn3m0/outliner \
81
+ import "/data" "Archive"
44
82
  ```
45
83
 
46
84
  #### Limitations
47
85
 
48
- - Images are currently not imported
86
+ - Images are currently not imported. Host them externally for this to work.
49
87
  - Only `.md` files are currently supported
50
88
 
51
89
  ## Development
data/entrypoint.sh ADDED
@@ -0,0 +1,21 @@
1
+ #!/bin/sh
2
+
3
+ if [ $# -eq 0 ]; then
4
+ echo "Please run with outliner [export|import] arguments"
5
+ exit
6
+ fi
7
+
8
+ case $1 in
9
+ export)
10
+ shift
11
+ bundle exec outliner-export $@
12
+ ;;
13
+ import)
14
+ shift
15
+ bundle exec outliner-import $@
16
+ break
17
+ ;;
18
+ *)
19
+ echo "Invalid command, please check README"
20
+ ;;
21
+ esac
@@ -0,0 +1,33 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "outliner"
5
+ require 'tempfile'
6
+
7
+ def validate
8
+ unless (ARGV.size == 1) and Dir.exists?(ARGV[0]) and ENV.key?('OUTLINE_BASE_URI') and ENV.key?('OUTLINE_TOKEN')
9
+ puts "[E] Please call as `outliner-export directory`"
10
+ puts "[E] Please export OUTLINE_BASE_URI and OUTLINE_TOKEN environment variables"
11
+ puts "[E] OUTLINE_BASE_URI should not include /api"
12
+ exit 1
13
+ end
14
+ end
15
+
16
+ # Run validations
17
+ validate
18
+
19
+ # Setup variables
20
+ local_directory = ARGV[0]
21
+ CLIENT = Outliner::Client.new ENV['OUTLINE_BASE_URI']
22
+
23
+ # Download the complete zip
24
+ response = CLIENT.collections_exportAll(download: true)
25
+
26
+ # Extract it to a tempfle
27
+ file = Tempfile.new('download.zip')
28
+ File.open(file.path, 'w') { |file| file.write(response.body) }
29
+
30
+ `unzip -o "#{file.path}" -d "#{local_directory}"`
31
+
32
+ # Delete tempfile
33
+ file.unlink
@@ -4,20 +4,11 @@ require "bundler/setup"
4
4
  require "outliner"
5
5
 
6
6
  def validate
7
- unless (ARGV.size == 2) and Dir.exists?(ARGV[0]) and ARGV[1].match(/\w+/) and ENV.key?('OUTLINE_BASE_URI')
8
- puts "[E] Please call as import local_directory remote_collection_name"
7
+ unless (ARGV.size == 2) and Dir.exists?(ARGV[0]) and ARGV[1].match(/\w+/) and ENV.key?('OUTLINE_BASE_URI') and ENV.key?('OUTLINE_TOKEN')
8
+ puts "[E] Please call as `outliner-import local_directory remote_collection_name`"
9
9
  puts "[E] Please export OUTLINE_BASE_URI and OUTLINE_TOKEN environment variables"
10
10
  puts "[E] OUTLINE_BASE_URI should not include /api"
11
- end
12
- end
13
-
14
- def find_or_create_collection(name)
15
- collections = CLIENT.collections_list(limit: 100)['data']
16
- collections.filter!{|c|c['name'] == name}
17
- if collections.size >= 1
18
- collections[0]['id']
19
- else
20
- CLIENT.collections_create(name: name, description: 'Imported Collection')['data']['id']
11
+ exit 1
21
12
  end
22
13
  end
23
14
 
@@ -63,7 +54,7 @@ remote_collection_name = ARGV[1]
63
54
 
64
55
  # Create a root collection
65
56
  CLIENT = Outliner::Client.new ENV['OUTLINE_BASE_URI']
66
- root_collection_id = find_or_create_collection(remote_collection_name)
57
+ root_collection_id = find_or_create_collection(CLIENT, remote_collection_name)
67
58
 
68
59
  begin
69
60
  create_documents_recursively(local_directory, root_collection_id)
@@ -0,0 +1,13 @@
1
+ module Outliner
2
+ class Helper
3
+ def find_or_create_collection(client, name)
4
+ collections = client.collections_list(limit: 100)['data']
5
+ collections.filter!{|c|c['name'] == name}
6
+ if collections.size >= 1
7
+ collections[0]['id']
8
+ else
9
+ client.collections_create(name: name, description: 'Imported Collection')['data']['id']
10
+ end
11
+ end
12
+ end
13
+ end
@@ -1,3 +1,3 @@
1
1
  module Outliner
2
- VERSION = "0.1.1"
2
+ VERSION = "0.2.0"
3
3
  end
data/lib/outliner.rb CHANGED
@@ -1,4 +1,5 @@
1
1
  require "outliner/version"
2
+ require "outliner/client"
2
3
 
3
4
  module Outliner
4
5
  class Error < StandardError; end
data/outliner.gemspec CHANGED
@@ -2,13 +2,13 @@ lib = File.expand_path("lib", __dir__)
2
2
  $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
3
3
 
4
4
  require "outliner/version"
5
- require "outliner/client"
6
5
 
7
6
  Gem::Specification.new do |spec|
8
7
  spec.name = "outliner"
9
8
  spec.version = Outliner::VERSION
10
9
  spec.authors = ["Nemo"]
11
10
  spec.email = ["rubygem.outliner@captnemo.in"]
11
+ spec.licenses = ["MIT"]
12
12
 
13
13
  spec.summary = "A simple HTTParty based client for outline knowledge base."
14
14
  spec.homepage = "https://github.com/captn3m0/outliner"
@@ -17,11 +17,8 @@ Gem::Specification.new do |spec|
17
17
  spec.metadata["source_code_uri"] = "https://github.com/captn3m0/outliner"
18
18
  spec.metadata["changelog_uri"] = "https://github.com/captn3m0/outliner/blob/master/CHANGELOG.md"
19
19
 
20
- # Specify which files should be added to the gem when it is released.
21
- # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
22
- spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
23
- `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
24
- end
20
+ spec.files = Dir['**/*'].reject { |f| f.match(%r{^(vendor|test|spec|features)/}) }
21
+
25
22
  spec.bindir = "exe"
26
23
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
27
24
  spec.require_paths = ["lib"]
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: outliner
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nemo
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2019-07-24 00:00:00.000000000 Z
11
+ date: 2019-08-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: httparty
@@ -83,27 +83,33 @@ dependencies:
83
83
  description:
84
84
  email:
85
85
  - rubygem.outliner@captnemo.in
86
- executables: []
86
+ executables:
87
+ - outliner-export
88
+ - outliner-import
87
89
  extensions: []
88
90
  extra_rdoc_files: []
89
91
  files:
90
- - ".editorconfig"
91
- - ".gitignore"
92
92
  - CHANGELOG.md
93
93
  - CODE_OF_CONDUCT.md
94
+ - Dockerfile
94
95
  - Gemfile
96
+ - Gemfile.lock
95
97
  - LICENSE
96
98
  - README.md
97
99
  - Rakefile
98
100
  - bin/console
99
- - bin/import
100
101
  - bin/setup
102
+ - entrypoint.sh
103
+ - exe/outliner-export
104
+ - exe/outliner-import
101
105
  - lib/outliner.rb
102
106
  - lib/outliner/client.rb
107
+ - lib/outliner/helper.rb
103
108
  - lib/outliner/version.rb
104
109
  - outliner.gemspec
105
110
  homepage: https://github.com/captn3m0/outliner
106
- licenses: []
111
+ licenses:
112
+ - MIT
107
113
  metadata:
108
114
  homepage_uri: https://github.com/captn3m0/outliner
109
115
  source_code_uri: https://github.com/captn3m0/outliner
data/.editorconfig DELETED
@@ -1,12 +0,0 @@
1
- ; This file is for unifying the coding style for different editors and IDEs.
2
- ; More information at http://EditorConfig.org
3
-
4
- root = true
5
- ; Use 2 spaces for indentation in all files
6
- [*]
7
- end_of_line = lf
8
- charset = utf-8
9
- trim_trailing_whitespace = true
10
- indent_style = space
11
- indent_size = 2
12
- insert_final_newline = true
data/.gitignore DELETED
@@ -1,10 +0,0 @@
1
- /.bundle/
2
- /.yardoc
3
- /_yardoc/
4
- /coverage/
5
- /doc/
6
- /pkg/
7
- /spec/reports/
8
- /tmp/
9
- /vendor/
10
- Gemfile.lock