cafe_basics_duo 0.1.30 → 0.1.35

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_duo.rb +149 -70
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 590eaca433387806ae34f75fd178e6ebeab8fa753d976fd2e3c94adda0b11eac
4
- data.tar.gz: d2d7e70e64d8c5a0e636d8ea7a5f8bdf352e6cdc61f1948b324fd015d4e364e9
3
+ metadata.gz: 847308247465d3e333517675219420ebedeed421b6e858c6da633ee96e68f1eb
4
+ data.tar.gz: 91bf88e0dd6f24a0cca7fd88fe39b89a17d832ec44f5fa358826fec8c9a8c08c
5
5
  SHA512:
6
- metadata.gz: 4a003b6382da4f1d6ee0213d7d97c6cd36c698d6a2ecd0c2dc93cc687ca57287efbfb7d51f07382995c5fddffafe3a8bce4bc2c8579ec50d3b57f0f70e804b06
7
- data.tar.gz: f0cf32ecc56ad4948673fbd159e1305736717c096b9f22b6a8677f76b2d64f70734a45bd66f4b7a2592fc98e50510b494d73e5aae1a9a0fd5700bd232ec34755
6
+ metadata.gz: 638d592ff8592c76e85202304b61ead5364595e761fd22a2df2e01132e734c9df51fec42229798cef748050a42773084d1967aa344ac8e9eb39e894aa5e00f0d
7
+ data.tar.gz: 0b779d085e8e7ca86012dcdb826165292175cf4110e9f241613d4f17a53fe088312319996b33a6dec1a8248a1b10ba779dc4102522c45fab9f6e7b16caa85f99
@@ -1,6 +1,6 @@
1
1
  require 'glimmer-dsl-libui'
2
2
  require 'selenium-webdriver'
3
- require 'webdrivers'
3
+ #require 'webdrivers'
4
4
  require 'iconv'
5
5
  require 'nokogiri'
6
6
  require 'http'
@@ -241,25 +241,6 @@ end
241
241
  class Naver
242
242
  def initialize
243
243
  @seed = 1
244
-
245
- begin
246
- # webdrivers가 사용자의 Chrome 버전에 맞는 chromedriver 다운로드 시도
247
-
248
- # Webdrivers가 드라이버를 다운로드할 경로를 설정
249
- Webdrivers.cache_time = 86_400 # 하루로 설정 (기본값: 86_400초)
250
- Webdrivers.install_dir = "./" # 크롬드라이버를 수동으로 설치할 경로를 설정
251
- # 크롬드라이버 자동 업데이트 시도
252
- Webdrivers::Chromedriver.update
253
- puts "chromedriver 자동 다운로드 성공"
254
- rescue => e
255
- puts "chromedriver 자동 다운로드 실패: #{e.message}"
256
- puts "폴더내 크롬드라이버를 사용합니다."
257
- puts "크롬드라이버가 오래된 경우 오류 발생될 수 있으며, 만일 오류 발생시 아래 지침을 따라주세요."
258
- puts "1.크롬 업데이트 2.프로그램 폴더 내부에 ★tip★-시작시-크롬창이....파일을 열어 드라이버를 교체하세요."
259
- chromedriver_path = './chromedriver.exe' # 수동 경로를 인스턴스 변수로 설정
260
- Selenium::WebDriver::Chrome::Service.driver_path = chromedriver_path
261
- end
262
-
263
244
  end
264
245
 
265
246
 
@@ -281,6 +262,18 @@ class Naver
281
262
  FileUtils.mkdir_p(naver_cookie_dir) unless File.exist?(naver_cookie_dir)
282
263
  if proxy == ''
283
264
  begin
265
+ begin
266
+ Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
267
+ rescue => e
268
+ puts "chromedriver 버전 불일치!!"
269
+ puts "아래 지침을 따라주세요."
270
+ puts "1.프로그램 종료!"
271
+ puts "2.크롬 업데이트!"
272
+ puts "3.프로그램 폴더 내부에 ★tip★-시작시-크롬창이....파일 실행"
273
+ puts "4.안내된 방식으로 크롬 드라이버 교체"
274
+ puts "5.재 시작"
275
+ exit 1
276
+ end
284
277
  options = Selenium::WebDriver::Chrome::Options.new
285
278
  options.add_argument('--no-first-run') # 자동 실행 시 나타나는 "첫 실행" 화면 방지
286
279
  #options.add_argument('--disable-extensions') # 확장 프로그램 초기화 화면 방지
@@ -308,7 +301,18 @@ class Naver
308
301
  end
309
302
  else
310
303
  begin
311
- #Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
304
+ begin
305
+ Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
306
+ rescue => e
307
+ puts "chromedriver 버전 불일치!!"
308
+ puts "아래 지침을 따라주세요."
309
+ puts "1.프로그램 종료!"
310
+ puts "2.크롬 업데이트!"
311
+ puts "3.프로그램 폴더 내부에 ★tip★-시작시-크롬창이....파일 실행"
312
+ puts "4.안내된 방식으로 크롬 드라이버 교체"
313
+ puts "5.재 시작"
314
+ exit 1
315
+ end
312
316
  options = Selenium::WebDriver::Chrome::Options.new
313
317
  options.add_argument('--no-first-run') # 자동 실행 시 나타나는 "첫 실행" 화면 방지
314
318
  options.add_argument('--disable-extensions') # 확장 프로그램 초기화 화면 방지
@@ -335,7 +339,18 @@ class Naver
335
339
  puts e
336
340
  puts 'proxy error...'
337
341
  begin
338
- #Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
342
+ begin
343
+ Selenium::WebDriver::Chrome::Service.driver_path = './chromedriver.exe'
344
+ rescue => e
345
+ puts "chromedriver 버전 불일치!!"
346
+ puts "아래 지침을 따라주세요."
347
+ puts "1.프로그램 종료!"
348
+ puts "2.크롬 업데이트!"
349
+ puts "3.프로그램 폴더 내부에 ★tip★-시작시-크롬창이....파일 실행"
350
+ puts "4.안내된 방식으로 크롬 드라이버 교체"
351
+ puts "5.재 시작"
352
+ exit 1
353
+ end
339
354
  options = Selenium::WebDriver::Chrome::Options.new
340
355
  options.add_argument('--no-first-run') # 자동 실행 시 나타나는 "첫 실행" 화면 방지
341
356
  options.add_argument('--disable-extensions') # 확장 프로그램 초기화 화면 방지
@@ -2579,6 +2594,22 @@ class Wordpress
2579
2594
  @data['table'].pop
2580
2595
  #제목끝
2581
2596
  # content = " #{content} "
2597
+ if @data['포스트설정']['gpt키워드'].checked?
2598
+ gpt_keyword_prompt = @data['포스트설정']['gpt키워드_프롬프트'].text.to_s.force_encoding('utf-8')
2599
+ gpt_keyword_prompt_sample = gpt_keyword_prompt.strip.empty? ? "프롬프트: 관련된 글을 1500자에서 2500자 사이로 만들어줘" : gpt_keyword_prompt
2600
+ chat = Chat.new(@data['포스트설정']['api_key'].text.to_s.force_encoding('utf-8'), gpt_keyword_prompt)
2601
+ gpt_text = chat.message(keyword)
2602
+ #content = content.to_s + "\n(자동생성글)\n" + gpt_text.to_s
2603
+ content = content.to_s + "(자동생성글)" + gpt_text.to_s
2604
+ elsif @data['포스트설정']['내용을자동생성'].checked?
2605
+ content = auto_text
2606
+ elsif @data['포스트설정']['내용과자동생성'].checked?
2607
+ #content = content + "\n(자동생성글)\n" + auto_text
2608
+ content = content + "(자동생성글)" + auto_text
2609
+ end
2610
+ @data['table'][index][-1] = 45
2611
+ @data['table'] << []
2612
+ @data['table'].pop
2582
2613
 
2583
2614
  if @data['포스트설정']['특정단어굵기'].checked?
2584
2615
  content2 = ''
@@ -2618,7 +2649,7 @@ class Wordpress
2618
2649
  content = content2
