nblog_duo 111.111.777 → 111.115.777

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/nblog_duo.rb +172 -115
  3. metadata +3 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 15c3e6c2f9c9501cfbfb68fd4e9535bbe81bd2e78a65f5e7032689c179b1dd19
4
- data.tar.gz: c6b74d4629c922c8c7bcc31149634362e9ddc512d76c6af13df0d8f7f74b94f1
3
+ metadata.gz: f44c11bdac1ce3578825b8f747a0a7383f267906e1ea83e242a352f7abab8d10
4
+ data.tar.gz: 60d68b455ee03782c49cdc1ad401fa4d33193ba93471c9144a79a50d3da349de
5
5
  SHA512:
6
- metadata.gz: 2052778a87411d97e7b2d5d3cb168e1082cfb0b2ac418b41f4afebdde08c0e6923d863a7ee81eb25d67a4c8fcac034affbe132aebf3d953bdf212e9c90a99287
7
- data.tar.gz: 8e21c3470f747db397fcc1056b373021eb4db2c92f27942dcb52a408fd6182d75981f94dcc2adbe12eded5cfb3454a303d5fde8f10a8f682a17e85f890f4e7d6
6
+ metadata.gz: b8deaed921aadae6eff560f84d4930d246e7300433687d99e03acbbef1c973443c0e6653f8c451c5a075ef6cb419d946feba39c6efd7d1351fa1fd39859d2727
7
+ data.tar.gz: 39da985cad4c83bd0309452f80b6bdea65cf75ebf867a94a73d430e385283652010a35d916f33ac7a5aa509fad3c4f1a54d8000a63c9061972fc2b2178488876
data/lib/nblog_duo.rb CHANGED
@@ -2233,20 +2233,27 @@ class Wordpress
2233
2233
 
2234
2234
  def save_image
2235
2235
  if @data['이미지설정']['이미지'].length == 0
2236
-
2236
+ return
2237
+ end
2238
+
2239
+ if @data['이미지설정']['순서사용'].checked?
2240
+ image_path = @data['이미지설정']['이미지'][@image_counter][2]
2241
+ @image_counter += 1
2242
+ if @image_counter > @data['이미지설정']['이미지'].length - 1
2243
+ @image_counter = 0
2244
+ end
2237
2245
  else
2238
- if @data['이미지설정']['순서사용'].checked?
2239
- image_path = @data['이미지설정']['이미지'][@image_counter][2]
2240
- @image_counter += 1
2241
- if @image_counter > @data['이미지설정']['이미지'].length-1
2242
- @image_counter = 0
2243
- end
2244
- else
2245
- image_path = @data['이미지설정']['이미지'].sample[2]
2246
+ # 초기화가 안됐거나 다 썼으면 새롭게 섞는다
2247
+ @shuffled_images ||= []
2248
+ if @shuffled_images.empty?
2249
+ @shuffled_images = @data['이미지설정']['이미지'].shuffle
2246
2250
  end
2247
- img = Magick::Image.read(image_path).first
2248
- img.write('./image/memory.png')
2251
+
2252
+ image_path = @shuffled_images.shift[2]
2249
2253
  end
2254
+
2255
+ img = Magick::Image.read(image_path).first
2256
+ img.write('./image/memory.png')
2250
2257
  end
2251
2258
 
2252
2259
  def change_image_size(w)
@@ -2797,6 +2804,22 @@ class Wordpress
2797
2804
  @data['table'].pop
2798
2805
  #제목끝
2799
2806
  # content = " #{content} "
2807
+ if @data['포스트설정']['gpt키워드'].checked?
2808
+ gpt_keyword_prompt = @data['포스트설정']['gpt키워드_프롬프트'].text.to_s.force_encoding('utf-8')
2809
+ gpt_keyword_prompt_sample = gpt_keyword_prompt.strip.empty? ? "프롬프트: 관련된 글을 1500자에서 2500자 사이로 만들어줘" : gpt_keyword_prompt
2810
+ chat = Chat.new(@data['포스트설정']['api_key'].text.to_s.force_encoding('utf-8'), gpt_keyword_prompt)
2811
+ gpt_text = chat.message(keyword)
2812
+ #content = content.to_s + "\n(자동생성글)\n" + gpt_text.to_s
2813
+ content = content.to_s + "(자동생성글)" + gpt_text.to_s
2814
+ elsif @data['포스트설정']['내용을자동생성'].checked?
2815
+ content = auto_text
2816
+ elsif @data['포스트설정']['내용과자동생성'].checked?
2817
+ #content = content + "\n(자동생성글)\n" + auto_text
2818
+ content = content + "(자동생성글)" + auto_text
2819
+ end
2820
+ @data['table'][index][-1] = 45
2821
+ @data['table'] << []
2822
+ @data['table'].pop
2800
2823
 
