cafe_basics 0.1.53 → 0.1.55

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/cafe_basics.rb +46 -8
  3. metadata +2 -2
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 1d0451aa966f88b0f13e3da4eab576aa33f5963cb34e6a8bd4d4c415e4bc5104
4
- data.tar.gz: 86ed985fe0ea99eaa3e09f4dc9993ac41f81808e840d0f8c9ece283826023bab
3
+ metadata.gz: 5bc35dab85d126c0d04c3309289d5229bc816f8e68795405b00f09d32fc99ae9
4
+ data.tar.gz: 8359d6130d74936404b41b8f99910e7abf1ce591fa0a136838c902e7d2f02d75
5
5
  SHA512:
6
- metadata.gz: b08db72d293ebde33a55ac524785316cc62130f4c18b63f0c37ce8703ece4aeeb59094688b6812e46e0abb62877bc86f6d53fc6cf4cf0ea4fcb41d1b35bd6421
7
- data.tar.gz: 2a1fd28e15ce350458c5ab6f7e9dcf688d5b9e4eb227b46b387f1d71d299b126643788a0ec7c0a39bdf46baecae4062548406ef30c0f538b84327c89d07559f9
6
+ metadata.gz: 5a840aebd6afc1ed38bf05deb3f49c43a9ca7440914f40b4633d24b0f7775b769e0fb030aa481c930420d3d4a3b189567729d8600555cf303762fd48b4b69e89
7
+ data.tar.gz: b38a340115a3b3b29667e6e93cfcde8c444a3dd052a2a6be58dcd87559e8a74b89a884229cff69b7bc924fb9feff295b3de6a7483034ec2e4af3d7995bb0504a
data/lib/cafe_basics.rb CHANGED
@@ -3554,15 +3554,34 @@ class Wordpress
3554
3554
  # title = content.split("\n")[0]
3555
3555
  #end
3556
3556
  if @data['포스트설정']['내용첫줄제목에입력'].checked?
3557
- # 콘텐츠를 줄 단위로 분리
3558
3557
  content_lines = content.split("\n")
3559
-
3560
- # 번째 줄이 <img src=로 시작하는지 확인하고, 시작하는 경우 두 번째 줄부터 확인
3561
- title = content_lines.find { |line| !line.start_with?('<img src=') }
3562
-
3563
- # 만약 첫 번째 줄부터 <img src=로 시작하는 경우, 두 번째 줄을 제목으로 설정
3564
- title ||= content_lines[1] # 첫 번째 줄이 <img src=일 경우 두 번째 줄을 사용
3565
-
3558
+
3559
+ title = content_lines.find do |line|
3560
+ line = line.strip
3561
+ !line.empty? && !line.start_with?('<img src=')
3562
+ end
3563
+
3564
+ title ||= content_lines[1]
3565
+
3566
+ if title
3567
+ # 마침표(.) 포함 첫 문장 추출
3568
+ first_part = title[/.*?\./]
3569
+ first_part = first_part ? first_part.strip : title.strip
3570
+
3571
+ # 200bytes 제한 (한글 100자 내외)
3572
+ bytes_limit = 200
3573
+ truncated = ""
3574
+ current_bytes = 0
3575
+
3576
+ first_part.each_char do |char|
3577
+ char_bytes = char.bytesize
3578
+ break if current_bytes + char_bytes > bytes_limit
3579
+ truncated << char
3580
+ current_bytes += char_bytes
3581
+ end
3582
+
3583
+ title = truncated
3584
+ end
3566
3585
  end
3567
3586
 
3568
3587
  if @data['포스트설정']['제목을내용첫줄입력'].checked?
@@ -3586,6 +3605,25 @@ class Wordpress
3586
3605
  @data['table'] << []
3587
3606
  @data['table'].pop
3588
3607
 
3608
+ # content를 줄 단위로 쪼갬
3609
+ lines = content.lines
3610
+
3611
+ # 맨 앞부터 빈 줄(공백 또는 빈 문자열) 갯수 계산
3612
+ empty_line_count = 0
3613
+ lines.each do |line|
3614
+ if line.strip.empty?
3615
+ empty_line_count += 1
3616
+ else
3617
+ break
3618
+ end
3619
+ end
3620
+
3621
+ # 앞 빈 줄 제거
3622
+ lines = lines.drop(empty_line_count)
3623
+
3624
+ # 다시 content로 합침
3625
+ content = lines.join
3626
+
3589
3627
  p option
3590
3628
 
3591
3629
  dd_time = @data['table'][index][9].to_s.force_encoding('utf-8').to_i
metadata CHANGED
@@ -1,13 +1,13 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cafe_basics
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.53
4
+ version: 0.1.55
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