2619
2650
  end
2620
2651
  end
2621
- @data['table'][index][-1] = 35
2652
+ @data['table'][index][-1] = 50
2622
2653
  @data['table'] << []
2623
2654
  @data['table'].pop
2624
2655
  if @data['포스트설정']['단어크기변경'].checked?
@@ -2639,19 +2670,7 @@ class Wordpress
2639
2670
  @data['table'][index][-1] = 50
2640
2671
  @data['table'] << []
2641
2672
  @data['table'].pop
2642
- if @data['포스트설정']['gpt키워드'].checked?
2643
- gpt_keyword_prompt = @data['포스트설정']['gpt키워드_프롬프트'].text.to_s.force_encoding('utf-8')
2644
- gpt_keyword_prompt_sample = gpt_keyword_prompt.strip.empty? ? "프롬프트: 관련된 글을 1500자에서 2500자 사이로 만들어줘" : gpt_keyword_prompt
2645
- chat = Chat.new(@data['포스트설정']['api_key'].text.to_s.force_encoding('utf-8'), gpt_keyword_prompt)
2646
- gpt_text = chat.message(keyword)
2647
- #content = content.to_s + "\n(자동생성글)\n" + gpt_text.to_s
2648
- content = content.to_s + "(자동생성글)" + gpt_text.to_s
2649
- elsif @data['포스트설정']['내용을자동생성'].checked?
2650
- content = auto_text
2651
- elsif @data['포스트설정']['내용과자동생성'].checked?
2652
- #content = content + "\n(자동생성글)\n" + auto_text
2653
- content = content + "(자동생성글)" + auto_text
2654
- end
2673
+
2655
2674
 
2656
2675
  if @data['포스트설정']['내용키워드삽입'].checked?
2657
2676
  puts '내용키워드삽입...'
@@ -2912,7 +2931,10 @@ class Wordpress
2912
2931
  end
2913
2932
  end
2914
2933
  end
2934
+
2915
2935
 
2936
+
2937
+ ##여기서부터 이미지 순서대로 수정코드 변경####-------------------------------------------------------------------------------
2916
2938
  @data['table'][index][-1] = 70
2917
2939
  @data['table'] << []
2918
2940
  @data['table'].pop
@@ -2920,13 +2942,22 @@ class Wordpress
2920
2942
  content_memory = content.split('(자동생성글)')
2921
2943
  content = content_memory[0]
2922
2944
  content_end = content_memory[1].to_s
2945
+ if @data['포스트설정']['gpt키워드'].checked?
2946
+ if @data['포스트설정']['gpt상단'].checked?
2947
+ content = "(자동생성글)\n" + content_end + "\n" + content
2948
+ else
2949
+ content = content + "\n(자동생성글)\n" + content_end
2950
+ end
2951
+ else
2952
+ content = content + "\n(자동생성글)\n" + content_end
2953
+ end
2923
2954
 
2924
2955
  if @data['포스트설정']['특정단어키워드로변경'].checked?
2925
2956
  @data['포스트설정']['특정단어키워드로변경값'].text.to_s.force_encoding('utf-8').split(',').each do |i|
2926
2957
  content = content.split(i.force_encoding('utf-8')).join(keyword)
2927
2958
  end
2928
2959
  end
2929
-
2960
+
2930
2961
  @data['table'][index][-1] = 75
2931
2962
  @data['table'] << []
2932
2963
  @data['table'].pop
@@ -2943,12 +2974,7 @@ class Wordpress
2943
2974
  ttr = 0
2944
2975
  @data['포스트설정']['단어사진으로변경단어'].text.to_s.force_encoding('utf-8').split(',').each do |i|
2945
2976
  ttr = 1
2946
- # image_url = get_image_file().force_encoding('utf-8')
2947
- # if @data['포스트설정']['내용사진링크'].checked?
2948
- # content = content.split(i.force_encoding('utf-8')).join('<a href="'+@data['포스트설정']['내용사진링크값'].text.to_s.force_encoding('utf-8')+'"><img src="'+image_url+'" alt="'+keyword+'"></a>')
2949
- # else
2950
- # content = content.split(i.force_encoding('utf-8')).join('<img src="'+image_url+'" alt="'+keyword+'">')
2951
- # end
2977
+
2952
2978
  content = content.split(i.force_encoding('utf-8'))
