nblog_zon 0.0.101 → 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_zon.rb +173 -116
  3. metadata +3 -6
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 800ef8d32d384cad3b8bcf0cc75fa691c0f83e0efcc9f8c157ef3e55ba91e499
4
- data.tar.gz: a6ae5b52f7edf6def7c25e49997a2328c0670255fcd40e019e41c5c8f3138348
3
+ metadata.gz: 25ed13d86ba37e1d7148f3f244e32f4e09ccad595dbd05b010bb7df959962356
4
+ data.tar.gz: 63fd6e53b871e37661d6f2561a447b73ab6b2508bebc007fdfdfc04d860f3577
5
5
  SHA512:
6
- metadata.gz: 7546506eff39f59be1ad66228106754d7a284d40048f5d1c3f06f3b8132b274037552849695b14d4532bde3fe3b6349b33dc4ef78031c4ad08e2e7bec376beca
7
- data.tar.gz: 42005f835e9583d08e31be158406219f9a21807690947501c2550f0320136ea80510875b8a1f5084e33a40966341aa3fdde6d7a390714da3026c3fa8533f04ef
6
+ metadata.gz: e4c3b6d7863487e9b4a54be4979c8ce1721c51849085a21248fbe075f31254def552485e803b1d868fdc43d4f254137a64d15c8001b4c51f28fc3bda9058d4ec
7
+ data.tar.gz: 0cbddb5f47a301779b0bca6d1ece6f557e2260bd37ad62111e1ff46d8f9c43beabb35fc1116c21fa770fc15abf27698e23edebbab1fa92a9e9c48eaed5fffa5e
data/lib/nblog_zon.rb CHANGED
@@ -2164,20 +2164,27 @@ class Wordpress
2164
2164
 
2165
2165
  def save_image
2166
2166
  if @data['이미지설정']['이미지'].length == 0
2167
-
2167
+ return
2168
+ end
2169
+
2170
+ if @data['이미지설정']['순서사용'].checked?
2171
+ image_path = @data['이미지설정']['이미지'][@image_counter][2]
2172
+ @image_counter += 1
2173
+ if @image_counter > @data['이미지설정']['이미지'].length - 1
2174
+ @image_counter = 0
2175
+ end
2168
2176
  else
2169
- if @data['이미지설정']['순서사용'].checked?
2170
- image_path = @data['이미지설정']['이미지'][@image_counter][2]
2171
- @image_counter += 1
2172
- if @image_counter > @data['이미지설정']['이미지'].length-1
2173
- @image_counter = 0
2174
- end
2175
- else
2176
- image_path = @data['이미지설정']['이미지'].sample[2]
2177
+ # 초기화가 안됐거나 다 썼으면 새롭게 섞는다
2178
+ @shuffled_images ||= []
2179
+ if @shuffled_images.empty?
2180
+ @shuffled_images = @data['이미지설정']['이미지'].shuffle
2177
2181
  end
2178
- img = Magick::Image.read(image_path).first
2179
- img.write('./image/memory.png')
2182
+
2183
+ image_path = @shuffled_images.shift[2]
2180
2184
  end
2185
+
2186
+ img = Magick::Image.read(image_path).first
2187
+ img.write('./image/memory.png')
2181
2188
  end
2182
2189
 
2183
2190
  def change_image_size(w)
@@ -2728,6 +2735,22 @@ class Wordpress
2728
2735
  @data['table'].pop
2729
2736
  #제목끝
2730
2737
  # content = " #{content} "
2738
+ if @data['포스트설정']['gpt키워드'].checked?
2739
+ gpt_keyword_prompt = @data['포스트설정']['gpt키워드_프롬프트'].text.to_s.force_encoding('utf-8')
2740
+ gpt_keyword_prompt_sample = gpt_keyword_prompt.strip.empty? ? "프롬프트: 관련된 글을 1500자에서 2500자 사이로 만들어줘" : gpt_keyword_prompt
2741
+ chat = Chat.new(@data['포스트설정']['api_key'].text.to_s.force_encoding('utf-8'), gpt_keyword_prompt)
2742
+ gpt_text = chat.message(keyword)
2743
+ #content = content.to_s + "\n(자동생성글)\n" + gpt_text.to_s
2744
+ content = content.to_s + "(자동생성글)" + gpt_text.to_s
2745
+ elsif @data['포스트설정']['내용을자동생성'].checked?
2746
+ content = auto_text
2747
+ elsif @data['포스트설정']['내용과자동생성'].checked?
2748
+ #content = content + "\n(자동생성글)\n" + auto_text
2749
+ content = content + "(자동생성글)" + auto_text
2750
+ end
2751
+ @data['table'][index][-1] = 45
2752
+ @data['table'] << []
2753
+ @data['table'].pop
2731
2754
 
