qiita_org 0.1.31 → 0.1.32
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/qiita_org.rb +27 -32
- data/lib/qiita_org/base.rb +78 -0
- data/lib/qiita_org/config.rb +3 -2
- data/lib/qiita_org/get.rb +6 -43
- data/lib/qiita_org/get_multiple_files.rb +3 -2
- data/lib/qiita_org/get_template.rb +6 -3
- data/lib/qiita_org/list.rb +7 -34
- data/lib/qiita_org/{check_pc_os.rb → old_programs/check_pc_os.rb} +0 -0
- data/lib/qiita_org/{decide_option.rb → old_programs/decide_option.rb} +0 -0
- data/lib/qiita_org/{get_file_path.rb → old_programs/get_file_path.rb} +0 -0
- data/lib/qiita_org/{get_file_url.rb → old_programs/get_file_url.rb} +0 -0
- data/lib/qiita_org/{search_conf_path.rb → old_programs/search_conf_path.rb} +0 -0
- data/lib/qiita_org/{select_path.rb → old_programs/select_path.rb} +0 -0
- data/lib/qiita_org/{set_config.rb → old_programs/set_config.rb} +0 -0
- data/lib/qiita_org/{show_file_and_url.rb → old_programs/show_file_and_url.rb} +0 -0
- data/lib/qiita_org/post.rb +26 -16
- data/lib/qiita_org/upload.rb +14 -7
- data/lib/qiita_org/version.rb +1 -1
- data/tests/test2.org +1 -2
- metadata +11 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3065c27fab3f91eef0df4ddb3f966fcddb54cebc741450e71977f0fd7f0d5961
|
4
|
+
data.tar.gz: 892613248797cf2f82497e6b355b7fa9e4fc05b48b9fc823d32516f05efbe03c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7005e750de0160ac668c0742c64d380e5898a26c7f0d1f56a4f09b901b52ea933902ea611478685ced7871724e47bbc3704342809f73bb129772bbb483eb1594
|
7
|
+
data.tar.gz: 59ad6b10fcc271bb2e11377963c4d5cde04ec3d7397642a1981eab81f17b5b40f95ebbe6099932f88172dbb953227420fbc7bfca368dad76245cc989c97bb44b
|
data/Gemfile.lock
CHANGED
data/lib/qiita_org.rb
CHANGED
@@ -9,12 +9,13 @@ require "qiita_org/get"
|
|
9
9
|
require "qiita_org/list"
|
10
10
|
require "qiita_org/all"
|
11
11
|
require "qiita_org/get_template"
|
12
|
-
require "qiita_org/check_pc_os"
|
12
|
+
#require "qiita_org/check_pc_os"
|
13
13
|
require "qiita_org/upload"
|
14
|
-
require "qiita_org/get_file_path"
|
15
|
-
require "qiita_org/show_file_and_url"
|
16
|
-
require "qiita_org/decide_option"
|
14
|
+
#require "qiita_org/get_file_path"
|
15
|
+
#require "qiita_org/show_file_and_url"
|
16
|
+
#require "qiita_org/decide_option"
|
17
17
|
require "qiita_org/get_multiple_files"
|
18
|
+
require "qiita_org/base"
|
18
19
|
#require "qiita_org/qiita_org_thor"
|
19
20
|
|
20
21
|
module QiitaOrg
|
@@ -25,6 +26,7 @@ module QiitaOrg
|
|
25
26
|
#
|
26
27
|
def initialize(*argv)
|
27
28
|
super(*argv)
|
29
|
+
@base = QiitaBase.new()
|
28
30
|
end
|
29
31
|
|
30
32
|
desc "say_hello", "say_hello"
|
@@ -37,17 +39,21 @@ module QiitaOrg
|
|
37
39
|
desc "post [FILE] [private/public/teams]", "post to qiita from org"
|
38
40
|
|
39
41
|
def post(*argv)
|
40
|
-
checkos = CheckPcOs.new
|
41
|
-
os = checkos.return_os()
|
42
|
+
#checkos = CheckPcOs.new
|
43
|
+
#os = checkos.return_os()
|
44
|
+
os = @base.check_pc_os()
|
42
45
|
|
43
46
|
if argv.size > 2
|
44
47
|
GetMultipleFiles.new(argv, os, "post").run()
|
45
|
-
elsif argv
|
46
|
-
|
48
|
+
elsif argv.size > 1
|
49
|
+
if argv[-1].match(/(.+).org/)
|
50
|
+
GetMultipleFiles.new(argv, os, "post").run()
|
51
|
+
end
|
47
52
|
else
|
48
53
|
p ["in qiita_org.rb", argv]
|
49
54
|
p file = argv[0] || "README.org"
|
50
|
-
p mode = argv[1] || DecideOption.new(file).decide_option()
|
55
|
+
#p mode = argv[1] || DecideOption.new(file).decide_option()
|
56
|
+
p mode = argv[1] || @base.pick_up_option(file)
|
51
57
|
qiita = QiitaPost.new(file, mode, os)
|
52
58
|
begin
|
53
59
|
qiita.select_option(mode)
|
@@ -62,35 +68,23 @@ module QiitaOrg
|
|
62
68
|
desc "upload [FILE] [teams/public/private]", "upload about image to qiita"
|
63
69
|
|
64
70
|
def upload(*argv)
|
65
|
-
checkos = CheckPcOs.new
|
66
|
-
os = checkos.return_os()
|
71
|
+
#checkos = CheckPcOs.new
|
72
|
+
#os = checkos.return_os()
|
73
|
+
os = @base.check_pc_os()
|
67
74
|
|
68
75
|
if argv.size > 2
|
69
76
|
GetMultipleFiles.new(argv, os, "upload").run()
|
70
|
-
elsif argv
|
71
|
-
|
77
|
+
elsif argv.size > 1
|
78
|
+
if argv[-1].match(/(.+).org/)
|
79
|
+
GetMultipleFiles.new(argv, os, "upload").run()
|
80
|
+
end
|
72
81
|
else
|
73
82
|
p file = argv[0] || "README.org"
|
74
|
-
p mode = argv[1] || DecideOption.new(file).decide_option()
|
83
|
+
#p mode = argv[1] || DecideOption.new(file).decide_option()
|
84
|
+
p mode = argv[1] || @base.pick_up_option(file)
|
75
85
|
|
76
86
|
qiita = QiitaFileUpLoad.new(file, mode, os).upload()
|
77
87
|
end
|
78
|
-
=begin
|
79
|
-
getpath = GetFilePath.new(file)
|
80
|
-
paths = getpath.get_file_path()
|
81
|
-
unless paths.empty?
|
82
|
-
showfile = ShowFile.new(paths, file, mode, os)
|
83
|
-
showfile.open_file_dir()
|
84
|
-
showfile.open_qiita()
|
85
|
-
|
86
|
-
puts "Input file URL's on #{file}? (y/n)".green
|
87
|
-
ans = STDIN.getch
|
88
|
-
|
89
|
-
if ans == "y"
|
90
|
-
showfile.input_url_to_org()
|
91
|
-
end
|
92
|
-
end
|
93
|
-
=end
|
94
88
|
end
|
95
89
|
|
96
90
|
desc "config [global/local] [option] [input]", "set config"
|
@@ -115,8 +109,9 @@ module QiitaOrg
|
|
115
109
|
desc "template", "make template.org"
|
116
110
|
|
117
111
|
def template(*argv)
|
118
|
-
checkos = CheckPcOs.new
|
119
|
-
os = checkos.return_os()
|
112
|
+
#checkos = CheckPcOs.new
|
113
|
+
#os = checkos.return_os()
|
114
|
+
os = @base.check_pc_os()
|
120
115
|
filename = argv[0] || "template.org"
|
121
116
|
filename = (filename.include?(".org"))? filename : "#{filename}.org"
|
122
117
|
|
@@ -0,0 +1,78 @@
|
|
1
|
+
require "colorize"
|
2
|
+
require "qiita_org/error_message.rb"
|
3
|
+
|
4
|
+
class QiitaBase
|
5
|
+
def initialize()
|
6
|
+
|
7
|
+
end
|
8
|
+
|
9
|
+
def check_pc_os()
|
10
|
+
if system "sw_vers"
|
11
|
+
return os = "mac"
|
12
|
+
elsif system "wmic.exe os get caption"
|
13
|
+
return os = "windows"
|
14
|
+
else
|
15
|
+
return nil
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def pick_up_option(src)
|
20
|
+
lines = File.readlines(src)
|
21
|
+
|
22
|
+
lines.each do |line|
|
23
|
+
m = []
|
24
|
+
if m = line.match(/\#\+qiita_(.+): (.+)/)
|
25
|
+
option = m[1]
|
26
|
+
unless option == "public" || option == "teams" || option == "private"
|
27
|
+
next
|
28
|
+
end
|
29
|
+
return option
|
30
|
+
end
|
31
|
+
end
|
32
|
+
return option = "private"
|
33
|
+
end
|
34
|
+
|
35
|
+
def search_conf_path(dir, home)
|
36
|
+
while dir != home
|
37
|
+
if File.exists?(File.join(dir, ".qiita.conf"))
|
38
|
+
return dir
|
39
|
+
else
|
40
|
+
dir = dir.match(/(.+)\//)[1]
|
41
|
+
end
|
42
|
+
end
|
43
|
+
return dir
|
44
|
+
end
|
45
|
+
|
46
|
+
def select_access_path(mode, teams_url)
|
47
|
+
case mode
|
48
|
+
when "teams"
|
49
|
+
qiita = teams_url
|
50
|
+
path = "api/v2/items?page=1&per_page=100"
|
51
|
+
else
|
52
|
+
qiita = "https://qiita.com/"
|
53
|
+
path = "api/v2/authenticated_user/items?page=1&per_page=100"
|
54
|
+
end
|
55
|
+
return qiita, path
|
56
|
+
end
|
57
|
+
|
58
|
+
def set_config()
|
59
|
+
conf_dir = search_conf_path(Dir.pwd, Dir.home)
|
60
|
+
lib = File.expand_path("../../../lib", __FILE__)
|
61
|
+
if conf_dir != Dir.home
|
62
|
+
puts "config file path: #{conf_dir.gsub(Dir.home, "~")}".green
|
63
|
+
else
|
64
|
+
puts "config file path: #{conf_dir}".green
|
65
|
+
end
|
66
|
+
|
67
|
+
conf_path = File.join(conf_dir, ".qiita.conf")
|
68
|
+
conf = JSON.load(File.read(conf_path))
|
69
|
+
access_token = conf["access_token"]
|
70
|
+
teams_url = conf["teams_url"]
|
71
|
+
display = conf["display"]
|
72
|
+
ox_qmd_load_path = File.join(lib, "qiita_org", "ox-qmd", "ox-qmd")
|
73
|
+
|
74
|
+
ErrorMessage.new().access_token_error(access_token)
|
75
|
+
|
76
|
+
return access_token, teams_url, display, ox_qmd_load_path
|
77
|
+
end
|
78
|
+
end
|
data/lib/qiita_org/config.rb
CHANGED
@@ -7,8 +7,9 @@ class QiitaConfig
|
|
7
7
|
@option = option
|
8
8
|
@input = input
|
9
9
|
if status == "local"
|
10
|
-
search = SearchConfPath.new(Dir.pwd, Dir.home)
|
11
|
-
conf_dir = search.search_conf_path()
|
10
|
+
#search = SearchConfPath.new(Dir.pwd, Dir.home)
|
11
|
+
#conf_dir = search.search_conf_path()
|
12
|
+
conf_dir = QiitaBase.new().search_conf_path(Dir.pwd, Dir.home)
|
12
13
|
if @option == "set"
|
13
14
|
@setup = File.join(Dir.pwd, ".qiita.conf")
|
14
15
|
else
|
data/lib/qiita_org/get.rb
CHANGED
@@ -3,8 +3,8 @@ require "json"
|
|
3
3
|
require "open-uri"
|
4
4
|
require "io/console"
|
5
5
|
require "colorize"
|
6
|
-
require "qiita_org/select_path.rb"
|
7
|
-
require "qiita_org/set_config.rb"
|
6
|
+
#require "qiita_org/select_path.rb"
|
7
|
+
#require "qiita_org/set_config.rb"
|
8
8
|
require "qiita_org/error_message.rb"
|
9
9
|
require "qiita_org/access_qiita.rb"
|
10
10
|
|
@@ -12,47 +12,10 @@ class QiitaGet
|
|
12
12
|
def initialize(mode, id)
|
13
13
|
@mode = mode
|
14
14
|
@get_id = id
|
15
|
-
@
|
15
|
+
@base = QiitaBase.new()
|
16
|
+
# @selectpath = SelectPath.new()
|
16
17
|
end
|
17
18
|
|
18
|
-
# select path
|
19
|
-
=begin
|
20
|
-
def select_path(mode)
|
21
|
-
case mode
|
22
|
-
when "teams"
|
23
|
-
qiita = @teams_url
|
24
|
-
path = "api/v2/items?page=1&per_page=100"
|
25
|
-
else
|
26
|
-
qiita = "https://qiita.com/"
|
27
|
-
path = "api/v2/authenticated_user/items?page=1&per_page=100"
|
28
|
-
end
|
29
|
-
return qiita, path
|
30
|
-
end
|
31
|
-
=end
|
32
|
-
|
33
|
-
# access qiita
|
34
|
-
=begin
|
35
|
-
def access_qiita()
|
36
|
-
uri = URI.parse(@qiita + @path)
|
37
|
-
|
38
|
-
headers = { "Authorization" => "Bearer # {@access_token}",
|
39
|
-
"Content-Type" => "application/json" }
|
40
|
-
|
41
|
-
begin
|
42
|
-
response = URI.open(
|
43
|
-
"# {uri}",
|
44
|
-
"Authorization" => "# {headers["Authorization"]}",
|
45
|
-
)
|
46
|
-
#raise "NOT FOUND: # {@get_id} report".red
|
47
|
-
rescue => e
|
48
|
-
puts "# {$!}".red
|
49
|
-
exit
|
50
|
-
else
|
51
|
-
@items = JSON.parse(response.read)
|
52
|
-
end
|
53
|
-
end
|
54
|
-
=end
|
55
|
-
|
56
19
|
# select report
|
57
20
|
def select_report()
|
58
21
|
@items.each do |item|
|
@@ -159,13 +122,13 @@ EOS
|
|
159
122
|
end
|
160
123
|
|
161
124
|
def run()
|
162
|
-
@access_token, @teams_url, @display, @ox_qmd_load_path =
|
125
|
+
@access_token, @teams_url, @display, @ox_qmd_load_path = @base.set_config()
|
163
126
|
if @mode == "teams"
|
164
127
|
ErrorMessage.new().teams_url_error(@teams_url)
|
165
128
|
end
|
166
129
|
|
167
130
|
if @get_id == nil
|
168
|
-
@qiita, @path = @
|
131
|
+
@qiita, @path = @base.select_access_path(@mode, @teams_url)
|
169
132
|
@items = AccessQiita.new(@access_token, @qiita, @path).access_qiita()
|
170
133
|
select_report()
|
171
134
|
else
|
@@ -2,7 +2,7 @@ require "colorize"
|
|
2
2
|
#require "../qiita_org/qiita_org.rb"
|
3
3
|
require "qiita_org/post.rb"
|
4
4
|
require "qiita_org/upload.rb"
|
5
|
-
require "qiita_org/decide_option.rb"
|
5
|
+
#require "qiita_org/decide_option.rb"
|
6
6
|
|
7
7
|
class GetMultipleFiles
|
8
8
|
def initialize(files, os, type)
|
@@ -19,7 +19,8 @@ class GetMultipleFiles
|
|
19
19
|
def run()
|
20
20
|
puts "post files: #{@files}".green
|
21
21
|
@files.each do |file|
|
22
|
-
mode = @option || DecideOption.new(file).decide_option()
|
22
|
+
#mode = @option || DecideOption.new(file).decide_option()
|
23
|
+
mode = @option || QiitaBase.new().pick_up_option(file)
|
23
24
|
puts "qiita #{@type} #{file} #{mode}".green
|
24
25
|
if @type == "post"
|
25
26
|
qiita = QiitaPost.new(file, mode, @os)
|
@@ -1,15 +1,16 @@
|
|
1
1
|
require "fileutils"
|
2
2
|
require "colorize"
|
3
3
|
require "kconv"
|
4
|
-
require "qiita_org/search_conf_path"
|
4
|
+
#require "qiita_org/search_conf_path"
|
5
5
|
require "qiita_org/error_message.rb"
|
6
6
|
|
7
7
|
class QiitaGetTemplate
|
8
8
|
def initialize(os, filename)
|
9
9
|
@os = os
|
10
10
|
@filename = filename
|
11
|
-
search = SearchConfPath.new(Dir.pwd, Dir.home)
|
12
|
-
@conf_dir = search.search_conf_path()
|
11
|
+
#search = SearchConfPath.new(Dir.pwd, Dir.home)
|
12
|
+
# @conf_dir = search.search_conf_path()
|
13
|
+
@conf_dir = QiitaBase.new().search_conf_path(Dir.pwd, Dir.home)
|
13
14
|
# check_write_header()
|
14
15
|
end
|
15
16
|
|
@@ -116,6 +117,7 @@ class QiitaGetTemplate
|
|
116
117
|
end
|
117
118
|
end
|
118
119
|
|
120
|
+
=begin
|
119
121
|
def get_name()
|
120
122
|
conts = File.readlines(@filename)
|
121
123
|
p "Type your name"
|
@@ -131,6 +133,7 @@ class QiitaGetTemplate
|
|
131
133
|
conts[4] = "#+EMAIL: (concat \"#{email.chomp}\")\n"
|
132
134
|
File.write(@filename, conts.join)
|
133
135
|
end
|
136
|
+
=end
|
134
137
|
|
135
138
|
def set_name_and_email()
|
136
139
|
conf_path = File.join(@conf_dir, ".qiita.conf")
|
data/lib/qiita_org/list.rb
CHANGED
@@ -2,54 +2,27 @@ require "net/https"
|
|
2
2
|
require "json"
|
3
3
|
require "open-uri"
|
4
4
|
require "colorize"
|
5
|
-
require "qiita_org/select_path.rb"
|
6
|
-
require "qiita_org/set_config.rb"
|
5
|
+
#require "qiita_org/select_path.rb"
|
6
|
+
#require "qiita_org/set_config.rb"
|
7
7
|
require "qiita_org/error_message.rb"
|
8
8
|
require "qiita_org/access_qiita.rb"
|
9
9
|
|
10
10
|
class QiitaList
|
11
11
|
def initialize(mode)
|
12
12
|
@mode = mode
|
13
|
-
@
|
13
|
+
@base = QiitaBase.new
|
14
|
+
# @access_token, @teams_url, @display, @ox_qmd_load_path = SetConfig.new().set_config()
|
15
|
+
@access_token, @teams_url, @display, @ox_qmd_load_path = @base.set_config()
|
14
16
|
if @mode == "teams"
|
15
17
|
ErrorMessage.new().teams_url_error(@teams_url)
|
16
18
|
end
|
17
19
|
|
18
|
-
@qiita, @path = SelectPath.new().select_path(@mode, @teams_url)
|
20
|
+
# @qiita, @path = SelectPath.new().select_path(@mode, @teams_url)
|
21
|
+
@qiita, @path = @base.select_access_path(@mode, @teams_url)
|
19
22
|
@items = AccessQiita.new(@access_token, @qiita, @path).access_qiita()
|
20
23
|
view_list()
|
21
24
|
end
|
22
25
|
|
23
|
-
# select path
|
24
|
-
=begin
|
25
|
-
def select_path()
|
26
|
-
case @mode
|
27
|
-
when "teams"
|
28
|
-
@qiita = @teams_url
|
29
|
-
@path = "api/v2/items?page=1&per_page=100"
|
30
|
-
else
|
31
|
-
@qiita = "https://qiita.com/"
|
32
|
-
@path = "api/v2/authenticated_user/items?page=1&per_page=100"
|
33
|
-
end
|
34
|
-
end
|
35
|
-
=end
|
36
|
-
|
37
|
-
# access qiita
|
38
|
-
=begin
|
39
|
-
def access_qiita()
|
40
|
-
uri = URI.parse(@qiita + @path)
|
41
|
-
|
42
|
-
headers = { "Authorization" => "Bearer # {@access_token}",
|
43
|
-
"Content-Type" => "application/json" }
|
44
|
-
|
45
|
-
response = URI.open(
|
46
|
-
"# {uri}",
|
47
|
-
"Authorization" => "# {headers["Authorization"]}",
|
48
|
-
)
|
49
|
-
@items = JSON.parse(response.read)
|
50
|
-
end
|
51
|
-
=end
|
52
|
-
|
53
26
|
def view_list()
|
54
27
|
@items.each do |item|
|
55
28
|
puts "title: #{item["title"]}"
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
data/lib/qiita_org/post.rb
CHANGED
@@ -5,15 +5,17 @@ require "json"
|
|
5
5
|
require "command_line/global"
|
6
6
|
require "colorize"
|
7
7
|
require "qiita_org/md_converter_for_image"
|
8
|
-
require "qiita_org/set_config.rb"
|
8
|
+
#require "qiita_org/set_config.rb"
|
9
9
|
require "qiita_org/error_message"
|
10
10
|
require "qiita_org/file_open.rb"
|
11
|
+
require "qiita_org/access_qiita.rb"
|
11
12
|
|
12
13
|
class QiitaPost
|
13
14
|
def initialize(file, option, os)
|
14
15
|
@src = file
|
15
16
|
@option = (option == "qiita" || option == "open")? "public" : option
|
16
17
|
@os = os
|
18
|
+
@base = QiitaBase.new
|
17
19
|
end
|
18
20
|
|
19
21
|
public
|
@@ -64,6 +66,26 @@ class QiitaPost
|
|
64
66
|
return qiita_id, patch
|
65
67
|
end
|
66
68
|
|
69
|
+
def check_change_public(conts, option, id)
|
70
|
+
qiita = "https://qiita.com/"
|
71
|
+
path = "api/v2/items/#{id}"
|
72
|
+
items = AccessQiita.new(@access_token, qiita, path).access_qiita()
|
73
|
+
|
74
|
+
if items["private"]
|
75
|
+
return conts, option
|
76
|
+
else
|
77
|
+
option = "public"
|
78
|
+
lines = File.readlines(@src)
|
79
|
+
file = File.open(@src, "w")
|
80
|
+
lines.each_with_index do |line, i|
|
81
|
+
lines[i] = "#+qiita_#{option}: #{id}\n" if line.match(/\#\+qiita_private: (.+)/)
|
82
|
+
file.print(lines[i])
|
83
|
+
end
|
84
|
+
conts = File.read(@src)
|
85
|
+
return conts, option
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
67
89
|
# check twitter post
|
68
90
|
def select_twitter(conts, option)
|
69
91
|
option == "public" && conts.match?(/^\#\+twitter:\s*on$/i)
|
@@ -146,24 +168,11 @@ class QiitaPost
|
|
146
168
|
end
|
147
169
|
end
|
148
170
|
|
149
|
-
# open qiita
|
150
|
-
=begin
|
151
|
-
def open_qiita()
|
152
|
-
if @os == "mac"
|
153
|
-
system "open # {@res_body["url"]}"
|
154
|
-
elsif @os == "windows"
|
155
|
-
system "explorer.exe # {@res_body["url"]}"
|
156
|
-
else
|
157
|
-
system "open # {@res_body["url"]}"
|
158
|
-
system "xdg-open # {@res_body["url"]}"
|
159
|
-
end
|
160
|
-
end
|
161
|
-
=end
|
162
|
-
|
163
171
|
def run()
|
164
172
|
@conts = File.read(@src)
|
165
173
|
@title, @tags = get_title_tags(@conts)
|
166
|
-
@access_token, @teams_url, @display, @ox_qmd_load_path = SetConfig.new().set_config()
|
174
|
+
# @access_token, @teams_url, @display, @ox_qmd_load_path = SetConfig.new().set_config()
|
175
|
+
@access_token, @teams_url, @display, @ox_qmd_load_path = @base.set_config()
|
167
176
|
|
168
177
|
if @option == "teams"
|
169
178
|
ErrorMessage.new().teams_url_error(@teams_url)
|
@@ -173,6 +182,7 @@ class QiitaPost
|
|
173
182
|
add_source_path_in_md()
|
174
183
|
@lines = MdConverter.new().convert_for_image(@lines)
|
175
184
|
@qiita_id, @patch = select_patch_or_post(@conts, @option)
|
185
|
+
@conts, @option = check_change_public(@conts, @option, @qiita_id) if (@patch and @option == "private")
|
176
186
|
@twitter = select_twitter(@conts, @option)
|
177
187
|
@qiita, @private = select_option(@option)
|
178
188
|
@res = qiita_post()
|
data/lib/qiita_org/upload.rb
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
require "colorize"
|
2
2
|
require "io/console"
|
3
|
-
require "qiita_org/get_file_path.rb"
|
4
|
-
require "qiita_org/show_file_and_url.rb"
|
3
|
+
#require "qiita_org/get_file_path.rb"
|
4
|
+
#require "qiita_org/show_file_and_url.rb"
|
5
5
|
require "qiita_org/file_open.rb"
|
6
|
-
require "qiita_org/set_config.rb"
|
6
|
+
#require "qiita_org/set_config.rb"
|
7
7
|
require "qiita_org/access_qiita.rb"
|
8
8
|
|
9
9
|
class QiitaFileUpLoad
|
@@ -12,7 +12,8 @@ class QiitaFileUpLoad
|
|
12
12
|
@option = (option == "qiita" || option == "open")? "public" : option
|
13
13
|
@os = os
|
14
14
|
@fileopen = FileOpen.new(@os)
|
15
|
-
@access_token, @teams_url, @display, @ox_qmd_load_path = SetConfig.new().set_config()
|
15
|
+
# @access_token, @teams_url, @display, @ox_qmd_load_path = SetConfig.new().set_config()
|
16
|
+
@access_token, @teams_url, @display, @ox_qmd_load_path = QiitaBase.new().set_config()
|
16
17
|
if @option == "teams"
|
17
18
|
ErrorMessage.new().teams_url_error(@teams_url)
|
18
19
|
end
|
@@ -97,7 +98,7 @@ class QiitaFileUpLoad
|
|
97
98
|
|
98
99
|
paths.each do |path|
|
99
100
|
file_name = File.basename(path).strip
|
100
|
-
url = get_file_url(id, file_name)
|
101
|
+
url = (get_file_url(id, file_name))? @file_url : next
|
101
102
|
lines.each_with_index do |line, i|
|
102
103
|
if line.match(/\[\[file:#{path}\]\]/)
|
103
104
|
lines[i] = "[[#{url}][file:#{path}]]\n"
|
@@ -114,7 +115,13 @@ class QiitaFileUpLoad
|
|
114
115
|
|
115
116
|
items = @access.access_qiita()
|
116
117
|
|
117
|
-
|
118
|
-
|
118
|
+
if items["body"].match?(/\!\[#{file_name}\]\(((.+))\)/)
|
119
|
+
@file_url = items["body"].match(/\!\[#{file_name}\]\(((.+))\)/)[2]
|
120
|
+
puts "Wrote #{file_name}'s URL".green
|
121
|
+
return true
|
122
|
+
else
|
123
|
+
puts "Can not find #{file_name}'s URL".red
|
124
|
+
return false
|
125
|
+
end
|
119
126
|
end
|
120
127
|
end
|
data/lib/qiita_org/version.rb
CHANGED
data/tests/test2.org
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
#+qiita_teams: 7e95d62ebdbedd022256
|
2
1
|
#+qiita_private: 6ce39fa8ae7f7a472cf2
|
3
2
|
#+OPTIONS: ^:{}
|
4
3
|
#+STARTUP: indent nolineimages
|
@@ -19,6 +18,6 @@ fogefoge
|
|
19
18
|
#+ATTR_LATEX: :width 8cm
|
20
19
|
[[https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/612049/ebf505d2-6960-6bb9-20f0-e16dab142f4a.png][file:../figs/fig1.png]]
|
21
20
|
|
22
|
-
[[
|
21
|
+
[[file:../figs/fig2.png]]
|
23
22
|
|
24
23
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: qiita_org
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.32
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kenta Yamamoto
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-12-
|
11
|
+
date: 2020-12-09 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -2558,26 +2558,27 @@ files:
|
|
2558
2558
|
- lib/qiita_org/.qiita.conf
|
2559
2559
|
- lib/qiita_org/access_qiita.rb
|
2560
2560
|
- lib/qiita_org/all.rb
|
2561
|
-
- lib/qiita_org/
|
2561
|
+
- lib/qiita_org/base.rb
|
2562
2562
|
- lib/qiita_org/config.json
|
2563
2563
|
- lib/qiita_org/config.rb
|
2564
|
-
- lib/qiita_org/decide_option.rb
|
2565
2564
|
- lib/qiita_org/error_message.rb
|
2566
2565
|
- lib/qiita_org/file_open.rb
|
2567
2566
|
- lib/qiita_org/get.rb
|
2568
|
-
- lib/qiita_org/get_file_path.rb
|
2569
|
-
- lib/qiita_org/get_file_url.rb
|
2570
2567
|
- lib/qiita_org/get_multiple_files.rb
|
2571
2568
|
- lib/qiita_org/get_template.rb
|
2572
2569
|
- lib/qiita_org/hoge.txt
|
2573
2570
|
- lib/qiita_org/list.rb
|
2574
2571
|
- lib/qiita_org/md_converter_for_image.rb
|
2572
|
+
- lib/qiita_org/old_programs/check_pc_os.rb
|
2573
|
+
- lib/qiita_org/old_programs/decide_option.rb
|
2574
|
+
- lib/qiita_org/old_programs/get_file_path.rb
|
2575
|
+
- lib/qiita_org/old_programs/get_file_url.rb
|
2576
|
+
- lib/qiita_org/old_programs/search_conf_path.rb
|
2577
|
+
- lib/qiita_org/old_programs/select_path.rb
|
2578
|
+
- lib/qiita_org/old_programs/set_config.rb
|
2579
|
+
- lib/qiita_org/old_programs/show_file_and_url.rb
|
2575
2580
|
- lib/qiita_org/ox-qmd/ox-qmd.el
|
2576
2581
|
- lib/qiita_org/post.rb
|
2577
|
-
- lib/qiita_org/search_conf_path.rb
|
2578
|
-
- lib/qiita_org/select_path.rb
|
2579
|
-
- lib/qiita_org/set_config.rb
|
2580
|
-
- lib/qiita_org/show_file_and_url.rb
|
2581
2582
|
- lib/qiita_org/template.org
|
2582
2583
|
- lib/qiita_org/upload.rb
|
2583
2584
|
- lib/qiita_org/version.rb
|