beerify 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +11 -0
- data/Rakefile +34 -0
- data/app/assets/fonts/beerify/glyphicons-halflings-regular.eot +0 -0
- data/app/assets/fonts/beerify/glyphicons-halflings-regular.svg +228 -0
- data/app/assets/fonts/beerify/glyphicons-halflings-regular.ttf +0 -0
- data/app/assets/fonts/beerify/glyphicons-halflings-regular.woff +0 -0
- data/app/assets/javascripts/beerify/application.js +3 -0
- data/app/assets/javascripts/beerify/bootstrap.js +1991 -0
- data/app/assets/stylesheets/beerify/application.css +3 -0
- data/app/assets/stylesheets/beerify/bootstrap.css +5909 -0
- data/app/controllers/application_controller.rb +2 -0
- data/app/controllers/contacts_controller.rb +21 -0
- data/app/helpers/application_helper.rb +2 -0
- data/app/helpers/contacts_helper.rb +2 -0
- data/app/models/ability.rb +28 -0
- data/app/models/catalog.rb +11 -0
- data/app/models/ckeditor/asset.rb +7 -0
- data/app/models/ckeditor/attachment_file.rb +7 -0
- data/app/models/ckeditor/picture.rb +7 -0
- data/app/models/contact.rb +8 -0
- data/app/models/news.rb +11 -0
- data/app/models/photo.rb +5 -0
- data/app/models/product.rb +12 -0
- data/app/models/settings.rb +10 -0
- data/app/models/user.rb +10 -0
- data/app/models/users/admin.rb +4 -0
- data/app/models/users/customer.rb +5 -0
- data/app/models/users/sudoer.rb +4 -0
- data/app/uploaders/ckeditor_attachment_file_uploader.rb +35 -0
- data/app/uploaders/ckeditor_picture_uploader.rb +46 -0
- data/app/uploaders/photo_uploader.rb +22 -0
- data/app/views/contacts/_form.html.slim +5 -0
- data/app/views/contacts/new.html.slim +2 -0
- data/app/views/devise/confirmations/new.html.erb +14 -0
- data/app/views/devise/mailer/confirmation_instructions.html.erb +3 -0
- data/app/views/devise/mailer/reset_password_instructions.html.erb +5 -0
- data/app/views/devise/mailer/unlock_instructions.html.erb +4 -0
- data/app/views/devise/passwords/edit.html.erb +16 -0
- data/app/views/devise/passwords/new.html.erb +14 -0
- data/app/views/devise/registrations/edit.html.erb +20 -0
- data/app/views/devise/registrations/new.html.erb +16 -0
- data/app/views/devise/sessions/new.html.erb +14 -0
- data/app/views/devise/shared/_links.erb +25 -0
- data/app/views/devise/unlocks/new.html.erb +14 -0
- data/app/views/layouts/beerify/application.html.erb +14 -0
- data/config/initializers/ckeditor.rb +21 -0
- data/config/initializers/devise.rb +254 -0
- data/config/initializers/kaminari.rb +3 -0
- data/config/initializers/rails_admin.rb +5 -0
- data/config/initializers/rails_admin/news_admin.rb +19 -0
- data/config/initializers/rails_admin/user_admin.rb +71 -0
- data/config/initializers/simple_form.rb +142 -0
- data/config/initializers/simple_form_bootstrap.rb +76 -0
- data/config/locales/attributes.en.yml +57 -0
- data/config/locales/attributes.fr.yml +57 -0
- data/config/locales/devise.en.yml +59 -0
- data/config/locales/devise.fr.yml +78 -0
- data/config/locales/devise.views.en.yml +59 -0
- data/config/locales/devise.views.fr.yml +51 -0
- data/config/locales/fr.yml +220 -0
- data/config/locales/main.en.yml +5 -0
- data/config/locales/main.fr.yml +5 -0
- data/config/locales/models.en.yml +30 -0
- data/config/locales/models.fr.yml +30 -0
- data/config/locales/rails_admin.fr.yml +129 -0
- data/config/locales/simple_form.en.yml +26 -0
- data/config/routes.rb +8 -0
- data/config/settings/beerify/development.yml +2 -0
- data/config/settings/beerify/production.yml +2 -0
- data/config/settings/beerify/settings.yml +1 -0
- data/db/migrate/20130805210910_create_users.rb +12 -0
- data/db/migrate/20130805212414_add_devise_to_users.rb +34 -0
- data/db/migrate/20130819142757_create_catalogs.rb +15 -0
- data/db/migrate/20130826095103_create_photos.rb +12 -0
- data/db/migrate/20130902160901_create_products.rb +16 -0
- data/db/migrate/20130902162315_add_photos_to_product.rb +6 -0
- data/db/migrate/20130903083519_create_contacts.rb +11 -0
- data/db/migrate/20130903130542_create_news.rb +17 -0
- data/db/migrate/20130904000525_create_ckeditor_assets.rb +23 -0
- data/db/migrate/20130918132647_add_highlight_to_products.rb +5 -0
- data/lib/beerify.rb +4 -0
- data/lib/beerify/engine.rb +28 -0
- data/lib/beerify/version.rb +3 -0
- data/lib/tasks/populate.rake +66 -0
- data/spec/beerify/models/catalog_spec.rb +9 -0
- data/spec/beerify/models/contact_spec.rb +6 -0
- data/spec/beerify/models/news_spec.rb +7 -0
- data/spec/beerify/models/photo_spec.rb +5 -0
- data/spec/beerify/models/product_spec.rb +8 -0
- data/spec/beerify/models/user_spec.rb +4 -0
- data/spec/beerify/models/users/admin_spec.rb +5 -0
- data/spec/beerify/models/users/customer_spec.rb +5 -0
- data/spec/dummy/README.rdoc +28 -0
- data/spec/dummy/Rakefile +6 -0
- data/spec/dummy/app/assets/javascripts/application.js +13 -0
- data/spec/dummy/app/assets/stylesheets/application.css +13 -0
- data/spec/dummy/app/controllers/application_controller.rb +5 -0
- data/spec/dummy/app/helpers/application_helper.rb +2 -0
- data/spec/dummy/app/views/layouts/application.html.erb +14 -0
- data/spec/dummy/bin/bundle +3 -0
- data/spec/dummy/bin/rails +4 -0
- data/spec/dummy/bin/rake +4 -0
- data/spec/dummy/config.ru +4 -0
- data/spec/dummy/config/application.rb +23 -0
- data/spec/dummy/config/boot.rb +5 -0
- data/spec/dummy/config/database.yml +11 -0
- data/spec/dummy/config/environment.rb +5 -0
- data/spec/dummy/config/environments/development.rb +29 -0
- data/spec/dummy/config/environments/production.rb +80 -0
- data/spec/dummy/config/environments/test.rb +36 -0
- data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
- data/spec/dummy/config/initializers/inflections.rb +16 -0
- data/spec/dummy/config/initializers/mime_types.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +12 -0
- data/spec/dummy/config/initializers/session_store.rb +3 -0
- data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
- data/spec/dummy/config/locales/en.yml +23 -0
- data/spec/dummy/config/routes.rb +56 -0
- data/spec/dummy/db/migrate/20130904085929_create_users.beerify.rb +13 -0
- data/spec/dummy/db/migrate/20130904085930_add_devise_to_users.beerify.rb +35 -0
- data/spec/dummy/db/migrate/20130904085931_create_catalogs.beerify.rb +16 -0
- data/spec/dummy/db/migrate/20130904085932_create_photos.beerify.rb +13 -0
- data/spec/dummy/db/migrate/20130904085933_create_products.beerify.rb +17 -0
- data/spec/dummy/db/migrate/20130904085934_add_photos_to_product.beerify.rb +7 -0
- data/spec/dummy/db/migrate/20130904085935_create_contacts.beerify.rb +12 -0
- data/spec/dummy/db/migrate/20130906090417_create_news.beerify.rb +18 -0
- data/spec/dummy/db/migrate/20130906090418_create_ckeditor_assets.beerify.rb +24 -0
- data/spec/dummy/db/migrate/20130918132952_add_highlight_to_products.beerify.rb +6 -0
- data/spec/dummy/db/schema.rb +116 -0
- data/spec/dummy/public/404.html +58 -0
- data/spec/dummy/public/422.html +58 -0
- data/spec/dummy/public/500.html +57 -0
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/spec_helper.rb +19 -0
- metadata +641 -0
@@ -0,0 +1,21 @@
|
|
1
|
+
class ContactsController < ApplicationController
|
2
|
+
def new
|
3
|
+
@contact = Contact.new
|
4
|
+
end
|
5
|
+
|
6
|
+
def create
|
7
|
+
@contact = Contact.new(contact_params)
|
8
|
+
|
9
|
+
if @contact.save
|
10
|
+
redirect_to new_contact_path, flash: { success: I18n.t('created') }
|
11
|
+
else
|
12
|
+
render 'new'
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
private
|
17
|
+
|
18
|
+
def contact_params
|
19
|
+
params.require(:contact).permit(:content, :email, :name)
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,28 @@
|
|
1
|
+
class Ability
|
2
|
+
include CanCan::Ability
|
3
|
+
|
4
|
+
def initialize(user)
|
5
|
+
if user && user.class.name === 'Users::Sudoer'
|
6
|
+
can :access, :ckeditor
|
7
|
+
can :access, :rails_admin
|
8
|
+
can :dashboard
|
9
|
+
|
10
|
+
can :manage, :all
|
11
|
+
end
|
12
|
+
|
13
|
+
if user && user.class.name === 'Users::Admin'
|
14
|
+
can :access, :ckeditor
|
15
|
+
can :access, :rails_admin
|
16
|
+
can :dashboard
|
17
|
+
|
18
|
+
can [:read, :create, :update, :destroy, :export], Catalog
|
19
|
+
can [:read, :create, :update, :destroy ], Ckeditor::Picture
|
20
|
+
can [:read, :export], Contact
|
21
|
+
can [:read, :create, :update, :destroy, :export], News
|
22
|
+
can [:read, :create, :update, :destroy, :export], Photo
|
23
|
+
can [:read, :create, :update, :destroy, :export], Product
|
24
|
+
can [:read, :create, :update, :destroy, :export], User
|
25
|
+
cannot :manage, Users::Sudoer
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
data/app/models/news.rb
ADDED
data/app/models/photo.rb
ADDED
@@ -0,0 +1,10 @@
|
|
1
|
+
class Settings < Settingslogic
|
2
|
+
def self.load_files
|
3
|
+
files = Dir["#{Rails.root}/config/settings/**/*.yml"] - Dir["#{Rails.root}/config/settings/beerify/**/*.yml"]
|
4
|
+
|
5
|
+
Dir["#{Rails.root}/config/settings/beerify/**/*.yml"] + files
|
6
|
+
end
|
7
|
+
|
8
|
+
source load_files
|
9
|
+
namespace Rails.env
|
10
|
+
end
|
data/app/models/user.rb
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
class CkeditorAttachmentFileUploader < CarrierWave::Uploader::Base
|
2
|
+
include Ckeditor::Backend::CarrierWave
|
3
|
+
|
4
|
+
# Include RMagick or ImageScience support:
|
5
|
+
# include CarrierWave::RMagick
|
6
|
+
# include CarrierWave::MiniMagick
|
7
|
+
# include CarrierWave::ImageScience
|
8
|
+
|
9
|
+
# Choose what kind of storage to use for this uploader:
|
10
|
+
storage :file
|
11
|
+
|
12
|
+
# Override the directory where uploaded files will be stored.
|
13
|
+
# This is a sensible default for uploaders that are meant to be mounted:
|
14
|
+
def store_dir
|
15
|
+
"uploads/ckeditor/attachments/#{model.id}"
|
16
|
+
end
|
17
|
+
|
18
|
+
# Provide a default URL as a default if there hasn't been a file uploaded:
|
19
|
+
# def default_url
|
20
|
+
# "/images/fallback/" + [version_name, "default.png"].compact.join('_')
|
21
|
+
# end
|
22
|
+
|
23
|
+
# Process files as they are uploaded:
|
24
|
+
# process :scale => [200, 300]
|
25
|
+
#
|
26
|
+
# def scale(width, height)
|
27
|
+
# # do something
|
28
|
+
# end
|
29
|
+
|
30
|
+
# Add a white list of extensions which are allowed to be uploaded.
|
31
|
+
# For images you might use something like this:
|
32
|
+
def extension_white_list
|
33
|
+
Ckeditor.attachment_file_types
|
34
|
+
end
|
35
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
class CkeditorPictureUploader < CarrierWave::Uploader::Base
|
2
|
+
include Ckeditor::Backend::CarrierWave
|
3
|
+
|
4
|
+
# Include RMagick or ImageScience support:
|
5
|
+
# include CarrierWave::RMagick
|
6
|
+
include CarrierWave::MiniMagick
|
7
|
+
# include CarrierWave::ImageScience
|
8
|
+
|
9
|
+
# Choose what kind of storage to use for this uploader:
|
10
|
+
storage :file
|
11
|
+
|
12
|
+
# Override the directory where uploaded files will be stored.
|
13
|
+
# This is a sensible default for uploaders that are meant to be mounted:
|
14
|
+
def store_dir
|
15
|
+
"uploads/ckeditor/pictures/#{model.id}"
|
16
|
+
end
|
17
|
+
|
18
|
+
# Provide a default URL as a default if there hasn't been a file uploaded:
|
19
|
+
# def default_url
|
20
|
+
# "/images/fallback/" + [version_name, "default.png"].compact.join('_')
|
21
|
+
# end
|
22
|
+
|
23
|
+
# Process files as they are uploaded:
|
24
|
+
# process :scale => [200, 300]
|
25
|
+
#
|
26
|
+
# def scale(width, height)
|
27
|
+
# # do something
|
28
|
+
# end
|
29
|
+
|
30
|
+
process :read_dimensions
|
31
|
+
|
32
|
+
# Create different versions of your uploaded files:
|
33
|
+
version :thumb do
|
34
|
+
process :resize_to_fill => [118, 100]
|
35
|
+
end
|
36
|
+
|
37
|
+
version :content do
|
38
|
+
process :resize_to_limit => [800, 800]
|
39
|
+
end
|
40
|
+
|
41
|
+
# Add a white list of extensions which are allowed to be uploaded.
|
42
|
+
# For images you might use something like this:
|
43
|
+
def extension_white_list
|
44
|
+
Ckeditor.image_file_types
|
45
|
+
end
|
46
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
|
3
|
+
class PhotoUploader < CarrierWave::Uploader::Base
|
4
|
+
include CarrierWave::RMagick
|
5
|
+
storage :file
|
6
|
+
|
7
|
+
def store_dir
|
8
|
+
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
|
9
|
+
end
|
10
|
+
|
11
|
+
def default_url
|
12
|
+
'/fallback/' + [version_name, 'photo_default.png'].compact.join('_')
|
13
|
+
end
|
14
|
+
|
15
|
+
version :thumb do
|
16
|
+
process :resize_to_fill => [200, 200]
|
17
|
+
end
|
18
|
+
|
19
|
+
def extension_white_list
|
20
|
+
%w(jpg jpeg gif png gif)
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<h2><%= t('.resend_confirmation_instructions') %></h2>
|
2
|
+
|
3
|
+
<%= simple_form_for(resource, as: resource_name, url: confirmation_path(resource_name), html: { method: :post }) do |f| %>
|
4
|
+
<%= devise_error_messages! %>
|
5
|
+
|
6
|
+
<div class="form-inputs">
|
7
|
+
<%= f.input :email %>
|
8
|
+
</div>
|
9
|
+
<div class="form-actions">
|
10
|
+
<%= f.submit t('.resend_confirmation_instructions'), class: 'btn btn-success' %>
|
11
|
+
</div>
|
12
|
+
<% end %>
|
13
|
+
|
14
|
+
<%= render 'devise/shared/links' %>
|
@@ -0,0 +1,5 @@
|
|
1
|
+
<p><%= t('.greeting', recipient: @resource.email) %></p>
|
2
|
+
<p><%= t('.instruction') %></p>
|
3
|
+
<p><%= link_to t('.action'), edit_password_url(@resource, reset_password_token: @resource.reset_password_token), class: 'btn' %></p>
|
4
|
+
<p><%= t('.instruction_2') %></p>
|
5
|
+
<p><%= t('.instruction_3') %></p>
|
@@ -0,0 +1,4 @@
|
|
1
|
+
<p><%= t('.greeting', recipient: @resource.email, default: "Hello #{@resource.email}!") %></p>
|
2
|
+
<p><%= t('.message') %></p>
|
3
|
+
<p><%= t('.instruction') %></p>
|
4
|
+
<p><%= link_to t('.action'), unlock_url(@resource, unlock_token: @resource.unlock_token), class: 'btn btn-success' %></p>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<h2><%= t('.change_your_password') %></h2>
|
2
|
+
|
3
|
+
<%= simple_form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :put }) do |f| %>
|
4
|
+
<%= devise_error_messages! %>
|
5
|
+
<%= f.hidden_field :reset_password_token %>
|
6
|
+
|
7
|
+
<div class="form-inputs">
|
8
|
+
<%= f.input :password, required: true, autofocus: true %>
|
9
|
+
<%= f.input :password_confirmation, t('.confirm_new_password'), :required => true %>
|
10
|
+
</div>
|
11
|
+
<div class="form-actions">
|
12
|
+
<%= f.submit t('.change_my_password'), class: 'btn btn-success' %>
|
13
|
+
</div>
|
14
|
+
<% end %>
|
15
|
+
|
16
|
+
<%= render 'devise/shared/links' %>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<h2><%= t('.forgot_your_password') %></h2>
|
2
|
+
|
3
|
+
<%= simple_form_for(resource, as: resource_name, url: password_path(resource_name), html: { method: :post }) do |f| %>
|
4
|
+
<%= devise_error_messages! %>
|
5
|
+
|
6
|
+
<div class="form-inputs">
|
7
|
+
<%= f.input :email %>
|
8
|
+
</div>
|
9
|
+
<div class="form-actions">
|
10
|
+
<%= f.submit t('.send_me_reset_password_instructions'), class: 'btn btn-success' %>
|
11
|
+
</div>
|
12
|
+
<% end %>
|
13
|
+
|
14
|
+
<%= render 'devise/shared/links' %>
|
@@ -0,0 +1,20 @@
|
|
1
|
+
<h2><%= t('.title', :resource : resource_class.model_name.human) %></h2>
|
2
|
+
|
3
|
+
<%= simple_form_for(resource, as: resource_name, url: registration_path(resource_name), html: { method: :put }) do |f| %>
|
4
|
+
<%= devise_error_messages! %>
|
5
|
+
|
6
|
+
<div class="form-inputs">
|
7
|
+
<%= f.input :email, required: true, autofocus: true %>
|
8
|
+
<%= f.input :password, autocomplete: "off", hint: t('.leave_blank_if_you_don_t_want_to_change_it'), required: false %>
|
9
|
+
<%= f.input :password_confirmation, :required => false %>
|
10
|
+
<%= f.input :current_password, hint: t('.we_need_your_current_password_to_confirm_your_changes'), required: true %>
|
11
|
+
</div>
|
12
|
+
<div class="form-actions">
|
13
|
+
<%= f.submit t('.update'), class: 'btn btn-success' %>
|
14
|
+
</div>
|
15
|
+
<% end %>
|
16
|
+
|
17
|
+
<h3><%= t('.cancel_my_account') %></h3>
|
18
|
+
<p><%= t('.unhappy') %>? <%= link_to t('.cancel_my_account'), registration_path(resource_name), data: { confirm: t('.are_you_sure') }, method: :delete, class: 'btn btn-danger' %>.</p>
|
19
|
+
|
20
|
+
<%= link_to t('.back'), :back, class: 'btn' %>
|
@@ -0,0 +1,16 @@
|
|
1
|
+
<h2><%= t('.sign_up') %></h2>
|
2
|
+
|
3
|
+
<%= simple_form_for(resource, as: resource_name, url: registration_path(resource_name)) do |f| %>
|
4
|
+
<%= devise_error_messages! %>
|
5
|
+
|
6
|
+
<div class="form-inputs">
|
7
|
+
<%= f.input :email, required: true, autofocus: true %>
|
8
|
+
<%= f.input :password, required: true %>
|
9
|
+
<%= f.input :password_confirmation %>
|
10
|
+
</div>
|
11
|
+
<div class="form-actions">
|
12
|
+
<%= f.submit t('.sign_up'), class: 'btn btn-success' %>
|
13
|
+
</div>
|
14
|
+
<% end %>
|
15
|
+
|
16
|
+
<%= render 'devise/shared/links' %>
|
@@ -0,0 +1,14 @@
|
|
1
|
+
<h2><%= t('.sign_in') %></h2>
|
2
|
+
|
3
|
+
<%= simple_form_for(resource, as: resource_name, url: session_path(resource_name)) do |f| %>
|
4
|
+
<div class="form-inputs">
|
5
|
+
<%= f.input :email %>
|
6
|
+
<%= f.input :password %>
|
7
|
+
<%= f.input :remember_me, as: :boolean if devise_mapping.rememberable? %>
|
8
|
+
</div>
|
9
|
+
<div class="form-actions">
|
10
|
+
<%= f.submit t('.sign_in'), class: 'btn btn-success' %>
|
11
|
+
</div>
|
12
|
+
<% end -%>
|
13
|
+
|
14
|
+
<%= render 'devise/shared/links' %>
|
@@ -0,0 +1,25 @@
|
|
1
|
+
<% if controller_name != 'sessions' %>
|
2
|
+
<%= link_to t(".sign_in"), new_session_path(resource_name), class: 'btn btn-success' %><br />
|
3
|
+
<% end %>
|
4
|
+
|
5
|
+
<% if devise_mapping.registerable? && controller_name != 'registrations' %>
|
6
|
+
<%= link_to t(".sign_up"), new_registration_path(resource_name), class: 'btn btn-success' %><br />
|
7
|
+
<% end %>
|
8
|
+
|
9
|
+
<% if devise_mapping.recoverable? && controller_name != 'passwords' %>
|
10
|
+
<%= link_to t(".forgot_your_password"), new_password_path(resource_name), class: 'btn btn-warning' %><br />
|
11
|
+
<% end %>
|
12
|
+
|
13
|
+
<% if devise_mapping.confirmable? && controller_name != 'confirmations' %>
|
14
|
+
<%= link_to t('.didn_t_receive_confirmation_instructions'), new_confirmation_path(resource_name), class: 'btn btn-info' %><br />
|
15
|
+
<% end %>
|
16
|
+
|
17
|
+
<% if devise_mapping.lockable? && resource_class.unlock_strategy_enabled?(:email) && controller_name != 'unlocks' %>
|
18
|
+
<%= link_to t('.didn_t_receive_unlock_instructions'), new_unlock_path(resource_name), class: 'btn btn-info' %><br />
|
19
|
+
<% end %>
|
20
|
+
|
21
|
+
<% if devise_mapping.omniauthable? %>
|
22
|
+
<% resource_class.omniauth_providers.each do |provider| %>
|
23
|
+
<%= link_to t('.sign_in_with_provider', provider: provider.to_s.titleize), omniauth_authorize_path(resource_name, provider), class: 'btn btn-success' %><br />
|
24
|
+
<% end %>
|
25
|
+
<% end %>
|