2953
2979
  content.each_with_index do |ccm, index3|
2954
2980
  if index3 == content.length-1
@@ -2958,6 +2984,7 @@ class Wordpress
2958
2984
  if i.force_encoding('utf-8').to_s.include?('@')
2959
2985
  image_memory << ""+'<img src="'+image_url+'" alt="'+keyword+'">'+""
2960
2986
  content[index3] = content[index3] + '**image()**'
2987
+
2961
2988
  else
2962
2989
  image_memory << ""+ '<img src="'+image_url+'" alt="'+keyword+'">'+""
2963
2990
  content[index3] = content[index3] + '**image**'
@@ -2967,6 +2994,8 @@ class Wordpress
2967
2994
  content = content.join('')
2968
2995
  end
2969
2996
  end
2997
+
2998
+
2970
2999
 
2971
3000
  con_memory = Array.new
2972
3001
  index5 = 0
@@ -3004,6 +3033,8 @@ class Wordpress
3004
3033
  content = content.split(i.force_encoding('utf-8')).join("<sticker></sticker>")
3005
3034
  end
3006
3035
  end
3036
+
3037
+
3007
3038
 
3008
3039
  if @data['포스트설정']['영상으로변경'].checked?
3009
3040
  if @video.length == 0
@@ -3032,36 +3063,79 @@ class Wordpress
3032
3063
  # end
3033
3064
  #end
3034
3065
  if @data['포스트설정']['지도로변경'].checked?
3035
- # 지도 주소와 사용자 설정 단어들을 가져옵니다.
3036
3066
  map_address = @data['포스트설정']['지도주소'].text.to_s.force_encoding('utf-8')
3037
-
3038
- # 여러 단어로 설정된 '지도로변경단어'를 분리하여 배열로 저장
3039
3067
  change_words = @data['포스트설정']['지도로변경단어'].text.to_s.force_encoding('utf-8').split(',')
3040
3068
 
3041
- # content를 각 줄로 분할
3042
3069
  content_lines = content.split("\n")
3070
+ new_lines = []
3071
+
3072
+ content_lines.each do |line|
3073
+ # 이미 처리된 줄은 건너뜀
3074
+ if line.include?("<koreamap>")
3075
+ new_lines << line
3076
+ next
3077
+ end
3078
+
3079
+ processed = false
3043
3080
 
3044
- content_lines.each_with_index do |line, index|
3045
- # 각 단어에 대해 처리
3046
3081
  change_words.each do |change_word|
