diff --git a/INSTALL.md b/INSTALL.md index 9ee16f86..e86f0662 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -63,6 +63,14 @@ We recommend to run OSEM in production with [mod_passenger](https://www.phusionp and the [apache web-server](https://www.apache.org/). There are tons of guides on how to deploy rails apps on various base operating systems. Check Google ;-) +#### ImageMagick +We use imagemagic for image manipulation of sponsor logo. You can get it from [direct install](http://software.opensuse.org/package/ImageMagick) page of the package or else check out [Download page](http://www.imagemagick.org/script/binary-releases.php) of ImageMagick. + +If you are upgrading your osem instance and would like to resize the exisiting logos, you would need to `reprocess!` the images. You can do it by running the following rake task: +``` +$ rake logo:reprocess +``` + #### Use openID In order to use the OpenID feature you need to register your application with the providers (Google and Facebook) and enter their API keys in config/secrets.yml file, changing the existing sample values. diff --git a/app/assets/stylesheets/osem-splash.css.scss b/app/assets/stylesheets/osem-splash.css.scss index 717c9ab4..d378d223 100644 --- a/app/assets/stylesheets/osem-splash.css.scss +++ b/app/assets/stylesheets/osem-splash.css.scss @@ -89,10 +89,11 @@ } } } - + #sponsors { .img-sponsor { max-height: 100px; + margin: 2% auto; } .img-sponsor-1 { max-height: 200px; diff --git a/app/helpers/sponsors_helper.rb b/app/helpers/sponsors_helper.rb new file mode 100644 index 00000000..e827c1fe --- /dev/null +++ b/app/helpers/sponsors_helper.rb @@ -0,0 +1,12 @@ +module SponsorsHelper + # returns the url to be used for logo on basis of sponsorship level position + def get_logo(sponsor) + if sponsor.sponsorship_level.position == 1 + sponsor.logo.url(:first) + elsif sponsor.sponsorship_level.position == 2 + sponsor.logo.url(:second) + else + sponsor.logo.url(:others) + end + end +end diff --git a/app/models/sponsor.rb b/app/models/sponsor.rb index 0981f24a..6b255886 100644 --- a/app/models/sponsor.rb +++ b/app/models/sponsor.rb @@ -2,10 +2,20 @@ class Sponsor < ActiveRecord::Base belongs_to :sponsorship_level belongs_to :conference has_attached_file :logo, - styles: { thumb: '100x100>', large: '300x300>' } + styles: { thumb: '100x100>', + first: '320x180>', + second: '320x150>', + others: '320x120>' }, + # places logo on a white background to maintain size + convert_options: { + first: '-background white -gravity center -extent 320x180', + second: '-background white -gravity center -extent 320x150', + others: '-background white -gravity center -extent 320x120' + } validates_attachment_content_type :logo, content_type: [/jpg/, /jpeg/, /png/, /gif/], size: { in: 0..500.kilobytes } - validates_presence_of :name, :website_url, :sponsorship_level + + validates_presence_of :name, :website_url, :sponsorship_level, :logo end diff --git a/app/views/conference/_sponsors.html.haml b/app/views/conference/_sponsors.html.haml index 6ce4bc84..dd202657 100644 --- a/app/views/conference/_sponsors.html.haml +++ b/app/views/conference/_sponsors.html.haml @@ -4,30 +4,33 @@ .container .row - .col-md-12 + .col-md-12.text-center %h2 Sponsors - %p.lead - whom without, - %span.notranslate - = @conference.short_title - wouldn't be possible! - @conference.sponsorship_levels.each do |sponsorship_level| -if sponsorship_level.sponsors.any? - sponsorship_level.sponsors.each_slice(3) do |slice| .row.row-centered - slice.each do |sponsor| .col-md-4.col-sm-4.col-centered.col-top - .thumbnail - - if sponsor.logo.blank? - %h3.text-center - = link_to(sponsor.website_url, title: "#{sponsor.name}") do + %a{ href: '#', data: { toggle: 'modal', target: "#modal_#{sponsor.id}" } } + = image_tag get_logo(sponsor), class: "img-responsive img-sponsor img-sponsor-#{sponsorship_level.position}" + + %div.modal.fade{ id: "modal_#{sponsor.id}" } + .modal-dialog + .modal-content + .modal-header + %button.close{ data: { dismiss: 'modal' } } + x + .modal-title = sponsor.name - - else - = link_to(sponsor.website_url, class: 'thumbnail') do - = image_tag sponsor.logo, class: "img-responsive img-sponsor img-sponsor-#{sponsorship_level.position}", title: "#{sponsor.name}" - .caption - -if sponsor.description.present? - = markdown(sponsor.description) + .modal-body.text-center + .logo + = link_to sponsor.website_url, target: '_blank' do + = image_tag get_logo(sponsor), class: "img-responsive img-sponsor img-sponsor-#{sponsorship_level.position}" + .description + = sponsor.description + .modal-footer + = link_to nil, "#{sponsor.website_url}", target: '_blank' -if @conference.contact and !@conference.contact.sponsor_email.blank? .row .col-md-12 @@ -36,4 +39,3 @@ Want to sponsor #{@conference.short_title}? = link_to("mailto: #{@conference.contact.sponsor_email}?subject=#{@conference.short_title}%20Sponsorship") do Please contact us! - diff --git a/lib/tasks/.gitkeep b/lib/tasks/.gitkeep deleted file mode 100644 index e69de29b..00000000 diff --git a/lib/tasks/logo.rake b/lib/tasks/logo.rake new file mode 100644 index 00000000..cea95113 --- /dev/null +++ b/lib/tasks/logo.rake @@ -0,0 +1,6 @@ +namespace :logo do + desc 'Resize existing logo of sponsors after change in image manipulation specifications' + task reprocess: :environment do + Sponsor.find_each { |s| s.logo.reprocess! } + end +end diff --git a/spec/helpers/sponsor_helper_spec.rb b/spec/helpers/sponsor_helper_spec.rb new file mode 100644 index 00000000..492f9df5 --- /dev/null +++ b/spec/helpers/sponsor_helper_spec.rb @@ -0,0 +1,40 @@ +require 'spec_helper' + +describe SponsorsHelper, type: :helper do + let(:sponsor) { create(:sponsor) } + + describe '#get_logo' do + context 'first sponsorship_level' do + before do + first_sponsorship_level = create(:sponsorship_level, position: 1) + sponsor.update_attributes(sponsorship_level: first_sponsorship_level) + end + + it 'returns correct url' do + expect(get_logo(sponsor)).to match %r{.*(\bfirst/rails.jpg\b)} + end + end + + context 'second sponsorship_level' do + before do + second_sponsorship_level = create(:sponsorship_level, position: 2) + sponsor.update_attributes(sponsorship_level: second_sponsorship_level) + end + + it 'returns correct url' do + expect(get_logo(sponsor)).to match %r{.*(\bsecond/rails.jpg\b)} + end + end + + context 'other sponsorship_level' do + before do + other_sponsorship_level = create(:sponsorship_level, position: 3) + sponsor.update_attributes(sponsorship_level: other_sponsorship_level) + end + + it 'returns correct url' do + expect(get_logo(sponsor)).to match %r{.*(\bothers/rails.jpg\b)} + end + end + end +end diff --git a/spec/views/conference/show.html.haml_spec.rb b/spec/views/conference/show.html.haml_spec.rb index 31b1cdea..04951b64 100644 --- a/spec/views/conference/show.html.haml_spec.rb +++ b/spec/views/conference/show.html.haml_spec.rb @@ -58,7 +58,6 @@ describe 'conference/show.html.haml' do it 'renders sponsors partial' do expect(view).to render_template(partial: 'conference/_sponsors') expect(rendered).to match(/example@example.com/) - expect(rendered).to match(/Example sponsor/) expect(rendered).to match(/www.example.com/) expect(rendered).to match(/Lorem Ipsum Dolor/) expect(rendered).to match(/rails.jpg/)