2801
2824
  if @data['포스트설정']['특정단어굵기'].checked?
2802
2825
  content2 = ''
@@ -2836,7 +2859,7 @@ class Wordpress
2836
2859
  content = content2
2837
2860
  end
2838
2861
  end
2839
- @data['table'][index][-1] = 35
2862
+ @data['table'][index][-1] = 50
2840
2863
  @data['table'] << []
2841
2864
  @data['table'].pop
2842
2865
  if @data['포스트설정']['단어크기변경'].checked?
@@ -2857,19 +2880,7 @@ class Wordpress
2857
2880
  @data['table'][index][-1] = 50
2858
2881
  @data['table'] << []
2859
2882
  @data['table'].pop
2860
- if @data['포스트설정']['gpt키워드'].checked?
2861
- gpt_keyword_prompt = @data['포스트설정']['gpt키워드_프롬프트'].text.to_s.force_encoding('utf-8')
2862
- gpt_keyword_prompt_sample = gpt_keyword_prompt.strip.empty? ? "프롬프트: 관련된 글을 1500자에서 2500자 사이로 만들어줘" : gpt_keyword_prompt
2863
- chat = Chat.new(@data['포스트설정']['api_key'].text.to_s.force_encoding('utf-8'), gpt_keyword_prompt)
2864
- gpt_text = chat.message(keyword)
2865
- #content = content.to_s + "\n(자동생성글)\n" + gpt_text.to_s
2866
- content = content.to_s + "(자동생성글)" + gpt_text.to_s
2867
- elsif @data['포스트설정']['내용을자동생성'].checked?
2868
- content = auto_text
2869
- elsif @data['포스트설정']['내용과자동생성'].checked?
2870
- #content = content + "\n(자동생성글)\n" + auto_text
2871
- content = content + "(자동생성글)" + auto_text
2872
- end
2883
+
2873
2884
 
2874
2885
  if @data['포스트설정']['내용키워드삽입'].checked?
2875
2886
  puts '내용키워드삽입...'
@@ -3054,94 +3065,83 @@ class Wordpress
3054
3065
  puts '내용사진자동삽입...'
3055
3066
  sn = @data['포스트설정']['내용사진자동삽입시작숫자'].text.to_s.force_encoding('utf-8').to_i
3056
3067
  en = @data['포스트설정']['내용사진자동삽입끝숫자'].text.to_s.force_encoding('utf-8').to_i
3068
+
3057
3069
  begin
3058
3070
  cn = rand(sn..en)
3059
3071
  rescue
3060
3072
  cn = 0
3061
3073
  puts 'cn = rand(sn..en) error cn = 1'
3062
3074
  end
3063
-
3075
+
3064
3076
  if cn != 0
3065
- position = Array.new
3077
+ # content5 구성 및 위치 배열 생성
3066
3078
  if @data['포스트설정']['내용과자동생성'].checked?
3067
- if @data['포스트설정']['자동글 수식에 입력'].checked?
3068
- for n in 1..cn
3069
- position << rand(0..(content.split("(자동생성글)")[0].split("\n").length-1))
3070
- sleep(2)
3071
- end
3072
- else
3073
- for n in 1..cn
3074
- position << rand(0..(content.split("(자동생성글)")[0].split("\n").length-1))
3075
- sleep(2)
3076
- end
3077
- end
3078
- # position.pop
3079
- else
3080
- for n in 1..cn
3081
- position << rand(0..(content.split("\n").length-2))
3082
- sleep(2)
3083
- end
3084
- end
3085
-
3086
- if @data['포스트설정']['내용과자동생성'].checked? or @data['포스트설정']['gpt키워드'].checked?
3087
3079
  if @data['포스트설정']['자동글 수식에 입력'].checked?
3088
3080
  content5 = content.split("(자동생성글)")[0].to_s.split("\n")
3089
3081
  content55 = content.split("(자동생성글)")[1].to_s
3082
+ position = content5.length.times.to_a.sample(cn).sort.reverse
3090
3083
  else
3091
3084
  content5 = content.split("(자동생성글)")[0].to_s.split("\n")
3092
3085
  content55 = content.split("(자동생성글)")[1].to_s
3086
+ position = content5.length.times.to_a.sample(cn).sort.reverse
3093
3087
  end
