Module: Advertisements::CommunityHelper
- Includes:
- Magick
- Defined in:
- app/helpers/advertisements/community_helper.rb
Instance Method Summary collapse
-
#community_ad ⇒ Object
rubocop:disable Metrics/BlockLength.
Instance Method Details
#community_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 60 61 62 63 64 65 66 67 68 69 70 71 72 73 |
# File 'app/helpers/advertisements/community_helper.rb', line 7 def community_ad Rails.cache.fetch 'community_ad', expires_in: 60.minutes 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, @community.host do |img| img.fill = 'white' end icon_path = SiteSetting['SiteLogoPath'] if icon_path.present? icon = community_icon(icon_path) icon.resize_to_fit!(400, 200) ad.composite!(icon, CenterGravity, 0, -175, SrcAtopCompositeOp) else name = @community.name community_name = Draw.new community_name.font_family = 'Roboto' community_name.font_weight = 900 community_name.font = './app/assets/imgfonts/Roboto-Black.ttf' community_name.pointsize = (50 + (100.0 / name.length)) community_name.gravity = CenterGravity community_name.annotate ad, 600, 250, 0, 0, name do |img| img.fill = 'black' end end 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 = EastGravity on_codidact.annotate ad, 0, 50, 500, 150, 'on codidact.com' 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(SiteSetting['SiteAdSlogan'], 500, 30).split("\n").each do |line| slogan.annotate ad, 500, 100, 50, 225 + (position * 45), line do |img| img.fill = '#333333' end position += 1 end ad.format = 'PNG' ad.border!(2, 2, 'black') ad end end |