qiita_org 0.1.15 → 0.1.16

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 88f0ea4de914134782eac18097c144c9a7d5393c0334bf03ef9f1cdd2374f60e
4
- data.tar.gz: fdd51bf362e3ff8635dcb873fcb9801d10a3124b63921b4dcfae3c572cba4aa5
3
+ metadata.gz: 5486363fde020c10fbd5fa617a3188b0d77596510b83177711026d9a17d13f78
4
+ data.tar.gz: e5f88669168b58df15df34325d0d6083bf4ff743e03d518ffc3bd028658c59da
5
5
  SHA512:
6
- metadata.gz: 65fd2e9345bfbf148e6bbeab986059a3ee07716571e9533da1f491cbc5d12685b120752f7986d557b4bc97778ebf0f0ab904257d99cfc4a3636c83ff85acff0d
7
- data.tar.gz: cb0723fc53febe667ecb933bd1e34a719979e2ff447b8893a10dafbfa7da052cadc8d79b7c768025d17f18fab7f11f44774557331231685efcf801565c9586ba
6
+ metadata.gz: f537c52acfdbb2bcb1d3354b5b69e2ff719ea518e98ddd932e290695ff49c60a7b0403355adcd8f22ab53fb77ba9d3c3000d37a61304e8377c8846ee1c626847
7
+ data.tar.gz: 37658438bf93d3a0ec4a25887e84a0ec525bdf9357621b2ea9330eeaa12228884190100668890eba4b4ae05c2c32ddf8cf20224b931e78b7ad7ddf5944345f31
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- qiita_org (0.1.14)
4
+ qiita_org (0.1.15)
5
5
  colorize
6
6
  command_line (> 2.0.0)
7
7
  fileutils
data/README.md CHANGED
@@ -1,42 +1,199 @@
1
+
2
+
1
3
  # QiitaOrg
2
4
 
