cafe_basics_duo 0.1.52 → 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.
- checksums.yaml +4 -4
- data/lib/cafe_basics_duo.rb +65 -23
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 254da32d83fd097f8d5ae9e26d4c3c306c4afbfbbe37f6e57a8529a577cf202f
|
4
|
+
data.tar.gz: c6d2b84d4404ed78ab26a0e5e892d5b45422c94876223d85e2fdfde8dd9749cb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 22a2b190f6907f9030b9ba07d68297b2c56725b9f42c65273479ba47765e96adc4ce8789306f5bc493c4b90fe51dc4cabe84524a573df4aad294f5b01a26e0cc
|
7
|
+
data.tar.gz: df99d99bcf10e80010526e0e0a0fb3abe361930114f17af054c30cf7dbdbdd04d971952d0eb4204d38a28de77e4ac1023e5d3cda4a316dbbf6342f13d8867b59
|
data/lib/cafe_basics_duo.rb
CHANGED
@@ -2097,24 +2097,28 @@ class Wordpress
|
|
2097
2097
|
|
2098
2098
|
|
2099
2099
|
def crop_image_height_under_width(path, min_crop_ratio = 0.625)
|
2100
|
-
|
2101
|
-
|
2102
|
-
|
2103
|
-
|
2104
|
-
|
2100
|
+
img = Magick::Image.read(path).first
|
2101
|
+
width = img.columns
|
2102
|
+
height = img.rows
|
2105
2103
|
|
2106
|
-
|
2107
|
-
|
2108
|
-
|
2109
|
-
|
2104
|
+
if height > width
|
2105
|
+
min_height = (width * min_crop_ratio).to_i
|
2106
|
+
new_height = rand(min_height..width)
|
2107
|
+
crop_top = ((height - new_height) / 2.0).round
|
2110
2108
|
|
2111
|
-
|
2112
|
-
cropped.write(path)
|
2109
|
+
cropped = img.crop(0, crop_top, width, new_height, true)
|
2113
2110
|
|
2114
|
-
|
2115
|
-
|
2116
|
-
|
2117
|
-
|
2111
|
+
retries = 0
|
2112
|
+
begin
|
2113
|
+
cropped.write(path)
|
2114
|
+
rescue => e
|
2115
|
+
retries += 1
|
2116
|
+
puts "이미지 저장 오류 (#{e.message}), 재시도 #{retries}/5"
|
2117
|
+
sleep(1)
|
2118
|
+
retry if retries < 5
|
2119
|
+
raise "이미지 저장 실패: #{e.message}"
|
2120
|
+
end
|
2121
|
+
end
|
2118
2122
|
end
|
2119
2123
|
|
2120
2124
|
def auto_image(keyword = nil)
|
@@ -3617,15 +3621,34 @@ class Wordpress
|
|
3617
3621
|
# title = content.split("\n")[0]
|
3618
3622
|
#end
|
3619
3623
|
if @data['포스트설정']['내용첫줄제목에입력'].checked?
|
3620
|
-
# 콘텐츠를 줄 단위로 분리
|
3621
3624
|
content_lines = content.split("\n")
|
3622
|
-
|
3623
|
-
|
3624
|
-
|
3625
|
-
|
3626
|
-
|
3627
|
-
|
3628
|
-
|
3625
|
+
|
3626
|
+
title = content_lines.find do |line|
|
3627
|
+
line = line.strip
|
3628
|
+
!line.empty? && !line.start_with?('<img src=')
|
3629
|
+
end
|
3630
|
+
|
3631
|
+
title ||= content_lines[1]
|
3632
|
+
|
3633
|
+
if title
|
3634
|
+
# 마침표(.) 포함 첫 문장 추출
|
3635
|
+
first_part = title[/.*?\./]
|
3636
|
+
first_part = first_part ? first_part.strip : title.strip
|
3637
|
+
|
3638
|
+
# 200bytes 제한 (한글 100자 내외)
|
3639
|
+
bytes_limit = 200
|
3640
|
+
truncated = ""
|
3641
|
+
current_bytes = 0
|
3642
|
+
|
3643
|
+
first_part.each_char do |char|
|
3644
|
+
char_bytes = char.bytesize
|
3645
|
+
break if current_bytes + char_bytes > bytes_limit
|
3646
|
+
truncated << char
|
3647
|
+
current_bytes += char_bytes
|
3648
|
+
end
|
3649
|
+
|
3650
|
+
title = truncated
|
3651
|
+
end
|
3629
3652
|
end
|
3630
3653
|
|
3631
3654
|
if @data['포스트설정']['제목을내용첫줄입력'].checked?
|
@@ -3649,6 +3672,25 @@ class Wordpress
|
|
3649
3672
|
@data['table'] << []
|
3650
3673
|
@data['table'].pop
|
3651
3674
|
|
3675
|
+
# content를 줄 단위로 쪼갬
|
3676
|
+
lines = content.lines
|
3677
|
+
|
3678
|
+
# 맨 앞부터 빈 줄(공백 또는 빈 문자열) 갯수 계산
|
3679
|
+
empty_line_count = 0
|
3680
|
+
lines.each do |line|
|
3681
|
+
if line.strip.empty?
|
3682
|
+
empty_line_count += 1
|
3683
|
+
else
|
3684
|
+
break
|
3685
|
+
end
|
3686
|
+
end
|
3687
|
+
|
3688
|
+
# 앞 빈 줄 제거
|
3689
|
+
lines = lines.drop(empty_line_count)
|
3690
|
+
|
3691
|
+
# 다시 content로 합침
|
3692
|
+
content = lines.join
|
3693
|
+
|
3652
3694
|
p option
|
3653
3695
|
|
3654
3696
|
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_duo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
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-
|
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
|