qiita_org 0.1.5 → 0.1.10
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 +8 -1
- data/lib/qiita_org/check_pc_os.rb +19 -0
- data/lib/qiita_org/config.rb +2 -2
- data/lib/qiita_org/get.rb +4 -1
- data/lib/qiita_org/get_template.rb +4 -1
- data/lib/qiita_org/list.rb +4 -1
- data/lib/qiita_org/ox-qmd/ox-qmd.el +313 -0
- data/lib/qiita_org/post.rb +16 -4
- data/lib/qiita_org/version.rb +1 -1
- metadata +7 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0dd6537ee44be13e6ee3cec336a5d6eaae6aee8422c80493a4b0255f4a19dcf6
|
4
|
+
data.tar.gz: e029336e5fb678e8737db77bedfba19b1045f2c2d142159f8a6424e885744dd2
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6a3a7b0ad871ab96a269c37504bfd500710a1c114ee6c43b9a68deff5bf4849bcd2ac76bb7f2852f3f4829d4e5c70242ba0442997f82f6e8674f75c968748e11
|
7
|
+
data.tar.gz: 3653eedd40df01ed28f68756a4c094cb2a71e5ba87ab11bd81e4a353dd11abc21b25c5273c6695561f14d0f9aa2948164fa80832259f76c248fd6815b1747d4c
|
data/Gemfile.lock
CHANGED
data/lib/qiita_org.rb
CHANGED
@@ -6,6 +6,7 @@ require "qiita_org/config"
|
|
6
6
|
require "qiita_org/get"
|
7
7
|
require "qiita_org/list"
|
8
8
|
require "qiita_org/get_template"
|
9
|
+
require "qiita_org/check_pc_os"
|
9
10
|
#require "qiita_org/qiita_org_thor"
|
10
11
|
|
11
12
|
module QiitaOrg
|
@@ -14,6 +15,11 @@ module QiitaOrg
|
|
14
15
|
# super(*argv)
|
15
16
|
# end
|
16
17
|
#
|
18
|
+
def initialize(*argv)
|
19
|
+
super(*argv)
|
20
|
+
@checkos = CheckPcOs.new
|
21
|
+
end
|
22
|
+
|
17
23
|
desc "say_hello", "say_hello"
|
18
24
|
|
19
25
|
def say_hello(*name)
|
@@ -24,10 +30,11 @@ module QiitaOrg
|
|
24
30
|
desc "post", "post to qiita from org"
|
25
31
|
|
26
32
|
def post(*argv)
|
33
|
+
os = @checkos.return_os()
|
27
34
|
p ["in qiita_org.rb", argv]
|
28
35
|
p file = argv[0] || "README.org"
|
29
36
|
p mode = argv[1] || "private"
|
30
|
-
qiita = QiitaPost.new(file, mode)
|
37
|
+
qiita = QiitaPost.new(file, mode, os)
|
31
38
|
begin
|
32
39
|
qiita.select_option(mode)
|
33
40
|
rescue RuntimeError => e
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class CheckPcOs
|
2
|
+
def initialize()
|
3
|
+
@macos = system "sw_vers"
|
4
|
+
@winos = system "wmic.exe os get caption"
|
5
|
+
end
|
6
|
+
|
7
|
+
def return_os()
|
8
|
+
if @macos
|
9
|
+
return os = "mac"
|
10
|
+
elsif @winos
|
11
|
+
return os = "windows"
|
12
|
+
else
|
13
|
+
return nil
|
14
|
+
end
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
#p os = CheckPcOs.new.return_os()
|
19
|
+
|
data/lib/qiita_org/config.rb
CHANGED
@@ -9,7 +9,7 @@ class QiitaConfig
|
|
9
9
|
if status == "local"
|
10
10
|
search = SearchConfPath.new(Dir.pwd, Dir.home)
|
11
11
|
conf_dir = search.search_conf_path()
|
12
|
-
if conf_dir == Dir.home
|
12
|
+
if conf_dir == Dir.home || @option == "set"
|
13
13
|
@setup = File.join(Dir.pwd, ".qiita.conf")
|
14
14
|
else
|
15
15
|
@setup = File.join(conf_dir, ".qiita.conf")
|
@@ -56,7 +56,7 @@ class QiitaConfig
|
|
56
56
|
end
|
57
57
|
|
58
58
|
def run()
|
59
|
-
if @option == nil
|
59
|
+
if @option == nil || @option == "set"
|
60
60
|
check_or_copy_config()
|
61
61
|
else
|
62
62
|
set_config()
|
data/lib/qiita_org/get.rb
CHANGED
@@ -3,16 +3,19 @@ require "json"
|
|
3
3
|
require "open-uri"
|
4
4
|
require "io/console"
|
5
5
|
require "colorize"
|
6
|
+
require "qiita_org/search_conf_path.rb"
|
6
7
|
|
7
8
|
class QiitaGet
|
8
9
|
def initialize(mode, id)
|
9
10
|
@mode = mode
|
10
11
|
@get_id = id
|
12
|
+
search = SearchConfPath.new(Dir.pwd, Dir.home)
|
13
|
+
@conf_dir = search.search_conf_path()
|
11
14
|
end
|
12
15
|
|
13
16
|
# set config
|
14
17
|
def set_config()
|
15
|
-
conf_path = File.join(
|
18
|
+
conf_path = File.join(@conf_dir, ".qiita.conf")
|
16
19
|
conf = JSON.load(File.read(conf_path))
|
17
20
|
@access_token = conf["access_token"]
|
18
21
|
@teams_url = conf["teams_url"]
|
@@ -1,9 +1,12 @@
|
|
1
1
|
require "fileutils"
|
2
2
|
require "colorize"
|
3
|
+
require "qiita_org/search_conf_path"
|
3
4
|
|
4
5
|
class QiitaGetTemplate
|
5
6
|
def initialize()
|
6
7
|
cp_template()
|
8
|
+
search = SearchConfPath.new(Dir.pwd, Dir.home)
|
9
|
+
@conf_dir = search.search_conf_path()
|
7
10
|
set_name_and_email()
|
8
11
|
# check_write_header()
|
9
12
|
check_write_contents()
|
@@ -83,7 +86,7 @@ class QiitaGetTemplate
|
|
83
86
|
end
|
84
87
|
|
85
88
|
def set_name_and_email()
|
86
|
-
conf_path = File.join(
|
89
|
+
conf_path = File.join(@conf_dir, ".qiita.conf")
|
87
90
|
conf = JSON.load(File.read(conf_path))
|
88
91
|
name = conf["name"]
|
89
92
|
email = conf["email"]
|
data/lib/qiita_org/list.rb
CHANGED
@@ -2,10 +2,13 @@ require "net/https"
|
|
2
2
|
require "json"
|
3
3
|
require "open-uri"
|
4
4
|
require "colorize"
|
5
|
+
require "qiita_org/search_conf_path.rb"
|
5
6
|
|
6
7
|
class QiitaList
|
7
8
|
def initialize(mode)
|
8
9
|
@mode = mode
|
10
|
+
search = SearchConfPath.new(Dir.pwd, Dir.home)
|
11
|
+
@conf_dir = search.search_conf_path()
|
9
12
|
set_config()
|
10
13
|
select_path()
|
11
14
|
access_qiita()
|
@@ -13,7 +16,7 @@ class QiitaList
|
|
13
16
|
end
|
14
17
|
|
15
18
|
def set_config()
|
16
|
-
conf_path = File.join(
|
19
|
+
conf_path = File.join(@conf_dir, ".qiita.conf")
|
17
20
|
conf = JSON.load(File.read(conf_path))
|
18
21
|
@access_token = conf["access_token"]
|
19
22
|
@teams_url = conf["teams_url"]
|
@@ -0,0 +1,313 @@
|
|
1
|
+
;;; ox-qmd.el --- Qiita Markdown Back-End for Org Export Engine
|
2
|
+
|
3
|
+
;; Copyright (C) 2015-2020 0x60DF
|
4
|
+
|
5
|
+
;; Author: 0x60DF <0x60DF@gmail.com>
|
6
|
+
;; URL: https://github.com/0x60df/ox-qmd
|
7
|
+
;; Version: 1.0.5
|
8
|
+
;; Package-Requires: ((org "8.0"))
|
9
|
+
;; Keywords: wp
|
10
|
+
|
11
|
+
;; This file is not part of GNU Emacs.
|
12
|
+
|
13
|
+
;; This program is free software: you can redistribute it and/or modify
|
14
|
+
;; it under the terms of the GNU General Public License as published by
|
15
|
+
;; the Free Software Foundation, either version 3 of the License, or
|
16
|
+
;; (at your option) any later version.
|
17
|
+
|
18
|
+
;; This program is distributed in the hope that it will be useful,
|
19
|
+
;; but WITHOUT ANY WARRANTY; without even the implied warranty of
|
20
|
+
;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
21
|
+
;; GNU General Public License for more details.
|
22
|
+
|
23
|
+
;; You should have received a copy of the GNU General Public License
|
24
|
+
;; along with this program. If not, see <http://www.gnu.org/licenses/>.
|
25
|
+
|
26
|
+
;;; Commentary:
|
27
|
+
|
28
|
+
;; This library implements a Markdown back-end (qiita flavor) for
|
29
|
+
;; Org exporter, based on `md' back-end and `gfm' back-end.
|
30
|
+
|
31
|
+
;; See http://orgmode.org/ for infomation about Org-mode and `md' back-end.
|
32
|
+
;; See http://github.com/larstvei/ox-gfm for information about `gfm' back-end.
|
33
|
+
|
34
|
+
;;; Code:
|
35
|
+
|
36
|
+
(require 'ox-md)
|
37
|
+
|
38
|
+
|
39
|
+
;;; User-Configurable Variables
|
40
|
+
|
41
|
+
(defvar ox-qmd-language-keyword-alist '(("emacs-lisp" . "el")))
|
42
|
+
(defvar ox-qmd-unfill-paragraph t)
|
43
|
+
|
44
|
+
|
45
|
+
|
46
|
+
;;; Define Back-End
|
47
|
+
|
48
|
+
(org-export-define-derived-backend 'qmd 'md
|
49
|
+
:filters-alist '((:filter-paragraph . org-qmd--unfill-paragraph))
|
50
|
+
:menu-entry
|
51
|
+
'(?9 "Export to Qiita Markdown"
|
52
|
+
((?0 "To temporary buffer"
|
53
|
+
(lambda (a s v b) (org-qmd-export-as-markdown a s v)))
|
54
|
+
(?9 "To file" (lambda (a s v b) (org-qmd-export-to-markdown a s v)))
|
55
|
+
(?o "To file and open"
|
56
|
+
(lambda (a s v b)
|
57
|
+
(if a (org-qmd-export-to-markdown t s v)
|
58
|
+
(org-open-file (org-qmd-export-to-markdown nil s v)))))
|
59
|
+
(?s "To temporary buffer from subtree"
|
60
|
+
(lambda (a s v b) (org-qmd-export-as-markdown a t v)))))
|
61
|
+
:translate-alist '((headline . org-qmd--headline)
|
62
|
+
(inner-template . org-qmd--inner-template)
|
63
|
+
(keyword . org--qmd-keyword)
|
64
|
+
(strike-through . org-qmd--strike-through)
|
65
|
+
(underline . org-qmd--undeline)
|
66
|
+
(src-block . org-qmd--src-block)
|
67
|
+
(latex-fragment . org-qmd--latex-fragment)
|
68
|
+
(latex-environment . org-qmd--latex-environment)
|
69
|
+
(table . org-qmd--table)))
|
70
|
+
|
71
|
+
|
72
|
+
|
73
|
+
;;; Filters
|
74
|
+
|
75
|
+
(defun org-qmd--unfill-paragraph (paragraph backend info)
|
76
|
+
"Unfill PARAGRAPH element.
|
77
|
+
Remove newline from PARAGRAPH and replace line-break string
|
78
|
+
with newline in PARAGRAPH if user-configurable variable
|
79
|
+
`ox-qmd-unfill-paragraph' is non-nil."
|
80
|
+
(if (and (org-export-derived-backend-p backend 'qmd)
|
81
|
+
ox-qmd-unfill-paragraph)
|
82
|
+
(concat (replace-regexp-in-string
|
83
|
+
" \n" "\n" (replace-regexp-in-string
|
84
|
+
"\\([^ ][^ ]\\|[^ ] \\| [^ ]\\)\n" "\\1" paragraph))
|
85
|
+
"\n")
|
86
|
+
paragraph))
|
87
|
+
|
88
|
+
|
89
|
+
|
90
|
+
;;; Transcode Functions
|
91
|
+
|
92
|
+
(defun org-qmd--headline (headline contents info)
|
93
|
+
"Transcode HEADLINE element into Qiita Markdown format.
|
94
|
+
CONTENTS is a content of the HEADLINE. INFO is a plist used
|
95
|
+
as a communication channel."
|
96
|
+
(let* ((info (copy-sequence info))
|
97
|
+
(info (plist-put info :with-toc nil)))
|
98
|
+
(org-md-headline headline contents info)))
|
99
|
+
|
100
|
+
|
101
|
+
(defun org-qmd--inner-template (contents info)
|
102
|
+
"Return body of document after converting it to Qiita Markdown syntax.
|
103
|
+
CONTENTS is the transcoded contents string. INFO is a plist
|
104
|
+
holding export options."
|
105
|
+
(let* ((info (copy-sequence info))
|
106
|
+
(info (plist-put info :with-toc nil)))
|
107
|
+
(org-md-inner-template contents info)))
|
108
|
+
|
109
|
+
|
110
|
+
(defun org-qmd--keyword (keyword contents info)
|
111
|
+
"Transcode a KEYWORD element into Qiita Markdown format.
|
112
|
+
CONTENTS is nil. INFO is a plist used as a communication
|
113
|
+
channel."
|
114
|
+
(let* ((info (copy-sequence info))
|
115
|
+
(info (plist-put info :with-toc nil)))
|
116
|
+
(org-html-keyword keyword contents info)))
|
117
|
+
|
118
|
+
|
119
|
+
(defun org-qmd--src-block (src-block contents info)
|
120
|
+
"Transcode SRC-BLOCK element into Qiita Markdown format.
|
121
|
+
CONTENTS is nil. INFO is a plist used as a communication
|
122
|
+
channel."
|
123
|
+
(let* ((lang (org-element-property :language src-block))
|
124
|
+
(lang (or (cdr (assoc lang ox-qmd-language-keyword-alist)) lang))
|
125
|
+
(name (org-element-property :name src-block))
|
126
|
+
(code (org-export-format-code-default src-block info))
|
127
|
+
(prefix (concat "```" lang (if name (concat ":" name) nil) "\n"))
|
128
|
+
(suffix "```"))
|
129
|
+
(concat prefix code suffix)))
|
130
|
+
|
131
|
+
|
132
|
+
(defun org-qmd--strike-through (strike-through contents info)
|
133
|
+
"Transcode STRIKE-THROUGH element into Qiita Markdown format.
|
134
|
+
CONTENTS is a content of the STRIKE-THROUGH. INFO is a plist
|
135
|
+
used as a communication channel."
|
136
|
+
(format "~~%s~~" contents))
|
137
|
+
|
138
|
+
|
139
|
+
(defun org-qmd--undeline (underline contents info)
|
140
|
+
"Transcode UNDERLINE element into Qiita Markdown format.
|
141
|
+
CONTENTS is a content of the UNDELINE. INFO is a plist used
|
142
|
+
as a communication channel."
|
143
|
+
contents)
|
144
|
+
|
145
|
+
|
146
|
+
(defun org-qmd--latex-fragment (latex-fragment contents info)
|
147
|
+
"Transcode a LATEX-FRAGMENT element into Qiita Markdown format.
|
148
|
+
CONTENTS is nil. INFO is a plist used as a communication
|
149
|
+
channel."
|
150
|
+
(replace-regexp-in-string
|
151
|
+
"^\\\\(\\(.+\\)\\\\)$" "$\\1$"
|
152
|
+
(replace-regexp-in-string
|
153
|
+
"^\\\\\\[\\(.+\\)\\\\\\]$" "$$\\1$$"
|
154
|
+
(let* ((info (copy-sequence info))
|
155
|
+
(info (plist-put info :with-latex 'verbatim)))
|
156
|
+
(org-html-latex-fragment latex-fragment contents info)))))
|
157
|
+
|
158
|
+
|
159
|
+
(defun org-qmd--latex-environment (latex-environment contents info)
|
160
|
+
"Transcode a LATEX-ENVIRONMENT element into Qiita Markdown format.
|
161
|
+
CONTENTS is nil. INFO is a plist used as a communication
|
162
|
+
channel."
|
163
|
+
(replace-regexp-in-string
|
164
|
+
"^.*?\\\\begin{.+}.*?$" "```math"
|
165
|
+
(replace-regexp-in-string
|
166
|
+
"^.*?\\\\end{.+}.*?$" "```"
|
167
|
+
(let* ((info (copy-sequence info))
|
168
|
+
(info (plist-put info :with-latex 'verbatim)))
|
169
|
+
(org-html-latex-environment latex-environment contents info)))))
|
170
|
+
|
171
|
+
|
172
|
+
(defun org-qmd--table (table contents info)
|
173
|
+
"Transcode a TABLE element into Qiita Markdown format.
|
174
|
+
CONTENTS is a content of the table. INFO is a plist used as
|
175
|
+
a communication channel."
|
176
|
+
(letrec ((filter (lambda (p l)
|
177
|
+
(cond ((null l) l)
|
178
|
+
((funcall p (car l)) (funcall filter p (cdr l)))
|
179
|
+
(t (cons (car l) (funcall filter p (cdr l)))))))
|
180
|
+
(zip (lambda (&rest l)
|
181
|
+
(cond ((null (car l)) (car l))
|
182
|
+
(t (cons (mapcar 'car l)
|
183
|
+
(apply zip (mapcar 'cdr l))))))))
|
184
|
+
(let* ((rows (org-element-map table 'table-row 'identity info))
|
185
|
+
(non-rule-rows
|
186
|
+
(funcall filter (lambda (row)
|
187
|
+
(eq 'rule (org-element-property :type row)))
|
188
|
+
rows))
|
189
|
+
(alignments (org-element-map (car non-rule-rows) 'table-cell
|
190
|
+
(lambda (cell)
|
191
|
+
(org-export-table-cell-alignment cell info))
|
192
|
+
info))
|
193
|
+
(widths (mapcar
|
194
|
+
(lambda (column)
|
195
|
+
(let ((max-difference
|
196
|
+
(apply
|
197
|
+
'max (mapcar
|
198
|
+
(lambda (cell)
|
199
|
+
(- (org-element-property :end cell)
|
200
|
+
(org-element-property :begin cell)))
|
201
|
+
column))))
|
202
|
+
(if (< max-difference 4) 3 (- max-difference 1))))
|
203
|
+
(apply
|
204
|
+
zip (mapcar
|
205
|
+
(lambda (row)
|
206
|
+
(org-element-map row 'table-cell 'identity info))
|
207
|
+
non-rule-rows))))
|
208
|
+
(joined-rows
|
209
|
+
(mapcar (lambda (row)
|
210
|
+
(let ((cells
|
211
|
+
(org-element-map row 'table-cell 'identity info)))
|
212
|
+
(mapconcat
|
213
|
+
(lambda (tuple)
|
214
|
+
(let ((alignment (car tuple))
|
215
|
+
(width (cadr tuple))
|
216
|
+
(cell (caddr tuple)))
|
217
|
+
(format (format " %%-%ds" (- width 1))
|
218
|
+
(or (org-export-data
|
219
|
+
(org-element-contents cell)
|
220
|
+
info)
|
221
|
+
""))))
|
222
|
+
(funcall zip alignments widths cells)
|
223
|
+
"|")))
|
224
|
+
non-rule-rows))
|
225
|
+
(joined-rows-with-delimiter-row
|
226
|
+
(cons (car joined-rows)
|
227
|
+
(cons (mapconcat
|
228
|
+
(lambda (tuple)
|
229
|
+
(let ((alignment (car tuple))
|
230
|
+
(width (cadr tuple)))
|
231
|
+
(format "%s%s%s"
|
232
|
+
(if (memq alignment '(left center))
|
233
|
+
":" "-")
|
234
|
+
(make-string (- width 2) ?-)
|
235
|
+
(if (memq alignment '(right center))
|
236
|
+
":" "-"))))
|
237
|
+
(funcall zip alignments widths)
|
238
|
+
"|")
|
239
|
+
(cdr joined-rows)))))
|
240
|
+
(mapconcat (lambda (row) (format "|%s|" row))
|
241
|
+
joined-rows-with-delimiter-row
|
242
|
+
"\n"))))
|
243
|
+
|
244
|
+
|
245
|
+
|
246
|
+
;;; Interactive function
|
247
|
+
|
248
|
+
;;;###autoload
|
249
|
+
(defun org-qmd-export-as-markdown (&optional async subtreep visible-only)
|
250
|
+
"Export current buffer to a Qiita Markdown buffer.
|
251
|
+
|
252
|
+
If narrowing is active in the current buffer, only export
|
253
|
+
its narrowed part.
|
254
|
+
|
255
|
+
If a region is active, export that region.
|
256
|
+
|
257
|
+
A non-nil optional argument ASYNC means the process should
|
258
|
+
happen asynchronously. The resulting buffer should be
|
259
|
+
accessible through the `org-export-stack' interface.
|
260
|
+
|
261
|
+
When optional argument SUBTREEP is non-nil, export the
|
262
|
+
sub-tree at point, extracting information from the headline
|
263
|
+
properties first.
|
264
|
+
|
265
|
+
When optional argument VISIBLE-ONLY is non-nil, don't export
|
266
|
+
contents of hidden elements.
|
267
|
+
|
268
|
+
Export is done in a buffer named \"*Org QMD Export*\", which
|
269
|
+
will be displayed when
|
270
|
+
`org-export-show-temporary-export-buffer' is non-nil."
|
271
|
+
(interactive)
|
272
|
+
(org-export-to-buffer 'qmd "*Org QMD Export*"
|
273
|
+
async subtreep visible-only nil nil (lambda () (text-mode))))
|
274
|
+
|
275
|
+
;;;###autoload
|
276
|
+
(defun org-qmd-convert-region-to-md ()
|
277
|
+
"Convert region into Qiita Markdown format.
|
278
|
+
Assume the current region has org-mode syntax, and convert
|
279
|
+
it to Qiita Markdown. This can be used in any buffer. For
|
280
|
+
example, you can write an itemized list in org-mode syntax
|
281
|
+
in a Markdown buffer and use this command to convert it."
|
282
|
+
(interactive)
|
283
|
+
(org-export-replace-region-by 'qmd))
|
284
|
+
|
285
|
+
|
286
|
+
;;;###autoload
|
287
|
+
(defun org-qmd-export-to-markdown (&optional async subtreep visible-only)
|
288
|
+
"Export current buffer to a Qiita Markdown file.
|
289
|
+
|
290
|
+
If narrowing is active in the current buffer, only export
|
291
|
+
its narrowed part.
|
292
|
+
|
293
|
+
If a region is active, export that region.
|
294
|
+
|
295
|
+
A non-nil optional argument ASYNC means the process should
|
296
|
+
happen asynchronously. The resulting file should be
|
297
|
+
accessible through the `org-export-stack' interface.
|
298
|
+
|
299
|
+
When optional argument SUBTREEP is non-nil, export the
|
300
|
+
sub-tree at point, extracting information from the headline
|
301
|
+
properties first.
|
302
|
+
|
303
|
+
When optional argument VISIBLE-ONLY is non-nil, don't export
|
304
|
+
contents of hidden elements.
|
305
|
+
|
306
|
+
Return output file's name."
|
307
|
+
(interactive)
|
308
|
+
(let ((outfile (org-export-output-file-name ".md" subtreep)))
|
309
|
+
(org-export-to-file 'qmd outfile async subtreep visible-only)))
|
310
|
+
|
311
|
+
(provide 'ox-qmd)
|
312
|
+
|
313
|
+
;;; ox-qmd.el ends here
|
data/lib/qiita_org/post.rb
CHANGED
@@ -7,9 +7,10 @@ require "colorize"
|
|
7
7
|
require "qiita_org/search_conf_path.rb"
|
8
8
|
|
9
9
|
class QiitaPost
|
10
|
-
def initialize(file, option)
|
10
|
+
def initialize(file, option, os)
|
11
11
|
@src = file
|
12
12
|
@option = (option == "qiita" || option == "open")? "public" : option
|
13
|
+
@os = os
|
13
14
|
search = SearchConfPath.new(Dir.pwd, Dir.home)
|
14
15
|
@conf_dir = search.search_conf_path()
|
15
16
|
p @conf_dir
|
@@ -39,7 +40,8 @@ class QiitaPost
|
|
39
40
|
@conf = JSON.load(File.read(conf_path))
|
40
41
|
@access_token = @conf["access_token"]
|
41
42
|
@teams_url = @conf["teams_url"]
|
42
|
-
|
43
|
+
lib = File.expand_path("../../../lib", __FILE__)
|
44
|
+
@ox_qmd_load_path = File.join(lib, "qiita_org", "ox-qmd", "ox-qmd") # @conf["ox_qmd_load_path"]
|
43
45
|
end
|
44
46
|
|
45
47
|
# src.org -> src.md
|
@@ -136,6 +138,17 @@ class QiitaPost
|
|
136
138
|
end
|
137
139
|
end
|
138
140
|
|
141
|
+
# open qiita
|
142
|
+
def open_qiita()
|
143
|
+
if @os == "mac"
|
144
|
+
system "open #{@res_body["url"]}"
|
145
|
+
elsif @os == "windows"
|
146
|
+
system "explorer.exe #{@res_body["url"]}"
|
147
|
+
else
|
148
|
+
system "open #{@res_body["url"]}"
|
149
|
+
end
|
150
|
+
end
|
151
|
+
|
139
152
|
def run()
|
140
153
|
get_title_tags()
|
141
154
|
set_config()
|
@@ -146,8 +159,7 @@ class QiitaPost
|
|
146
159
|
qiita_post()
|
147
160
|
get_and_print_qiita_return()
|
148
161
|
|
149
|
-
|
150
|
-
system "open #{@res_body["url"]}"
|
162
|
+
open_qiita()
|
151
163
|
|
152
164
|
add_qiita_id_on_org()
|
153
165
|
end
|
data/lib/qiita_org/version.rb
CHANGED
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.10
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Kenta Yamamoto
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2020-
|
11
|
+
date: 2020-10-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -953,12 +953,14 @@ files:
|
|
953
953
|
- hoge.rb
|
954
954
|
- lib/qiita_org.rb
|
955
955
|
- lib/qiita_org/.qiita.conf
|
956
|
+
- lib/qiita_org/check_pc_os.rb
|
956
957
|
- lib/qiita_org/config.json
|
957
958
|
- lib/qiita_org/config.rb
|
958
959
|
- lib/qiita_org/get.rb
|
959
960
|
- lib/qiita_org/get_template.rb
|
960
961
|
- lib/qiita_org/hoge.txt
|
961
962
|
- lib/qiita_org/list.rb
|
963
|
+
- lib/qiita_org/ox-qmd/ox-qmd.el
|
962
964
|
- lib/qiita_org/post.rb
|
963
965
|
- lib/qiita_org/search_conf_path.rb
|
964
966
|
- lib/qiita_org/template.org
|
@@ -968,7 +970,7 @@ homepage: https://github.com/yamatoken/qiita_org
|
|
968
970
|
licenses:
|
969
971
|
- MIT
|
970
972
|
metadata: {}
|
971
|
-
post_install_message:
|
973
|
+
post_install_message:
|
972
974
|
rdoc_options: []
|
973
975
|
require_paths:
|
974
976
|
- lib
|
@@ -984,7 +986,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
984
986
|
version: '0'
|
985
987
|
requirements: []
|
986
988
|
rubygems_version: 3.1.4
|
987
|
-
signing_key:
|
989
|
+
signing_key:
|
988
990
|
specification_version: 4
|
989
991
|
summary: this is qiita post gem from org.
|
990
992
|
test_files: []
|