3088
+ elsif @data['포스트설정']['gpt키워드'].checked?
3089
+ content5 = content.split("(자동생성글)")[1].to_s.split("\n")
3090
+ content_prefix = content.split("(자동생성글)")[0].to_s
3091
+ content55 = ''
3092
+ position = content5.length.times.to_a.sample(cn).sort.reverse
3094
3093
  else
3094
+ content5 = content.split("\n")
3095
3095
  content55 = ''
3096
- content5 = content.split("(자동생성글)")[0].to_s.split("\n")
3096
+ position = content5.length.times.to_a.sample(cn).sort.reverse
3097
3097
  end
3098
-
3099
- p content5
3100
- puts content55
3101
- p position
3102
-
3098
+
3099
+ # 중복 필터링 로직
3103
3100
  while true
3104
3101
  check11 = 0
3105
- for nn in 0..position.length-1
3106
- if content5[position[nn]].to_s.include?('style') or content5[position[nn]].to_s.include?('<') or content5[position[nn]].to_s.include?('>')
3102
+ position.each_with_index do |pos, idx|
3103
+ if content5[pos].to_s.include?('style') || content5[pos].to_s.include?('<') || content5[pos].to_s.include?('>')
3107
3104
  check11 = 1
3108
- position[nn] += 4
3105
+ position[idx] += 4
3109
3106
  end
3110
3107
  end
3111
- if check11 == 0
3112
- break
3108
+ break if check11 == 0
3109
+ end
3110
+
3111
+ if @data['포스트설정']['내용과자동생성'].checked? || @data['포스트설정']['gpt키워드'].checked?
3112
+ sleep(2)
3113
+ puts '이미지 자동 세탁 중 · · · '
3114
+ end
3115
+
3116
+ p content5
3117
+ puts content55
3118
+ p position
3119
+
3120
+ sleep(2)
3121
+ position.each do |i|
3122
+ image_url22 = get_image_file().force_encoding('utf-8')
3123
+ if @data['포스트설정']['내용사진링크'].checked?
3124
+ image_tag = '<a href="' + @data['포스트설정']['내용사진링크값'].text.to_s.force_encoding('utf-8') +
3125
+ '"><img src="' + image_url22 + '" alt="' + keyword.force_encoding('utf-8') + '" class="aligncenter size-full"></a>'
3126
+ else
3127
+ image_tag = '<img src="' + image_url22 + '" alt="' + keyword + '" class="aligncenter size-full">'
3113
3128
  end
3129
+ content5.insert(i, image_tag)
3130
+ end
3131
+
3132
+ sleep(2)
3133
+ puts '이미지 자동 세탁 완료 · · · '
3134
+
3135
+ if @data['포스트설정']['내용과자동생성'].checked?
3136
+ content = content5.join("\n") + '(자동생성글)' + content55
3137
+ elsif @data['포스트설정']['gpt키워드'].checked?
3138
+ content = content_prefix + "(자동생성글)" + content5.join("\n")
3139
+ else
3140
+ content = content5.join("\n")
3114
3141
  end
3115
-
3116
- position = position.sort
3117
-
3118
- if @data['포스트설정']['내용과자동생성'].checked? or @data['포스트설정']['gpt키워드'].checked?
3119
- sleep(2)
3120
- puts '이미지 자동 세탁 중 · · · '
3121
- end
3122
- sleep(2)
3123
- position.each do |i|
3124
- image_url22 = get_image_file().force_encoding('utf-8')
3125
- puts image_url22
3126
- puts '사진넣는위치 => '+i.to_s
3127
- if @data['포스트설정']['내용사진링크'].checked?
3128
- image_memory << ""+'<a href="'+@data['포스트설정']['내용사진링크값'].text.to_s.force_encoding('utf-8').force_encoding('utf-8')+'"><img src="'+image_url22+'" alt="'+keyword.force_encoding('utf-8')+'"></a>'+""
3129
- content5.insert(i, '**image**')
3130
- else
3131
- image_memory << ""+'<img src="'+image_url22+'" alt="'+keyword+'" class="aligncenter size-full">'+""
3132
- content5.insert(i, '**image**')
3133
- end
3134
- end
3135
- sleep(2)
3136
- puts '이미지 자동 세탁 완료 · · · '
3137
- if @data['포스트설정']['내용과자동생성'].checked? or @data['포스트설정']['gpt키워드'].checked?
3138
- content = content5.join("\n")+'(자동생성글)'+content55
3139
- puts content
3140
- else
3141
- content = content5.join("\n")
3142
3142
  end
3143
3143
  end
3144
- end
3144
+
3145
3145
 
3146
3146
 
3147
3147
  ##여기서부터 이미지 순서대로 수정코드 변경####-------------------------------------------------------------------------------
@@ -3152,6 +3152,15 @@ class Wordpress
3152
3152
  content_memory = content.split('(자동생성글)')
3153
3153
  content = content_memory[0]
3154
3154
  content_end = content_memory[1].to_s
3155
+ if @data['포스트설정']['gpt키워드'].checked?
3156
+ if @data['포스트설정']['gpt상단'].checked?
3157
+ content = "(자동생성글)\n" + content_end + "\n" + content
3158
+ else
3159
+ content = content + "\n(자동생성글)\n" + content_end
3160
+ end
3161
+ else
3162
+ content = content + "\n(자동생성글)\n" + content_end
3163
+ end
3155
3164
 
3156
3165
  if @data['포스트설정']['특정단어키워드로변경'].checked?
3157
3166
  @data['포스트설정']['특정단어키워드로변경값'].text.to_s.force_encoding('utf-8').split(',').each do |i|
@@ -3240,8 +3249,8 @@ class Wordpress
3240
3249
  slide_names_only = slide_images.map { |pair| pair[1] }.join(' ')
3241
3250
 
3242
3251
  # 각각 <slide>와 <slide1> 태그로 감싸기
3243
- slide_html_full = "<slide>" + slide_full_paths + "</slide>"
3244
- slide_html_names = "<slide1>" + slide_names_only + "</slide1>"
3252
+ slide_html_full = "\n<slide>" + slide_full_paths + "</slide>\n"
3253
+ slide_html_names = "\n<slide1>" + slide_names_only + "</slide1>\n"
3245
3254
 
3246
3255
  # 두 태그를 content에 추가
3247
3256
  content[index3] = content[index3] + slide_html_full
@@ -3317,36 +3326,79 @@ class Wordpress
3317
3326
  # end
3318
3327
  #end
3319
3328
  if @data['포스트설정']['지도로변경'].checked?
3320
- # 지도 주소와 사용자 설정 단어들을 가져옵니다.
3321
3329
  map_address = @data['포스트설정']['지도주소'].text.to_s.force_encoding('utf-8')
3322
-
3323
- # 여러 단어로 설정된 '지도로변경단어'를 분리하여 배열로 저장
3324
3330
  change_words = @data['포스트설정']['지도로변경단어'].text.to_s.force_encoding('utf-8').split(',')
3325
3331
 
3326
- # content를 각 줄로 분할
3327
3332
  content_lines = content.split("\n")
3333
+ new_lines = []
3334
+
3335
+ content_lines.each do |line|
3336
+ # 이미 처리된 줄은 건너뜀
3337
+ if line.include?("<koreamap>")
3338
+ new_lines << line
3339
+ next
3340
+ end
3341
+
3342
+ processed = false
3328
3343
 
3329
- content_lines.each_with_index do |line, index|
3330
- # 각 단어에 대해 처리
3331
3344
  change_words.each do |change_word|
