mirror of
https://github.com/openSUSE/osem.git
synced 2026-08-13 19:54:02 +00:00
Merge pull request #970 from hennevogel/feature_cloudinary
Switch to carrierwave for for upload management
This commit is contained in:
commit
3ce62979bd
37 changed files with 252 additions and 153 deletions
68
Gemfile
68
Gemfile
|
|
@ -21,14 +21,19 @@ gem 'rails-observers'
|
|||
# for tracking data changes
|
||||
gem 'paper_trail'
|
||||
|
||||
# Internationalizing gem , use gem according to version of your rails application
|
||||
gem 'rails-i18n', '~> 4.0.0' # For 4.0.x
|
||||
# for upload management
|
||||
gem 'carrierwave'
|
||||
gem 'mini_magick'
|
||||
gem 'carrierwave-bombshelter'
|
||||
|
||||
# for internationalizing
|
||||
gem 'rails-i18n', '~> 4.0.0'
|
||||
|
||||
# as authentification framework
|
||||
gem 'devise'
|
||||
gem 'devise_ichain_authenticatable'
|
||||
|
||||
# to support openID authentication
|
||||
# for openID authentication
|
||||
gem 'omniauth'
|
||||
gem 'omniauth-facebook'
|
||||
gem 'omniauth-openid'
|
||||
|
|
@ -37,7 +42,8 @@ gem 'omniauth-github'
|
|||
|
||||
# as authorization framework
|
||||
gem 'cancancan'
|
||||
# to set roles
|
||||
|
||||
# for roles
|
||||
gem 'rolify'
|
||||
|
||||
# to show flash messages from ajax requests
|
||||
|
|
@ -66,17 +72,16 @@ gem 'formtastic-bootstrap'
|
|||
gem 'formtastic', '~> 3.1.1'
|
||||
gem 'cocoon'
|
||||
|
||||
# frontend javascripts
|
||||
|
||||
# as the JavaScript library
|
||||
gem 'jquery-rails'
|
||||
|
||||
# frontend javascripts
|
||||
source 'https://rails-assets.org' do
|
||||
# for placeholder images
|
||||
gem 'rails-assets-holderjs'
|
||||
# for formating dates
|
||||
gem 'rails-assets-date.format'
|
||||
# for or parsing, validating, manipulating, and formatting dates.
|
||||
# for or parsing, validating, manipulating, and formatting dates
|
||||
gem 'rails-assets-momentjs'
|
||||
# for smooth scrolling
|
||||
gem 'rails-assets-jquery-smooth-scroll'
|
||||
|
|
@ -97,8 +102,10 @@ end
|
|||
# as date picker
|
||||
gem 'bootstrap3-datetimepicker-rails', '~> 3.0.2'
|
||||
gem 'jquery-datatables-rails', '~> 2.2.1'
|
||||
|
||||
# for charts
|
||||
gem 'chart-js-rails'
|
||||
|
||||
# for displaying maps
|
||||
gem 'leaflet-rails'
|
||||
|
||||
|
|
@ -108,9 +115,6 @@ gem 'gravtastic'
|
|||
# for country selects
|
||||
gem 'country_select'
|
||||
|
||||
# for upload management
|
||||
gem 'paperclip'
|
||||
|
||||
# as PDF generator
|
||||
gem 'prawn_rails'
|
||||
|
||||
|
|
@ -120,24 +124,21 @@ gem 'axlsx_rails'
|
|||
# as error catcher
|
||||
gem 'hoptoad_notifier', '~> 2.3'
|
||||
|
||||
# to make links faster. Read more: https://github.com/rails/turbolinks
|
||||
# to make links faster
|
||||
gem 'turbolinks'
|
||||
|
||||
# for JSON serialization of our API
|
||||
gem 'active_model_serializers'
|
||||
|
||||
# for icon fonts
|
||||
# as icon font
|
||||
gem 'font-awesome-rails'
|
||||
|
||||
# for Markdown in description
|
||||
# for markdown
|
||||
gem 'redcarpet'
|
||||
|
||||
# as rdoc generator
|
||||
gem 'rdoc-generator-fivefish'
|
||||
|
||||
# for seeds
|
||||
gem 'factory_girl_rails'
|
||||
|
||||
# for visitor tracking
|
||||
gem 'ahoy_matey'
|
||||
gem 'activeuuid'
|
||||
|
|
@ -162,44 +163,51 @@ gem 'bootstrap-switch-rails', '~> 3.0.0'
|
|||
# for parsing OEmbed data
|
||||
gem 'ruby-oembed'
|
||||
|
||||
# Use guard and spring for testing in development
|
||||
# for uploading images to the cloud
|
||||
gem 'cloudinary'
|
||||
|
||||
group :development do
|
||||
# rspec Guard rules
|
||||
# to launch specs when files are modified
|
||||
gem 'guard-rspec', '~> 4.2.8'
|
||||
gem 'spring-commands-rspec'
|
||||
# Get HoundCi comments locally
|
||||
# for static code analisys
|
||||
gem 'rubocop'
|
||||
# Silence rack assests messages
|
||||
# to silence rack assests messages
|
||||
gem 'quiet_assets'
|
||||
# Use sqlite3 as the database in development
|
||||
# as database
|
||||
gem 'sqlite3'
|
||||
# Use letter_opener to open mails in development
|
||||
# to open mails
|
||||
gem 'letter_opener'
|
||||
# Use letter_opener_web to open mails in browser (e.g. necessary for Vagrant)
|
||||
# to open mails in browser
|
||||
gem 'letter_opener_web'
|
||||
# mina is a blazing fast deployment system
|
||||
# as deployment system
|
||||
gem 'mina'
|
||||
# as debugger on error pages
|
||||
gem 'web-console', '~> 2.0'
|
||||
end
|
||||
|
||||
# Use rspec and capybara as testing framework
|
||||
group :test do
|
||||
# We use coveralls for measuring test coverage
|
||||
gem 'coveralls', require: false
|
||||
# as test framework
|
||||
gem 'rspec-rails'
|
||||
gem 'capybara'
|
||||
gem 'database_cleaner'
|
||||
gem 'capybara'
|
||||
gem 'poltergeist'
|
||||
gem 'phantomjs', :require => 'phantomjs/poltergeist'
|
||||
# Set of rails validations matchers to describe models
|
||||
# for measuring test coverage
|
||||
gem 'coveralls', require: false
|
||||
# for describing models
|
||||
gem 'shoulda-matchers', require: false
|
||||
# Extracted from RSpec 3 stub_model and mock_model
|
||||
# for stubing/mocking models
|
||||
gem 'rspec-activemodel-mocks'
|
||||
# to freeze time
|
||||
gem 'timecop'
|
||||
# for mocking external requests
|
||||
gem 'webmock'
|
||||
end
|
||||
|
||||
group :development, :test do
|
||||
# as debugger
|
||||
gem 'byebug'
|
||||
# for seeds
|
||||
gem 'factory_girl_rails'
|
||||
end
|
||||
|
|
|
|||
47
Gemfile.lock
47
Gemfile.lock
|
|
@ -64,6 +64,7 @@ GEM
|
|||
json
|
||||
awesome_nested_set (3.0.0.rc.5)
|
||||
activerecord (>= 4.0.0, < 5)
|
||||
aws_cf_signer (0.1.3)
|
||||
axlsx (2.0.1)
|
||||
htmlentities (~> 4.3.1)
|
||||
nokogiri (>= 1.4.1)
|
||||
|
|
@ -93,6 +94,15 @@ GEM
|
|||
rack (>= 1.0.0)
|
||||
rack-test (>= 0.5.4)
|
||||
xpath (~> 2.0)
|
||||
carrierwave (0.11.0)
|
||||
activemodel (>= 3.2.0)
|
||||
activesupport (>= 3.2.0)
|
||||
json (>= 1.7)
|
||||
mime-types (>= 1.16)
|
||||
carrierwave-bombshelter (0.1.1.6)
|
||||
activesupport (>= 3.2.0)
|
||||
carrierwave
|
||||
fastimage
|
||||
celluloid (0.15.2)
|
||||
timers (~> 1.1.0)
|
||||
celluloid-io (0.15.0)
|
||||
|
|
@ -101,11 +111,10 @@ GEM
|
|||
chart-js-rails (0.0.6)
|
||||
railties (> 3.1)
|
||||
chronic (0.10.2)
|
||||
climate_control (0.0.3)
|
||||
activesupport (>= 3.0)
|
||||
cliver (0.3.2)
|
||||
cocaine (0.5.8)
|
||||
climate_control (>= 0.0.3, < 1.0)
|
||||
cloudinary (1.1.6)
|
||||
aws_cf_signer
|
||||
rest-client
|
||||
cocoon (1.2.6)
|
||||
coderay (1.1.0)
|
||||
coffee-rails (4.1.1)
|
||||
|
|
@ -151,6 +160,8 @@ GEM
|
|||
devise (>= 2.2)
|
||||
diff-lcs (1.2.5)
|
||||
docile (1.1.5)
|
||||
domain_name (0.5.20160310)
|
||||
unf (>= 0.0.5, < 1.0.0)
|
||||
erubis (2.7.0)
|
||||
execjs (2.6.0)
|
||||
factory_girl (4.5.0)
|
||||
|
|
@ -160,6 +171,8 @@ GEM
|
|||
railties (>= 3.0.0)
|
||||
faraday (0.9.0)
|
||||
multipart-post (>= 1.2, < 3)
|
||||
fastimage (2.0.0)
|
||||
addressable (~> 2)
|
||||
ffi (1.9.3)
|
||||
font-awesome-rails (4.1.0.0)
|
||||
railties (>= 3.2, < 5.0)
|
||||
|
|
@ -194,6 +207,8 @@ GEM
|
|||
activesupport
|
||||
builder
|
||||
htmlentities (4.3.1)
|
||||
http-cookie (1.0.2)
|
||||
domain_name (~> 0.5)
|
||||
i18n (0.7.0)
|
||||
i18n_data (0.7.0)
|
||||
inversion (0.12.3)
|
||||
|
|
@ -228,10 +243,10 @@ GEM
|
|||
mime-types (>= 1.16, < 3)
|
||||
method_source (0.8.2)
|
||||
mime-types (2.99.1)
|
||||
mimemagic (0.3.0)
|
||||
mina (0.3.8)
|
||||
open4 (~> 1.3.4)
|
||||
rake
|
||||
mini_magick (4.5.1)
|
||||
mini_portile2 (2.0.0)
|
||||
minitest (5.8.4)
|
||||
momentjs-rails (2.8.1)
|
||||
|
|
@ -250,6 +265,7 @@ GEM
|
|||
multi_xml (0.5.5)
|
||||
multipart-post (2.0.0)
|
||||
mysql2 (0.4.2)
|
||||
netrc (0.11.0)
|
||||
nio4r (1.2.1)
|
||||
nokogiri (1.6.7.2)
|
||||
mini_portile2 (~> 2.0.0.rc2)
|
||||
|
|
@ -283,12 +299,6 @@ GEM
|
|||
paper_trail (3.0.1)
|
||||
activerecord (>= 3.0, < 5.0)
|
||||
activesupport (>= 3.0, < 5.0)
|
||||
paperclip (4.3.2)
|
||||
activemodel (>= 3.2.0)
|
||||
activesupport (>= 3.2.0)
|
||||
cocaine (~> 0.5.5)
|
||||
mime-types
|
||||
mimemagic (= 0.3.0)
|
||||
parser (2.3.0.3)
|
||||
ast (~> 2.2)
|
||||
pdf-core (0.2.5)
|
||||
|
|
@ -384,6 +394,10 @@ GEM
|
|||
request_store (1.0.6)
|
||||
responders (2.1.1)
|
||||
railties (>= 4.2.0, < 5.1)
|
||||
rest-client (1.8.0)
|
||||
http-cookie (>= 1.0.2, < 2.0)
|
||||
mime-types (>= 1.16, < 3.0)
|
||||
netrc (~> 0.7)
|
||||
rolify (5.0.0)
|
||||
rspec (3.0.0)
|
||||
rspec-core (~> 3.0.0)
|
||||
|
|
@ -466,6 +480,9 @@ GEM
|
|||
thread_safe (~> 0.1)
|
||||
uglifier (3.0.0)
|
||||
execjs (>= 0.3.0, < 3)
|
||||
unf (0.1.4)
|
||||
unf_ext
|
||||
unf_ext (0.0.7.2)
|
||||
unicode-display_width (0.3.1)
|
||||
unicode_utils (1.4.0)
|
||||
unobtrusive_flash (3.1.0)
|
||||
|
|
@ -510,7 +527,10 @@ DEPENDENCIES
|
|||
byebug
|
||||
cancancan
|
||||
capybara
|
||||
carrierwave
|
||||
carrierwave-bombshelter
|
||||
chart-js-rails
|
||||
cloudinary
|
||||
cocoon
|
||||
country_select
|
||||
coveralls
|
||||
|
|
@ -533,6 +553,7 @@ DEPENDENCIES
|
|||
letter_opener
|
||||
letter_opener_web
|
||||
mina
|
||||
mini_magick
|
||||
money-rails
|
||||
mysql2
|
||||
omniauth
|
||||
|
|
@ -541,7 +562,6 @@ DEPENDENCIES
|
|||
omniauth-google-oauth2
|
||||
omniauth-openid
|
||||
paper_trail
|
||||
paperclip
|
||||
phantomjs
|
||||
piwik_analytics (~> 1.0.1)
|
||||
poltergeist
|
||||
|
|
@ -581,3 +601,6 @@ DEPENDENCIES
|
|||
web-console (~> 2.0)
|
||||
webmock
|
||||
whenever
|
||||
|
||||
BUNDLED WITH
|
||||
1.11.2
|
||||
|
|
|
|||
|
|
@ -180,12 +180,12 @@ module Admin
|
|||
params.require(:conference).permit(:title, :short_title, :description, :timezone,
|
||||
:start_date, :end_date, :rooms_attributes, :tracks_attributes,
|
||||
:tickets_attributes, :event_types_attributes,
|
||||
:logo, :questions_attributes,
|
||||
:picture, :picture_cache, :questions_attributes,
|
||||
:question_ids, :answers_attributes, :answer_ids, :difficulty_levels_attributes,
|
||||
:use_difficulty_levels, :use_vpositions, :use_vdays, :vdays_attributes,
|
||||
:vpositions_attributes, :use_volunteers, :color,
|
||||
:sponsorship_levels_attributes, :sponsors_attributes,
|
||||
:photos_attributes, :targets, :targets_attributes,
|
||||
:targets, :targets_attributes,
|
||||
:campaigns, :campaigns_attributes, :registration_limit)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ module Admin
|
|||
private
|
||||
|
||||
def lodging_params
|
||||
params.require(:lodging).permit(:name, :description, :photo, :website_link, :conference_id)
|
||||
params.require(:lodging).permit(:name, :description, :picture, :picture_cache, :website_link, :conference_id)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ module Admin
|
|||
private
|
||||
|
||||
def sponsor_params
|
||||
params.require(:sponsor).permit(:name, :description, :website_url, :logo, :sponsorship_level_id, :conference_id)
|
||||
params.require(:sponsor).permit(:name, :description, :website_url, :picture, :picture_cache, :sponsorship_level_id, :conference_id)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ module Admin
|
|||
private
|
||||
|
||||
def venue_params
|
||||
params.require(:venue).permit(:name, :street, :postalcode, :city, :country, :longitude, :latitude, :description, :website, :photo, :lodgings_attributes, :conference_id)
|
||||
params.require(:venue).permit(:name, :street, :postalcode, :city, :country, :longitude, :latitude, :description, :website, :picture, :picture_cache, :lodgings_attributes, :conference_id)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -23,11 +23,6 @@ class ConferenceController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def gallery_photos
|
||||
@photos = @conference.photos
|
||||
render 'photos', formats: [:js]
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def respond_to_options
|
||||
|
|
|
|||
|
|
@ -2,11 +2,11 @@ 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)
|
||||
sponsor.picture.first.url
|
||||
elsif sponsor.sponsorship_level.position == 2
|
||||
sponsor.logo.url(:second)
|
||||
sponsor.picture.second.url
|
||||
else
|
||||
sponsor.logo.url(:others)
|
||||
sponsor.picture.others.url
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -30,7 +30,6 @@ class Conference < ActiveRecord::Base
|
|||
has_many :vpositions, dependent: :destroy
|
||||
has_many :sponsorship_levels, -> { order('position ASC') }, dependent: :destroy
|
||||
has_many :sponsors, dependent: :destroy
|
||||
has_many :photos, dependent: :destroy
|
||||
has_many :targets, dependent: :destroy
|
||||
has_many :campaigns, dependent: :destroy
|
||||
has_many :commercials, as: :commercialable, dependent: :destroy
|
||||
|
|
@ -44,16 +43,10 @@ class Conference < ActiveRecord::Base
|
|||
accepts_nested_attributes_for :questions, allow_destroy: true
|
||||
accepts_nested_attributes_for :vdays, allow_destroy: true
|
||||
accepts_nested_attributes_for :vpositions, allow_destroy: true
|
||||
accepts_nested_attributes_for :photos, allow_destroy: true
|
||||
accepts_nested_attributes_for :targets, allow_destroy: true
|
||||
accepts_nested_attributes_for :campaigns, allow_destroy: true
|
||||
|
||||
has_attached_file :logo,
|
||||
styles: { thumb: '100x100>', large: '300x300>' }
|
||||
|
||||
validates_attachment_content_type :logo,
|
||||
content_type: [/jpg/, /jpeg/, /png/, /gif/],
|
||||
size: { in: 0..500.kilobytes }
|
||||
mount_uploader :picture, PictureUploader, mount_on: :logo_file_name
|
||||
|
||||
validates_presence_of :title,
|
||||
:short_title,
|
||||
|
|
|
|||
|
|
@ -3,10 +3,5 @@ class Lodging < ActiveRecord::Base
|
|||
|
||||
validates :name, presence: true
|
||||
|
||||
has_attached_file :photo,
|
||||
styles: { thumb: '100x100>', large: '300x300>' }
|
||||
|
||||
validates_attachment_content_type :photo,
|
||||
content_type: [/jpg/, /jpeg/, /png/, /gif/],
|
||||
size: { in: 0..500.kilobytes }
|
||||
mount_uploader :picture, PictureUploader, mount_on: :photo_file_name
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,10 +0,0 @@
|
|||
class Photo < ActiveRecord::Base
|
||||
belongs_to :conference
|
||||
validates_presence_of :picture
|
||||
has_attached_file :picture,
|
||||
styles: { thumb: '100x100>', large: '300x300>', banner: '600x300>' }
|
||||
|
||||
validates_attachment_content_type :picture,
|
||||
content_type: [/jpg/, /jpeg/, /png/, /gif/],
|
||||
size: { in: 0..500.kilobytes }
|
||||
end
|
||||
|
|
@ -1,21 +1,8 @@
|
|||
class Sponsor < ActiveRecord::Base
|
||||
belongs_to :sponsorship_level
|
||||
belongs_to :conference
|
||||
has_attached_file :logo,
|
||||
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 }
|
||||
mount_uploader :picture, PictureUploader, mount_on: :logo_file_name
|
||||
|
||||
validates_presence_of :name, :website_url, :sponsorship_level, :logo
|
||||
validates_presence_of :name, :website_url, :sponsorship_level
|
||||
end
|
||||
|
|
|
|||
|
|
@ -8,11 +8,7 @@ class Venue < ActiveRecord::Base
|
|||
validates :name, :street, :city, :country, presence: true
|
||||
validates :conference_id, presence: true, uniqueness: true
|
||||
|
||||
has_attached_file :photo,
|
||||
styles: { thumb: '100x100>', large: '300x300>' }
|
||||
validates_attachment_content_type :photo,
|
||||
content_type: [/jpg/, /jpeg/, /png/, /gif/],
|
||||
size: { in: 0..500.kilobytes }
|
||||
mount_uploader :picture, PictureUploader, mount_on: :photo_file_name
|
||||
|
||||
before_save :send_mail_notification
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,5 @@
|
|||
class ConferenceSerializer < ActiveModel::Serializer
|
||||
attributes :short_title, :title, :description, :start_date, :end_date, :logo,
|
||||
attributes :short_title, :title, :description, :start_date, :end_date, :picture_url,
|
||||
:difficulty_levels, :event_types, :rooms, :tracks,
|
||||
:date_range, :revision
|
||||
|
||||
|
|
|
|||
87
app/uploaders/picture_uploader.rb
Normal file
87
app/uploaders/picture_uploader.rb
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
# encoding: utf-8
|
||||
|
||||
class PictureUploader < CarrierWave::Uploader::Base
|
||||
include CarrierWave::MiniMagick
|
||||
include CarrierWave::Compatibility::Paperclip
|
||||
include CarrierWave::BombShelter
|
||||
|
||||
# use cloudinary if it's configured
|
||||
if Cloudinary.config.cloud_name
|
||||
include Cloudinary::CarrierWave
|
||||
end
|
||||
|
||||
def paperclip_path
|
||||
"system/#{object_class_name}/#{extra_store_dir}/#{id_partition}/:style/:basename.:extension"
|
||||
end
|
||||
|
||||
def object_class_name
|
||||
model.class.to_s.underscore.pluralize
|
||||
end
|
||||
|
||||
# compatibility with our paperclip storage paths..
|
||||
def extra_store_dir
|
||||
case object_class_name
|
||||
when 'conferences'
|
||||
'logos'
|
||||
when 'lodgings'
|
||||
'photos'
|
||||
when 'sponsors'
|
||||
'logos'
|
||||
when 'venues'
|
||||
'photos'
|
||||
else mounted_as
|
||||
end
|
||||
end
|
||||
|
||||
# Returns the id of the instance in a split path form. e.g. returns
|
||||
# 000/001/234 for an id of 1234. Stolen from paperclip...
|
||||
def id_partition
|
||||
('%09d'.freeze % model.id).scan(/\d{3}/).join('/'.freeze)
|
||||
end
|
||||
|
||||
# Override the directory where uploaded files will be stored.
|
||||
# This is a sensible default for uploaders that are meant to be mounted:
|
||||
def store_dir
|
||||
"system/#{object_class_name}/#{mounted_as}/#{model.id}"
|
||||
end
|
||||
|
||||
# Create different versions of your uploaded files:
|
||||
version :large do
|
||||
process resize_to_fit: [300, 300]
|
||||
end
|
||||
|
||||
version :thumb, from_version: :large do
|
||||
process resize_to_fit: [100, 100]
|
||||
end
|
||||
|
||||
version :first, if: :sponsor?
|
||||
version :first do
|
||||
process resize_and_pad: [320, 180, 'white']
|
||||
end
|
||||
|
||||
version :second, if: :sponsor?
|
||||
version :second, from_version: :first do
|
||||
process resize_and_pad: [320, 150, 'white']
|
||||
end
|
||||
|
||||
version :others, if: :sponsor?
|
||||
version :others, from_version: :second do
|
||||
process resize_and_pad: [320, 120, 'white']
|
||||
end
|
||||
|
||||
# Add a white list of extensions which are allowed to be uploaded.
|
||||
# For images you might use something like this:
|
||||
def extension_white_list
|
||||
%w(jpg jpeg gif png)
|
||||
end
|
||||
|
||||
def content_type_whitelist
|
||||
%r{/image\//}
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def sponsor?(_picture)
|
||||
object_class_name == 'sponsors'
|
||||
end
|
||||
end
|
||||
|
|
@ -11,9 +11,12 @@
|
|||
= f.input :short_title, :hint => "A short title, e.g. 'oSC14', to be used in URLs"
|
||||
= f.input :description, hint: markdown_hint('A description of the conference.'), input_html: { rows: 5, data: { provide: 'markdown-editable' } }
|
||||
= f.input :color, :hint => "The color will be used eg for the dashboard.", :input_html => {:size => 6, :type => "color"}
|
||||
- if !@conference.logo.blank?
|
||||
= image_tag @conference.logo(:thumb)
|
||||
= f.input :logo, :label => "Conference Logo", :hint => "This will be displayed on the front page."
|
||||
= f.label 'Conference Logo'
|
||||
%br
|
||||
- if @conference.picture?
|
||||
= image_tag @conference.picture.thumb.url
|
||||
= f.input :picture, :label => false, :hint => "This will be displayed on the front page."
|
||||
= f.hidden_field :picture_cache
|
||||
= f.inputs :name => "Scheduling" do
|
||||
= f.input :timezone, :as => :time_zone, :hint => "The conference time zone"
|
||||
= f.input :start_date, :as => :string, :input_html => { :id => "conference-start-datepicker", :readonly => "readonly" }
|
||||
|
|
|
|||
|
|
@ -12,8 +12,8 @@
|
|||
= f.input :name
|
||||
= f.input :website_link
|
||||
= f.input :description, input_html: { rows: 5, cols: 20, data: { provide: 'markdown-editable' } }, hint: markdown_hint
|
||||
- unless @lodging.photo.blank?
|
||||
= image_tag @lodging.photo(:thumb)
|
||||
= f.input :photo
|
||||
- if @lodging.picture?
|
||||
= image_tag @lodging.picture.thumb.url
|
||||
= f.input :picture
|
||||
%p.text-right
|
||||
= f.action :submit, as: :button, button_html: { class: 'btn btn-primary' }
|
||||
|
|
|
|||
|
|
@ -10,15 +10,15 @@
|
|||
- slice.each do |lodging|
|
||||
.col-md-4
|
||||
.thumbnail
|
||||
- if lodging.photo.blank?
|
||||
- if !lodging.picture?
|
||||
%p.text-center
|
||||
%i.fa.fa-home.fa-5x
|
||||
- else
|
||||
-if lodging.website_link.present?
|
||||
= link_to(lodging.website_link, class: 'thumbnail') do
|
||||
= image_tag lodging.photo(:thumb), class: 'img-responsive img-lodging'
|
||||
= image_tag lodging.picture.thumb, class: 'img-responsive img-lodging'
|
||||
- else
|
||||
= image_tag lodging.photo(:thumb), class: 'img-responsive img-lodging'
|
||||
= image_tag lodging.picture.thumb, class: 'img-responsive img-lodging'
|
||||
.caption
|
||||
%h3.text-center
|
||||
= lodging.name
|
||||
|
|
|
|||
|
|
@ -11,8 +11,8 @@
|
|||
= semantic_form_for(@sponsor, :url => (@sponsor.new_record? ? admin_conference_sponsors_path : admin_conference_sponsor_path(@conference.short_title, @sponsor))) do |f|
|
||||
= f.input :name
|
||||
= f.input :description
|
||||
= image_tag f.object.logo(:thumb) if !f.object.logo.blank?
|
||||
= f.input :logo
|
||||
= image_tag f.object.picture.thumb.url if f.object.picture?
|
||||
= f.input :picture
|
||||
= f.input :website_url
|
||||
= f.input :sponsorship_level, collection: @conference.sponsorship_levels
|
||||
%p.text-right
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@
|
|||
- @conference.sponsors.each do |sponsor|
|
||||
%tr
|
||||
%td
|
||||
= image_tag(sponsor.logo(:thumb), width: '20%')
|
||||
= image_tag(sponsor.picture.thumb.url, width: '20%')
|
||||
%td
|
||||
= sponsor.name
|
||||
%td
|
||||
|
|
|
|||
|
|
@ -8,7 +8,7 @@
|
|||
= link_to 'Details', '#details-content', 'data-toggle' => 'tab'
|
||||
%li
|
||||
= link_to 'Commercials', '#commercials-content', 'data-toggle' => 'tab'
|
||||
|
||||
|
||||
.tab-content
|
||||
#details-content.tab-pane.active
|
||||
.col-md-8
|
||||
|
|
@ -16,9 +16,9 @@
|
|||
= f.inputs :name, :website
|
||||
= f.input :description, input_html: { rows: 5, cols: 20, data: { provide: 'markdown-editable' } }, hint: markdown_hint
|
||||
= f.inputs :street, :postalcode, :city, :country, :latitude, :longitude
|
||||
- unless @venue.photo.blank?
|
||||
= image_tag @venue.photo(:thumb)
|
||||
= f.input :photo
|
||||
- if @venue.picture?
|
||||
= image_tag @venue.picture.thumb.url
|
||||
= f.input :picture
|
||||
= f.action :submit, as: :button, button_html: { class: 'btn btn-primary' }
|
||||
|
||||
#commercials-content.tab-pane
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
.well
|
||||
.row
|
||||
.col-md-4.text-center
|
||||
= image_tag(conference.logo(:original), class: 'img-responsive') if conference.logo?
|
||||
= image_tag(conference.picture_url, class: 'img-responsive') if conference.picture?
|
||||
.col-md-6
|
||||
%h3
|
||||
= conference.title
|
||||
|
|
|
|||
|
|
@ -1,7 +0,0 @@
|
|||
- photos.each_with_index do |photo,index|
|
||||
%div.item{ class: (index==0? 'active' : '') }
|
||||
= image_tag(photo.picture(:banner))
|
||||
- unless photo.description.blank?
|
||||
%div.carousel-caption
|
||||
.lead
|
||||
= photo.description
|
||||
|
|
@ -13,18 +13,17 @@
|
|||
- slice.each do |lodging|
|
||||
.col-md-4.col-sm-4.ticket.col-centered.col-top
|
||||
.thumbnail
|
||||
- if lodging.photo.blank?
|
||||
- if !lodging.picture?
|
||||
%p.text-center
|
||||
%i.fa.fa-home.fa-5x
|
||||
- else
|
||||
-if lodging.website_link.present?
|
||||
= link_to(lodging.website_link, class: 'thumbnail') do
|
||||
= image_tag lodging.photo(:large), class: 'img-responsive img-lodging'
|
||||
= image_tag lodging.picture.large.url, class: 'img-responsive img-lodging'
|
||||
- else
|
||||
= image_tag lodging.photo(:large), class: 'img-responsive img-lodging'
|
||||
= image_tag lodging.picture.large.url, class: 'img-responsive img-lodging'
|
||||
.caption
|
||||
%h3.text-center
|
||||
= lodging.name
|
||||
-if lodging.description.present?
|
||||
= markdown(lodging.description)
|
||||
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@
|
|||
.col-md-8.col-md-offset-2#header
|
||||
.row
|
||||
.col-md-4
|
||||
= image_tag(@conference.logo(:original), class: 'img-responsive img-center', id: 'splash-logo') if @conference.logo?
|
||||
= image_tag(@conference.picture_url, class: 'img-responsive img-center', id: 'splash-logo') if @conference.picture?
|
||||
.col-md-8
|
||||
%h1
|
||||
= @conference.title
|
||||
|
|
|
|||
4
config/cloudinary.yml.example
Normal file
4
config/cloudinary.yml.example
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
production:
|
||||
cloud_name: "sample"
|
||||
api_key: "874837483274837"
|
||||
api_secret: "a676b67565c6767a6767d6767f676fe1"
|
||||
5
config/initializers/carrierwave.rb
Normal file
5
config/initializers/carrierwave.rb
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
CarrierWave.configure do |config|
|
||||
config.storage = :file
|
||||
config.cache_dir = "#{Rails.root}/tmp/uploads"
|
||||
config.enable_processing = false if Rails.env.test?
|
||||
end
|
||||
4
config/initializers/fuckups.rb
Normal file
4
config/initializers/fuckups.rb
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
# Add methods here that slipped into migrations in the dark ages...
|
||||
def remove_attachment(*args)
|
||||
true
|
||||
end
|
||||
13
db/migrate/20160427101444_remove_photos.rb
Normal file
13
db/migrate/20160427101444_remove_photos.rb
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
class RemovePhotos < ActiveRecord::Migration
|
||||
def change
|
||||
drop_table :photos do |t|
|
||||
t.text :description
|
||||
t.string :picture_file_name
|
||||
t.string :picture_content_type
|
||||
t.integer :picture_file_size
|
||||
t.datetime :picture_updated_at
|
||||
t.belongs_to :conference
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
8
db/migrate/20160427104236_add_pictures.rb
Normal file
8
db/migrate/20160427104236_add_pictures.rb
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
class AddPictures < ActiveRecord::Migration
|
||||
def change
|
||||
add_column :conferences, :picture, :string
|
||||
add_column :lodgings, :picture, :string
|
||||
add_column :sponsors, :picture, :string
|
||||
add_column :venues, :picture, :string
|
||||
end
|
||||
end
|
||||
17
db/schema.rb
17
db/schema.rb
|
|
@ -11,7 +11,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20160403214841) do
|
||||
ActiveRecord::Schema.define(version: 20160427104236) do
|
||||
|
||||
create_table "ahoy_events", force: :cascade do |t|
|
||||
t.uuid "visit_id", limit: 16
|
||||
|
|
@ -101,6 +101,7 @@ ActiveRecord::Schema.define(version: 20160403214841) do
|
|||
t.text "events_per_week"
|
||||
t.text "description"
|
||||
t.integer "registration_limit", default: 0
|
||||
t.string "picture"
|
||||
end
|
||||
|
||||
create_table "conferences_questions", id: false, force: :cascade do |t|
|
||||
|
|
@ -246,6 +247,7 @@ ActiveRecord::Schema.define(version: 20160403214841) do
|
|||
t.datetime "updated_at"
|
||||
t.string "website_link"
|
||||
t.integer "conference_id"
|
||||
t.string "picture"
|
||||
end
|
||||
|
||||
create_table "openids", force: :cascade do |t|
|
||||
|
|
@ -257,17 +259,6 @@ ActiveRecord::Schema.define(version: 20160403214841) do
|
|||
t.datetime "updated_at"
|
||||
end
|
||||
|
||||
create_table "photos", force: :cascade do |t|
|
||||
t.text "description"
|
||||
t.string "picture_file_name"
|
||||
t.string "picture_content_type"
|
||||
t.integer "picture_file_size"
|
||||
t.datetime "picture_updated_at"
|
||||
t.integer "conference_id"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
end
|
||||
|
||||
create_table "programs", force: :cascade do |t|
|
||||
t.integer "conference_id"
|
||||
t.integer "rating", default: 0
|
||||
|
|
@ -377,6 +368,7 @@ ActiveRecord::Schema.define(version: 20160403214841) do
|
|||
t.integer "conference_id"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.string "picture"
|
||||
end
|
||||
|
||||
create_table "sponsorship_levels", force: :cascade do |t|
|
||||
|
|
@ -509,6 +501,7 @@ ActiveRecord::Schema.define(version: 20160403214841) do
|
|||
t.string "latitude"
|
||||
t.string "longitude"
|
||||
t.integer "conference_id"
|
||||
t.string "picture"
|
||||
end
|
||||
|
||||
create_table "versions", force: :cascade do |t|
|
||||
|
|
|
|||
|
|
@ -5,11 +5,14 @@ FactoryGirl.define do
|
|||
name 'Example sponsor'
|
||||
website_url 'http://www.example.com'
|
||||
description 'Lorem Ipsum Dolor'
|
||||
logo_file_name 'rails.jpg'
|
||||
logo_file_size 2000
|
||||
logo_content_type 'image/jpeg'
|
||||
logo_updated_at DateTime.current
|
||||
sponsorship_level
|
||||
conference
|
||||
|
||||
after(:create) do |sponsor|
|
||||
uploader = PictureUploader.new(sponsor, :picture)
|
||||
File.open('app/assets/images/rails.png') { |f| uploader.store!(f) }
|
||||
sponsor.logo_file_name = 'rails.png'
|
||||
sponsor.save
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ feature Lodging do
|
|||
|
||||
fill_in 'lodging_name', with: 'New lodging'
|
||||
fill_in 'lodging_website_link', with: 'http:\\www.google.com'
|
||||
attach_file 'Photo', path
|
||||
attach_file 'Picture', path
|
||||
|
||||
click_button 'Create Lodging'
|
||||
|
||||
|
|
@ -42,7 +42,7 @@ feature Lodging do
|
|||
|
||||
fill_in 'lodging_name', with: 'New lodging'
|
||||
fill_in 'lodging_website_link', with: 'http:\\www.google.com'
|
||||
attach_file 'Photo', path
|
||||
attach_file 'Picture', path
|
||||
|
||||
click_button 'Update Lodging'
|
||||
|
||||
|
|
|
|||
|
|
@ -19,7 +19,7 @@ feature Sponsor do
|
|||
|
||||
fill_in 'sponsor_name', with: 'SUSE'
|
||||
fill_in 'sponsor_description', with: 'The original provider of the enterprise Linux distribution'
|
||||
attach_file 'Logo', path
|
||||
attach_file 'Picture', path
|
||||
fill_in 'sponsor_website_url', with: 'http://www.suse.com'
|
||||
select('Platin', from: 'sponsor_sponsorship_level_id')
|
||||
|
||||
|
|
|
|||
|
|
@ -11,7 +11,7 @@ describe SponsorsHelper, type: :helper do
|
|||
end
|
||||
|
||||
it 'returns correct url' do
|
||||
expect(get_logo(sponsor)).to match %r{.*(\bfirst/rails.jpg\b)}
|
||||
expect(get_logo(sponsor)).to match %r{.*(\bfirst/rails.png\b)}
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -22,7 +22,7 @@ describe SponsorsHelper, type: :helper do
|
|||
end
|
||||
|
||||
it 'returns correct url' do
|
||||
expect(get_logo(sponsor)).to match %r{.*(\bsecond/rails.jpg\b)}
|
||||
expect(get_logo(sponsor)).to match %r{.*(\bsecond/rails.png\b)}
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -33,7 +33,7 @@ describe SponsorsHelper, type: :helper do
|
|||
end
|
||||
|
||||
it 'returns correct url' do
|
||||
expect(get_logo(sponsor)).to match %r{.*(\bothers/rails.jpg\b)}
|
||||
expect(get_logo(sponsor)).to match %r{.*(\bothers/rails.png\b)}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -16,7 +16,7 @@ describe ConferenceSerializer, type: :serializer do
|
|||
description: 'Lorem ipsum dolor sit',
|
||||
start_date: '2014-03-04',
|
||||
end_date: '2014-03-10',
|
||||
logo: '/logos/original/missing.png',
|
||||
picture_url: nil,
|
||||
difficulty_levels:
|
||||
[{id: 1,
|
||||
title: 'Easy',
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ describe 'conference/show.html.haml' do
|
|||
expect(rendered).to match(/example@example.com/)
|
||||
expect(rendered).to match(/www.example.com/)
|
||||
expect(rendered).to match(/Lorem Ipsum Dolor/)
|
||||
expect(rendered).to match(/rails.jpg/)
|
||||
expect(rendered).to match(/rails.png/)
|
||||
end
|
||||
|
||||
it 'renders social media partial' do
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue