nblog_duo 111.120.002 → 111.120.005

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 +62 -20
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 92d60eb5158a9850b865e0f0610181c13e6a90968e27e8ab32667a3bcbcd51ae
4
- data.tar.gz: 68ca780336905933aeb6584b78944eb437524209d48fa65508fe0e966f599981
3
+ metadata.gz: 76def0a49a36e9251c9be08af5f3843cd22d35f2c7a27d0e0fa837194db92236
4
+ data.tar.gz: bf3f94327a2caf50bcb23db5d8e0cb716fab3de4cf3353b0099eff415cf77881
5
5
  SHA512:
6
- metadata.gz: 654a707ff0466ecdd152c4983dbcc8a31e2ad073fe1839b2a8d89574161b2189676f8908fda768bb667d87fe814734851ed03be1bfd0589d5abdba8eb72d738f
7
- data.tar.gz: 9a539dfd8d82121f8eb79c313be8d1d5f54ffc86cc436fbcc26f420aaf955d532e555c095d8dcb55cd8dc68e721764b67da959ef4f67c459b0b9c9907e3cfd4a
6
+ metadata.gz: f30e1f0db3dcc850b995fb23c2ef46b74ebea34b46bccf1e3fed174a87e5ce47b93e2a70adda736aeaa8312401f5415b8272c95db8b338625f303978b52a6850
7
+ data.tar.gz: 2c709f923361390f2391b1b5668370ba5e44d5532232d5c2aa1b21e11287affb7bf13cb5250942b8b5010cd35cef12cd86ed5e014d55a64dd53f9e4964f0b65b
data/lib/nblog_duo.rb CHANGED
@@ -2317,20 +2317,24 @@ class Wordpress
2317
2317
  width = img.columns
2318
2318
  height = img.rows
2319
2319
 
2320
+ if height > width
2321
+ min_height = (width * min_crop_ratio).to_i
2322
+ new_height = rand(min_height..width)
2323
+ crop_top = ((height - new_height) / 2.0).round
2320
2324
 
2325
+ cropped = img.crop(0, crop_top, width, new_height, true)
2321
2326
 
2322
- if height > width
2323
- min_height = (width * min_crop_ratio).to_i
2324
- new_height = rand(min_height..width)
2325
- crop_top = ((height - new_height) / 2.0).round
2326
-
2327
- cropped = img.crop(0, crop_top, width, new_height, true)
2328
- cropped.write(path)
2329
-
2330
-
2331
- else
2332
-
2333
- end
2327
+ retries = 0
2328
+ begin
2329
+ cropped.write(path)
2330
+ rescue => e
2331
+ retries += 1
2332
+ puts "이미지 저장 오류 (#{e.message}), 재시도 #{retries}/5"
2333
+ sleep(1)
2334
+ retry if retries < 5
2335
+ raise "이미지 저장 실패: #{e.message}"
2336
+ end
2337
+ end
2334
2338
  end
2335
2339
 
2336
2340
  def auto_image(keyword = nil)
@@ -3947,15 +3951,34 @@ class Wordpress
3947
3951
  # title = content.split("\n")[0]
3948
3952
  #end
3949
3953
  if @data['포스트설정']['내용첫줄제목에입력'].checked?
3950
- # 콘텐츠를 줄 단위로 분리
3951
3954
  content_lines = content.split("\n")
3952
-
3953
- # 번째 줄이 <img src=로 시작하는지 확인하고, 시작하는 경우 두 번째 줄부터 확인
3954
- title = content_lines.find { |line| !line.start_with?('<img src=') }
3955
-
3956
- # 만약 첫 번째 줄부터 <img src=로 시작하는 경우, 두 번째 줄을 제목으로 설정
3957
- title ||= content_lines[1] # 첫 번째 줄이 <img src=일 경우 두 번째 줄을 사용
3958
-
3955
+
3956
+ title = content_lines.find do |line|
3957
+ line = line.strip
3958
+ !line.empty? && !line.start_with?('<img src=')
3959
+ end
3960
+
3961
+ title ||= content_lines[1]
3962
+
3963
+ if title
3964
+ # 마침표(.) 포함 첫 문장 추출
3965
+ first_part = title[/.*?\./]
3966
+ first_part = first_part ? first_part.strip : title.strip
3967
+
3968
+ # 200bytes 제한 (한글 100자 내외)
3969
+ bytes_limit = 200
3970
+ truncated = ""
3971
+ current_bytes = 0
3972
+
3973
+ first_part.each_char do |char|
3974
+ char_bytes = char.bytesize
3975
+ break if current_bytes + char_bytes > bytes_limit
3976
+ truncated << char
3977
+ current_bytes += char_bytes
3978
+ end
3979
+
3980
+ title = truncated
3981
+ end
3959
3982
  end
3960
3983
 
3961
3984
  if @data['포스트설정']['제목을내용첫줄입력'].checked?
@@ -3988,6 +4011,25 @@ class Wordpress
3988
4011
  @data['table'] << []
3989
4012
  @data['table'].pop
3990
4013
 
4014
+ # content를 줄 단위로 쪼갬
4015
+ lines = content.lines
4016
+
4017
+ # 맨 앞부터 빈 줄(공백 또는 빈 문자열) 갯수 계산
4018
+ empty_line_count = 0
4019
+ lines.each do |line|
4020
+ if line.strip.empty?
4021
+ empty_line_count += 1
4022
+ else
4023
+ break
4024
+ end
4025
+ end
4026
+
4027
+ # 앞 빈 줄 제거
4028
+ lines = lines.drop(empty_line_count)
4029
+
4030
+ # 다시 content로 합침
4031
+ content = lines.join
4032
+
3991
4033
  dd_time = @data['table'][index][10].to_s.force_encoding('utf-8').to_i
3992
4034
  #template_no = @data['table'][index][7].to_s.force_encoding('utf-8').to_i
3993
4035
  naver.update(title,content,option,soosick_1,soosick_2, dd_time)
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nblog_duo
3
3
  version: !ruby/object:Gem::Version
4
- version: 111.120.002
4
+ version: 111.120.005
5
5
  platform: ruby
6
6
  authors:
7
7
  - zon
8
8
  bindir: bin
9
9
  cert_chain: []
10
- date: 2025-06-26 00:00:00.000000000 Z
10
+ date: 2025-07-02 00:00:00.000000000 Z
11
11
  dependencies: []
12
12
  description: File to Clipboard gem
13
13
  email: mymin26@naver.com