3332
- # 'change_word'가 포함된 줄에 대해서만 처리
3333
- if line.include?(change_word)
3334
- # 설정된 단어 뒤에 괄호가 있는지 확인
3335
- if line.include?("[") && line.include?("]")
3336
- # 괄호 안의 주소를 찾아서 그 주소는 그대로 두고, 지도로 변경된 주소로 교체
3337
- address_in_brackets = line.match(/\[(.*?)\]/)[1] # 괄호 안의 주소를 추출
3338
- content_lines[index] = "<koreamap>#{address_in_brackets}</koreamap>"
3339
- else
3340
- # 괄호가 없다면 @data['포스트설정']['지도주소']를 추가
3341
- content_lines[index] = "<koreamap>#{map_address}</koreamap>"
3345
+ # 1. [단어][주소] 패턴 처리: 분리 + 출력
3346
+ if line =~ /#{Regexp.escape(change_word)}\[(.*?)\]/
3347
+ match_data = line.match(/(.*)#{Regexp.escape(change_word)}\[(.*?)\](.*)/)
3348
+ if match_data
3349
+ before = match_data[1]
3350
+ address = match_data[2]
3351
+ after = match_data[3]
3352
+
3353
+ # 태그 추출
3354
+ open_tag = before[/<p[^>]*?>/i] || ""
3355
+ close_tag = after[/<\/p>/i] || ""
3356
+
3357
+ # 텍스트 정리
3358
+ before_text = before.sub(open_tag, '')
3359
+ after_text = after.sub(close_tag, '')
3360
+
3361
+ # 줄 분리
3362
+ new_lines << "#{open_tag}#{before_text}</p>" unless before_text.strip.empty?
3363
+ new_lines << "<koreamap>#{address}</koreamap>"
3364
+ new_lines << "#{open_tag}#{after_text}#{close_tag}" unless after_text.strip.empty?
3365
+
3366
+ processed = true
3367
+ break
3342
3368
  end
3343
3369
  end
3370
+
3371
+ # 2. 일반 단어 처리 (한 줄에만 등장하는 경우)
3372
+ if !processed && line.include?(change_word)
3373
+ parts = line.split(change_word, 2)
3374
+ prefix = parts[0]
3375
+ suffix = parts[1]
3376
+
3377
+ open_tag = prefix[/<p[^>]*?>/i] || ""
3378
+ close_tag = suffix[/<\/p>/i] || ""
3379
+
3380
+ prefix_text = prefix.sub(open_tag, '')
3381
+ suffix_text = suffix.sub(close_tag, '')
3382
+
3383
+ new_lines << "#{open_tag}#{prefix_text}</p>" unless prefix_text.strip.empty?
3384
+ new_lines << "<koreamap>#{map_address}</koreamap>"
3385
+ new_lines << "#{open_tag}#{suffix_text}#{close_tag}" unless suffix_text.strip.empty?
3386
+
3387
+ processed = true
3388
+ break
3389
+ end
3344
3390
  end
3391
+
3392
+ # 변경이 없었으면 원래 줄 추가
3393
+ new_lines << line unless processed
3345
3394
  end
3346
3395
 
3347
- # 다시 content로 합치기
3348
- content = content_lines.join("\n")
3396
+ content = new_lines.join("\n")
3349
3397
  end
3398
+
3399
+
3400
+
3401
+
3350
3402
 
3351
3403
  if @data['포스트설정']['인용구변경'].checked?
3352
3404
  if @data['포스트설정']['인용구문구설정'].checked?
@@ -3384,21 +3436,26 @@ class Wordpress
3384
3436
  @data['table'] << []
3385
3437
  @data['table'].pop
3386
3438
 
3439
+
3440
+ parts = content.split('(자동생성글)', 2)
3441
+ content_main = parts[0].strip
3442
+ content_end = parts[1].to_s.strip
3443
+
3387
3444
  soosick_1 = ''
3388
3445
  soosick_2 = ''
3389
3446
  if @data['포스트설정']['자동글 수식에 입력'].checked?
3390
- content = content
3391
- soosick_1 = content_end
3447
+ content = content_main
3448
+ soosick_1 = content_end
3392
3449
  else
3393
- if @data['포스트설정']['gpt키워드'].checked?
3394
- if @data['포스트설정']['gpt상단'].checked?
3395
- content = content_end+"\n"+content+"\n"
3396
- else
3397
- content = content+"\n"+content_end+"\n"
3398
- end
3450
+ if @data['포스트설정']['gpt키워드'].checked?
3451
+ if @data['포스트설정']['gpt상단'].checked?
3452
+ content = content_end + "\n" + content_main + "\n"
3399
3453
  else
3400
- content = content+"\n"+content_end+"\n"
3454
+ content = content_main + "\n" + content_end + "\n"
3401
3455
  end
3456
+ else
3457
+ content = content_main + "\n" + content_end + "\n"
3458
+ end
3402
3459
  end
3403
3460
 
3404
3461
  if @data['포스트설정']['막글삽입'].checked?
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nblog_duo
3
3
  version: !ruby/object:Gem::Version
4
- version: 111.111.777
4
+ version: 111.115.777
5
5
  platform: ruby
6
6
  authors:
7
7
  - zon
8
- autorequire:
9
8
  bindir: bin
10
9
  cert_chain: []
11
- date: 2025-04-11 00:00:00.000000000 Z
10
+ date: 2025-04-24 00:00:00.000000000 Z
12
11
  dependencies: []
13
12
  description: File to Clipboard gem
14
13
  email: mymin26@naver.com
@@ -21,7 +20,6 @@ homepage: ''
21
20
  licenses:
22
21
  - zon
23
22
  metadata: {}
24
- post_install_message:
25
23
  rdoc_options: []
26
24
  require_paths:
27
25
  - lib
@@ -36,8 +34,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
36
34
  - !ruby/object:Gem::Version
37
35
  version: '0'
38
36
  requirements: []
39
- rubygems_version: 3.3.7
40
- signing_key:
37
+ rubygems_version: 3.6.7
41
38
  specification_version: 4
42
39
  summary: file to clipboard
43
40
  test_files: []