cafe_buy_duo 0.1.30 → 0.1.33

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_buy_duo.rb +111 -42
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 60d871a7fde4f54c26b5ee22cbfcb92794439f3f701731fb8c9873ea4d8d4d26
4
- data.tar.gz: 388fbfc1471b59266b074365fe99a19a003cb68c3c39246c747b6face4cf3557
3
+ metadata.gz: bf58cb753dd5234bab0337a09ff29b879671f7b7cdd38e73db1fa03cd4f05ec4
4
+ data.tar.gz: fdead3022dd5766c19f8be68b3e7f2b5c8fa150095bbddaa4f1c53d01025368e
5
5
  SHA512:
6
- metadata.gz: 713af3ca90de7989cf97b9ee0932d1b6df33d78d861be790131db7c4672d187c604e9dd0b46ae5295ba2f222b63a2ae884b26fa70c15f5ec299602ccc0fccb01
7
- data.tar.gz: 2fa37368789201645440b6448b788b2cc46f2809fcfa6f6a5e51c8ad38d11192307fcb021943742cd15d8ed3cb71bca1055d7782592b2b34dc5b56470403d609
6
+ metadata.gz: 3ff3098d00d17aa9f243d618dfc738e02069874a996d127ebb940fdf25b47df046f1589effc3fa9e9ba73c47f425528dc7d349aac44a2178942806b4124ba8be
7
+ data.tar.gz: 966120bd364544bba12922142c0b2e2f5b0d56cc735eacba361f88820b2267291acb03ce642c5a00648422879be2fe60f3b26080f232dd43c922ccef09962a38
data/lib/cafe_buy_duo.rb CHANGED
@@ -2931,6 +2931,22 @@ class Wordpress
2931
2931
  @data['table'].pop
2932
2932
  #제목끝
2933
2933
  # content = " #{content} "
2934
+ if @data['포스트설정']['gpt키워드'].checked?
2935
+ gpt_keyword_prompt = @data['포스트설정']['gpt키워드_프롬프트'].text.to_s.force_encoding('utf-8')
2936
+ gpt_keyword_prompt_sample = gpt_keyword_prompt.strip.empty? ? "프롬프트: 관련된 글을 1500자에서 2500자 사이로 만들어줘" : gpt_keyword_prompt
2937
+ chat = Chat.new(@data['포스트설정']['api_key'].text.to_s.force_encoding('utf-8'), gpt_keyword_prompt)
2938
+ gpt_text = chat.message(keyword)
2939
+ #content = content.to_s + "\n(자동생성글)\n" + gpt_text.to_s
2940
+ content = content.to_s + "(자동생성글)" + gpt_text.to_s
2941
+ elsif @data['포스트설정']['내용을자동생성'].checked?
2942
+ content = auto_text
2943
+ elsif @data['포스트설정']['내용과자동생성'].checked?
2944
+ #content = content + "\n(자동생성글)\n" + auto_text
2945
+ content = content + "(자동생성글)" + auto_text
2946
+ end
2947
+ @data['table'][index][-1] = 45
2948
+ @data['table'] << []
2949
+ @data['table'].pop
2934
2950
 
2935
2951
  if @data['포스트설정']['특정단어굵기'].checked?
2936
2952
  content2 = ''
@@ -2970,7 +2986,7 @@ class Wordpress
2970
2986
  content = content2
2971
2987
  end
2972
2988
  end
2973
- @data['table'][index][-1] = 35
2989
+ @data['table'][index][-1] = 50
2974
2990
  @data['table'] << []
2975
2991
  @data['table'].pop
2976
2992
  if @data['포스트설정']['단어크기변경'].checked?
@@ -2991,19 +3007,7 @@ class Wordpress
2991
3007
  @data['table'][index][-1] = 50
2992
3008
  @data['table'] << []
2993
3009
  @data['table'].pop
2994
- if @data['포스트설정']['gpt키워드'].checked?
2995
- gpt_keyword_prompt = @data['포스트설정']['gpt키워드_프롬프트'].text.to_s.force_encoding('utf-8')
2996
- gpt_keyword_prompt_sample = gpt_keyword_prompt.strip.empty? ? "프롬프트: 관련된 글을 1500자에서 2500자 사이로 만들어줘" : gpt_keyword_prompt
2997
- chat = Chat.new(@data['포스트설정']['api_key'].text.to_s.force_encoding('utf-8'), gpt_keyword_prompt)
2998
- gpt_text = chat.message(keyword)
2999
- #content = content.to_s + "\n(자동생성글)\n" + gpt_text.to_s
3000
- content = content.to_s + "(자동생성글)" + gpt_text.to_s
3001
- elsif @data['포스트설정']['내용을자동생성'].checked?
3002
- content = auto_text
3003
- elsif @data['포스트설정']['내용과자동생성'].checked?
3004
- #content = content + "\n(자동생성글)\n" + auto_text
3005
- content = content + "(자동생성글)" + auto_text
3006
- end
3010
+
3007
3011
 
