diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4e54274 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +config.env +*.csv +logs/ +archive/ +*.log diff --git a/publish_digest.rb b/publish_digest.rb index d0bfabc..66b38f3 100644 --- a/publish_digest.rb +++ b/publish_digest.rb @@ -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