mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
Merge pull request #967 from sonalkr132/sponsers
Splash page sponsers section style improvement
This commit is contained in:
commit
9e07212cb5
9 changed files with 99 additions and 21 deletions
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -89,10 +89,11 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#sponsors {
|
||||
.img-sponsor {
|
||||
max-height: 100px;
|
||||
margin: 2% auto;
|
||||
}
|
||||
.img-sponsor-1 {
|
||||
max-height: 200px;
|
||||
|
|
|
|||
12
app/helpers/sponsors_helper.rb
Normal file
12
app/helpers/sponsors_helper.rb
Normal file
|
|
@ -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
|
||||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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!
|
||||
|
||||
|
|
|
|||
6
lib/tasks/logo.rake
Normal file
6
lib/tasks/logo.rake
Normal file
|
|
@ -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
|
||||
40
spec/helpers/sponsor_helper_spec.rb
Normal file
40
spec/helpers/sponsor_helper_spec.rb
Normal file
|
|
@ -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
|
||||
|
|
@ -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/)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue