nblog_zon 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_zon.rb +66 -23
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 595965e5f3c7b1d69d7c74b60132fdf593929cdae756140076d27e752b293262
4
- data.tar.gz: 120f11c6c018d9ce3f5c4fe0f6200cc26687343102895b9fea21d9d6b5051c64
3
+ metadata.gz: b3b94404780022c0989c4af14f8afde18358c17b6854fbbb5da857b6a3b180ee
4
+ data.tar.gz: b5a23c8a6ec9e454ffc0d7ea17fdc9a056479c95833b8bd5b554452282d1a2cf
5
5
  SHA512:
6
- metadata.gz: 98e94f6a657edf2483cb147d0685bf1f22e4778e4cd9cd25c78847e71e452dadc41b3ac39d3fffecd34a905808a5bf7bc8a6e74dafd21b2495588d0cf32d20a0
7
- data.tar.gz: fd9770bbc34d96c45c3cadd0a452ef31317cdad42ba6dc2466ec47783fc79ce1cfcf4de0f6daefb0acd9af9a2020dc1ff14ffcda7caa5e0dfdb3bc5c787ceb40
6
+ metadata.gz: 9b425dba02142d503994d8ff65bb98b60bfc13f1e85af818ca1ac6d7a961029a678a843818d5e68e222c204bd3b082bb093ae4bbf217bd8905b8b173af928ab4
7
+ data.tar.gz: 47ccedbaab3c34c37084e152cbfe9b7dc864026de02ef196fb5acbe15cea91d9f17779cc68ba57a40c0ef59ebb6ec90176a889cd7b71cf9830b2a87c1d1dc0d0
data/lib/nblog_zon.rb CHANGED
@@ -22,6 +22,7 @@ require 'httpclient'
22
22
  include AutoClickMethods
23
23
  using Rainbow
24
24
  include Glimmer
25
+
25
26
  class Chat
26
27
  def initialize(api_key, gpt_keyword_prompt, model)
27
28
  @api_key = api_key
@@ -2241,24 +2242,28 @@ class Wordpress
2241
2242
  end
2242
2243
 
2243
2244
  def crop_image_height_under_width(path, min_crop_ratio = 0.625)
2244
- img = Magick::Image.read(path).first
2245
- width = img.columns
2246
- height = img.rows
2247
-
2248
-
2245
+ img = Magick::Image.read(path).first
2246
+ width = img.columns
2247
+ height = img.rows
2249
2248
 
2250
- if height > width
2251
- min_height = (width * min_crop_ratio).to_i
2252
- new_height = rand(min_height..width)
2253
- crop_top = ((height - new_height) / 2.0).round
2249
+ if height > width
2250
+ min_height = (width * min_crop_ratio).to_i
2251
+ new_height = rand(min_height..width)
2252
+ crop_top = ((height - new_height) / 2.0).round
2254
2253
 
2255
- cropped = img.crop(0, crop_top, width, new_height, true)
2256
- cropped.write(path)
2254
+ cropped = img.crop(0, crop_top, width, new_height, true)
2257
2255
 
2258
-
2259
- else
2260
-
2261
- end
2256
+ retries = 0
2257
+ begin
2258
+ cropped.write(path)
2259
+ rescue => e
2260
+ retries += 1
2261
+ puts "이미지 저장 오류 (#{e.message}), 재시도 #{retries}/5"
2262
+ sleep(1)
2263
+ retry if retries < 5
2264
+ raise "이미지 저장 실패: #{e.message}"
2265
+ end
2266
+ end
2262
2267
  end
2263
2268
 
2264
2269
  def auto_image(keyword = nil)
@@ -3875,15 +3880,34 @@ class Wordpress
3875
3880
  # title = content.split("\n")[0]
3876
3881
  #end
3877
3882
  if @data['포스트설정']['내용첫줄제목에입력'].checked?
3878
- # 콘텐츠를 줄 단위로 분리
3879
3883
  content_lines = content.split("\n")
3880
-
3881
- # 번째 줄이 <img src=로 시작하는지 확인하고, 시작하는 경우 두 번째 줄부터 확인
3882
- title = content_lines.find { |line| !line.start_with?('<img src=') }
3883
-
3884
- # 만약 첫 번째 줄부터 <img src=로 시작하는 경우, 두 번째 줄을 제목으로 설정
3885
- title ||= content_lines[1] # 첫 번째 줄이 <img src=일 경우 두 번째 줄을 사용
3886
-
3884
+
3885
+ title = content_lines.find do |line|
3886
+ line = line.strip
3887
+ !line.empty? && !line.start_with?('<img src=')
3888
+ end
3889
+
3890
+ title ||= content_lines[1]
3891
+
3892
+ if title
3893
+ # 마침표(.) 포함 첫 문장 추출
3894
+ first_part = title[/.*?\./]
3895
+ first_part = first_part ? first_part.strip : title.strip
3896
+
3897
+ # 200bytes 제한 (한글 100자 내외)
3898
+ bytes_limit = 200
3899
+ truncated = ""
3900
+ current_bytes = 0
3901
+
3902
+ first_part.each_char do |char|
3903
+ char_bytes = char.bytesize
3904
+ break if current_bytes + char_bytes > bytes_limit
3905
+ truncated << char
3906
+ current_bytes += char_bytes
3907
+ end
3908
+
3909
+ title = truncated
3910
+ end
3887
3911
  end
3888
3912
 
3889
3913
  if @data['포스트설정']['제목을내용첫줄입력'].checked?
@@ -3916,6 +3940,25 @@ class Wordpress
3916
3940
  @data['table'] << []
3917
3941
  @data['table'].pop
3918
3942
 
3943
+ # content를 줄 단위로 쪼갬
3944
+ lines = content.lines
3945
+
3946
+ # 맨 앞부터 빈 줄(공백 또는 빈 문자열) 갯수 계산
3947
+ empty_line_count = 0
3948
+ lines.each do |line|
3949
+ if line.strip.empty?
3950
+ empty_line_count += 1
3951
+ else
3952
+ break
3953
+ end
3954
+ end
3955
+
3956
+ # 앞 빈 줄 제거
3957
+ lines = lines.drop(empty_line_count)
3958
+
3959
+ # 다시 content로 합침
3960
+ content = lines.join
3961
+
3919
3962
  dd_time = @data['table'][index][10].to_s.force_encoding('utf-8').to_i
3920
3963
  #template_no = @data['table'][index][7].to_s.force_encoding('utf-8').to_i
3921
3964
  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_zon
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: rnjstnswp123@naver.com