2732
2755
  if @data['포스트설정']['특정단어굵기'].checked?
2733
2756
  content2 = ''
@@ -2767,7 +2790,7 @@ class Wordpress
2767
2790
  content = content2
2768
2791
  end
2769
2792
  end
2770
- @data['table'][index][-1] = 35
2793
+ @data['table'][index][-1] = 50
2771
2794
  @data['table'] << []
2772
2795
  @data['table'].pop
2773
2796
  if @data['포스트설정']['단어크기변경'].checked?
@@ -2788,19 +2811,7 @@ class Wordpress
2788
2811
  @data['table'][index][-1] = 50
2789
2812
  @data['table'] << []
2790
2813
  @data['table'].pop
2791
- if @data['포스트설정']['gpt키워드'].checked?
2792
- gpt_keyword_prompt = @data['포스트설정']['gpt키워드_프롬프트'].text.to_s.force_encoding('utf-8')
2793
- gpt_keyword_prompt_sample = gpt_keyword_prompt.strip.empty? ? "프롬프트: 관련된 글을 1500자에서 2500자 사이로 만들어줘" : gpt_keyword_prompt
2794
- chat = Chat.new(@data['포스트설정']['api_key'].text.to_s.force_encoding('utf-8'), gpt_keyword_prompt)
2795
- gpt_text = chat.message(keyword)
2796
- #content = content.to_s + "\n(자동생성글)\n" + gpt_text.to_s
2797
- content = content.to_s + "(자동생성글)" + gpt_text.to_s
2798
- elsif @data['포스트설정']['내용을자동생성'].checked?
2799
- content = auto_text
2800
- elsif @data['포스트설정']['내용과자동생성'].checked?
2801
- #content = content + "\n(자동생성글)\n" + auto_text
2802
- content = content + "(자동생성글)" + auto_text
2803
- end
2814
+
2804
2815
 
2805
2816
  if @data['포스트설정']['내용키워드삽입'].checked?
2806
2817
  puts '내용키워드삽입...'
@@ -2985,94 +2996,83 @@ class Wordpress
2985
2996
  puts '내용사진자동삽입...'
2986
2997
  sn = @data['포스트설정']['내용사진자동삽입시작숫자'].text.to_s.force_encoding('utf-8').to_i
2987
2998
  en = @data['포스트설정']['내용사진자동삽입끝숫자'].text.to_s.force_encoding('utf-8').to_i
2999
+
2988
3000
  begin
2989
3001
  cn = rand(sn..en)
2990
3002
  rescue
2991
3003
  cn = 0
2992
3004
  puts 'cn = rand(sn..en) error cn = 1'
2993
3005
  end
2994
-
3006
+
2995
3007
  if cn != 0
2996
- position = Array.new
3008
+ # content5 구성 및 위치 배열 생성
2997
3009
  if @data['포스트설정']['내용과자동생성'].checked?
2998
- if @data['포스트설정']['자동글 수식에 입력'].checked?
2999
- for n in 1..cn
3000
- position << rand(0..(content.split("(자동생성글)")[0].split("\n").length-1))
3001
- sleep(2)
3002
- end
3003
- else
3004
- for n in 1..cn
3005
- position << rand(0..(content.split("(자동생성글)")[0].split("\n").length-1))
3006
- sleep(2)
3007
- end
3008
- end
3009
- # position.pop
3010
- else
3011
- for n in 1..cn
3012
- position << rand(0..(content.split("\n").length-2))
3013
- sleep(2)
3014
- end
3015
- end
3016
-
3017
- if @data['포스트설정']['내용과자동생성'].checked? or @data['포스트설정']['gpt키워드'].checked?
3018
3010
  if @data['포스트설정']['자동글 수식에 입력'].checked?
3019
3011
  content5 = content.split("(자동생성글)")[0].to_s.split("\n")
3020
3012
  content55 = content.split("(자동생성글)")[1].to_s
3013
+ position = content5.length.times.to_a.sample(cn).sort.reverse
3021
3014
  else
3022
3015
  content5 = content.split("(자동생성글)")[0].to_s.split("\n")