3047
- # 'change_word'가 포함된 줄에 대해서만 처리
3048
- if line.include?(change_word)
3049
- # 설정된 단어 뒤에 괄호가 있는지 확인
3050
- if line.include?("[") && line.include?("]")
3051
- # 괄호 안의 주소를 찾아서 그 주소는 그대로 두고, 지도로 변경된 주소로 교체
3052
- address_in_brackets = line.match(/\[(.*?)\]/)[1] # 괄호 안의 주소를 추출
3053
- content_lines[index] = "<koreamap>#{address_in_brackets}</koreamap>"
3054
- else
3055
- # 괄호가 없다면 @data['포스트설정']['지도주소']를 추가
3056
- content_lines[index] = "<koreamap>#{map_address}</koreamap>"
3082
+ # 1. [단어][주소] 패턴 처리: 분리 + 출력
3083
+ if line =~ /#{Regexp.escape(change_word)}\[(.*?)\]/
3084
+ match_data = line.match(/(.*)#{Regexp.escape(change_word)}\[(.*?)\](.*)/)
3085
+ if match_data
3086
+ before = match_data[1]
3087
+ address = match_data[2]
3088
+ after = match_data[3]
3089
+
3090
+ # 태그 추출
3091
+ open_tag = before[/<p[^>]*?>/i] || ""
3092
+ close_tag = after[/<\/p>/i] || ""
3093
+
3094
+ # 텍스트 정리
3095
+ before_text = before.sub(open_tag, '')
3096
+ after_text = after.sub(close_tag, '')
3097
+
3098
+ # 줄 분리
3099
+ new_lines << "#{open_tag}#{before_text}</p>" unless before_text.strip.empty?
3100
+ new_lines << "<koreamap>#{address}</koreamap>"
3101
+ new_lines << "#{open_tag}#{after_text}#{close_tag}" unless after_text.strip.empty?
3102
+
3103
+ processed = true
3104
+ break
3057
3105
  end
3058
3106
  end
3107
+
3108
+ # 2. 일반 단어 처리 (한 줄에만 등장하는 경우)
3109
+ if !processed && line.include?(change_word)
3110
+ parts = line.split(change_word, 2)
3111
+ prefix = parts[0]
3112
+ suffix = parts[1]
3113
+
3114
+ open_tag = prefix[/<p[^>]*?>/i] || ""
3115
+ close_tag = suffix[/<\/p>/i] || ""
3116
+
3117
+ prefix_text = prefix.sub(open_tag, '')
3118
+ suffix_text = suffix.sub(close_tag, '')
3119
+
3120
+ new_lines << "#{open_tag}#{prefix_text}</p>" unless prefix_text.strip.empty?
3121
+ new_lines << "<koreamap>#{map_address}</koreamap>"
3122
+ new_lines << "#{open_tag}#{suffix_text}#{close_tag}" unless suffix_text.strip.empty?
3123
+
3124
+ processed = true
3125
+ break
3126
+ end
3059
3127
  end
3128
+
3129
+ # 변경이 없었으면 원래 줄 추가
3130
+ new_lines << line unless processed
3060
3131
  end
3061
3132
 
3062
- # 다시 content로 합치기
3063
- content = content_lines.join("\n")
3133
+ content = new_lines.join("\n")
3064
3134
  end
3135
+
3136
+
3137
+
3138
+
3065
3139
 
3066
3140
  if @data['포스트설정']['인용구변경'].checked?
3067
3141
  if @data['포스트설정']['인용구문구설정'].checked?
@@ -3099,21 +3173,26 @@ class Wordpress
3099
3173
  @data['table'] << []
3100
3174
  @data['table'].pop
3101
3175
 
3176
+
3177
+ parts = content.split('(자동생성글)', 2)
3178
+ content_main = parts[0].strip
3179
+ content_end = parts[1].to_s.strip
3180
+
3102
3181
  soosick_1 = ''
3103
3182
  soosick_2 = ''
3104
3183
  if @data['포스트설정']['자동글 수식에 입력'].checked?
3105
- content = content
3106
- soosick_1 = content_end
3184
+ content = content_main
3185
+ soosick_1 = content_end
3107
3186
  else
3108
- if @data['포스트설정']['gpt키워드'].checked?
3109
- if @data['포스트설정']['gpt상단'].checked?
3110
- content = content_end+"\n"+content+"\n"
3111
- else
3112
- content = content+"\n"+content_end+"\n"
3113
- end
3187
+ if @data['포스트설정']['gpt키워드'].checked?
3188
+ if @data['포스트설정']['gpt상단'].checked?
3189
+ content = content_end + "\n" + content_main + "\n"
3114
3190
  else
3115
- content = content+"\n"+content_end+"\n"
3191
+ content = content_main + "\n" + content_end + "\n"
3116
3192
  end
3193
+ else
3194
+ content = content_main + "\n" + content_end + "\n"
3195
+ end
3117
3196
  end
3118
3197
 
3119
3198
  if @data['포스트설정']['막글삽입'].checked?
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cafe_basics_duo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.30
4
+ version: 0.1.35
5
5
  platform: ruby
6
6
  authors:
7
7
  - zon
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-04-17 00:00:00.000000000 Z
10
+ date: 2025-05-22 00:00:00.000000000 Z
11
11
  dependencies: []
12
12
  description: File to Clipboard gem
13
13
  email: mymin26@naver.com