3
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file \`lib/qiita\_org\\\`. To experiment with that code, run \`bin/console\` for an interactive prompt.
5
+ \![Mac OS X-10.13.3](<https://img.shields.io/badge/MacOSX-10.13.3-brightgreen>) \![ruby-2.7.0p0](<https://img.shields.io/badge/ruby-2.7.0p0-brightgreen>) \![qiita\_org version](<https://img.shields.io/badge/qiitaorg-0.1.8-brightgreen>)
6
+
7
+
8
+ ## 概要
9
+
10
+ qiita\_orgはqiitaへの投稿にあたって,テキストの作成から投稿までをterminal上で一括で行いたいというコンセプトでできたgemです.
11
+
12
+ emacs org-modeで作成したテキストをCUIでqiitaに投稿します.
13
+
14
+ 注意点:command\_lineを使用しているのでrubyのバージョンは2.4.0以上にしてください.また,emacsのバージョンは26.3以上をお勧めします.
15
+
16
+
17
+ ## 使用例
18
+
19
+ まず,org-modeの投稿用テンプレートを取得します.'qiita template'とコマンドを打ち,環境を書き込むかを決めtemplate.orgを作成します.![img](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/612049/76dc9d92-3a77-5523-7a21-571f691402bb.png)
20
+
21
+ すると,このようなorgが作成されます.![img](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/612049/4a38e62f-9cae-1bf1-ee51-080706c64f6f.png)
22
+
23
+ ここのtitle,tagをqiitaに載せる用のものに変更してあとは従来通り本文を書くだけ.
24
+
25
+ 本文が作成できたら,あとは投稿用のコマンドを実行するだけ.試しに限定共有投稿へ投稿してみるとこんな感じ.![img](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/612049/3f7179f4-e150-7a63-b8ba-e936b925d7be.png)
26
+
27
+ ズラズラーっと出ますが,設定がちゃんとできていれば投稿が完了し,Safariで投稿したページが開きます.
28
+
29
+ 投稿した記事にはSouceとしてどこのディレクトリに元のorgテキストがあるか表示されるので,少し前の記事を編集したい時でも便利なはず...
30
+
31
+
32
+ ## インストール
33
+
34
+ ```bash
35
+ gem install qiita_org
36
+ ```
37
+
38
+ get commandにpandocを使っているのでインストールしてください.macなら
39
+
40
+ ```bash
41
+ brew install pandoc
42
+ ```
43
+
44
+ ubuntuなら
45
+
46
+ ```bash
47
+ sudo apt update
48
+ sudo apt install pandoc
49
+ ```
50
+
51
+
52
+ ## 設定ファイルの作成
53
+
54
+ ```bash
55
+ qiita config global
56
+ ```
57
+
58
+ とし,設定ファイルをホームディレクトリに作成する.
59
+
60
+
61
+ ### Qiitaのアクセストークンの作成方法と設定ファイルへの書き込み
62
+
63
+ [<https://qiita.com/settings/applications>](<https://qiita.com/settings/applications>)にて
64
+
65
+ 個人用アクセストークンの'新しくトークンを発行する'をクリック.![img](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/612049/de93b61e-b42d-8364-7282-ee1bdbd572ad.png)
66
+
67
+ アクセストークンの説明を書き,スコープのところは画像のように全てにチェックを入れる.その後発行をおす.![img](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/612049/7012077d-fba8-e823-d29c-dc93939b4d6b.png)
68
+
69
+ ページが移動すると個人用アクセストークンのところにアクセストークンが表示されているので,コピーしてください.(この文字列はページを移動すると再表示できなくなるので注意してください.)
70
+
71
+ ターミナルに戻り,以下のように実行.
72
+
73
+ ```bash
74
+ qiita config global access_token 'your accesstoken'
75
+ ```
76
+
77
+ 'your accesstoken'のところには先ほどコピーしたアクセストークンをペーストしてください.
78
+
79
+
80
+ ### 名前の登録
81
+
82
+ ```bash
83
+ qiita config global name 'your name'
84
+ ```
85
+
86
+
87
+ ### メールアドレスの登録
88
+
89
+ ```bash
90
+ qiita config global email 'your email'
91
+ ```
92
+
93
+
94
+ ### QiitaTeamURLの登録
95
+
96
+ 'teams'というoptionを使うために必要なので,所属しているQiitaTeamがあるのならこの設定を行なってください.なければ設定しなくて大丈夫です.
97
+
98
+ ```bash
99
+ qiita config global teams_url 'https://foge.qiita.com/'
100
+ ```
101
+
102
+ URLは最後に'/'をつけるのを忘れないように注意してください.
103
+
4
104
 
5
- TODO: Delete this and the text above, and describe your gem
105
+ ### localの設定ファイルを作る方法
6
106
 
7
- ## Installation
107
+ 複数のTeamに所属している場合や,ディレクトリごとにメールアドレスを設定したい場合があればlocalの設定ファイルを指定できます.
8
108
 
9
- Add this line to your application's Gemfile:
109
+ 設定ファイルを作りたいディレクトリにて,
10
110
 
11
- ```ruby
12
- gem 'qiita_org'
111
+ ```bash
112
+ qiita config local set
13
113
  ```
14
114
 
15
- And then execute:
115
+ とし,上記の初期設定のglobalをlocalに変えてそのほかを同じように書き込んでいくとできます.
116
+
117
+
118
+ # コマンド一覧
119
+
120
+ - qiita all
121
+ - qiita config [global/local] [option] [input]
122
+ - qiita get [qiita/teams] [記事のID]
123
+ - qiita list [qiita/teams]
124
+ - qiita post [FILE] [private/public/teams]
125
+ - qiita template
126
+
127
+
128
+ ## qiita all
129
+
130
+ カレントディレクトリ内の全てのorgファイルをqiitaに投稿するコマンドです.
131
+
132
+ orgファイル内にidの記載のあるものは記事の更新,id記載のないものに関しては全て限定共有投稿に投稿されます.
133
+
134
+
135
+ ## qiita config
136
+
137
+ qiita\_orgの設定ファイルの作成と確認を行うコマンドです.
138
+
139
+ 設定方法については上記の通りです.
16
140
 
17
- $ bundle install
18
141
 
19
- Or install it yourself as:
142
+ ## qiita get
20
143
 
21
- $ gem install qiita_org
144
+ Qiitaの記事を取得するためのコマンドです.
22
145
 
23
- ## Usage
24
146
 
25
- TODO: Write usage instructions here
147
+ ## 特定記事の取得方法
26
148
 
27
- ## Development
149
+ qiita get [qiita/teams] [記事のID]
28
150
 
