Module: Advertisements::CodidactHelper
- Includes:
- Magick
- Defined in:
- app/helpers/advertisements/codidact_helper.rb
Instance Method Summary collapse
-
#codidact_ad ⇒ Object
rubocop:disable Metrics/BlockLength.
Instance Method Details
#codidact_ad ⇒ Object
rubocop:disable Metrics/BlockLength
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
# File 'app/helpers/advertisements/codidact_helper.rb', line 7 def codidact_ad Rails.cache.fetch 'network/codidact_ad', expires_in: 60.minutes, include_community: false do ad = Image.new(600, 500) ad.background_color = 'white' = Draw.new .fill '#4B68FF' .rectangle 0, 450, 600, 500 .draw ad community_url = Draw.new community_url.font_family = 'Roboto' community_url.font = './app/assets/imgfonts/Roboto-Bold.ttf' community_url.font_weight = 700 community_url.pointsize = 20 community_url.gravity = CenterGravity community_url.annotate ad, 600, 50, 0, 450, 'Try on codidact.com' do |img| img.fill = 'white' end icon = ::Magick::ImageList.new('./app/assets/images/codidact.png') icon.resize_to_fit!(500, 300) ad.composite!(icon, CenterGravity, 0, -125, SrcAtopCompositeOp) on_codidact = Draw.new on_codidact.font_family = 'Roboto' on_codidact.font_weight = 700 on_codidact.font = './app/assets/imgfonts/Roboto-Bold.ttf' on_codidact.pointsize = 25 on_codidact.gravity = CenterGravity on_codidact.annotate ad, 400, 50, 100, 200, 'The Open Source Q&A Platform.' do |img| img.fill = '#666666' end slogan = Draw.new slogan.font_family = 'Roboto' slogan.font_weight = 400 slogan.font = './app/assets/imgfonts/Roboto-Regular.ttf' slogan.pointsize = 30 slogan.gravity = NorthGravity position = 0 wrap_text('Join our communities or build your own on codidact.com.', 500, 30).split("\n").each do |line| slogan.annotate ad, 500, 100, 50, 300 + (position * 45), line do |img| img.fill = '#333333' end position += 1 end ad.format = 'PNG' ad.border!(2, 2, 'black') ad end end |