qiita_org 0.1.4 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/qiita_org.rb +4 -3
- data/lib/qiita_org/config.rb +14 -4
- 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 +10 -4
- data/lib/qiita_org/search_conf_path.rb +18 -0
- 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: 9e7a075ad1c16002e53fff794d556f9ce5bb2c6e7d5e37768a37a8deb59f28e9
|
4
|
+
data.tar.gz: aad3df025127c3e87d3ccb71a262f28083904d63b12e7371cea4c80cf68ecdf1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c4e4645899b5b8ef3cf84b4203b911d3cdc3da1cf3f58d67cc1ca8d64b06f95ada184fe7491102c69fd9d75da91346db01f734ad384fcbac492a9169d81238cf
|
7
|
+
data.tar.gz: 72dcab368ce64937c26ed77e89d25face880d71cff3ac9ff5e2797dcdb78023d4d5e6be1a747813426a3851ad6f2a9b9edd7d3bffa9bd4156e8962763b039a48
|
data/Gemfile.lock
CHANGED
data/lib/qiita_org.rb
CHANGED
@@ -40,9 +40,10 @@ module QiitaOrg
|
|
40
40
|
desc "config", "set config"
|
41
41
|
|
42
42
|
def config(*argv)
|
43
|
-
|
44
|
-
|
45
|
-
|
43
|
+
status = argv[0] || "local"
|
44
|
+
option = argv[1] || nil
|
45
|
+
input = [argv[2], argv[3], argv[4]]
|
46
|
+
config = QiitaConfig.new(status, option, input)
|
46
47
|
config.run
|
47
48
|
end
|
48
49
|
|
data/lib/qiita_org/config.rb
CHANGED
@@ -3,10 +3,20 @@ require "fileutils"
|
|
3
3
|
require "json"
|
4
4
|
|
5
5
|
class QiitaConfig
|
6
|
-
def initialize(option, input)
|
6
|
+
def initialize(status, option, input)
|
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()
|
12
|
+
if conf_dir == Dir.home || @option == "set"
|
13
|
+
@setup = File.join(Dir.pwd, ".qiita.conf")
|
14
|
+
else
|
15
|
+
@setup = File.join(conf_dir, ".qiita.conf")
|
16
|
+
end
|
17
|
+
else
|
18
|
+
@setup = File.join(Dir.home, ".qiita.conf")
|
19
|
+
end
|
10
20
|
end
|
11
21
|
|
12
22
|
# check qiita.conf or copy qiita.conf
|
@@ -14,7 +24,7 @@ class QiitaConfig
|
|
14
24
|
lib = File.expand_path("../../../lib", __FILE__)
|
15
25
|
cp_file = File.join(lib, "qiita_org", ".qiita.conf")
|
16
26
|
|
17
|
-
if File.exists?("#{ENV["HOME"]}/.qiita.conf")
|
27
|
+
if File.exists?(@setup) # "# {ENV["HOME"]}/.qiita.conf")
|
18
28
|
puts @setup.green
|
19
29
|
print_config("now", "black")
|
20
30
|
else
|
@@ -46,7 +56,7 @@ class QiitaConfig
|
|
46
56
|
end
|
47
57
|
|
48
58
|
def run()
|
49
|
-
if @option == nil
|
59
|
+
if @option == nil || @option == "set"
|
50
60
|
check_or_copy_config()
|
51
61
|
else
|
52
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
@@ -4,11 +4,15 @@ require "net/https"
|
|
4
4
|
require "json"
|
5
5
|
require "command_line/global"
|
6
6
|
require "colorize"
|
7
|
+
require "qiita_org/search_conf_path.rb"
|
7
8
|
|
8
9
|
class QiitaPost
|
9
10
|
def initialize(file, option)
|
10
11
|
@src = file
|
11
12
|
@option = (option == "qiita" || option == "open")? "public" : option
|
13
|
+
search = SearchConfPath.new(Dir.pwd, Dir.home)
|
14
|
+
@conf_dir = search.search_conf_path()
|
15
|
+
p @conf_dir
|
12
16
|
end
|
13
17
|
|
14
18
|
public
|
@@ -31,11 +35,12 @@ class QiitaPost
|
|
31
35
|
end
|
32
36
|
|
33
37
|
def set_config()
|
34
|
-
conf_path = File.join(
|
38
|
+
conf_path = File.join(@conf_dir, ".qiita.conf")
|
35
39
|
@conf = JSON.load(File.read(conf_path))
|
36
40
|
@access_token = @conf["access_token"]
|
37
41
|
@teams_url = @conf["teams_url"]
|
38
|
-
|
42
|
+
lib = File.expand_path("../../../lib", __FILE__)
|
43
|
+
@ox_qmd_load_path = File.join(lib, "qiita_org", "ox-qmd", "ox-qmd") # @conf["ox_qmd_load_path"]
|
39
44
|
end
|
40
45
|
|
41
46
|
# src.org -> src.md
|
@@ -65,8 +70,9 @@ class QiitaPost
|
|
65
70
|
end
|
66
71
|
|
67
72
|
def select_option(option)
|
68
|
-
qiita = (option == "teams")? "https://
|
69
|
-
|
73
|
+
qiita = (option == "teams")? @teams_url : "https://qiita.com/"
|
74
|
+
#qiita = (option == "teams")? "https://nishitani.qiita.com/" :
|
75
|
+
# "https://qiita.com/"
|
70
76
|
case option
|
71
77
|
when "teams", "qiita", "public", "open"
|
72
78
|
private = false
|
@@ -0,0 +1,18 @@
|
|
1
|
+
class SearchConfPath
|
2
|
+
def initialize(dir, home)
|
3
|
+
@dir = dir
|
4
|
+
@home = home
|
5
|
+
search_conf_path()
|
6
|
+
end
|
7
|
+
|
8
|
+
def search_conf_path()
|
9
|
+
while @dir != @home
|
10
|
+
if File.exists?(File.join(@dir, ".qiita.conf"))
|
11
|
+
return @dir
|
12
|
+
else
|
13
|
+
@dir = @dir.match(/(.+)\//)[1]
|
14
|
+
end
|
15
|
+
end
|
16
|
+
return @dir
|
17
|
+
end
|
18
|
+
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.9
|
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
|
@@ -959,7 +959,9 @@ files:
|
|
959
959
|
- lib/qiita_org/get_template.rb
|
960
960
|
- lib/qiita_org/hoge.txt
|
961
961
|
- lib/qiita_org/list.rb
|
962
|
+
- lib/qiita_org/ox-qmd/ox-qmd.el
|
962
963
|
- lib/qiita_org/post.rb
|
964
|
+
- lib/qiita_org/search_conf_path.rb
|
963
965
|
- lib/qiita_org/template.org
|
964
966
|
- lib/qiita_org/version.rb
|
965
967
|
- qiita_org.gemspec
|
@@ -967,7 +969,7 @@ homepage: https://github.com/yamatoken/qiita_org
|
|
967
969
|
licenses:
|
968
970
|
- MIT
|
969
971
|
metadata: {}
|
970
|
-
post_install_message:
|
972
|
+
post_install_message:
|
971
973
|
rdoc_options: []
|
972
974
|
require_paths:
|
973
975
|
- lib
|
@@ -983,7 +985,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
983
985
|
version: '0'
|
984
986
|
requirements: []
|
985
987
|
rubygems_version: 3.1.4
|
986
|
-
signing_key:
|
988
|
+
signing_key:
|
987
989
|
specification_version: 4
|
988
990
|
summary: this is qiita post gem from org.
|
989
991
|
test_files: []
|