cafe_basics 0.0.55 → 0.0.59

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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/lib/cafe_basics.rb +583 -483
  3. metadata +2 -2
data/lib/cafe_basics.rb CHANGED
@@ -22,97 +22,107 @@ using Rainbow
22
22
  include Glimmer
23
23
 
24
24
  class Chat
25
-
26
- def initialize(api_key)
25
+ def initialize(api_key, gpt_keyword_prompt)
27
26
  @api_key = api_key
27
+ @gpt_keyword_prompt = gpt_keyword_prompt
28
28
  end
29
29
 
30
- def message2(keyword)
31
- puts'[GPT] 키워드 기반 글을 생성 중입니다.......'.yellow
32
- url = 'https://api.openai.com/v1/chat/completions'
33
- h = {
34
- 'Content-Type' => 'application/json',
35
- 'Authorization' => 'Bearer ' + @api_key
36
- }
37
- d = {
38
- #'model' => 'gpt-3.5-turbo',
39
- 'model' => 'gpt-4',
40
- 'messages' => [{
41
- "role" => "assistant",
42
- "content" => keyword.to_s+" 소개하는 글을 1500자에서 2500자 사이로 만들어줘"
43
- }]
44
- }
45
- answer = ''
46
- begin
47
- req = HTTP.headers(h).post(url, :json => d)
48
- print(req.to_s)
49
- answer = JSON.parse(req.to_s)['choices'][0]['message']['content']
50
- rescue => e
51
- begin
52
- answer = JSON.parse(req.to_s)['choices'][0]['message']['message']
53
- rescue
30
+ def message(keyword)
31
+ puts 'Sending request to GPT...(키워드 기반 생성 중...)'
54
32
 
33
+ # "키워드 기반 글 생성 중..." 메시지 출력 스레드
34
+ thread = Thread.new do
35
+ while true
36
+ print "▶"
37
+ sleep 3
55
38
  end
56
39
  end
57
40
 
58
-
59
- print('api return ==> ')
60
- puts(answer)
61
-
62
- return answer
63
- end
64
-
65
- def message(keyword)
66
- puts 'chat gpt ...'
67
41
  url = 'https://api.openai.com/v1/chat/completions'
68
- h = {
42
+ headers = {
69
43
  'Content-Type' => 'application/json',
70
44
  'Authorization' => 'Bearer ' + @api_key
71
45
  }
72
- d = {
73
- #'model' => 'gpt-3.5-turbo',
46
+
47
+ # 사용자로부터 받은 입력과 GPT 프롬프트의 토큰 수 계산
48
+ message_tokens = calculate_tokens(keyword) + calculate_tokens(@gpt_keyword_prompt)
49
+
50
+ # 8,192 토큰을 초과하지 않도록 최대 토큰 수를 설정
51
+ max_response_tokens = [8192 - message_tokens, 4000].min # 8,192 - 입력된 토큰 수, 4,000 이하로 설정
52
+
53
+ # 요청 데이터 설정
54
+ data = {
74
55
  'model' => 'gpt-4',
75
- 'messages' => [{
76
- "role" => "assistant",
77
- "content" => keyword.to_s+" 관련된 글을 1500자에서 2500자 사이로 만들어줘"
78
- }]
56
+ 'messages' => [
57
+ {
58
+ "role" => "assistant",
59
+ "content" => "#{keyword}\n#{@gpt_keyword_prompt}"
60
+ }
61
+ ],
62
+ 'max_tokens' => max_response_tokens # 최대 응답 토큰 설정
79
63
  }
64
+
65
+
66
+
80
67
  answer = ''
81
68
  begin
82
- req = HTTP.headers(h).post(url, :json => d)
83
- print(req.to_s)
84
- answer = JSON.parse(req.to_s)['choices'][0]['message']['content']
85
- rescue => e
86
- begin
87
- answer = JSON.parse(req.to_s)['choices'][0]['message']['message']
88
- rescue
69
+ req = HTTP.headers(headers).post(url, :json => data)
89
70
 
71
+ # 상태 코드 확인
72
+ if req.status != 200
73
+ raise "HTTP Error: #{req.status}, Response Body: #{req.body.to_s}"
90
74
  end
91
- end
92
- con = 0
93
- while con > 5
94
- answer = answer + message2(keyword)
95
- if answer.length > 2000
96
- break
75
+
76
+ # 응답 내용 출력 (디버깅용)
77
+ response = JSON.parse(req.to_s)
78
+
79
+
80
+ # 응답 데이터에서 안전하게 값 추출
81
+ if response['choices'] && response['choices'][0] && response['choices'][0]['message']
82
+ answer = response['choices'][0]['message']['content']
83
+ else
84
+ raise "Invalid API response format"
97
85
  end
98
- con += 1
86
+ rescue => e
87
+ # 오류 메시지 출력
88
+ puts "Error occurred: #{e.message}"
89
+ answer = "오류가 발생했습니다."
99
90
  end
100
91
 
101
- print('api return ==> ')
102
- puts(answer)
92
+ # "생성 중..." 메시지 출력 종료
93
+ thread.kill
103
94
 
95
+ # 결과 로그 출력
96
+ puts "Final API response ==> #{answer}"
104
97
  return answer
105
98
  end
99
+
100
+ def calculate_tokens(text)
101
+ # 간단한 방식으로 텍스트의 토큰 수 계산 (정확도는 다를 수 있음)
102
+ # OpenAI API는 1토큰이 대략 4글자 정도임
103
+ text.split(/\s+/).length # 간단한 단어 수로 계산
104
+ end
106
105
  end
107
106
 
107
+
108
+
109
+
110
+
108
111
  class Chat_title
109
-
110
- def initialize(api_key)
112
+ def initialize(api_key, gpt_title_prompt)
111
113
  @api_key = api_key
114
+ @gpt_title_prompt = gpt_title_prompt
112
115
  end
113
116
 
114
117
  def message(title)
115
- puts'[GPT] 유사 제목을 생성 중입니다.......'.yellow
118
+ puts 'Sending request to GPT...(제목 생성 중...)'
119
+ # "키워드 기반 글 생성 중..." 메시지를 별도 스레드로 처리
120
+ thread = Thread.new do
121
+ while true
122
+ print "▶"
123
+ sleep(3)
124
+ end
125
+ end
116
126
  url = 'https://api.openai.com/v1/chat/completions'
117
127
  headers = {
118
128
  'Content-Type' => 'application/json',
@@ -126,15 +136,15 @@ class Chat_title
126
136
  },
127
137
  {
128
138
  "role" => "user",
129
- "content" => "#{title}\n위 문장을 비슷한 길이로 ChatGPT의 멘트는 빼고 표현을 더 추가해서 하나만 만들어줘."
139
+ "content" => "#{@gpt_title_prompt}\n#{title}"
130
140
  }]
131
141
  }
132
142
 
133
143
  begin
134
144
  req = HTTP.headers(headers).post(url, json: data)
135
- puts "HTTP Status: #{req.status}" # 상태 코드 확인
145
+
136
146
  response = JSON.parse(req.body.to_s)
137
- puts "API Response: #{response}" # 전체 응답 출력
147
+
138
148
 
139
149
  if req.status == 429
140
150
  return "API 요청 제한을 초과했습니다. 플랜 및 할당량을 확인하세요."
@@ -142,11 +152,18 @@ class Chat_title
142
152
 
143
153
  # 응답 데이터에서 안전하게 값 추출
144
154
  answer = response.dig('choices', 0, 'message', 'content')
145
- answer ||= (title) # 응답이 없을 경우 기본 메시지 설정
155
+
156
+ # 따옴표 제거
157
+ answer = answer.gsub('"', '') if answer
158
+
159
+ answer ||= title # 응답이 없을 경우 기본 메시지 설정
146
160
  rescue => e
147
161
  puts "Error: #{e.message}"
148
162
  answer = "오류가 발생했습니다."
149
163
  end
164
+
165
+ # "생성 중..." 메시지 출력 종료
166
+ thread.kill
150
167
 
151
168
  puts 'API return ==> '
152
169
  puts answer
@@ -154,14 +171,24 @@ class Chat_title
154
171
  end
155
172
  end
156
173
 
174
+
157
175
  class Chat_content
158
-
159
- def initialize(api_key)
176
+ def initialize(api_key, gpt_content_prompt)
160
177
  @api_key = api_key
178
+ @gpt_content_prompt = gpt_content_prompt
161
179
  end
162
180
 
163
181
  def message(content)
164
- puts'[GPT] 유사 내용을 생성 중입니다! 조금만 기다려주세요.......'.yellow
182
+ puts '주의:GPT 특성상 원고 길이가 공백 포함 4천자를 넘기면 오류가 발생할 수 있습니다.'
183
+ puts 'Sending request to GPT...(내용 변형 중...)'
184
+ # "키워드 기반 글 생성 중..." 메시지를 별도 스레드로 처리
185
+ thread = Thread.new do
186
+ while true
187
+ print "▶"
188
+ sleep(3)
189
+ end
190
+ end
191
+
165
192
  url = 'https://api.openai.com/v1/chat/completions'
166
193
  headers = {
167
194
  'Content-Type' => 'application/json',
@@ -175,15 +202,16 @@ class Chat_content
175
202
  },
176
203
  {
177
204
  "role" => "user",
178
- "content" => "#{content}\nChatGPT의 멘트는 빼고 위 전체적인 내용의 형식을 똑같이 표현을 더 추가하고 유사어로 변경하여 하나 만들어줘! 전화번호,연락처,가격,홈페이지안내 ,상담안내 관련 문구는 유지해야해"
205
+ "content" => "#{@gpt_content_prompt}\n#{content}"
206
+
179
207
  }]
180
208
  }
181
209
 
182
210
  begin
183
211
  req = HTTP.headers(headers).post(url, json: data)
184
- puts "HTTP Status: #{req.status}" # 상태 코드 확인
212
+
185
213
  response = JSON.parse(req.body.to_s)
186
- puts "API Response: #{response}" # 전체 응답 출력
214
+
187
215
 
188
216
  if req.status == 429
189
217
  return "API 요청 제한을 초과했습니다. 플랜 및 할당량을 확인하세요."
@@ -197,6 +225,9 @@ class Chat_content
197
225
  answer = "오류가 발생했습니다."
198
226
  end
199
227
 
228
+ # "생성 중..." 메시지 출력 종료
229
+ thread.kill
230
+
200
231
  puts 'API return ==> '
201
232
  puts answer
202
233
  answer
@@ -204,6 +235,7 @@ class Chat_content
204
235
  end
205
236
 
206
237
 
238
+
207
239
  #############################################gpt############################################
208
240
 
209
241
  class Naver
@@ -214,9 +246,13 @@ class Naver
214
246
  naver_cookie_dir = "C:/naver_cookie"
215
247
  FileUtils.mkdir_p(naver_cookie_dir) unless File.exist?(naver_cookie_dir)
216
248
  if proxy == ''