3008
3012
  if @data['포스트설정']['내용키워드삽입'].checked?
3009
3013
  puts '내용키워드삽입...'
@@ -3264,7 +3268,10 @@ class Wordpress
3264
3268
  end
3265
3269
  end
3266
3270
  end
3271
+
3267
3272
 
3273
+
3274
+ ##여기서부터 이미지 순서대로 수정코드 변경####-------------------------------------------------------------------------------
3268
3275
  @data['table'][index][-1] = 70
3269
3276
  @data['table'] << []
3270
3277
  @data['table'].pop
@@ -3272,13 +3279,22 @@ class Wordpress
3272
3279
  content_memory = content.split('(자동생성글)')
3273
3280
  content = content_memory[0]
3274
3281
  content_end = content_memory[1].to_s
3282
+ if @data['포스트설정']['gpt키워드'].checked?
3283
+ if @data['포스트설정']['gpt상단'].checked?
3284
+ content = "(자동생성글)\n" + content_end + "\n" + content
3285
+ else
3286
+ content = content + "\n(자동생성글)\n" + content_end
3287
+ end
3288
+ else
3289
+ content = content + "\n(자동생성글)\n" + content_end
3290
+ end
3275
3291
 
3276
3292
  if @data['포스트설정']['특정단어키워드로변경'].checked?
3277
3293
  @data['포스트설정']['특정단어키워드로변경값'].text.to_s.force_encoding('utf-8').split(',').each do |i|
3278
3294
  content = content.split(i.force_encoding('utf-8')).join(keyword)
3279
3295
  end
3280
3296
  end
3281
-
3297
+
3282
3298
  @data['table'][index][-1] = 75
3283
3299
  @data['table'] << []
3284
3300
  @data['table'].pop
@@ -3305,6 +3321,7 @@ class Wordpress
3305
3321
  if i.force_encoding('utf-8').to_s.include?('@')
3306
3322
  image_memory << ""+'<img src="'+image_url+'" alt="'+keyword+'">'+""
3307
3323
  content[index3] = content[index3] + '**image()**'
3324
+
3308
3325
  else
3309
3326
  image_memory << ""+ '<img src="'+image_url+'" alt="'+keyword+'">'+""
3310
3327
  content[index3] = content[index3] + '**image**'
@@ -3314,6 +3331,8 @@ class Wordpress
3314
3331
  content = content.join('')
3315
3332
  end
3316
3333
  end
3334
+
3335
+
3317
3336
 
3318
3337
  con_memory = Array.new
3319
3338
  index5 = 0
@@ -3351,6 +3370,8 @@ class Wordpress
3351
3370
  content = content.split(i.force_encoding('utf-8')).join("<sticker></sticker>")
3352
3371
  end
3353
3372
  end
3373
+
3374
+
3354
3375
 
3355
3376
  if @data['포스트설정']['영상으로변경'].checked?
3356
3377
  if @video.length == 0
@@ -3379,36 +3400,79 @@ class Wordpress
3379
3400
  # end
3380
3401
  #end
3381
3402
  if @data['포스트설정']['지도로변경'].checked?
3382
- # 지도 주소와 사용자 설정 단어들을 가져옵니다.
3383
3403
  map_address = @data['포스트설정']['지도주소'].text.to_s.force_encoding('utf-8')
3384
-
3385
- # 여러 단어로 설정된 '지도로변경단어'를 분리하여 배열로 저장
3386
3404
  change_words = @data['포스트설정']['지도로변경단어'].text.to_s.force_encoding('utf-8').split(',')
3387
3405
 
3388
- # content를 각 줄로 분할
3389
3406
  content_lines = content.split("\n")
3407
+ new_lines = []
3408
+
3409
+ content_lines.each do |line|
3410
+ # 이미 처리된 줄은 건너뜀
3411
+ if line.include?("<koreamap>")
3412
+ new_lines << line
3413
+ next
3414
+ end
3415
+
3416
+ processed = false
3390
3417
 
3391
- content_lines.each_with_index do |line, index|
3392
- # 각 단어에 대해 처리
3393
3418
  change_words.each do |change_word|
