cafe_basics 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.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: 5bc35dab85d126c0d04c3309289d5229bc816f8e68795405b00f09d32fc99ae9
|
4
|
+
data.tar.gz: 8359d6130d74936404b41b8f99910e7abf1ce591fa0a136838c902e7d2f02d75
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5a840aebd6afc1ed38bf05deb3f49c43a9ca7440914f40b4633d24b0f7775b769e0fb030aa481c930420d3d4a3b189567729d8600555cf303762fd48b4b69e89
|
7
|
+
data.tar.gz: b38a340115a3b3b29667e6e93cfcde8c444a3dd052a2a6be58dcd87559e8a74b89a884229cff69b7bc924fb9feff295b3de6a7483034ec2e4af3d7995bb0504a
|
data/lib/cafe_basics.rb
CHANGED
@@ -2030,24 +2030,28 @@ class Wordpress
|
|
2030
2030
|
|
2031
2031
|
|
2032
2032
|
def crop_image_height_under_width(path, min_crop_ratio = 0.625)
|
2033
|
-
|
2034
|
-
|
2035
|
-
|
2036
|
-
|
2037
|
-
|
2033
|
+
img = Magick::Image.read(path).first
|
2034
|
+
width = img.columns
|
2035
|
+
height = img.rows
|
2038
2036
|
|
2039
|
-
|
2040
|
-
|
2041
|
-
|
2042
|
-
|
2037
|
+
if height > width
|
2038
|
+
min_height = (width * min_crop_ratio).to_i
|
2039
|
+
new_height = rand(min_height..width)
|
2040
|
+
crop_top = ((height - new_height) / 2.0).round
|
2043
2041
|
|
2044
|
-
|
2045
|
-
cropped.write(path)
|
2042
|
+
cropped = img.crop(0, crop_top, width, new_height, true)
|
2046
2043
|
|
2047
|
-
|
2048
|
-
|
2049
|
-
|
2050
|
-
|
2044
|
+
retries = 0
|
2045
|
+
begin
|
2046
|
+
cropped.write(path)
|
2047
|
+
rescue => e
|
2048
|
+
retries += 1
|
2049
|
+
puts "이미지 저장 오류 (#{e.message}), 재시도 #{retries}/5"
|
2050
|
+
sleep(1)
|
2051
|
+
retry if retries < 5
|
2052
|
+
raise "이미지 저장 실패: #{e.message}"
|
2053
|
+
end
|
2054
|
+
end
|
2051
2055
|
end
|
2052
2056
|
|
2053
2057
|
def auto_image(keyword = nil)
|
@@ -3550,15 +3554,34 @@ class Wordpress
|
|
3550
3554
|
# title = content.split("\n")[0]
|
3551
3555
|
#end
|
3552
3556
|
if @data['포스트설정']['내용첫줄제목에입력'].checked?
|
3553
|
-
# 콘텐츠를 줄 단위로 분리
|
3554
3557
|
content_lines = content.split("\n")
|
3555
|
-
|
3556
|
-
|
3557
|
-
|
3558
|
-
|
3559
|
-
|
3560
|
-
|
3561
|
-
|
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
|
3562
3585
|
end
|
3563
3586
|
|
3564
3587
|
if @data['포스트설정']['제목을내용첫줄입력'].checked?
|
@@ -3582,6 +3605,25 @@ class Wordpress
|
|
3582
3605
|
@data['table'] << []
|
3583
3606
|
@data['table'].pop
|
3584
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
|
+
|
3585
3627
|
p option
|
3586
3628
|
|
3587
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.
|
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
|