3023
3016
  content55 = content.split("(자동생성글)")[1].to_s
3017
+ position = content5.length.times.to_a.sample(cn).sort.reverse
3024
3018
  end
3019
+ elsif @data['포스트설정']['gpt키워드'].checked?
3020
+ content5 = content.split("(자동생성글)")[1].to_s.split("\n")
3021
+ content_prefix = content.split("(자동생성글)")[0].to_s
3022
+ content55 = ''
3023
+ position = content5.length.times.to_a.sample(cn).sort.reverse
3025
3024
  else
3025
+ content5 = content.split("\n")
3026
3026
  content55 = ''
3027
- content5 = content.split("(자동생성글)")[0].to_s.split("\n")
3027
+ position = content5.length.times.to_a.sample(cn).sort.reverse
3028
3028
  end
3029
-
3030
- p content5
3031
- puts content55
3032
- p position
3033
-
3029
+
3030
+ # 중복 필터링 로직
3034
3031
  while true
3035
3032
  check11 = 0
3036
- for nn in 0..position.length-1
3037
- if content5[position[nn]].to_s.include?('style') or content5[position[nn]].to_s.include?('<') or content5[position[nn]].to_s.include?('>')
3033
+ position.each_with_index do |pos, idx|
3034
+ if content5[pos].to_s.include?('style') || content5[pos].to_s.include?('<') || content5[pos].to_s.include?('>')
3038
3035
  check11 = 1
3039
- position[nn] += 4
3036
+ position[idx] += 4
3040
3037
  end
3041
3038
  end
3042
- if check11 == 0
3043
- break
3039
+ break if check11 == 0
3040
+ end
3041
+
3042
+ if @data['포스트설정']['내용과자동생성'].checked? || @data['포스트설정']['gpt키워드'].checked?
3043
+ sleep(2)
3044
+ puts '이미지 자동 세탁 중 · · · '
3045
+ end
3046
+
3047
+ p content5
3048
+ puts content55
3049
+ p position
3050
+
3051
+ sleep(2)
3052
+ position.each do |i|
3053
+ image_url22 = get_image_file().force_encoding('utf-8')
3054
+ if @data['포스트설정']['내용사진링크'].checked?
3055
+ image_tag = '<a href="' + @data['포스트설정']['내용사진링크값'].text.to_s.force_encoding('utf-8') +
3056
+ '"><img src="' + image_url22 + '" alt="' + keyword.force_encoding('utf-8') + '" class="aligncenter size-full"></a>'
3057
+ else
3058
+ image_tag = '<img src="' + image_url22 + '" alt="' + keyword + '" class="aligncenter size-full">'
3044
3059
  end
3060
+ content5.insert(i, image_tag)
3061
+ end
3062
+
3063
+ sleep(2)
3064
+ puts '이미지 자동 세탁 완료 · · · '
3065
+
3066
+ if @data['포스트설정']['내용과자동생성'].checked?
3067
+ content = content5.join("\n") + '(자동생성글)' + content55
3068
+ elsif @data['포스트설정']['gpt키워드'].checked?
3069
+ content = content_prefix + "(자동생성글)" + content5.join("\n")
3070
+ else
3071
+ content = content5.join("\n")
3045
3072
  end
3046
-
3047
- position = position.sort
3048
-
3049
- if @data['포스트설정']['내용과자동생성'].checked? or @data['포스트설정']['gpt키워드'].checked?
3050
- sleep(2)
3051
- puts '이미지 자동 세탁 중 · · · '
3052
- end
3053
- sleep(2)
3054
- position.each do |i|
3055
- image_url22 = get_image_file().force_encoding('utf-8')
3056
- puts image_url22
3057
- puts '사진넣는위치 => '+i.to_s
3058
- if @data['포스트설정']['내용사진링크'].checked?
3059
- 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>'+""
3060
- content5.insert(i, '**image**')
3061
- else
3062
- image_memory << ""+'<img src="'+image_url22+'" alt="'+keyword+'" class="aligncenter size-full">'+""
3063
- content5.insert(i, '**image**')
3064
- end
3065
- end
3066
- sleep(2)
3067
- puts '이미지 자동 세탁 완료 · · · '
3068
- if @data['포스트설정']['내용과자동생성'].checked? or @data['포스트설정']['gpt키워드'].checked?
3069
- content = content5.join("\n")+'(자동생성글)'+content55
3070
- puts content
3071
- else
3072
- content = content5.join("\n")
3073
3073
  end