217
- system(%{"C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe" https://naver.com/ --remote-debugging-port=9222 --user-data-dir=C:/naver_cookie/#{user_id}})
249
+
250
+ system(%{"C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe" https://naver.com/ --remote-debugging-port=9222 --user-data-dir=C:/naver_cookie/#{user_id} --no-first-run --no-default-browser-check --disable-sync})
251
+
218
252
  else
219
- system(%{"C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe" "https://naver.com/" --remote-debugging-port=9222 --user-data-dir=C:/naver_cookie/#{user_id} --proxy-server=#{proxy.to_s.force_encoding('utf-8').to_s}})
253
+
254
+ system(%{"C:\\Program Files\\Google\\Chrome\\Application\\chrome.exe" https://naver.com/ --remote-debugging-port=9222 --user-data-dir=C:/naver_cookie/#{user_id} --proxy-server=#{proxy.to_s.force_encoding('utf-8').to_s} --no-first-run --no-default-browser-check --disable-sync})
255
+
220
256
  end
221
257
  end
222
258
  def chrome_start(proxy, user_id)
@@ -228,6 +264,9 @@ class Naver
228
264
  options = Selenium::WebDriver::Chrome::Options.new
229
265
  options.add_argument('--no-first-run') # 자동 실행 시 나타나는 "첫 실행" 화면 방지
230
266
  options.add_argument('--disable-extensions') # 확장 프로그램 초기화 화면 방지
267
+ options.add_argument('--disable-sync') # Chrome 동기화 비활성화
268
+ options.add_argument('--disable-popup-blocking') # 팝업 방지 (로그인 창이 뜨는 경우 대비)
269
+ options.add_argument('--no-default-browser-check')
231
270
  options.page_load_strategy = :normal
232
271
  options.timeouts = {page_load: 20_000}
233
272
  options.page_load_strategy = 'none'
@@ -253,6 +292,9 @@ class Naver
253
292
  options = Selenium::WebDriver::Chrome::Options.new
254
293
  options.add_argument('--no-first-run') # 자동 실행 시 나타나는 "첫 실행" 화면 방지
255
294
  options.add_argument('--disable-extensions') # 확장 프로그램 초기화 화면 방지
295
+ options.add_argument('--disable-sync') # Chrome 동기화 비활성화
296
+ options.add_argument('--disable-popup-blocking') # 팝업 방지 (로그인 창이 뜨는 경우 대비)
297
+ options.add_argument('--no-default-browser-check')
256
298
  options.add_argument '--proxy-server='+proxy.to_s.force_encoding('utf-8').to_s
257
299
  options.page_load_strategy = :normal
258
300
  options.timeouts = {page_load: 20_000}
@@ -277,6 +319,9 @@ class Naver
277
319
  options = Selenium::WebDriver::Chrome::Options.new
278
320
  options.add_argument('--no-first-run') # 자동 실행 시 나타나는 "첫 실행" 화면 방지
279
321
  options.add_argument('--disable-extensions') # 확장 프로그램 초기화 화면 방지
322
+ options.add_argument('--disable-sync') # Chrome 동기화 비활성화
323
+ options.add_argument('--disable-popup-blocking') # 팝업 방지 (로그인 창이 뜨는 경우 대비)
324
+ options.add_argument('--no-default-browser-check')
280
325
  options.page_load_strategy = :normal
281
326
  options.timeouts = {page_load: 20_000}
282
327
  options.page_load_strategy = 'none'
@@ -301,6 +346,8 @@ class Naver
301
346
 
302
347
 
303
348
 
349
+
350
+
304
351
  def login(user_id, user_pw, proxy)
305
352
  @user_id = user_id
306
353
  @user_id11 = user_id
@@ -339,13 +386,20 @@ class Naver
339
386
  puts'[Step.02] 계정 세션 확인!! 로그인 skip.......'.yellow
340
387
  sleep(2.5)
341
388
  rescue
342
- wait = Selenium::WebDriver::Wait.new(:timeout => 7)
343
- #요소가 나타날 때까지 3초 동안 기다립니다.
344
- wait.until { @driver.find_element(:xpath, '//*[@class="MyView-module__link_login___HpHMW"]') }
345
- sleep(1.5)
346
- @driver.find_element(:xpath, '//*[@class="MyView-module__link_login___HpHMW"]').click
347
- check_cookie_login = 0
348
- sleep(1)
389
+ begin
390
+ wait = Selenium::WebDriver::Wait.new(:timeout => 7)
391
+ # 요소가 나타날 때까지 기다립니다.
392
+ wait.until { @driver.find_element(:xpath, '//*[@class="MyView-module__link_login___HpHMW"]') }
393
+ sleep(1.5)
394
+
395
+ # 요소가 있으면 클릭
396
+ @driver.find_element(:xpath, '//*[@class="MyView-module__link_login___HpHMW"]').click
397
+ check_cookie_login = 0
398
+ sleep(1)
399
+ rescue
400
+ @driver.quit
401
+ return 0
402
+ end
349
403
  end
350
404
 
351
405
  if check_cookie_login == 0
@@ -380,8 +434,9 @@ class Naver
380
434
  puts "Failed to close tab: #{e.message}"
381
435
  end
382
436
  end
383
- return 0
384
437
  @driver.quit
438
+ return 0
439
+
385
440
  end
386
441
 
387
442
  else
@@ -404,8 +459,9 @@ class Naver
404
459
  puts "Failed to close tab: #{e.message}"
405
460
  end
406
461
  end
407
- return 0
408
462
  @driver.quit
463
+ return 0
464
+
409
465
  end
410
466
  end
411
467
 
@@ -731,8 +787,9 @@ class Naver
731
787
  puts "Failed to close tab: #{e.message}"
732
788
  end
733
789
  end
734
- return 0
735
- @driver.quit
790
+ @driver.quit
791
+ return 0
792
+
736
793
  end
737
794
 
738
795
 
@@ -760,8 +817,9 @@ class Naver
760
817
  puts "Failed to close tab: #{e.message}"
761
818
  end
762
819
  end
763
- return 0
764
820
  @driver.quit
821
+ return 0
822
+
765
823
  end
766
824
  sleep(2)
767
825
  @driver.action.key_down(:control).key_down('a').key_up('a').key_up(:control).perform
@@ -2210,7 +2268,15 @@ class Wordpress
2210
2268
  end
2211
2269
 
2212
2270
  if @data['포스트설정']['gpt제목'].checked?
2213
- chat = Chat_title.new(@data['포스트설정']['api_key'].text.to_s.force_encoding('utf-8'))
2271
+ gpt_title_prompt = @data['포스트설정']['gpt제목_프롬프트'].text.to_s.force_encoding('utf-8')
2272
+
2273
+ # 공백을 포함한 빈 문자열을 체크하기 위해 strip을 사용
2274
+ gpt_title_prompt_sample = gpt_title_prompt.strip.empty? ? "프롬프트: 문장을 비슷한 길이로 ChatGPT의 멘트는 빼고 표현을 더 추가해서 하나만 만들어줘." : gpt_title_prompt
2275
+
2276
+ # gpt_title_prompt_sample을 Chat_title 객체에 전달
2277
+ chat = Chat_title.new(@data['포스트설정']['api_key'].text.to_s.force_encoding('utf-8'), gpt_title_prompt_sample)
2278
+
2279
+ # 메시지 요청 후 title에 저장
2214
2280
  gpt_text1 = chat.message(title)
2215
2281
  title = gpt_text1.to_s
2216
2282
  end
@@ -2255,18 +2321,16 @@ class Wordpress
2255
2321
 
2256
2322
 
2257
2323
  if @data['포스트설정']['gpt내용'].checked?
2324
+ gpt_content_prompt = @data['포스트설정']['gpt내용_프롬프트'].text.to_s.force_encoding('utf-8')
2258
2325
  api_key = @data['포스트설정']['api_key'].text.to_s.force_encoding('utf-8')
2259
- #key_change = @data['포스트설정']['특정단어키워드로변경값'].text.to_s.force_encoding('utf-8')
2260
- #imotcon_change = @data['포스트설정']['스티커로변경단어'].text.to_s.force_encoding('utf-8')
2261
- #template_change = @data['포스트설정']['내템플릿변경단어'].text.to_s.force_encoding('utf-8')
2262
- #ttdanar_change = @data['포스트설정']['단어링크적용단어'].text.to_s.force_encoding('utf-8')
2263
- #sajine_change = @data['포스트설정']['단어사진으로변경단어'].text.to_s.force_encoding('utf-8')
2264
- #mov_change = @data['포스트설정']['영상으로변경단어'].text.to_s.force_encoding('utf-8')
2265
- #map_change = @data['포스트설정']['지도로변경단어'].text.to_s.force_encoding('utf-8')
2266
- #inyong9_change = @data['포스트설정']['인용구변경단어'].text.to_s.force_encoding('utf-8')
2267
-
2268
2326
 
2269
- chat = Chat_content.new(api_key)
2327
+ # 공백을 포함한 빈 문자열을 체크하기 위해 strip을 사용
2328
+ gpt_content_prompt_sample = gpt_content_prompt.strip.empty? ? "프롬프트:ChatGPT의 멘트는 빼고 위 전체적인 내용의 형식을 똑같이 표현을 더 추가하고 유사어로 변경하여 하나 만들어줘! 전화번호,연락처,가격,홈페이지안내 ,상담안내 관련 문구는 유지해야해" : gpt_content_prompt
2329
+
2330
+ # Chat_content 객체 생성 시 api_key와 gpt_content_prompt_sample을 두 개의 인자로 전달
2331
+ chat = Chat_content.new(api_key, gpt_content_prompt_sample)
2332
+
2333
+ # 메시지 요청 후 content에 저장
2270
2334
  gpt_text3 = chat.message(content)
2271
2335
  content = gpt_text3.to_s
2272
2336
  end
@@ -2470,13 +2534,17 @@ class Wordpress
2470
2534
  @data['table'] << []
2471
2535
  @data['table'].pop
2472
2536
  if @data['포스트설정']['gpt키워드'].checked?
2473
- chat = Chat.new(@data['포스트설정']['api_key'].text.to_s.force_encoding('utf-8'))
2537
+ gpt_keyword_prompt = @data['포스트설정']['gpt키워드_프롬프트'].text.to_s.force_encoding('utf-8')
2538
+ gpt_keyword_prompt_sample = gpt_keyword_prompt.strip.empty? ? "프롬프트: 관련된 글을 1500자에서 2500자 사이로 만들어줘" : gpt_keyword_prompt
2539
+ chat = Chat.new(@data['포스트설정']['api_key'].text.to_s.force_encoding('utf-8'), gpt_keyword_prompt)
2474
2540
  gpt_text = chat.message(keyword)
2475
- content = content + "\n(자동생성글)\n" + gpt_text
2541
+ #content = content.to_s + "\n(자동생성글)\n" + gpt_text.to_s
2542
+ content = content.to_s + "(자동생성글)" + gpt_text.to_s
2476
2543
  elsif @data['포스트설정']['내용을자동생성'].checked?
2477
2544
  content = auto_text
2478
2545
  elsif @data['포스트설정']['내용과자동생성'].checked?
2479
- content = content + "\n(자동생성글)\n" + auto_text
2546
+ #content = content + "\n(자동생성글)\n" + auto_text
2547
+ content = content + "(자동생성글)" + auto_text
2480
2548
  end
2481
2549
 
2482
2550
  if @data['포스트설정']['내용키워드삽입'].checked?
@@ -2511,7 +2579,8 @@ class Wordpress
2511
2579
  end
2512
2580
 
2513
2581
  if @data['포스트설정']['내용을자동생성'].checked?
2514
- content2 = content.split("\n")
2582
+ #content2 = content.split("\n")
2583
+ content2 = content.split
2515
2584
  end
2516
2585
 
2517
2586
  if @data['포스트설정']['내용과자동생성'].checked? or @data['포스트설정']['gpt키워드'].checked?
@@ -3633,423 +3702,439 @@ class Wordpress
3633
3702
  }
3634
3703
  }
3635
3704
  tab_item('내용설정'){
3705
+ horizontal_box{
3706
+ vertical_box{
3636
3707
  horizontal_box{
3637
- vertical_box{
3638
- horizontal_box{
3639
- stretchy false
3640
- button('키워드불러오기'){
3641
- on_clicked{
3642
- file = open_file
3643
- if file != nil
3644
- file_data = File.open(file, 'r', :encoding => 'utf-8').read()
3645
- file_data.split("\n").each do |keyword|
3646
- if keyword.split(' ').join('').length < 2
3647
-
3648
- else
3649
- @data['키워드설정']['키워드'] << [false, keyword]
3650
- @data['키워드설정']['키워드'] << [false, keyword]
3651
- @data['키워드설정']['키워드'].pop
3652
- end
3653
- end
3654
- end
3655
-
3656
- }
3657
- }
3708
+ stretchy false
3709
+ button('키워드불러오기'){
3710
+ on_clicked{
3711
+ file = open_file
3712
+ if file != nil
3713
+ file_data = File.open(file, 'r', :encoding => 'utf-8').read()
3714
+ file_data.split("\n").each do |keyword|
3715
+ if keyword.split(' ').join('').length < 2
3658
3716
 
3659
- }
3660
- horizontal_box{
3661
- stretchy false
3662
- grid{
3663
- button('전체선택'){
3664
- top 1
3665
- left 1
3666
- on_clicked{
3667
- for n in 0..@data['키워드설정']['키워드'].length-1
3668
- @data['키워드설정']['키워드'][n][0] = true
3669
- @data['키워드설정']['키워드'] << []
3670
- @data['키워드설정']['키워드'].pop
3671
- end
3672
- }
3673
- }
3674
- button('선택해제'){
3675
- top 1
3676
- left 2
3677
- on_clicked{
3678
- for n in 0..@data['키워드설정']['키워드'].length-1
3679
- @data['키워드설정']['키워드'][n][0] = false
3680
- @data['키워드설정']['키워드'] << []
3717
+ else
3718
+ @data['키워드설정']['키워드'] << [false, keyword]
3719
+ @data['키워드설정']['키워드'] << [false, keyword]
3681
3720
  @data['키워드설정']['키워드'].pop
3682
3721
  end
3683
- }
3684
- }
3685
- button('삭제하기'){
3686
- top 1
3687
- left 3
3688
- on_clicked{
3689
- m = Array.new
3690
- for n in 0..@data['키워드설정']['키워드'].length-1
3691
- if @data['키워드설정']['키워드'][n][0] == true
3692
- m << n
3693
- end
3694
- end
3722
+ end
3723
+ end
3695
3724
 
3696
- m.reverse.each do |i|
3697
- @data['키워드설정']['키워드'].delete_at(i)
3698
- end
3699
- @data['키워드설정']['키워드'].delete(nil)
3700
- }
3701
- }
3702
3725
  }
3703
-
3704
- @data['키워드설정']['순서사용'] = checkbox('순서사용'){
3705
- stretchy false
3706
- on_toggled{ |c|
3707
- if c.checked?
3708
- @data['키워드설정']['랜덤사용'].checked = false
3709
- end
3710
- }
3711
- }
3712
- @data['키워드설정']['랜덤사용'] = checkbox('랜덤사용'){
3713
- stretchy false
3714
- on_toggled{ |c|
3715
- if c.checked?
3716
- @data['키워드설정']['순서사용'].checked = false
3717
- end
3718
- }
3719
- }
3726
+ }
3727
+
3728
+ }
3729
+ horizontal_box{
3730
+ stretchy false
3731
+ grid{
3732
+ button('전체선택'){
3733
+ top 1
3734
+ left 1
3735
+ on_clicked{
3736
+ for n in 0..@data['키워드설정']['키워드'].length-1
3737
+ @data['키워드설정']['키워드'][n][0] = true
3738
+ @data['키워드설정']['키워드'] << []
3739
+ @data['키워드설정']['키워드'].pop
3740
+ end
3720
3741
  }
3721
- vertical_separator{
3722
- stretchy false
3742
+ }
3743
+ button('선택해제'){
3744
+ top 1
3745
+ left 2
3746
+ on_clicked{
3747
+ for n in 0..@data['키워드설정']['키워드'].length-1
3748
+ @data['키워드설정']['키워드'][n][0] = false
3749
+ @data['키워드설정']['키워드'] << []
3750
+ @data['키워드설정']['키워드'].pop
3751
+ end
3723
3752
  }
3724
- horizontal_box{
3725
- stretchy false
3726
- grid{
3727
- @data['포스트설정']['gpt키워드'] = checkbox('GPT 키워드 기반 글 생성'){
3728
- top 1
3729
- left 0
3730
- #enabled false # 기본적으로 비활성화
3731
- on_toggled {
3732
- if @data['포스트설정']['gpt키워드'].checked?
3733
- @data['포스트설정']['gpt상단'].enabled = true # '내용투명' 활성화
3734
- @data['포스트설정']['gpt하단'].enabled = true # '내용투명' 활성화
3735
- else
3736
- @data['포스트설정']['gpt상단'].checked = false # 체크 해제
3737
- @data['포스트설정']['gpt상단'].enabled = false # 비활성화
3738
- @data['포스트설정']['gpt하단'].checked = false # 체크 해제
3739
- @data['포스트설정']['gpt하단'].enabled = false # 비활성화
3740
- end
3741
- }
3742
-
3743
- }
3744
-
3745
- @data['포스트설정']['gpt상단'] = checkbox('원고 위에 넣기'){
3746
- top 1
3747
- left 1
3748
- enabled false # 기본적으로 비활성화
3749
- on_toggled{
3750
- if @data['포스트설정']['gpt상단'].checked?
3751
- @data['포스트설정']['gpt하단'].checked = false
3752
- end
3753
- }
3754
- }
3755
-
3756
- @data['포스트설정']['gpt하단'] = checkbox('원고 아래 넣기'){
3757
- top 1
3758
- left 2
3759
- enabled false # 기본적으로 비활성화
3760
- on_toggled{
3761
- if @data['포스트설정']['gpt하단'].checked?
3762
- @data['포스트설정']['gpt상단'].checked = false
3753
+ }
3754
+ button('삭제하기'){
3755
+ top 1
3756
+ left 3
3757
+ on_clicked{
3758
+ m = Array.new
3759
+ for n in 0..@data['키워드설정']['키워드'].length-1
3760
+ if @data['키워드설정']['키워드'][n][0] == true
3761
+ m << n
3763
3762
  end
3764
- }
3765
- }
3766
- } }
3767
- horizontal_box{
3768
- stretchy false
3769
- grid{
3770
- label('※ GPT 기능 사용시 포스트설정1에서 GPT사용에 체크 필수'){
3771
- } } }
3772
-
3773
-
3774
- table{
3775
- checkbox_column('선택'){
3776
- editable true
3777
- }
3778
- text_column('키워드'){
3779
-
3780
- }
3763
+ end
3781
3764
 
3782
- cell_rows @data['키워드설정']['키워드']
3765
+ m.reverse.each do |i|
3766
+ @data['키워드설정']['키워드'].delete_at(i)
3767
+ end
3768
+ @data['키워드설정']['키워드'].delete(nil)
3783
3769
  }
3784
-
3785
-
3786
-
3787
3770
  }
3788
- vertical_separator{
3771
+ }
3772
+
3773
+ @data['키워드설정']['순서사용'] = checkbox('순서사용'){
3789
3774
  stretchy false
3775
+ on_toggled{ |c|
3776
+ if c.checked?
3777
+ @data['키워드설정']['랜덤사용'].checked = false
3778
+ end
3779
+ }
3780
+ }
3781
+ @data['키워드설정']['랜덤사용'] = checkbox('랜덤사용'){
3782
+ stretchy false
3783
+ on_toggled{ |c|
3784
+ if c.checked?
3785
+ @data['키워드설정']['순서사용'].checked = false
3786
+ end
3787
+ }
3788
+ }
3789
+ }
3790
+ vertical_separator{
3791
+ stretchy false
3792
+ }
3793
+ horizontal_box{
3794
+ stretchy false
3795
+ grid{
3796
+ @data['포스트설정']['gpt키워드'] = checkbox('GPT 키워드 기반 글 생성'){
3797
+ top 1
3798
+ left 0
3799
+ #enabled false # 기본적으로 비활성화
3800
+ on_toggled {
3801
+ if @data['포스트설정']['gpt키워드'].checked?
3802
+ @data['포스트설정']['gpt상단'].enabled = true # '내용투명' 활성화
3803
+ @data['포스트설정']['gpt하단'].enabled = true # '내용투명' 활성화
3804
+ else
3805
+ @data['포스트설정']['gpt상단'].checked = false # 체크 해제
3806
+ @data['포스트설정']['gpt상단'].enabled = false # 비활성화
3807
+ @data['포스트설정']['gpt하단'].checked = false # 체크 해제
3808
+ @data['포스트설정']['gpt하단'].enabled = false # 비활성화
3809
+ end
3810
+ }
3811
+
3812
+ }
3813
+
3814
+ @data['포스트설정']['gpt상단'] = checkbox('원고 위에 넣기'){
3815
+ top 1
3816
+ left 1
3817
+ enabled false # 기본적으로 비활성화
3818
+ on_toggled{
3819
+ if @data['포스트설정']['gpt상단'].checked?
3820
+ @data['포스트설정']['gpt하단'].checked = false
3821
+ end
3822
+ }
3790
3823
  }
3791
- vertical_box{
3792
- horizontal_box{
3793
- stretchy false
3794
- button('제목불러오기'){
3795
- on_clicked{
3796
- file = open_file
3797
- if file != nil
3798
- file_data = File.open(file, 'r', :encoding => 'utf-8').read()
3799
- file_data.split("\n").each do |title|
3800
- if title.split(" ").join('').length < 2
3801
-
3802
- else
3803
- @data['제목설정']['제목'] << [false, title]
3804
- @data['제목설정']['제목'] << [false, title]
3805
- @data['제목설정']['제목'].pop
3806
- end
3807
- end
3808
- end
3809
- }
3810
- }
3811
3824
 
3825
+ @data['포스트설정']['gpt하단'] = checkbox('원고 아래 넣기'){
3826
+ top 1
3827
+ left 2
3828
+ enabled false # 기본적으로 비활성화
3829
+ on_toggled{
3830
+ if @data['포스트설정']['gpt하단'].checked?
3831
+ @data['포스트설정']['gpt상단'].checked = false
3832
+ end
3812
3833
  }
3813
- horizontal_box{
3814
- stretchy false
3815
- grid{
3816
- button('전체선택'){
3817
- top 1
3818
- left 1
3819
- on_clicked{
3820
- for n in 0..@data['제목설정']['제목'].length-1
3821
- @data['제목설정']['제목'][n][0] = true
3822
- @data['제목설정']['제목'] << []
3823
- @data['제목설정']['제목'].pop
3824
- end
3825
- }
3826
- }
3827
- button('선택해제'){
3828
- top 1
3829
- left 2
3830
- on_clicked{
3831
- for n in 0..@data['제목설정']['제목'].length-1
3832
- @data['제목설정']['제목'][n][0] = false
3833
- @data['제목설정']['제목'] << []
3834
+ }
3835
+ } }
3836
+ horizontal_box{
3837
+ stretchy false
3838
+ @data['포스트설정']['gpt키워드_프롬프트'] = entry(){
3839
+ text '프롬프트:관련 글을 1500자에서 2500자 사이로 만들어줘'
3840
+ }}
3841
+ horizontal_box{
3842
+ stretchy false
3843
+ grid{
3844
+ label('※ GPT 기능 사용시 포스트설정1에서 GPT사용에 체크 필수'){
3845
+ } } }
3846
+
3847
+
3848
+ table{
3849
+ checkbox_column('선택'){
3850
+ editable true
3851
+ }
3852
+ text_column('키워드'){
3853
+
3854
+ }
3855
+
3856
+ cell_rows @data['키워드설정']['키워드']
3857
+ }
3858
+
3859
+
3860
+
3861
+ }
3862
+ vertical_separator{
3863
+ stretchy false
3864
+ }
3865
+ vertical_box{
3866
+ horizontal_box{
3867
+ stretchy false
3868
+ button('제목불러오기'){
3869
+ on_clicked{
3870
+ file = open_file
3871
+ if file != nil
3872
+ file_data = File.open(file, 'r', :encoding => 'utf-8').read()
3873
+ file_data.split("\n").each do |title|
3874
+ if title.split(" ").join('').length < 2
3875
+
3876
+ else
3877
+ @data['제목설정']['제목'] << [false, title]
3878
+ @data['제목설정']['제목'] << [false, title]
3834
3879
  @data['제목설정']['제목'].pop
3835
3880
  end
3836
- }
3837
- }
3838
- button('삭제하기'){
3839
- top 1
3840
- left 3
3841
- on_clicked{
3842
- m = Array.new
3843
- for n in 0..@data['제목설정']['제목'].length-1
3844
- if @data['제목설정']['제목'][n][0] == true
3845
- m << n
3846
- end
3847
- end
3881
+ end
3882
+ end
3883
+ }
3884
+ }
3848
3885
 
3849
- m.reverse.each do |i|
3850
- @data['제목설정']['제목'].delete_at(i)
3851
- end
3852
- @data['제목설정']['제목'].delete(nil)
3853
- }
3854
- }
3886
+ }
3887
+ horizontal_box{
3888
+ stretchy false
3889
+ grid{
3890
+ button('전체선택'){
3891
+ top 1
3892
+ left 1
3893
+ on_clicked{
3894
+ for n in 0..@data['제목설정']['제목'].length-1
3895
+ @data['제목설정']['제목'][n][0] = true
3896
+ @data['제목설정']['제목'] << []
3897
+ @data['제목설정']['제목'].pop
3898
+ end
3855
3899
  }
3856
- @data['제목설정']['순서사용'] = checkbox('순서사용'){
3857
- stretchy false
3858
- on_toggled{ |c|
3859
- if c.checked?
3860
- @data['제목설정']['랜덤사용'].checked = false
3861
- end
3862
- }
3863
- }
3864
- @data['제목설정']['랜덤사용'] = checkbox('랜덤사용'){
3865
- stretchy false
3866
- on_toggled{ |c|
3867
- if c.checked?
3868
- @data['제목설정']['순서사용'].checked = false
3869
- end
3870
- }
3871
- }
3900
+ }
3901
+ button('선택해제'){
3902
+ top 1
3903
+ left 2
3904
+ on_clicked{
3905
+ for n in 0..@data['제목설정']['제목'].length-1
3906
+ @data['제목설정']['제목'][n][0] = false
3907
+ @data['제목설정']['제목'] << []
3908
+ @data['제목설정']['제목'].pop
3909
+ end
3872
3910
  }
3873
- vertical_separator{
3874
- stretchy false
3911
+ }
3912
+ button('삭제하기'){
3913
+ top 1
3914
+ left 3
3915
+ on_clicked{
3916
+ m = Array.new
3917
+ for n in 0..@data['제목설정']['제목'].length-1
3918
+ if @data['제목설정']['제목'][n][0] == true
3919
+ m << n
3920
+ end
3921
+ end
3922
+
3923
+ m.reverse.each do |i|
3924
+ @data['제목설정']['제목'].delete_at(i)
3925
+ end
3926
+ @data['제목설정']['제목'].delete(nil)
3875
3927
  }
3876
- horizontal_box{
3877
- stretchy false
3878
- grid{
3879
- @data['포스트설정']['gpt제목'] = checkbox('제목을 이용해 GPT로 비슷한 제목 생성'){
3880
-
3881
-
3882
- }}}
3883
- horizontal_box{
3884
- stretchy false
3885
- grid{
3886
- label(' GPT 기능 사용시 포스트설정1에서 GPT사용에 체크 필수'){
3887
- } } }
3888
-
3928
+ }
3929
+ }
3930
+ @data['제목설정']['순서사용'] = checkbox('순서사용'){
3931
+ stretchy false
3932
+ on_toggled{ |c|
3933
+ if c.checked?
3934
+ @data['제목설정']['랜덤사용'].checked = false
3935
+ end
3936
+ }
3937
+ }
3938
+ @data['제목설정']['랜덤사용'] = checkbox('랜덤사용'){
3939
+ stretchy false
3940
+ on_toggled{ |c|
3941
+ if c.checked?
3942
+ @data['제목설정']['순서사용'].checked = false
3943
+ end
3944
+ }
3945
+ }
3946
+ }
3947
+ vertical_separator{
3948
+ stretchy false
3949
+ }
3950
+ horizontal_box{
3951
+ stretchy false
3952
+ grid{
3953
+ @data['포스트설정']['gpt제목'] = checkbox('제목을 이용해 GPT로 비슷한 제목 생성'){
3954
+
3955
+
3956
+ }}}
3957
+ horizontal_box{
3958
+ stretchy false
3959
+ @data['포스트설정']['gpt제목_프롬프트'] = entry(){
3960
+ text '프롬프트:비슷한 길이로 제목으로 사용할수있게 하나만 만들어줘'
3961
+ }}
3962
+ horizontal_box{
3963
+ stretchy false
3964
+ grid{
3965
+ label('※ GPT 기능 사용시 포스트설정1에서 GPT사용에 체크 필수'){
3966
+ } } }
3967
+
3889
3968
 
3890
- table{
3891
- checkbox_column('선택'){
3892
- editable true
3893
- }
3894
- text_column('제목'){
3969
+ table{
3970
+ checkbox_column('선택'){
3971
+ editable true
3972
+ }
3973
+ text_column('제목'){
3895
3974
 
3896
- }
3975
+ }
3897
3976
 
3898
- cell_rows @data['제목설정']['제목']
3899
- }
3900
-
3977
+ cell_rows @data['제목설정']['제목']
3978
+ }
3979
+
3901
3980
 
3981
+ }
3982
+ vertical_separator{
3983
+ stretchy false
3984
+ }
3985
+ vertical_box{
3986
+ horizontal_box{
3987
+ stretchy false
3988
+ button('내용불러오기'){
3989
+ on_clicked{
3990
+ file = open_file
3991
+ if file != nil
3992
+ file_name = file.split("\\")[-1]
3993
+ file_data = File.open(file,'r', :encoding => 'utf-8').read()
3994
+ if file_data.split("\n").length < 2
3995
+ file_data = file_data + "\n"
3996
+ end
3997
+ @data['내용설정']['내용'] << [false, file_name, file_data]
3998
+ @data['내용설정']['내용'] << [false, file_name, file_data]
3999
+ @data['내용설정']['내용'].pop
4000
+ end
4001
+ }
3902
4002
  }
3903
- vertical_separator{
3904
- stretchy false
3905
- }
3906
- vertical_box{
3907
- horizontal_box{
3908
- stretchy false
3909
- button('내용불러오기'){
3910
- on_clicked{
3911
- file = open_file
3912
- if file != nil
3913
- file_name = file.split("\\")[-1]
3914
- file_data = File.open(file,'r', :encoding => 'utf-8').read()
3915
- if file_data.split("\n").length < 2
3916
- file_data = file_data + "\n"
3917
- end
3918
- @data['내용설정']['내용'] << [false, file_name, file_data]
3919
- @data['내용설정']['내용'] << [false, file_name, file_data]
3920
- @data['내용설정']['내용'].pop
3921
- end
3922
- }
3923
- }
3924
4003
 
4004
+ }
4005
+ horizontal_box{
4006
+ stretchy false
4007
+ grid{
4008
+ button('전체선택'){
4009
+ top 1
4010
+ left 1
4011
+ on_clicked{
4012
+ for n in 0..@data['내용설정']['내용'].length-1
4013
+ @data['내용설정']['내용'][n][0] = true
4014
+ @data['내용설정']['내용'] << []
4015
+ @data['내용설정']['내용'].pop
4016
+ end
3925
4017
  }
3926
- horizontal_box{
3927
- stretchy false
3928
- grid{
3929
- button('전체선택'){
3930
- top 1
3931
- left 1
3932
- on_clicked{
3933
- for n in 0..@data['내용설정']['내용'].length-1
3934
- @data['내용설정']['내용'][n][0] = true
3935
- @data['내용설정']['내용'] << []
3936
- @data['내용설정']['내용'].pop
3937
- end
3938
- }
3939
- }
3940
- button('선택해제'){
3941
- top 1
3942
- left 2
3943
- on_clicked{
3944
- for n in 0..@data['내용설정']['내용'].length-1
3945
- @data['내용설정']['내용'][n][0] = false
3946
- @data['내용설정']['내용'] << []
3947
- @data['내용설정']['내용'].pop
3948
- end
3949
- }
3950
- }
3951
- button('삭제하기'){
3952
- top 1
3953
- left 3
3954
- on_clicked{
3955
- m = Array.new
3956
- for n in 0..@data['내용설정']['내용'].length-1
3957
- if @data['내용설정']['내용'][n][0] == true
3958
- m << n
3959
- end
3960
- end
4018
+ }
4019
+ button('선택해제'){
4020
+ top 1
4021
+ left 2
4022
+ on_clicked{
4023
+ for n in 0..@data['내용설정']['내용'].length-1
4024
+ @data['내용설정']['내용'][n][0] = false
4025
+ @data['내용설정']['내용'] << []
4026
+ @data['내용설정']['내용'].pop
4027
+ end
4028
+ }
4029
+ }
4030
+ button('삭제하기'){
4031
+ top 1
4032
+ left 3
4033
+ on_clicked{
4034
+ m = Array.new
4035
+ for n in 0..@data['내용설정']['내용'].length-1
4036
+ if @data['내용설정']['내용'][n][0] == true
4037
+ m << n
4038
+ end
4039
+ end
3961
4040
 
3962
- m.reverse.each do |i|
3963
- @data['내용설정']['내용'].delete_at(i)
3964
- end
3965
- @data['내용설정']['내용'].delete(nil)
3966
- }
3967
- }
4041
+ m.reverse.each do |i|
4042
+ @data['내용설정']['내용'].delete_at(i)
4043
+ end
4044
+ @data['내용설정']['내용'].delete(nil)
3968
4045
  }
3969
- @data['내용설정']['순서사용'] = checkbox('순서사용'){
3970
- stretchy false
3971
- on_toggled{ |c|
3972
- if c.checked?
3973
- @data['내용설정']['랜덤사용'].checked = false
3974
- end
3975
- }
3976
- }
3977
- @data['내용설정']['랜덤사용'] = checkbox('랜덤사용'){
3978
- stretchy false
3979
- on_toggled{ |c|
3980
- if c.checked?
3981
- @data['내용설정']['순서사용'].checked = false
3982
- end
3983
- }
3984
- }
4046
+ }
4047
+ }
4048
+ @data['내용설정']['순서사용'] = checkbox('순서사용'){
4049
+ stretchy false
4050
+ on_toggled{ |c|
4051
+ if c.checked?
4052
+ @data['내용설정']['랜덤사용'].checked = false
4053
+ end
3985
4054
  }
3986
- vertical_separator{
3987
- stretchy false
4055
+ }
4056
+ @data['내용설정']['랜덤사용'] = checkbox('랜덤사용'){
4057
+ stretchy false
4058
+ on_toggled{ |c|
4059
+ if c.checked?
4060
+ @data['내용설정']['순서사용'].checked = false
4061
+ end
3988
4062
  }
3989
- horizontal_box{
3990
- stretchy false
3991
- grid{
3992
- @data['포스트설정']['gpt내용'] = checkbox('내용파일을 이용해 GPT로 글 변형'){
3993
-
3994
-
3995
- }}}
3996
- horizontal_box{
3997
- stretchy false
3998
- grid{
3999
- label('※ GPT 기능 사용시 포스트설정1에서 GPT사용에 체크 필수'){
4000
- } } }
4001
-
4002
- table{
4003
- checkbox_column('선택'){
4004
- editable true
4005
- }
4006
- text_column('내용파일'){
4063
+ }
4064
+ }
4065
+ vertical_separator{
4066
+ stretchy false
4067
+ }
4068
+ horizontal_box{
4069
+ stretchy false
4070
+ grid{
4071
+ @data['포스트설정']['gpt내용'] = checkbox('내용파일을 이용해 GPT로 글 변형'){
4072
+
4073
+
4074
+ }}}
4075
+ horizontal_box{
4076
+ stretchy false
4077
+ @data['포스트설정']['gpt내용_프롬프트'] = entry(){
4078
+ text '프롬프트:동의어,유사어를 이용해 변경해줘'
4079
+ }}
4080
+ horizontal_box{
4081
+ stretchy false
4082
+ grid{
4083
+ label('※ GPT 기능 사용시 포스트설정1에서 GPT사용에 체크 필수'){
4084
+ } } }
4085
+
4086
+ table{
4087
+ checkbox_column('선택'){
4088
+ editable true
4089
+ }
4090
+ text_column('내용파일'){
4007
4091
 
4008
- }
4092
+ }
4009
4093
 
4010
- cell_rows @data['내용설정']['내용']
4011
- }
4094
+ cell_rows @data['내용설정']['내용']
4095
+ }
4012
4096
 
4013
- horizontal_box{
4014
- stretchy false
4015
- @data['이미지설정']['폴더경로2'] = entry{
4016
- stretchy false
4017
- text "내용폴더경로 ex)C:\\내용\\폴더1"
4018
- }
4019
- button('폴더째로 불러오기') {
4020
- on_clicked {
4021
- path = @data['이미지설정']['폴더경로2'].text.to_s.force_encoding('utf-8')
4097
+ horizontal_box{
4098
+ stretchy false
4099
+ @data['이미지설정']['폴더경로2'] = entry{
4100
+ stretchy false
4101
+ text "내용폴더경로 ex)C:\\내용\\폴더1"
4102
+ }
4022
4103
 
4023
- # 경로가 유효한지 확인
4024
- if Dir.exist?(path)
4025
- Dir.entries(path).each do |file|
4026
- if file == '.' or file == '..'
4027
- next
4028
- else
4029
- begin
4030
- # 파일을 열고 내용을 읽어서 추가
4031
- file_data = File.open(path + '/' + file, 'r', encoding: 'utf-8').read
4032
- @data['내용설정']['내용'] << [false, file, file_data]
4033
- rescue => e
4034
- # 파일을 열 수 없는 경우, 오류 메시지 출력
4035
- puts "파일을 열 수 없습니다: #{file}, 오류: #{e.message}"
4036
- end
4037
- end
4038
- end
4104
+ button('폴더째로 불러오기') {
4105
+ on_clicked {
4106
+ path = @data['이미지설정']['폴더경로2'].text.to_s.force_encoding('utf-8')
4039
4107
 
4040
- # 내용 배열에서 마지막 빈 항목 제거
4041
- @data['내용설정']['내용'] << []
4042
- @data['내용설정']['내용'].pop
4108
+ # 경로가 유효한지 확인
4109
+ if Dir.exist?(path)
4110
+ Dir.entries(path).each do |file|
4111
+ if file == '.' or file == '..'
4112
+ next
4043
4113
  else
4044
- # 경로가 유효하지 않을 경우, 오류 메시지 출력
4045
- puts "경로가 존재하지 않습니다: #{path}"
4114
+ begin
4115
+ # 파일을 열고 내용을 읽어서 추가
4116
+ file_data = File.open(path + '/' + file, 'r', encoding: 'utf-8').read
4117
+ @data['내용설정']['내용'] << [false, file, file_data]
4118
+ rescue => e
4119
+ # 파일을 열 수 없는 경우, 오류 메시지 출력
4120
+ puts "파일을 열 수 없습니다: #{file}, 오류: #{e.message}"
4121
+ end
4046
4122
  end
4047
- }
4048
- }
4123
+ end
4124
+
4125
+ # 내용 배열에서 마지막 빈 항목 제거
4126
+ @data['내용설정']['내용'] << []
4127
+ @data['내용설정']['내용'].pop
4128
+ else
4129
+ # 경로가 유효하지 않을 경우, 오류 메시지 출력
4130
+ puts "경로가 존재하지 않습니다: #{path}"
4131
+ end
4049
4132
  }
4050
4133
  }
4051
4134
  }
4052
4135
  }
4136
+ }
4137
+ }
4053
4138
  tab_item('이미지설정'){
4054
4139
  horizontal_box{
4055
4140
  vertical_box{
@@ -4525,7 +4610,7 @@ class Wordpress
4525
4610
  left 1
4526
4611
  text 'URL'
4527
4612
  }
4528
- @data['포스트설정']['내용을자동생성'] = checkbox('키워드기반 생성으로만 등록(GPT사용시 자체 생성)'){
4613
+ @data['포스트설정']['내용을자동생성'] = checkbox('키워드기반 글만 등록(GPT사용시 체크 해제)'){
4529
4614
  top 9
4530
4615
  left 0
4531
4616
  on_toggled{
@@ -4533,31 +4618,46 @@ class Wordpress
4533
4618
  @data['포스트설정']['내용과자동생성'].checked = false
4534
4619
  @data['포스트설정']['내용투명'].checked = false
4535
4620
  @data['포스트설정']['자동글 수식에 입력'].checked = false
4536
-
4621
+
4537
4622
  end
4538
4623
  }
4539
4624
  }
4540
-
4541
-
4625
+ label('※GPT사용시 내용설정 탭에서 설정'){
4626
+ top 9
4627
+ left 1
4628
+ }
4629
+
4630
+ label('※GPT 미 사용시 세팅 권장'){
4631
+ top 9
4632
+ left 3
4633
+ }
4634
+
4542
4635
 
4543
-
4544
4636
  aa1 = 2
4545
- @data['포스트설정']['내용과자동생성'] = checkbox('내용파일+키워드기반 생성 등록(GPT사용시 자체 생성)') {
4637
+ @data['포스트설정']['내용과자동생성'] = checkbox('원고+키워드기반 등록(GPT사용시 체크 해제)') {
4546
4638
  top 10 + aa1
4547
4639
  left 0
4548
4640
  on_toggled {
4549
- if @data['포스트설정']['내용과자동생성'].checked?
4641
+ if @data['포스트설정']['내용과자동생성'].checked?
4550
4642
  @data['포스트설정']['내용을자동생성'].checked = false
4551
4643
  @data['포스트설정']['내용투명'].enabled = true # '내용투명' 활성화
4552
4644
  @data['포스트설정']['자동글 수식에 입력'].enabled = true # '내용투명' 활성화
4553
- else
4645
+ else
4554
4646
  @data['포스트설정']['내용투명'].checked = false # 체크 해제
4555
4647
  @data['포스트설정']['내용투명'].enabled = false # 비활성화
4556
4648
  @data['포스트설정']['자동글 수식에 입력'].checked = false # 체크 해제
4557
4649
  @data['포스트설정']['자동글 수식에 입력'].enabled = false # 비활성화
4558
- end
4650
+ end
4559
4651
  }
4560
- }
4652
+ }
4653
+ label('※GPT사용시 내용설정 탭에서 설정'){
4654
+ top 10 + aa1
4655
+ left 1
4656
+ }
4657
+ label('※GPT 미 사용시 세팅 권장'){
4658
+ top 10 + aa1
4659
+ left 3
4660
+ }
4561
4661
 
4562
4662
  @data['포스트설정']['내용투명'] = checkbox('키워드 기반 자동 생성글 안보이게 처리') {
4563
4663
  top 11 + aa1