29
- After checking out the repo, run \`bin/setup\` to install dependencies. Then, run \`rake spec\` to run the tests. You can also run \`bin/console\` for an interactive prompt that will allow you to experiment.
151
+ 実行することで指定した記事をid.orgとしてディレクトリ内に作成します.
30
152
 
31
- To install this gem onto your local machine, run \`bundle exec rake install\`. To release a new version, update the version number in \`version.rb\`, and then run \`bundle exec rake release\`, which will create a git tag for the version, push git commits and tags, and push the \`.gem\` file to [rubygems.org](<https://rubygems.org>).
32
153
 
33
- ## Contributing
154
+ ## 複数記事の取得方法
34
155
 
35
- Bug reports and pull requests are welcome on GitHub at <https://github.com/[USERNAME]/qiita_org>.
156
+ 自分のQiitaもしくはQiitaTeamの記事を最新から100個まで表示し取得できます.
36
157
 
37
- ## License
158
+ qiita get [qiita/teams]
159
+
160
+ 実行するとタイトルが表示されるので,保存したければ'y'いらなければ'n'を入力する.終了は'e'
161
+
162
+
163
+ ## qiita list
164
+
165
+ 自分のQiitaもしくはQiitaTeamの記事を最新から100個までterminal上に表示するコマンドです.
166
+
167
+ qiita list [qiita/teams]
168
+
169
+ 実行するとオプションがqiitaならtitle, URL, 記事の元となったorgファイルの場所が表示されます.
170
+
171
+ teamsの方ではさらに誰の記事かが表示されます.
172
+
173
+
174
+ ## qiita post
175
+
176
+ Qiitaにorg-modeで書いたテキストを投稿するためのコマンドです.
177
+
178
+ qiita post [FILE] [private/public/teams]
179
+
180
+ FILEには投稿したいorgファイルを,privateは限定共有投稿,publicは公開記事,teamsはQiitaTeamに投稿されます.
181
+
182
+ 例:
183
+
184
+ ```
185
+ qiita post example.org private
186
+ ```
187
+
188
+ と実行すると限定共有記事にexample.orgの内容が投稿されます.
189
+
190
+
191
+ ## qiita template
192
+
193
+ qiita\_orgで投稿するためのヘッダーがついたorgファイルを取得するコマンドです.
194
+
195
+ カレントディレクトリにtemplate.orgを作成します.すでにtemplate.orgがある場合は作成されません.
38
196
 
39
- The gem is available as open source under the terms of the [MIT License](<https://opensource.org/licenses/MIT>).
40
197
 
41
198
  # future features
42
199
 
@@ -48,4 +205,5 @@ The gem is available as open source under the terms of the [MIT License](<https:
48
205
  - giita config => configを表示
49
206
 
50
207
  - cui, 変数名を適切に選ぶ,teams\_path -> teams\_url
51
- - qiita getの実装,
208
+ - qiita getの実装,
209
+
data/README.org CHANGED
@@ -11,46 +11,175 @@
11
11
 
12
12
 
13
13
  * QiitaOrg
14
+ ![Mac OS X-10.13.3](https://img.shields.io/badge/MacOSX-10.13.3-brightgreen) ![ruby-2.7.0p0](https://img.shields.io/badge/ruby-2.7.0p0-brightgreen) ![qiita_org version](https://img.shields.io/badge/qiitaorg-0.1.8-brightgreen)
15
+ ** 概要
16
+ qiita_orgはqiitaへの投稿にあたって,テキストの作成から投稿までを
17
+ terminal上で一括で行いたいというコンセプトでできたgemです.
14
18
 
15
- Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/qiita_org`. To experiment with that code, run `bin/console` for an interactive prompt.
19
+ emacs org-modeで作成したテキストをCUIでqiitaに投稿します.
16
20
 
17
- TODO: Delete this and the text above, and describe your gem
21
+ 注意点:command_lineを使用しているのでrubyのバージョンは2.4.0以上にしてください.
22
+ また,emacsのバージョンは26.3以上をお勧めします.
23
+ ** 使用例
18
24
 
19
- ** Installation
25
+ まず,org-modeの投稿用テンプレートを取得します.
26
+ 'qiita template'とコマンドを打ち,環境を書き込むかを決めtemplate.orgを作成します.
27
+ https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/612049/76dc9d92-3a77-5523-7a21-571f691402bb.png
20
28
 
21
- Add this line to your application's Gemfile:
29
+ すると,このようなorgが作成されます.
30
+ https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/612049/4a38e62f-9cae-1bf1-ee51-080706c64f6f.png
22
31
 
