lib/fastlane/plugin/polidea/helper/page_generator.rb in fastlane-plugin-polidea-2.1.0 vs lib/fastlane/plugin/polidea/helper/page_generator.rb in fastlane-plugin-polidea-2.1.1.pre

- old
+ new

@@ -2,11 +2,32 @@ require 'base64' require 'json' module Fastlane module PageGenerator - def self.generate(config) + def self.mail(config) + UI.message("Generating e-mail...") + eth = Fastlane::ErbTemplateHelper + html_template = eth.load_from_path("#{__dir__}/../templates/download.erb") + eth.render(html_template, { + author: config[:author], + last_commit: config[:last_commit], + is_android: config[:is_android], + app_icon: config[:app_icon] ? "cid:#{config[:app_icon]}" : "https://s3.eu-central-1.amazonaws.com/fota.polidea.com/mails/images/icon-placeholder.png", + app_name: config[:app_name], + app_version: config[:app_version], + build_number: config[:build_number], + installation_link: config[:installation_link], + release_notes: parse_release_notes(config[:release_notes]), + platform: config[:platform], + release_date: config[:release_date], + binary_size: config[:binary_size], + qr_code: "cid:#{config[:qr_code]}" + }) + end + + def self.installation_page(config) if config[:installation_password] generate_private(config) else generate_public(config) end @@ -24,11 +45,11 @@ app_version: config[:app_version], build_number: config[:build_number], app_name: config[:app_name], app_icon: config[:app_icon], platform: config[:platform], - release_notes: config[:release_notes] + release_notes: parse_release_notes(config[:release_notes]) }) end private_class_method :generate_private def self.generate_public(config) @@ -40,11 +61,11 @@ app_version: config[:app_version], build_number: config[:build_number], app_name: config[:app_name], app_icon: config[:app_icon], platform: config[:platform], - release_notes: config[:release_notes] + release_notes: parse_release_notes(config[:release_notes]) }) end private_class_method :generate_public def self.encrypt(url, password) @@ -65,7 +86,22 @@ installation_link = Base64.encode64(var).delete "\n" salt = Base64.encode64(salt).delete "\n" return installation_link, salt, iv end private_class_method :encrypt + + def self.parse_release_notes(release_notes) + renderer = Redcarpet::Render::HTML.new({ + filter_html: true, + no_styles: true + }) + markdown = Redcarpet::Markdown.new( + renderer, + fenced_code_blocks: true, + autolink: false, + tables: false + ) + markdown.render(release_notes || "No release notes.") + end + private_class_method :parse_release_notes end end