Add .gitignore and fixed publish_digest.rb

This commit is contained in:
2026-01-06 10:46:40 +01:00
parent 252ba9f5cc
commit 21930ce600
2 changed files with 13 additions and 10 deletions

5
.gitignore vendored Normal file
View File

@@ -0,0 +1,5 @@
config.env
*.csv
logs/
archive/
*.log

View File

@@ -2,12 +2,7 @@
# -*- coding: utf-8 -*-
#
# Zprávobot.news - AI Daily Digest Publisher
# Version: 1.0.1 (Cloudron - Direct HTTP)
#
# Generates and publishes daily digest posts to Mastodon bots:
# - @zpravobot (7:30) - neutral overview
# - @pozitivni (12:00) - positive news
# - @sarkasticky (19:00) - sarcastic commentary
# Version: 1.0.2 (Fixed URLs)
require 'csv'
require 'json'
@@ -376,25 +371,26 @@ def generate_links_toot(topics, style)
posts = topics[topic]
links << "\n#{topic}:"
# Select diverse posts (first and middle)
selected = []
selected << posts[0] if posts[0]
selected << posts[posts.size / 2] if posts.size > 1
selected[0...max_links_per_topic].each do |post|
# Extract title (first line, max 50 chars)
title = post['text'].split("\n")[0][0..50].strip
title = title.gsub(/\s+/, ' ')
url = post['extracted_url']
next unless url && !url.empty?
short_url = url.gsub(/https?:\/\//, '')
short_url = short_url[0..37] + '...' if short_url.length > 40
# Use full URL (Mastodon counts it as 23 chars anyway)
links << "#{title}..."
links << " 🔗 #{short_url}"
links << " #{url}"
end
end
# Style-specific header and footer
case style
when 'neutral'
header = "📌 VYBRANÉ ČLÁNKY DNE:"
@@ -411,7 +407,9 @@ def generate_links_toot(topics, style)
toot = header + links.join("\n") + footer
# Ensure under 500 chars
if toot.length > 500
# Truncate links section
truncated_links = links[0..(links.size * 2 / 3)]
toot = header + truncated_links.join("\n") + footer