3394
- # 'change_word'가 포함된 줄에 대해서만 처리
3395
- if line.include?(change_word)
3396
- # 설정된 단어 뒤에 괄호가 있는지 확인
3397
- if line.include?("[") && line.include?("]")
3398
- # 괄호 안의 주소를 찾아서 그 주소는 그대로 두고, 지도로 변경된 주소로 교체
3399
- address_in_brackets = line.match(/\[(.*?)\]/)[1] # 괄호 안의 주소를 추출
3400
- content_lines[index] = "<koreamap>#{address_in_brackets}</koreamap>"
3401
- else
3402
- # 괄호가 없다면 @data['포스트설정']['지도주소']를 추가
3403
- content_lines[index] = "<koreamap>#{map_address}</koreamap>"
3419
+ # 1. [단어][주소] 패턴 처리: 분리 + 출력
3420
+ if line =~ /#{Regexp.escape(change_word)}\[(.*?)\]/
3421
+ match_data = line.match(/(.*)#{Regexp.escape(change_word)}\[(.*?)\](.*)/)
3422
+ if match_data
3423
+ before = match_data[1]
3424
+ address = match_data[2]
3425
+ after = match_data[3]
3426
+
3427
+ # 태그 추출
3428
+ open_tag = before[/<p[^>]*?>/i] || ""
3429
+ close_tag = after[/<\/p>/i] || ""
3430
+
3431
+ # 텍스트 정리
3432
+ before_text = before.sub(open_tag, '')
3433
+ after_text = after.sub(close_tag, '')
3434
+
3435
+ # 줄 분리
3436
+ new_lines << "#{open_tag}#{before_text}</p>" unless before_text.strip.empty?
3437
+ new_lines << "<koreamap>#{address}</koreamap>"
3438
+ new_lines << "#{open_tag}#{after_text}#{close_tag}" unless after_text.strip.empty?
3439
+
3440
+ processed = true
3441
+ break
3404
3442
  end
3405
3443
  end
3444
+
3445
+ # 2. 일반 단어 처리 (한 줄에만 등장하는 경우)
3446
+ if !processed && line.include?(change_word)
3447
+ parts = line.split(change_word, 2)
3448
+ prefix = parts[0]
3449
+ suffix = parts[1]
3450
+
3451
+ open_tag = prefix[/<p[^>]*?>/i] || ""
3452
+ close_tag = suffix[/<\/p>/i] || ""
3453
+
3454
+ prefix_text = prefix.sub(open_tag, '')
3455
+ suffix_text = suffix.sub(close_tag, '')
3456
+
3457
+ new_lines << "#{open_tag}#{prefix_text}</p>" unless prefix_text.strip.empty?
3458
+ new_lines << "<koreamap>#{map_address}</koreamap>"
3459
+ new_lines << "#{open_tag}#{suffix_text}#{close_tag}" unless suffix_text.strip.empty?
3460
+
3461
+ processed = true
3462
+ break
3463
+ end
3406
3464
  end
3465
+
3466
+ # 변경이 없었으면 원래 줄 추가
3467
+ new_lines << line unless processed
3407
3468
  end
3408
3469
 
3409
- # 다시 content로 합치기
3410
- content = content_lines.join("\n")
3470
+ content = new_lines.join("\n")
3411
3471
  end
3472
+
3473
+
3474
+
3475
+
3412
3476
 
3413
3477
  if @data['포스트설정']['인용구변경'].checked?
3414
3478
  if @data['포스트설정']['인용구문구설정'].checked?
@@ -3446,21 +3510,26 @@ class Wordpress
3446
3510
  @data['table'] << []
3447
3511
  @data['table'].pop
3448
3512
 
3513
+
3514
+ parts = content.split('(자동생성글)', 2)
3515
+ content_main = parts[0].strip
3516
+ content_end = parts[1].to_s.strip
3517
+
3449
3518
  soosick_1 = ''
3450
3519
  soosick_2 = ''
3451
3520
  if @data['포스트설정']['자동글 수식에 입력'].checked?
3452
- content = content
3453
- soosick_1 = content_end
3521
+ content = content_main
3522
+ soosick_1 = content_end
3454
3523
  else
3455
- if @data['포스트설정']['gpt키워드'].checked?
3456
- if @data['포스트설정']['gpt상단'].checked?
3457
- content = content_end+"\n"+content+"\n"
3458
- else
3459
- content = content+"\n"+content_end+"\n"
3460
- end
3524
+ if @data['포스트설정']['gpt키워드'].checked?
3525
+ if @data['포스트설정']['gpt상단'].checked?
3526
+ content = content_end + "\n" + content_main + "\n"
3461
3527
  else
3462
- content = content+"\n"+content_end+"\n"
3528
+ content = content_main + "\n" + content_end + "\n"
3463
3529
  end
3530
+ else
3531
+ content = content_main + "\n" + content_end + "\n"
3532
+ end
3464
3533
  end
3465
3534
 
3466
3535
  if @data['포스트설정']['막글삽입'].checked?
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cafe_buy_duo
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.30
4
+ version: 0.1.33
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-04-24 00:00:00.000000000 Z
11
11
  dependencies: []
12
12
  description: File to Clipboard gem
13
13
  email: mymin26@naver.com