23
- #+begin_src ruby
24
- gem 'qiita_org'
32
+ ここのtitle,tagをqiitaに載せる用のものに変更してあとは従来通り本文を書くだけ.
33
+
34
+ 本文が作成できたら,あとは投稿用のコマンドを実行するだけ.
35
+ 試しに限定共有投稿へ投稿してみるとこんな感じ.
36
+ https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/612049/3f7179f4-e150-7a63-b8ba-e936b925d7be.png
37
+
38
+ ズラズラーっと出ますが,設定がちゃんとできていれば投稿が完了し,
39
+ Safariで投稿したページが開きます.
40
+
41
+ 投稿した記事にはSouceとしてどこのディレクトリに元のorgテキストがあるか
42
+ 表示されるので,少し前の記事を編集したい時でも便利なはず...
43
+
44
+ ** インストール
45
+ #+begin_src bash
46
+ gem install qiita_org
47
+ #+end_src
48
+
49
+ get commandにpandocを使っているのでインストールしてください.
50
+ macなら
51
+ #+begin_src bash
52
+ brew install pandoc
53
+ #+end_src
54
+
55
+ ubuntuなら
56
+ #+begin_src bash
57
+ sudo apt update
58
+ sudo apt install pandoc
59
+ #+end_src
60
+ ** 設定ファイルの作成
61
+ #+begin_src bash
62
+ qiita config global
25
63
  #+end_src
26
64
 
27
- And then execute:
65
+ とし,設定ファイルをホームディレクトリに作成する.
28
66
 