3074
3074
  end
3075
- end
3075
+
3076
3076
 
3077
3077
 
3078
3078
  ##여기서부터 이미지 순서대로 수정코드 변경####-------------------------------------------------------------------------------
@@ -3083,6 +3083,15 @@ class Wordpress
3083
3083
  content_memory = content.split('(자동생성글)')
3084
3084
  content = content_memory[0]
3085
3085
  content_end = content_memory[1].to_s
3086
+ if @data['포스트설정']['gpt키워드'].checked?
3087
+ if @data['포스트설정']['gpt상단'].checked?
3088
+ content = "(자동생성글)\n" + content_end + "\n" + content
3089
+ else
3090
+ content = content + "\n(자동생성글)\n" + content_end
3091
+ end
3092
+ else
3093
+ content = content + "\n(자동생성글)\n" + content_end
3094
+ end
3086
3095
 
3087
3096
  if @data['포스트설정']['특정단어키워드로변경'].checked?
3088
3097
  @data['포스트설정']['특정단어키워드로변경값'].text.to_s.force_encoding('utf-8').split(',').each do |i|
@@ -3171,8 +3180,8 @@ class Wordpress
3171
3180
  slide_names_only = slide_images.map { |pair| pair[1] }.join(' ')
3172
3181
 
3173
3182
  # 각각 <slide>와 <slide1> 태그로 감싸기
3174
- slide_html_full = "<slide>" + slide_full_paths + "</slide>"
3175
- slide_html_names = "<slide1>" + slide_names_only + "</slide1>"
3183
+ slide_html_full = "\n<slide>" + slide_full_paths + "</slide>\n"
3184
+ slide_html_names = "\n<slide1>" + slide_names_only + "</slide1>\n"
3176
3185
 
3177
3186
  # 두 태그를 content에 추가
3178
3187
  content[index3] = content[index3] + slide_html_full
@@ -3248,36 +3257,79 @@ class Wordpress
3248
3257
  # end
3249
3258
  #end
3250
3259
  if @data['포스트설정']['지도로변경'].checked?
3251
- # 지도 주소와 사용자 설정 단어들을 가져옵니다.
3252
3260
  map_address = @data['포스트설정']['지도주소'].text.to_s.force_encoding('utf-8')
3253
-
3254
- # 여러 단어로 설정된 '지도로변경단어'를 분리하여 배열로 저장
3255
3261
  change_words = @data['포스트설정']['지도로변경단어'].text.to_s.force_encoding('utf-8').split(',')
3256
3262
 
3257
- # content를 각 줄로 분할
3258
3263
  content_lines = content.split("\n")
3264
+ new_lines = []
3265
+
3266
+ content_lines.each do |line|
3267
+ # 이미 처리된 줄은 건너뜀
3268
+ if line.include?("<koreamap>")
3269
+ new_lines << line
3270
+ next
3271
+ end
3272
+
3273
+ processed = false
3259
3274
 
3260
- content_lines.each_with_index do |line, index|
3261
- # 각 단어에 대해 처리
3262
3275
  change_words.each do |change_word|
