nblog_zon 111.120.003 → 111.120.007

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 -8
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fe5bf260ce4df25706be5b4c50d08b9b31c50949b0e7ed6c17dbd6dbc566b622
4
- data.tar.gz: 0d4b42bf5d55b0b553c6dede47877dc82b218b49c7deba4c2474cd59ab426cc1
3
+ metadata.gz: '09e743a070f6cfa1a84d4f0857203dc6eb6ce4f21e3f4ca6525d7892324b1224'
4
+ data.tar.gz: 05d0d35e7d1842b66404a345fadc29a50340fc1406889ea42a946a22ae5f87f3
5
5
  SHA512:
6
- metadata.gz: '0870375b45d3327fc7b74eb96a86ccf16f3c9d0714f1c3f0942174af02a2f3bfcd4703f5f3bedfe7b1db225bec6d26ae9e9db11de602e20f4d486b29b9316482'
7
- data.tar.gz: 3bece6f01d16968e558695f5d457809f90f5ae6c141e7c5ba908fcc34d490027111e8aa9e259d6486e9fc36be1c5963dd03eaeb384b69efc670cff976591b1a7
6
+ metadata.gz: 49ee4ef1a31bc37943a6de592651693148a2168eaed6b8e80ae1f9acf473eb9e1d8bfa7a793b93d5056dc05de87c33ac5c199eb7ea03f83681e0322a7578df50
7
+ data.tar.gz: fcb9dadc89b8ab19ecae5b2c1fa358d6a830f9dd5c6da6b31b90e173a321eb920c9e3e8d434b72e71ac64c64a4280c5f7c44edf5fd740bdf92a04b15f26eee72
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
@@ -1981,6 +1982,25 @@ class Naver
1981
1982
 
1982
1983
  end
1983
1984
 
1985
+ begin
1986
+ posting_url = @driver.current_url
1987
+ now = Time.now
1988
+
1989
+ # 로그 폴더 생성
1990
+ FileUtils.mkdir_p('./log') unless Dir.exist?('./log')
1991
+
1992
+ # 오늘 날짜 기준 로그 파일 경로
1993
+ log_file = "./log/#{now.strftime('%Y%m%d')}_log.txt"
1994
+
1995
+ # 로그 줄 내용
1996
+ log_line = "[#{now.strftime('%Y년%m월%d일 %H시%M분%S초')}] #{posting_url}\n"
1997
+
1998
+ # 파일에 추가 (없으면 생성)
1999
+ File.open(log_file, 'a') { |f| f.write(log_line) }
2000
+ rescue
2001
+ end
2002
+
2003
+
1984
2004
  begin
1985
2005
  @driver.window_handles.each do |handle|
1986
2006
  @driver.switch_to.window(handle)
@@ -3879,15 +3899,34 @@ class Wordpress
3879
3899
  # title = content.split("\n")[0]
3880
3900
  #end
3881
3901
  if @data['포스트설정']['내용첫줄제목에입력'].checked?
3882
- # 콘텐츠를 줄 단위로 분리
3883
3902
  content_lines = content.split("\n")
3884
-
3885
- # 번째 줄이 <img src=로 시작하는지 확인하고, 시작하는 경우 두 번째 줄부터 확인
3886
- title = content_lines.find { |line| !line.start_with?('<img src=') }
3887
-
3888
- # 만약 첫 번째 줄부터 <img src=로 시작하는 경우, 두 번째 줄을 제목으로 설정
3889
- title ||= content_lines[1] # 첫 번째 줄이 <img src=일 경우 두 번째 줄을 사용
3890
-
3903
+
3904
+ title = content_lines.find do |line|
3905
+ line = line.strip
3906
+ !line.empty? && !line.start_with?('<img src=')
3907
+ end
3908
+
3909
+ title ||= content_lines[1]
3910
+
3911
+ if title
3912
+ # 마침표(.) 포함 첫 문장 추출
3913
+ first_part = title[/.*?\./]
3914
+ first_part = first_part ? first_part.strip : title.strip
3915
+
3916
+ # 200bytes 제한 (한글 100자 내외)
3917
+ bytes_limit = 200
3918
+ truncated = ""
3919
+ current_bytes = 0
3920
+
3921
+ first_part.each_char do |char|
3922
+ char_bytes = char.bytesize
3923
+ break if current_bytes + char_bytes > bytes_limit
3924
+ truncated << char
3925
+ current_bytes += char_bytes
3926
+ end
3927
+
3928
+ title = truncated
3929
+ end
3891
3930
  end
3892
3931
 
3893
3932
  if @data['포스트설정']['제목을내용첫줄입력'].checked?
@@ -3920,6 +3959,25 @@ class Wordpress
3920
3959
  @data['table'] << []
3921
3960
  @data['table'].pop
3922
3961
 
3962
+ # content를 줄 단위로 쪼갬
3963
+ lines = content.lines
3964
+
3965
+ # 맨 앞부터 빈 줄(공백 또는 빈 문자열) 갯수 계산
3966
+ empty_line_count = 0
3967
+ lines.each do |line|
3968
+ if line.strip.empty?
3969
+ empty_line_count += 1
3970
+ else
3971
+ break
3972
+ end
3973
+ end
3974
+
3975
+ # 앞 빈 줄 제거
3976
+ lines = lines.drop(empty_line_count)
3977
+
3978
+ # 다시 content로 합침
3979
+ content = lines.join
3980
+
3923
3981
  dd_time = @data['table'][index][10].to_s.force_encoding('utf-8').to_i
3924
3982
  #template_no = @data['table'][index][7].to_s.force_encoding('utf-8').to_i
3925
3983
  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.003
4
+ version: 111.120.007
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-04 00:00:00.000000000 Z
11
11
  dependencies: []
12
12
  description: File to Clipboard gem
13
13
  email: rnjstnswp123@naver.com