29
- : $ bundle install
67
+ *** Qiitaのアクセストークンの作成方法と設定ファイルへの書き込み
68
+ [https://qiita.com/settings/applications](https://qiita.com/settings/applications)にて
30
69
 
31
- Or install it yourself as:
70
+ 個人用アクセストークンの'新しくトークンを発行する'をクリック.
71
+ https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/612049/de93b61e-b42d-8364-7282-ee1bdbd572ad.png
32
72
 
33
- : $ gem install qiita_org
73
+ アクセストークンの説明を書き,スコープのところは画像のように全てにチェックを入れる.その後発行をおす.
74
+ https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/612049/7012077d-fba8-e823-d29c-dc93939b4d6b.png
34
75
 
35
- ** Usage
76
+ ページが移動すると個人用アクセストークンのところにアクセストークンが表示されているので,
77
+ コピーしてください.(この文字列はページを移動すると再表示できなくなるので注意してください.)
36
78
 
37
- TODO: Write usage instructions here
79
+ ターミナルに戻り,以下のように実行.
80
+ #+begin_src bash
81
+ qiita config global access_token 'your accesstoken'
82
+ #+end_src
83
+ 'your accesstoken'のところには先ほどコピーしたアクセストークンをペーストしてください.
38
84
 
39
- ** Development
85
+ *** 名前の登録
86
+ #+begin_src bash
87
+ qiita config global name 'your name'
88
+ #+end_src
40
89
 
41
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
90
+ *** メールアドレスの登録
91
+ #+begin_src bash
92
+ qiita config global email 'your email'
93
+ #+end_src
42
94
 
43
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
95
+ *** QiitaTeamURLの登録
96
+ 'teams'というoptionを使うために必要なので,
97
+ 所属しているQiitaTeamがあるのならこの設定を行なってください.
98
+ なければ設定しなくて大丈夫です.
99
+
100
+ #+begin_src bash
101
+ qiita config global teams_url 'https://foge.qiita.com/'
102
+ #+end_src
103
+
104
+ URLは最後に'/'をつけるのを忘れないように注意してください.
105
+
106
+ *** localの設定ファイルを作る方法
107
+ 複数のTeamに所属している場合や,ディレクトリごとにメールアドレスを設定したい場合が
108
+ あればlocalの設定ファイルを指定できます.
109
+
110
+ 設定ファイルを作りたいディレクトリにて,
111
+ #+begin_src bash
112
+ qiita config local set
113
+ #+end_src
44
114
 
45
- ** Contributing
115
+ とし,上記の初期設定のglobalをlocalに変えて
116
+ そのほかを同じように書き込んでいくとできます.
117
+ * コマンド一覧
118
+ - qiita all
119
+ - qiita config [global/local] [option] [input]
120
+ - qiita get [qiita/teams] [記事のID]
121
+ - qiita list [qiita/teams]
122
+ - qiita post [FILE] [private/public/teams]
123
+ - qiita template
46
124
 
47
- Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/qiita_org.
125
+ ** qiita all
126
+ カレントディレクトリ内の全てのorgファイルをqiitaに投稿するコマンドです.
48
127
 
128
+ orgファイル内にidの記載のあるものは記事の更新,id記載のないものに関しては
129
+ 全て限定共有投稿に投稿されます.
130
+
131
+ ** qiita config
132
+ qiita_orgの設定ファイルの作成と確認を行うコマンドです.
133
+
134
+ 設定方法については上記の通りです.
135
+
136
+ ** qiita get
137
+ Qiitaの記事を取得するためのコマンドです.
138
+
139
+ ** 特定記事の取得方法
140
+ qiita get [qiita/teams] [記事のID]
141
+
142
+ 実行することで指定した記事をid.orgとしてディレクトリ内に作成します.
143
+
144
+ ** 複数記事の取得方法
145
+ 自分のQiitaもしくはQiitaTeamの記事を最新から100個まで表示し取得できます.
146
+
147
+ qiita get [qiita/teams]
148
+
149
+ 実行するとタイトルが表示されるので,保存したければ'y'いらなければ'n'を入力する.
150
+ 終了は'e'
151
+
152
+ ** qiita list
153
+ 自分のQiitaもしくはQiitaTeamの記事を最新から100個まで
154
+ terminal上に表示するコマンドです.
155
+
156
+ qiita list [qiita/teams]
157
+
158
+ 実行するとオプションがqiitaならtitle, URL, 記事の元となったorgファイルの場所
159
+ が表示されます.
160
+
161
+ teamsの方ではさらに誰の記事かが表示されます.
162
+
163
+ ** qiita post
164
+ Qiitaにorg-modeで書いたテキストを投稿するためのコマンドです.
165
+
166
+ qiita post [FILE] [private/public/teams]
167
+
168
+ FILEには投稿したいorgファイルを,
169
+ privateは限定共有投稿,publicは公開記事,teamsはQiitaTeamに投稿されます.
170
+
171
+ 例:
172
+ #+begin_src
173
+ qiita post example.org private
174
+ #+end_src
49
175
 
50
- ** License
176
+ と実行すると限定共有記事にexample.orgの内容が投稿されます.
51
177
 
52
- The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
178
+ ** qiita template
179
+ qiita_orgで投稿するためのヘッダーがついたorgファイルを取得するコマンドです.
53
180
 
181
+ カレントディレクトリにtemplate.orgを作成します.
182
+ すでにtemplate.orgがある場合は作成されません.
54
183
  * future features
55
184
  - qiita post => refactoring
56
185
 
Binary file
Binary file
Binary file
Binary file
Binary file
@@ -1,6 +1,7 @@
1
1
  # -*- coding: utf-8 -*-
2
2
  require "thor"
3
3
  require "colorize"
4
+ require "io/console"
4
5
  require "qiita_org/version"
5
6
  require "qiita_org/post"
6
7
  require "qiita_org/config"
@@ -8,7 +9,8 @@ require "qiita_org/get"
8
9
  require "qiita_org/list"
9
10
  require "qiita_org/get_template"
10
11
  require "qiita_org/check_pc_os"
11
- require "qiita_org/version"
12
+ require "qiita_org/get_file_path"
13
+ require "qiita_org/show_file_and_url"
12
14
  #require "qiita_org/qiita_org_thor"
13
15
 
14
16
  module QiitaOrg
@@ -45,6 +47,21 @@ module QiitaOrg
45
47
  else
46
48
  qiita.run
47
49
  end
50
+
51
+ =begin
52
+ getpath = GetFilePath.new(file)
53
+ paths = getpath.get_file_path()
54
+ unless paths.empty?
55
+ showfile = ShowFile.new(paths, file, mode)
56
+ showfile.open_file_dir()
57
+ puts "Do you show file URL? (y/n)".green
58
+ ans = STDIN.getch
59
+
60
+ if ans == "y"
61
+ showfile.show_file_url()
62
+ end
63
+ end
64
+ =end
48
65
  end
49
66
 
50
67
  desc "config [global/local] [option] [input]", "set config"
@@ -0,0 +1,23 @@
1
+ class GetFilePath
2
+ def initialize(src)
3
+ @src = src
4
+ end
5
+
6
+ def get_file_path()
7
+ lines = File.readlines(@src.gsub(".org", ".md"))
8
+ files = []
9
+ lines.each do |line|
10
+ if path2 = line.match(/\!\[img\]\(((.+))"(.+)"\)/)
11
+ files << path2[2]
12
+ end
13
+ end
14
+
15
+ paths = []
16
+ files.each do |file|
17
+ paths << File.join(Dir.pwd, file)
18
+ end
19
+ return paths
20
+ end
21
+ end
22
+
23
+ #GetFilePath.new("thesis.org")
@@ -0,0 +1,50 @@
1
+ require "net/https"
2
+ require "json"
3
+ require "open-uri"
4
+ require "io/console"
5
+ require "colorize"
6
+ require "qiita_org/search_conf_path.rb"
7
+
8
+ class GetFileUrl
9
+ def initialize(id, file, mode)
10
+ @id = id
11
+ @file = file
12
+ @mode = (mode == "qiita" || mode == "open")? "public" : mode
13
+ search = SearchConfPath.new(Dir.pwd, Dir.home)
14
+ @conf_dir = search.search_conf_path()
15
+ set_config()
16
+ end
17
+
18
+ def set_config()
19
+ conf_path = File.join(@conf_dir, ".qiita.conf")
20
+ @conf = JSON.load(File.read(conf_path))
21
+ @access_token = @conf["access_token"]
22
+ @teams_url = @conf["teams_url"]
23
+ end
24
+
25
+ def get_file_url()
26
+ qiita = (@mode == "teams")? @teams_url : "https://qiita.com/"
27
+ path = "api/v2/items/#{@id}"
28
+
29
+ items = access_qiita(@access_token, qiita, path)
30
+
31
+ file_url = items["body"].match(/\!\[#{@file}\]\(((.+))\)/)[2]
32
+ return file_url
33
+
34
+ #File.write("url_text.md", items["body"])
35
+ end
36
+
37
+ def access_qiita(access_token, qiita, path)
38
+ uri = URI.parse(qiita + path)
39
+
40
+ headers = { "Authorization" => "Bearer #{access_token}",
41
+ "Content-Type" => "application/json" }
42
+
43
+ response = URI.open(
44
+ "#{uri}",
45
+ "Authorization" => "#{headers["Authorization"]}",
46
+ )
47
+ items = JSON.parse(response.read)
48
+ return items
49
+ end
50
+ end
@@ -19,19 +19,19 @@ class QiitaPost
19
19
  public
20
20
  def get_title_tags()
21
21
  @conts = File.read(@src)
22
- @title = @conts.match(/\#\+(TITLE|title|Title): (.+)/)[2] || "テスト"
23
- m = []
22
+ m = @conts.match(/\#\+(TITLE|title|Title): (.+)/)
23
+ @title = m ? m[2] : "テスト"
24
24
  @tags = if m = @conts.match(/\#\+(TAG|tag|Tag|tags|TAGS|Tags): (.+)/)
25
- if m[2].count(",") >= 5
26
- puts "The maximum number of tag is five. Please delete some tags.".red
27
- exit
28
- end
29
- m[2].split(",").inject([]) do |l, c|
30
- l << { name: c.strip } #, versions: []}
31
- end
32
- else
33
- [{ name: "hoge" }] #, versions: [] }]
34
- end
25
+ if m[2].count(",") >= 5
26
+ puts "The maximum number of tag is five. Please delete some tags.".red
27
+ exit
28
+ end
29
+ m[2].split(",").inject([]) do |l, c|
30
+ l << { name: c.strip } #, versions: []}
31
+ end
32
+ else
33
+ [{ name: "hoge" }] #, versions: [] }]
34
+ end
35
35
  p @tags
36
36
  end
37
37
 
@@ -0,0 +1,36 @@
1
+ require "colorize"
2
+ require "qiita_org/get_file_url.rb"
3
+
4
+ class ShowFile
5
+ def initialize(paths, src, mode)
6
+ @paths = paths
7
+ @src = src
8
+ @mode = (mode == "qiita" || mode == "open")? "public" : mode
9
+ end
10
+
11
+ def open_file_dir()
12
+ previous_paths = []
13
+ previous_paths << File.join(@paths[0].split("/")[0..-2])
14
+ system "open #{File.join(@paths[0].split("/")[0..-2])}"
15
+ @paths.each do |path|
16
+ dir_path = File.join(path.split("/")[0..-2])
17
+ unless previous_paths.include?(dir_path)
18
+ previous_paths << dir_path
19
+ system "open #{dir_path}"
20
+ end
21
+ end
22
+ end
23
+
24
+ def show_file_url()
25
+ conts = File.read(@src)
26
+ id = conts.match(/\#\+qiita_#{@mode}: (.+)/)[1]
27
+
28
+ @paths.each do |path|
29
+ file_name = File.basename(path).strip
30
+ geturl = GetFileUrl.new(id, file_name, @mode)
31
+ url = geturl.get_file_url()
32
+ puts "#{file_name}'s URL".green
33
+ puts url
34
+ end
35
+ end
36
+ end
@@ -1,3 +1,3 @@
1
1
  module QiitaOrg
2
- VERSION = "0.1.15"
2
+ VERSION = "0.1.16"
3
3
  end
data/test.md ADDED
@@ -0,0 +1,8 @@
1
+ \![Mac OS X-10.13.3](<https://img.shields.io/badge/MacOSX-10.13.3-brightgreen>) \![ruby-2.7.0p0](<https://img.shields.io/badge/ruby-2.7.0p0-brightgreen>)
2
+
3
+ fogefoge
4
+
5
+ [![img](figs/fig1.png)](https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/612049/a3b2ab02-f903-f5d6-d8b9-5407e8db5a2a.png)
6
+
7
+ ![img](figs/fig0.png)
8
+
@@ -0,0 +1,22 @@
1
+ #+qiita_private: 5f8c73e8007e52ef3f40
2
+ #+OPTIONS: ^:{}
3
+ #+STARTUP: indent nolineimages
4
+ #+TITLE: test
5
+ #+AUTHOR: Kenta Yamamoto
6
+ #+EMAIL: (concat "doi35077@kwansei.ac.jp")
7
+ #+LANGUAGE: jp
8
+ # +OPTIONS: H:4 toc:t num:2
9
+ #+OPTIONS: toc:nil
10
+ #+TAG: test
11
+ # +SETUPFILE: ~/.emacs.d/org-mode/theme-readtheorg.setup
12
+
13
+ ![Mac OS X-10.13.3](https://img.shields.io/badge/MacOSX-10.13.3-brightgreen) ![ruby-2.7.0p0](https://img.shields.io/badge/ruby-2.7.0p0-brightgreen)
14
+
15
+ fogefoge
16
+ # +caption: example qiita template command
17
+ # +name: fig:fig1
18
+ #+ATTR_LATEX: :width 8cm
19
+ [[https://qiita-image-store.s3.ap-northeast-1.amazonaws.com/0/612049/a3b2ab02-f903-f5d6-d8b9-5407e8db5a2a.png][file:figs/fig1.png]]
20
+
21
+ file:figs/fig0.png
22
+
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.15
4
+ version: 0.1.16
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-10-15 00:00:00.000000000 Z
11
+ date: 2020-10-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -510,6 +510,11 @@ files:
510
510
  - bin/setup
511
511
  - exe/qiita
512
512
  - exe/qiita_org
513
+ - figs/fig1.png
514
+ - figs/fig2.png
515
+ - figs/fig3.png
516
+ - figs/fig4.png
517
+ - figs/fig5.png
513
518
  - gems/ruby/2.7.0/bin/htmldiff
514
519
  - gems/ruby/2.7.0/bin/ldiff
515
520
  - gems/ruby/2.7.0/bin/qiita
@@ -957,15 +962,20 @@ files:
957
962
  - lib/qiita_org/config.json
958
963
  - lib/qiita_org/config.rb
959
964
  - lib/qiita_org/get.rb
965
+ - lib/qiita_org/get_file_path.rb
966
+ - lib/qiita_org/get_file_url.rb
960
967
  - lib/qiita_org/get_template.rb
961
968
  - lib/qiita_org/hoge.txt
962
969
  - lib/qiita_org/list.rb
963
970
  - lib/qiita_org/ox-qmd/ox-qmd.el
964
971
  - lib/qiita_org/post.rb
965
972
  - lib/qiita_org/search_conf_path.rb
973
+ - lib/qiita_org/show_file_and_url.rb
966
974
  - lib/qiita_org/template.org
967
975
  - lib/qiita_org/version.rb
968
976
  - qiita_org.gemspec
977
+ - test.md
978
+ - test.org
969
979
  homepage: https://github.com/yamatoken/qiita_org
970
980
  licenses:
971
981
  - MIT