3263
- # 'change_word'가 포함된 줄에 대해서만 처리
3264
- if line.include?(change_word)
3265
- # 설정된 단어 뒤에 괄호가 있는지 확인
3266
- if line.include?("[") && line.include?("]")
3267
- # 괄호 안의 주소를 찾아서 그 주소는 그대로 두고, 지도로 변경된 주소로 교체
3268
- address_in_brackets = line.match(/\[(.*?)\]/)[1] # 괄호 안의 주소를 추출
3269
- content_lines[index] = "<koreamap>#{address_in_brackets}</koreamap>"
3270
- else
3271
- # 괄호가 없다면 @data['포스트설정']['지도주소']를 추가
3272
- content_lines[index] = "<koreamap>#{map_address}</koreamap>"
3276
+ # 1. [단어][주소] 패턴 처리: 분리 + 출력
3277
+ if line =~ /#{Regexp.escape(change_word)}\[(.*?)\]/
3278
+ match_data = line.match(/(.*)#{Regexp.escape(change_word)}\[(.*?)\](.*)/)
3279
+ if match_data
3280
+ before = match_data[1]
3281
+ address = match_data[2]
3282
+ after = match_data[3]
3283
+
3284
+ # 태그 추출
3285
+ open_tag = before[/<p[^>]*?>/i] || ""
3286
+ close_tag = after[/<\/p>/i] || ""
3287
+
3288
+ # 텍스트 정리
3289
+ before_text = before.sub(open_tag, '')
3290
+ after_text = after.sub(close_tag, '')
3291
+
3292
+ # 줄 분리
3293
+ new_lines << "#{open_tag}#{before_text}</p>" unless before_text.strip.empty?
3294
+ new_lines << "<koreamap>#{address}</koreamap>"
3295
+ new_lines << "#{open_tag}#{after_text}#{close_tag}" unless after_text.strip.empty?
3296
+
3297
+ processed = true
3298
+ break
3273
3299
  end
3274
3300
  end
3301
+
3302
+ # 2. 일반 단어 처리 (한 줄에만 등장하는 경우)
3303
+ if !processed && line.include?(change_word)
3304
+ parts = line.split(change_word, 2)
3305
+ prefix = parts[0]
3306
+ suffix = parts[1]
3307
+
3308
+ open_tag = prefix[/<p[^>]*?>/i] || ""
3309
+ close_tag = suffix[/<\/p>/i] || ""
3310
+
3311
+ prefix_text = prefix.sub(open_tag, '')
3312
+ suffix_text = suffix.sub(close_tag, '')
3313
+
3314
+ new_lines << "#{open_tag}#{prefix_text}</p>" unless prefix_text.strip.empty?
3315
+ new_lines << "<koreamap>#{map_address}</koreamap>"
3316
+ new_lines << "#{open_tag}#{suffix_text}#{close_tag}" unless suffix_text.strip.empty?
3317
+
3318
+ processed = true
3319
+ break
3320
+ end
3275
3321
  end
3322
+
3323
+ # 변경이 없었으면 원래 줄 추가
3324
+ new_lines << line unless processed
3276
3325
  end
3277
3326
 
3278
- # 다시 content로 합치기
3279
- content = content_lines.join("\n")
3327
+ content = new_lines.join("\n")
3280
3328
  end
3329
+
3330
+
3331
+
3332
+
3281
3333
 
3282
3334
  if @data['포스트설정']['인용구변경'].checked?
3283
3335
  if @data['포스트설정']['인용구문구설정'].checked?
@@ -3315,21 +3367,26 @@ class Wordpress
3315
3367
  @data['table'] << []
3316
3368
  @data['table'].pop
3317
3369
 
3370
+
3371
+ parts = content.split('(자동생성글)', 2)
3372
+ content_main = parts[0].strip
3373
+ content_end = parts[1].to_s.strip
3374
+
3318
3375
  soosick_1 = ''
3319
3376
  soosick_2 = ''
3320
3377
  if @data['포스트설정']['자동글 수식에 입력'].checked?
3321
- content = content
3322
- soosick_1 = content_end
3378
+ content = content_main
3379
+ soosick_1 = content_end
3323
3380
  else
3324
- if @data['포스트설정']['gpt키워드'].checked?
3325
- if @data['포스트설정']['gpt상단'].checked?
3326
- content = content_end+"\n"+content+"\n"
3327
- else
3328
- content = content+"\n"+content_end+"\n"
3329
- end
3381
+ if @data['포스트설정']['gpt키워드'].checked?
3382
+ if @data['포스트설정']['gpt상단'].checked?
3383
+ content = content_end + "\n" + content_main + "\n"
3330
3384
  else
3331
- content = content+"\n"+content_end+"\n"
3385
+ content = content_main + "\n" + content_end + "\n"
3332
3386
  end
3387
+ else
3388
+ content = content_main + "\n" + content_end + "\n"
3389
+ end
3333
3390
  end
3334
3391
 
3335
3392
  if @data['포스트설정']['막글삽입'].checked?
@@ -3499,7 +3556,7 @@ class Wordpress
3499
3556
  dd_time = @data['table'][index][10].to_s.force_encoding('utf-8').to_i
3500
3557
  #template_no = @data['table'][index][7].to_s.force_encoding('utf-8').to_i
3501
3558
  naver.update(title,content,option,soosick_1,soosick_2, dd_time)
3502
-
3559
+
3503
3560
 
3504
3561
  # if @data['포스트설정']['태그삽입2'].checked?
3505
3562
  # snumber = @data['포스트설정']['태그삽입2시작숫자'].text.to_s.force_encoding('utf-8').to_i
metadata CHANGED
@@ -1,14 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nblog_zon
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.101
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-03-13 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: rnjstnswp123@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: []