nblog_duo 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_duo.rb +65 -8
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 86ab7a8651d203747ab15ea4cca81b769adfec5c0e7c0cc10636b14a8daea03a
4
- data.tar.gz: 0df26f49762720cdc20d17b8d4943539db9aa51b31161c6fc0268bdee600f6d6
3
+ metadata.gz: a494a604797a91e90b8f25b1ecced39a68aedfe04366b1df4b79cd8e673a50a0
4
+ data.tar.gz: 52bd6b99a600ffe5bdf923502b7a22a19ed4af3a40fde7fb926ae87d882bf789
5
5
  SHA512:
6
- metadata.gz: 553ce970ce17140182002e176f8eaa14a2d9e426dc5fdd9bd003ae9f749088a08b318092fcf1b51c69e142d57491927f8213755819dee32970cf770b81c2284a
7
- data.tar.gz: 65ad848b5e5e2a90cc97502afa5f5186463e9b6028c380e6191a3ccea8a44be9cd1ffd2bb9dc2c1e03ff3e70669a2f9eaaae033e8239902bed9e186759b6bd83
6
+ metadata.gz: 9d767aff89fee41a2822b174a348c2f9bedab384277e913de88dfc16bcdc1d9f0780e6d4f2e5b9c2e90359b6d799823f7c683d336018898127ee0ed87c9d21cd
7
+ data.tar.gz: bccec96423a3ed5a2e3c4d08fe4c260a18bdd01ea3870233d57188673a8fc0e10623e2d6ad12812315346c02114e957e4fa2325bd3dfb13aaddc7344d9105ee6
data/lib/nblog_duo.rb CHANGED
@@ -1984,6 +1984,25 @@ class Naver
1984
1984
 
1985
1985
  end
1986
1986
 
1987
+ begin
1988
+ posting_url = @driver.current_url
1989
+ now = Time.now
1990
+
1991
+ # 로그 폴더 생성
1992
+ FileUtils.mkdir_p('./log') unless Dir.exist?('./log')
1993
+
1994
+ # 오늘 날짜 기준 로그 파일 경로
1995
+ log_file = "./log/#{now.strftime('%Y%m%d')}_log.txt"
1996
+
1997
+ # 로그 줄 내용
1998
+ log_line = "[#{now.strftime('%Y년%m월%d일 %H시%M분%S초')}] #{posting_url}\n"
1999
+
2000
+ # 파일에 추가 (없으면 생성)
2001
+ File.open(log_file, 'a') { |f| f.write(log_line) }
2002
+ rescue
2003
+ end
2004
+
2005
+
1987
2006
  begin
1988
2007
  @driver.window_handles.each do |handle|
1989
2008
  @driver.switch_to.window(handle)
@@ -3951,15 +3970,34 @@ class Wordpress
3951
3970
  # title = content.split("\n")[0]
3952
3971
  #end
3953
3972
  if @data['포스트설정']['내용첫줄제목에입력'].checked?
3954
- # 콘텐츠를 줄 단위로 분리
3955
3973
  content_lines = content.split("\n")
3956
-
3957
- # 번째 줄이 <img src=로 시작하는지 확인하고, 시작하는 경우 두 번째 줄부터 확인
3958
- title = content_lines.find { |line| !line.start_with?('<img src=') }
3959
-
3960
- # 만약 첫 번째 줄부터 <img src=로 시작하는 경우, 두 번째 줄을 제목으로 설정
3961
- title ||= content_lines[1] # 첫 번째 줄이 <img src=일 경우 두 번째 줄을 사용
3962
-
3974
+
3975
+ title = content_lines.find do |line|
3976
+ line = line.strip
3977
+ !line.empty? && !line.start_with?('<img src=')
3978
+ end
3979
+
3980
+ title ||= content_lines[1]
3981
+
3982
+ if title
3983
+ # 마침표(.) 포함 첫 문장 추출
3984
+ first_part = title[/.*?\./]
3985
+ first_part = first_part ? first_part.strip : title.strip
3986
+
3987
+ # 200bytes 제한 (한글 100자 내외)
3988
+ bytes_limit = 200
3989
+ truncated = ""
3990
+ current_bytes = 0
3991
+
3992
+ first_part.each_char do |char|
3993
+ char_bytes = char.bytesize
3994
+ break if current_bytes + char_bytes > bytes_limit
3995
+ truncated << char
3996
+ current_bytes += char_bytes
3997
+ end
3998
+
3999
+ title = truncated
4000
+ end
3963
4001
  end
3964
4002
 
3965
4003
  if @data['포스트설정']['제목을내용첫줄입력'].checked?
@@ -3992,6 +4030,25 @@ class Wordpress
3992
4030
  @data['table'] << []
3993
4031
  @data['table'].pop
3994
4032
 
4033
+ # content를 줄 단위로 쪼갬
4034
+ lines = content.lines
4035
+
4036
+ # 맨 앞부터 빈 줄(공백 또는 빈 문자열) 갯수 계산
4037
+ empty_line_count = 0
4038
+ lines.each do |line|
4039
+ if line.strip.empty?
4040
+ empty_line_count += 1
4041
+ else
4042
+ break
4043
+ end
4044
+ end
4045
+
4046
+ # 앞 빈 줄 제거
4047
+ lines = lines.drop(empty_line_count)
4048
+
4049
+ # 다시 content로 합침
4050
+ content = lines.join
4051
+
3995
4052
  dd_time = @data['table'][index][10].to_s.force_encoding('utf-8').to_i
3996
4053
  #template_no = @data['table'][index][7].to_s.force_encoding('utf-8').to_i
3997
4054
  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.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: mymin26@naver.com