tblog_duopack 0.0.3 → 0.0.5

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/tblog_duopack.rb +40 -70
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 4699f944ce442434a828f85b9823cc53c51718fb009cb6a4842a859ea11580ec
4
- data.tar.gz: 2bbe21704fc4949c8a6b51df953a0160eb9a7ee8d08a445a09ed0c0b13692042
3
+ metadata.gz: 67aca1228ea382eedfe5cd4311bba5bac0f58c7086bab65742981b1fd94df259
4
+ data.tar.gz: 4d9399e4ca2201f9124d730528fad53e94d6ea74e140202e8510a70eb51dcd9e
5
5
  SHA512:
6
- metadata.gz: 1d8c5f4dcaf281cbd55af4807bf31b5839518c3c53796856e607a1f044d94b3294676af47f09c0d02886e987c2d79cfd52598a91a44e85782650a12e56cd6fbc
7
- data.tar.gz: 4b317223275a21156bb1d1b0424fea392983c69f5baf85c523bab1fdaa7be6851efc395c9b8b28e5107b56cf66a0135fe37bb7c498d33691818977bd0366b5b9
6
+ metadata.gz: a5bfde0b177e7c1ec89d2651af06931fd4e54ff71e7f4ee5de1486fcaddea5f90c51945b7ed2c61c80a3d31d253de780a9381e34414c4e0bd3c11717ca01f9f0
7
+ data.tar.gz: 04b37e0db153e7973c7b480e0affd256418358187bf51f02cfe105a280724d0e2352dc4ab900a053d945e0d829e70ffc906575cf70cb11e07acb45f3125acae2
data/lib/tblog_duopack.rb CHANGED
@@ -2250,104 +2250,74 @@ class Wordpress
2250
2250
  end
2251
2251
 
2252
2252
  image_thum_ids = Array.new
2253
-
2254
2253
  image_memory = Array.new
2255
-
2254
+
2256
2255
  if @data['포스트설정']['내용사진자동삽입'].checked?
2257
2256
  puts '내용사진자동삽입...'
2257
+
2258
2258
  sn = @data['포스트설정']['내용사진자동삽입시작숫자'].text.to_s.force_encoding('utf-8').to_i
2259
2259
  en = @data['포스트설정']['내용사진자동삽입끝숫자'].text.to_s.force_encoding('utf-8').to_i
2260
+
2260
2261
  begin
2261
2262
  cn = rand(sn..en)
2262
2263
  rescue
2263
2264
  cn = 0
2264
2265
  puts 'cn = rand(sn..en) error cn = 1'
2265
2266
  end
2266
-
2267
+
2267
2268
  if cn != 0
2268
- position = Array.new
2269
- if @data['포스트설정']['내용과자동생성'].checked?
2270
- for n in 1..cn
2271
- position << rand(0..(content.split("(자동생성글)")[1].split("\n").length-1))
2272
- sleep(2)
2273
- end
2274
- position.pop
2275
- else
2276
- for n in 1..cn
2277
- position << rand(0..(content.split("\n").length-2))
2278
- sleep(2)
2279
- end
2280
- end
2281
-
2282
- if @data['포스트설정']['내용과자동생성'].checked? or @data['포스트설정']['gpt키워드'].checked?
2283
- content5 = content.split("(자동생성글)")[0].to_s.split("\n")
2284
- content55 = content.split("(자동생성글)")[1].to_s
2285
-
2286
- else
2287
- content55 = ''
2288
- content5 = content.split("(자동생성글)")[0].to_s.split("\n")
2289
- end
2290
-
2291
- p content5
2292
- puts content55
2293
- p position
2294
-
2295
- while true
2296
- check11 = 0
2297
- for nn in 0..position.length-1
2298
- if content5[position[nn]].to_s.include?('style') or content5[position[nn]].to_s.include?('<') or content5[position[nn]].to_s.include?('>')
2299
- check11 = 1
2300
- position[nn] += 4
2301
- end
2302
- end
2303
- if check11 == 0
2304
- break
2269
+ # 내용 분할 (자동 생성 글과 텍스트)
2270
+ content5 = content.split("(자동생성글)")[0].to_s.split("\n")
2271
+ content55 = content.split("(자동생성글)")[1].to_s if @data['포스트설정']['내용과자동생성'].checked? || @data['포스트설정']['gpt키워드'].checked?
2272
+
2273
+ # 빈 줄 찾기
2274
+ empty_positions = content5.each_with_index.select { |line, index| line.strip.empty? }.map { |line, index| index }
2275
+
2276
+ # 빈 줄이 부족하면 텍스트 끝에 빈 줄 추가
2277
+ if empty_positions.length < cn
2278
+ # 부족한 빈 줄의 수
2279
+ missing_empty_lines = cn - empty_positions.length
2280
+ missing_empty_lines.times do
2281
+ content5 << "" # 텍스트 마지막에 빈 줄 추가
2305
2282
  end
2283
+ empty_positions = content5.each_with_index.select { |line, index| line.strip.empty? }.map { |line, index| index } # 다시 빈 줄 위치 계산
2306
2284
  end
2307
-
2308
- position = position.sort
2309
-
2310
- if @data['포스트설정']['내용과자동생성'].checked? or @data['포스트설정']['gpt키워드'].checked?
2285
+
2286
+ # 이미지 삽입할 위치를 지정 (빈 줄 위치에 삽입)
2287
+ position = empty_positions[0..cn-1]
2288
+
2289
+ # 이미지 URL 가져오기
2290
+ if @data['포스트설정']['내용과자동생성'].checked? || @data['포스트설정']['gpt키워드'].checked?
2311
2291
  image_url22 = get_image_file().force_encoding('utf-8')
2312
2292
  end
2313
-
2293
+
2294
+ # 각 위치에 이미지를 하나씩만 삽입
2314
2295
  position.each do |i|
2315
2296
  image_url = get_image_file().force_encoding('utf-8')
2316
- puts image_url
2317
-
2318
- puts '사진넣는위치 => '+i.to_s
2297
+ puts '사진넣는위치 => ' + i.to_s
2298
+
2299
+ # 링크가 있을 경우 링크 포함
2319
2300
  if @data['포스트설정']['내용사진링크'].checked?
2320
- image_memory << ""+'<a href="'+@data['포스트설정']['내용사진링크값'].text.to_s.force_encoding('utf-8').force_encoding('utf-8')+'"><img src="'+image_url+'" alt="'+keyword.force_encoding('utf-8')+'"></a>'+""
2321
- content5.insert(i, '**image**')
2301
+ image_memory << "<a href='" + @data['포스트설정']['내용사진링크값'].text.to_s.force_encoding('utf-8') + "'><img src='" + image_url + "' alt='" + keyword.force_encoding('utf-8') + "'></a>"
2302
+ content5[i] = '**image**' # 빈 줄에 이미지를 삽입
2322
2303
  else
2323
- image_memory << ""+'<img src="'+image_url+'" alt="'+keyword+'" class="aligncenter size-full">'+""
2324
- content5.insert(i, '**image**')
2304
+ image_memory << "<img src='" + image_url + "' alt='" + keyword + "' class='aligncenter size-full'>"
2305
+ content5[i] = '**image**' # 빈 줄에 이미지를 삽입
2325
2306
  end
2326
2307
  end
2327
-
2328
- if @data['포스트설정']['내용과자동생성'].checked? or @data['포스트설정']['gpt키워드'].checked?
2329
- content = content5.join("\n")+'(자동생성글)'+content55
2330
- # iconv = Iconv.new('UTF-8', 'ASCII-8BIT')
2331
- # content = iconv.iconv(content)
2332
- # content = content.encode('UTF-8', 'binary', invalid: :replace, replace: '')
2333
- puts content
2334
- image_url = image_url22
2335
-
2336
- # if @data['포스트설정']['자동글 수식에 입력'].checked?
2337
-
2338
- # else
2339
- # if @data['포스트설정']['내용사진링크'].checked?
2340
- # content = content.split('(자동생성글)')[0]+""+'<a href="'+@data['포스트설정']['내용사진링크값'].text.to_s.force_encoding('utf-8')+'"><img src="'+image_url+'" alt="'+keyword+'"></a>'+""+'(자동생성글)'+content.split('(자동생성글)')[1]
2341
- # else
2342
- # content = content.split('(자동생성글)')[0]+""+'<img src="'+image_url+'" alt="'+keyword+'" >'+""+'(자동생성글)'+content.split('(자동생성글)')[1]
2343
- # end
2344
- # end
2308
+
2309
+ # 자동 생성된 내용과 합치기
2310
+ if @data['포스트설정']['내용과자동생성'].checked? || @data['포스트설정']['gpt키워드'].checked?
2311
+ content = content5.join("\n") + '(자동생성글)' + content55
2345
2312
  else
2346
2313
  content = content5.join("\n")
2347
2314
  end
2315
+
2316
+ puts content
2348
2317
  end
2349
2318
  end
2350
2319
 
2320
+
2351
2321
  @data['table'][index][-1] = 70
2352
2322
  @data['table'] << []
2353
2323
  @data['table'].pop
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tblog_duopack
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.3
4
+ version: 0.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - zon
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-12-19 00:00:00.000000000 Z
11
+ date: 2024-12-20 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: File to Clipboard gem
14
14
  email: mymin26@naver.com