chili_pepper 0.0.2
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.rdoc +3 -0
- data/Rakefile +27 -0
- data/app/assets/javascripts/chili_pepper/dishes.js.coffee +9 -0
- data/app/assets/javascripts/chili_pepper/items.js.coffee +10 -0
- data/app/assets/javascripts/chili_pepper/layout.js.coffee +10 -0
- data/app/assets/javascripts/chili_pepper/menus.js.coffee +0 -0
- data/app/assets/javascripts/chili_pepper/sections.js.coffee +12 -0
- data/app/assets/javascripts/chili_pepper.js +15 -0
- data/app/assets/stylesheets/chili_pepper/application.css +13 -0
- data/app/assets/stylesheets/chili_pepper/dishes.css +4 -0
- data/app/assets/stylesheets/chili_pepper/items.css +4 -0
- data/app/assets/stylesheets/chili_pepper/menus.css +4 -0
- data/app/assets/stylesheets/chili_pepper/sections.css +4 -0
- data/app/controllers/chili_pepper/application_controller.rb +4 -0
- data/app/controllers/chili_pepper/dishes_controller.rb +82 -0
- data/app/controllers/chili_pepper/items_controller.rb +34 -0
- data/app/controllers/chili_pepper/menus_controller.rb +95 -0
- data/app/controllers/chili_pepper/sections_controller.rb +80 -0
- data/app/decorators/chili_pepper/item_decorator.rb +54 -0
- data/app/decorators/chili_pepper/menu_decorator.rb +97 -0
- data/app/decorators/chili_pepper/section_decorator.rb +19 -0
- data/app/helpers/chili_pepper/application_helper.rb +23 -0
- data/app/helpers/chili_pepper/dishes_helper.rb +4 -0
- data/app/helpers/chili_pepper/items_helper.rb +4 -0
- data/app/helpers/chili_pepper/menus_helper.rb +4 -0
- data/app/helpers/chili_pepper/sections_helper.rb +4 -0
- data/app/models/chili_pepper/admin.rb +26 -0
- data/app/models/chili_pepper/dish.rb +28 -0
- data/app/models/chili_pepper/item.rb +32 -0
- data/app/models/chili_pepper/menu.rb +70 -0
- data/app/models/chili_pepper/section.rb +29 -0
- data/app/views/chili_pepper/dishes/_form.html.haml +26 -0
- data/app/views/chili_pepper/dishes/edit.html.haml +9 -0
- data/app/views/chili_pepper/dishes/new.html.haml +9 -0
- data/app/views/chili_pepper/items/_item.html.haml +18 -0
- data/app/views/chili_pepper/menus/_form.html.haml +29 -0
- data/app/views/chili_pepper/menus/_navigation.html.haml +12 -0
- data/app/views/chili_pepper/menus/edit.html.haml +7 -0
- data/app/views/chili_pepper/menus/new.html.haml +7 -0
- data/app/views/chili_pepper/menus/show.html.haml +13 -0
- data/app/views/chili_pepper/sections/_column.html.haml +8 -0
- data/app/views/chili_pepper/sections/_form.html.haml +10 -0
- data/app/views/chili_pepper/sections/_section_nav_item.html.haml +6 -0
- data/app/views/chili_pepper/sections/edit.html.haml +8 -0
- data/app/views/chili_pepper/sections/new.html.haml +8 -0
- data/app/views/chili_pepper/sections/show.html.haml +25 -0
- data/app/views/devise/confirmations/new.html.haml +9 -0
- data/app/views/devise/mailer/confirmation_instructions.html.haml +4 -0
- data/app/views/devise/mailer/reset_password_instructions.html.haml +6 -0
- data/app/views/devise/mailer/unlock_instructions.html.haml +5 -0
- data/app/views/devise/passwords/edit.html.haml +14 -0
- data/app/views/devise/passwords/new.html.haml +9 -0
- data/app/views/devise/registrations/edit.html.haml +30 -0
- data/app/views/devise/registrations/new.html.haml +17 -0
- data/app/views/devise/sessions/new.html.haml +16 -0
- data/app/views/devise/shared/_links.haml +19 -0
- data/app/views/devise/unlocks/new.html.haml +9 -0
- data/app/views/layouts/chili_pepper/menu.html.haml +42 -0
- data/config/initializers/devise.rb +259 -0
- data/config/initializers/friendly_id.rb +88 -0
- data/config/initializers/simple_form.rb +145 -0
- data/config/locales/devise.en.yml +59 -0
- data/config/locales/simple_form.en.yml +26 -0
- data/config/routes.rb +21 -0
- data/db/migrate/20140428211712_create_chili_pepper_menus.rb +11 -0
- data/db/migrate/20140508093442_add_attributes_to_menus.rb +9 -0
- data/db/migrate/20140508094807_create_friendly_id_slugs.rb +15 -0
- data/db/migrate/20140514134818_create_chili_pepper_sections.rb +12 -0
- data/db/migrate/20140514141708_add_slug_to_chili_pepper_sections.rb +6 -0
- data/db/migrate/20140514143903_create_chili_pepper_dishes.rb +11 -0
- data/db/migrate/20140514144108_create_chili_pepper_items.rb +13 -0
- data/db/migrate/20140514144550_add_vegetarian_option_to_chili_pepper_dishes.rb +5 -0
- data/db/migrate/20140514153016_add_published_status_to_menus.rb +5 -0
- data/db/migrate/20140612152411_devise_create_chili_pepper_admins.rb +42 -0
- data/db/migrate/20140616162854_add_pictures_to_dishes.rb +5 -0
- data/db/migrate/20140616163025_add_attachements_to_menus.rb +6 -0
- data/db/migrate/20140616163238_add_attachments_to_sections.rb +5 -0
- data/lib/chili_pepper/configuration.rb +9 -0
- data/lib/chili_pepper/engine.rb +45 -0
- data/lib/chili_pepper/version.rb +3 -0
- data/lib/chili_pepper.rb +17 -0
- data/lib/tasks/auto_annotate_models.rake +34 -0
- data/lib/tasks/chili_pepper_tasks.rake +4 -0
- data/lib/templates/haml/scaffold/_form.html.haml +10 -0
- metadata +464 -0
checksums.yaml
ADDED
@@ -0,0 +1,7 @@
|
|
1
|
+
---
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: f0549b3418e8a065e5638d7fa82a122496418aa0
|
4
|
+
data.tar.gz: e57bb127cbe1436ca6766b93fde4391bd050bf4e
|
5
|
+
SHA512:
|
6
|
+
metadata.gz: dd6ca94fe0bbe93c5f4b424c9756cbb3eb824a1cfceba57d9db3ef094e1b89973bbdc5cf02607362a93db60257f3515406ef96e0544f7e3f9ffeb4473625e15f
|
7
|
+
data.tar.gz: 22865f5bf949c91955237fc9a90a116110142e19bc4eb9cf52ec5c38bcd26eef70c32fa0b02d720b9149d205314608c192cefa6649c3f7d16ce1cbfbba4a366c
|
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2014 YOURNAME
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
data/Rakefile
ADDED
@@ -0,0 +1,27 @@
|
|
1
|
+
begin
|
2
|
+
require 'bundler/setup'
|
3
|
+
rescue LoadError
|
4
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
5
|
+
end
|
6
|
+
|
7
|
+
Bundler::GemHelper.install_tasks
|
8
|
+
|
9
|
+
require 'rdoc/task'
|
10
|
+
require 'rspec/core/rake_task'
|
11
|
+
task :default => :spec
|
12
|
+
RSpec::Core::RakeTask.new
|
13
|
+
|
14
|
+
RDoc::Task.new(:rdoc) do |rdoc|
|
15
|
+
rdoc.rdoc_dir = 'rdoc'
|
16
|
+
rdoc.title = 'ChiliPepper'
|
17
|
+
rdoc.options << '--line-numbers'
|
18
|
+
rdoc.rdoc_files.include('README.rdoc')
|
19
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
20
|
+
end
|
21
|
+
|
22
|
+
APP_RAKEFILE = File.expand_path("../spec/test_app/Rakefile", __FILE__)
|
23
|
+
load 'rails/tasks/engine.rake'
|
24
|
+
|
25
|
+
|
26
|
+
|
27
|
+
|
@@ -0,0 +1,9 @@
|
|
1
|
+
@DishForm =
|
2
|
+
act_on_select: ->
|
3
|
+
$('#dish_name').bind('railsAutocomplete.select', (event, data) ->
|
4
|
+
section = $('#section_id').val()
|
5
|
+
column = $('.dish_items_column input').val()
|
6
|
+
link = $('#dish_attributes_list').data('engine-root') + '/' + data.item.id + "/edit?section_id=" + section + "&column=" + column;
|
7
|
+
window.location.href = link
|
8
|
+
)
|
9
|
+
|
@@ -0,0 +1,10 @@
|
|
1
|
+
# Javascript sorting functino for dish items
|
2
|
+
|
3
|
+
@ItemsAdminControls =
|
4
|
+
init_sort: ->
|
5
|
+
$('#menu_dishes ul.column').sortable(
|
6
|
+
items: "> li.item"
|
7
|
+
connectWith: '#menu_dishes ul.column'
|
8
|
+
update: ->
|
9
|
+
$.post($(this).data('update-url'), {item: $(this).sortable('toArray'), column_number: $(this).data('column-number')})
|
10
|
+
)
|
File without changes
|
@@ -0,0 +1,15 @@
|
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
6
|
+
//
|
7
|
+
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
8
|
+
// compiled file.
|
9
|
+
//
|
10
|
+
// Read Sprockets README (https://github.com/sstephenson/sprockets#sprockets-directives) for details
|
11
|
+
// about supported directives.
|
12
|
+
//
|
13
|
+
|
14
|
+
//= require autocomplete-rails
|
15
|
+
//= require_tree ./chili_pepper
|
@@ -0,0 +1,13 @@
|
|
1
|
+
/*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the top of the
|
9
|
+
* compiled file, but it's generally better to create a new file per style scope.
|
10
|
+
*
|
11
|
+
*= require_self
|
12
|
+
*= require_tree .
|
13
|
+
*/
|
@@ -0,0 +1,82 @@
|
|
1
|
+
require_dependency 'chili_pepper/application_controller'
|
2
|
+
|
3
|
+
module ChiliPepper
|
4
|
+
class DishesController < ApplicationController
|
5
|
+
before_action :authenticate_admin!
|
6
|
+
before_action :section, :menu, except: [:autocomplete_dish_name]
|
7
|
+
before_action :find_dish, except: [:new, :create, :autocomplete_dish_name]
|
8
|
+
before_action :find_item, except: [:new, :create, :autocomplete_dish_name]
|
9
|
+
autocomplete :dish, :name, class_name: 'chili_pepper/dish' #, display_value: :name_for_autocomplete
|
10
|
+
|
11
|
+
def new
|
12
|
+
@dish = Dish.new
|
13
|
+
@item = build_item
|
14
|
+
end
|
15
|
+
|
16
|
+
def create
|
17
|
+
@dish = Dish.new(dish_params)
|
18
|
+
if @dish.save!
|
19
|
+
redirect_to_menu_section
|
20
|
+
else
|
21
|
+
render action: :new
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
def edit
|
26
|
+
end
|
27
|
+
|
28
|
+
def update
|
29
|
+
if @dish.update(dish_params)
|
30
|
+
redirect_to_menu_section
|
31
|
+
else
|
32
|
+
render action: :edit
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
def destroy
|
37
|
+
@dish.destroy
|
38
|
+
redirect_to_menu_section
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def redirect_to_menu_section
|
44
|
+
redirect_to menu_section_path(@menu, @section)
|
45
|
+
end
|
46
|
+
|
47
|
+
def find_dish
|
48
|
+
@dish = Dish.find(params[:id])
|
49
|
+
end
|
50
|
+
|
51
|
+
def find_item
|
52
|
+
@item = if params[:item_id].present?
|
53
|
+
Item.find(params[:item_id])
|
54
|
+
else
|
55
|
+
build_item
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
def section
|
60
|
+
@section = Section.find(params[:section_id])
|
61
|
+
end
|
62
|
+
|
63
|
+
def menu
|
64
|
+
@menu = @section.menu
|
65
|
+
end
|
66
|
+
|
67
|
+
def build_item
|
68
|
+
@dish.items.build(section_id: @section.id, column: params[:column])
|
69
|
+
end
|
70
|
+
|
71
|
+
def dish_params
|
72
|
+
params.require(:dish).permit(
|
73
|
+
:name,
|
74
|
+
:description,
|
75
|
+
:picture,
|
76
|
+
:coeliac,
|
77
|
+
:vegetarian,
|
78
|
+
items_attributes: [:section_id, :price, :column, :dish_id, :id]
|
79
|
+
)
|
80
|
+
end
|
81
|
+
end
|
82
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
require_dependency "chili_pepper/application_controller"
|
2
|
+
|
3
|
+
module ChiliPepper
|
4
|
+
class ItemsController < ApplicationController
|
5
|
+
def sort
|
6
|
+
if params[:item].present?
|
7
|
+
params[:item].compact.each_with_index do |item, index|
|
8
|
+
item = Item.find(item_id(item))
|
9
|
+
item.update_attributes(position: index + 1, column: (params[:column_number].to_i - 1))
|
10
|
+
end
|
11
|
+
Item.find(item_id(params[:item].first)).section.touch
|
12
|
+
end
|
13
|
+
render nothing: true
|
14
|
+
|
15
|
+
|
16
|
+
end
|
17
|
+
|
18
|
+
def destroy
|
19
|
+
@item = Item.find(params[:id])
|
20
|
+
@section = @item.section
|
21
|
+
@item.destroy
|
22
|
+
redirect_to menu_section_path(@section.menu, @section)
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
private
|
27
|
+
|
28
|
+
def item_id(array_item)
|
29
|
+
array_item.sub(/item_/, '').to_i
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
|
34
|
+
end
|
@@ -0,0 +1,95 @@
|
|
1
|
+
require_dependency 'chili_pepper/application_controller'
|
2
|
+
|
3
|
+
module ChiliPepper
|
4
|
+
class MenusController < ApplicationController
|
5
|
+
before_action :authenticate_admin!, except: [:show, :index]
|
6
|
+
before_action :menu, except: [:index, :new, :create]
|
7
|
+
|
8
|
+
def index
|
9
|
+
menu_type = params[:menu_type] || :food
|
10
|
+
if admin_signed_in?
|
11
|
+
@menu = Menu
|
12
|
+
.where(menu_type: Menu::menu_types[menu_type])
|
13
|
+
.first
|
14
|
+
redirect_to @menu.present? ? @menu : new_menu_path
|
15
|
+
else
|
16
|
+
@menu = Menu.published
|
17
|
+
.where(menu_type: Menu::menu_types[menu_type])
|
18
|
+
.first
|
19
|
+
redirect_to @menu.present? ? @menu : main_app.root_path
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def show
|
24
|
+
@similar_menus = pick_similar_menus
|
25
|
+
|
26
|
+
if @menu.sections.any?
|
27
|
+
redirect_to menu_section_path(@menu, @menu.sections.first)
|
28
|
+
else
|
29
|
+
@section = ''
|
30
|
+
render layout: 'chili_pepper/menu'
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def new
|
35
|
+
menu_type = params[:menu_type] ||= 'food'
|
36
|
+
@menu = Menu.new(menu_type: menu_type)
|
37
|
+
end
|
38
|
+
|
39
|
+
def create
|
40
|
+
@menu = Menu.new(menu_params)
|
41
|
+
if @menu.save
|
42
|
+
redirect_to action: 'show', id: @menu
|
43
|
+
# set_annotations_positions(@menu)
|
44
|
+
# clear_menu_caches
|
45
|
+
else
|
46
|
+
render action: :new
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
def edit
|
51
|
+
end
|
52
|
+
|
53
|
+
def update
|
54
|
+
if @menu.update(menu_params)
|
55
|
+
redirect_to action: 'show', id: @menu
|
56
|
+
# set_annotations_positions(@menu)
|
57
|
+
# clear_menu_caches
|
58
|
+
else
|
59
|
+
render action: :edit
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def destroy
|
64
|
+
@menu.destroy
|
65
|
+
redirect_to action: :index
|
66
|
+
end
|
67
|
+
|
68
|
+
private
|
69
|
+
|
70
|
+
def menu
|
71
|
+
@menu = Menu.friendly.find(params[:id]).decorate
|
72
|
+
end
|
73
|
+
|
74
|
+
def pick_similar_menus
|
75
|
+
if admin_signed_in?
|
76
|
+
Menu.same_type_menus(@menu.menu_type)
|
77
|
+
else
|
78
|
+
Menu.same_type_menus(@menu.menu_type)
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
def menu_params
|
83
|
+
params.require(:menu) .permit(
|
84
|
+
:name,
|
85
|
+
:description,
|
86
|
+
:menu_type,
|
87
|
+
:availability,
|
88
|
+
:price,
|
89
|
+
:published,
|
90
|
+
:downloadable_pdf,
|
91
|
+
:image
|
92
|
+
)
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
@@ -0,0 +1,80 @@
|
|
1
|
+
require_dependency 'chili_pepper/application_controller'
|
2
|
+
|
3
|
+
module ChiliPepper
|
4
|
+
class SectionsController < ApplicationController
|
5
|
+
before_action :authenticate_admin!, except: :show
|
6
|
+
before_action :menu
|
7
|
+
before_action :section, except: [:new, :create, :show, :sort]
|
8
|
+
|
9
|
+
def show
|
10
|
+
@similar_menus = pick_similar_menus
|
11
|
+
@all_menu_sections = @menu.sections
|
12
|
+
.order('position')
|
13
|
+
.select('id, name, position, slug')
|
14
|
+
.decorate
|
15
|
+
@section = Section.includes(:items).friendly.find(params[:id]).decorate
|
16
|
+
@columns_number = ChiliPepper.columns_number
|
17
|
+
@item_groups = @section.items.sort_by(&:position).group_by(&:column)
|
18
|
+
render layout: 'chili_pepper/menu'
|
19
|
+
end
|
20
|
+
|
21
|
+
def new
|
22
|
+
@section = @menu.sections.build
|
23
|
+
end
|
24
|
+
|
25
|
+
def create
|
26
|
+
@section = Section.new(section_params)
|
27
|
+
if @section.save
|
28
|
+
redirect_to menu_section_path(@menu, @section)
|
29
|
+
else
|
30
|
+
render action: :new
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def edit
|
35
|
+
end
|
36
|
+
|
37
|
+
def update
|
38
|
+
if @section.update(section_params)
|
39
|
+
redirect_to menu_section_path(@menu, @section)
|
40
|
+
else
|
41
|
+
render action: :edit
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
def destroy
|
46
|
+
@section.destroy
|
47
|
+
redirect_to @menu
|
48
|
+
end
|
49
|
+
|
50
|
+
def sort
|
51
|
+
params[:section].each_with_index do |id, index|
|
52
|
+
Section.find(id).update_attributes(position: index + 1)
|
53
|
+
end
|
54
|
+
Section.find(params[:section].first).menu.touch
|
55
|
+
render nothing: true
|
56
|
+
end
|
57
|
+
|
58
|
+
private
|
59
|
+
|
60
|
+
def menu
|
61
|
+
@menu = Menu.friendly.find(params[:menu_id]).decorate
|
62
|
+
end
|
63
|
+
|
64
|
+
def pick_similar_menus
|
65
|
+
if admin_signed_in?
|
66
|
+
Menu.same_type_menus(@menu.menu_type)
|
67
|
+
else
|
68
|
+
Menu.same_type_menus(@menu.menu_type)
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def section
|
73
|
+
@section = Section.friendly.find(params[:id]).decorate
|
74
|
+
end
|
75
|
+
|
76
|
+
def section_params
|
77
|
+
params.require(:section).permit(:name, :description, :image, :menu_id)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
end
|
@@ -0,0 +1,54 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
module ChiliPepper
|
4
|
+
class ItemDecorator < Draper::Decorator
|
5
|
+
delegate_all
|
6
|
+
def show_dish_name
|
7
|
+
dish.name
|
8
|
+
end
|
9
|
+
|
10
|
+
# def photo_featured_class
|
11
|
+
# 'dish_photo_featured' if image_featured?
|
12
|
+
# end
|
13
|
+
|
14
|
+
# def show_item_photograph
|
15
|
+
# if image_featured?
|
16
|
+
# link_to image_tag(dish.dish_photo.url(:medium), alt: dish.name, height: 144, width: 310), item_path, remote: true, class: 'load_window', title: dish.name
|
17
|
+
|
18
|
+
# end
|
19
|
+
# end
|
20
|
+
|
21
|
+
def show_price
|
22
|
+
if price?
|
23
|
+
h.content_tag(:span, h.number_to_currency(price, unit: '€'), class: 'dish_price')
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def show_description
|
28
|
+
if dish.description?
|
29
|
+
h.content_tag(:p, h.markdown(dish.description), class: 'dish_description')
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
def show_extra_informations
|
34
|
+
extras = []
|
35
|
+
|
36
|
+
unless dish.not_coeliac_friendly? || dish.coeliac.blank?
|
37
|
+
extras << h.content_tag(:li, dish.coeliac.humanize, class: dish.coeliac)
|
38
|
+
end
|
39
|
+
|
40
|
+
if dish.vegetarian?
|
41
|
+
extras << h.content_tag(:li, 'Suitable for Vegetarian', class: 'vegetarian')
|
42
|
+
end
|
43
|
+
|
44
|
+
# if dish.dish_photo?
|
45
|
+
# photo = TRUE
|
46
|
+
# extras << h.content_tag(:li, link_to('Photo available', item_path, remote: true, class: 'load_window'), class: 'dish_photo_link')
|
47
|
+
# end
|
48
|
+
|
49
|
+
if dish.coeliac_friendly? || dish.coeliac_option_available? || dish.vegetarian? # || photo
|
50
|
+
h.content_tag(:ul, h.raw(extras.join("\n")), class: 'extra_informations')
|
51
|
+
end
|
52
|
+
end
|
53
|
+
end
|
54
|
+
end
|
@@ -0,0 +1,97 @@
|
|
1
|
+
# encoding: UTF-8
|
2
|
+
|
3
|
+
module ChiliPepper
|
4
|
+
class MenuDecorator < Draper::Decorator
|
5
|
+
delegate_all
|
6
|
+
|
7
|
+
def display_price
|
8
|
+
if price?
|
9
|
+
euro_sign = h.content_tag(:span, '€', class: euro_sign)
|
10
|
+
price_to_display = h.number_to_currency(price, unit: '')
|
11
|
+
price_content = h.content_tag(:div, euro_sign + price_to_display, id: 'big_price')
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def display_availability
|
16
|
+
if availability?
|
17
|
+
h.content_tag(:h2, availability, class: 'menu_availibilities')
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
def display_description
|
22
|
+
if description?
|
23
|
+
h.content_tag(:h3, h.markdown(description), class: 'menu_description')
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
# def header_img
|
28
|
+
# if menu_image?
|
29
|
+
# h.image_tag menu_image.url(), style: "margin-top: #{menu_img_margin_top(menu_image.url)}"
|
30
|
+
# end
|
31
|
+
# end
|
32
|
+
|
33
|
+
def pdf_link
|
34
|
+
if downloadable_pdf?
|
35
|
+
pdf_size = h.content_tag(:span, "(#{h.number_to_human_size(downloadable_pdf.size)})")
|
36
|
+
link = h.link_to(h.raw("Download PDF #{pdf_size}"), downloadable_pdf.url, onclick: "javascript: _gaq.push(['_trackPageview', '/downloads/#{slug}']);")
|
37
|
+
h.content_tag(:p, link, class: 'pdf_download')
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
def footnotes
|
42
|
+
return if menu_type == 'drinks'
|
43
|
+
|
44
|
+
footnotes_class = "menu_footnotes"
|
45
|
+
|
46
|
+
# if menu_annotations.present?
|
47
|
+
# footnotes_class += ' with_supplements'
|
48
|
+
# section_content = health_footnotes + supplementary_footnotes_columns
|
49
|
+
|
50
|
+
# else
|
51
|
+
# footnotes_class += ' no_supplements'
|
52
|
+
section_content = health_footnotes
|
53
|
+
# end
|
54
|
+
h.content_tag(:section, section_content, class: footnotes_class)
|
55
|
+
end
|
56
|
+
|
57
|
+
private
|
58
|
+
|
59
|
+
def health_footnotes
|
60
|
+
list_content = ''
|
61
|
+
health_footnotes = {'vegetarian' => 'Vegetarian', 'coeliac' => 'Coeliac friendly', 'coeliac_option' => 'Coeliac Option Available, please ask your waiter'}
|
62
|
+
health_footnotes.each do |key, value|
|
63
|
+
list_content << h.raw(h.content_tag(:li, h.content_tag(:span) + value, class: key))
|
64
|
+
end
|
65
|
+
h.raw(h.content_tag(:ul, h.raw(list_content), class: 'icons_legend'))
|
66
|
+
end
|
67
|
+
|
68
|
+
# def supplementary_footnotes_columns
|
69
|
+
# supplementary_footnotes_columns = ''
|
70
|
+
# slice_num = (menu_annotations.size.to_f/2).ceil
|
71
|
+
# menu_annotations.each_slice(slice_num).with_index do |list,i|
|
72
|
+
# list_content = ''
|
73
|
+
# list.each {|ma| list_content << list_item(ma)}
|
74
|
+
# supplementary_footnotes_columns << h.content_tag(:ul, h.raw(list_content), class: "supplements_list_#{i+1}")
|
75
|
+
# end
|
76
|
+
|
77
|
+
# h.raw(supplementary_footnotes_columns)
|
78
|
+
# end
|
79
|
+
|
80
|
+
# def list_item(ma)
|
81
|
+
# h.content_tag(:li, h.content_tag(:span, ('*' * ma.position ), class: 'dish_stars') + ma.description)
|
82
|
+
# end
|
83
|
+
|
84
|
+
# def menu_img_margin_top(img)
|
85
|
+
# require 'fastimage'
|
86
|
+
|
87
|
+
# # path = (Rails.root.to_s + '/public' + img).sub(/\?\d+$/, '')
|
88
|
+
# path = img
|
89
|
+
# dimensions = FastImage.size(path)
|
90
|
+
# if dimensions.present?
|
91
|
+
# height = dimensions[1]
|
92
|
+
# margin_top = ((126 - height) / 2).to_s + 'px'
|
93
|
+
# end
|
94
|
+
# end
|
95
|
+
|
96
|
+
end
|
97
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module ChiliPepper
|
2
|
+
class SectionDecorator < Draper::Decorator
|
3
|
+
delegate_all
|
4
|
+
decorates_association :items
|
5
|
+
|
6
|
+
def show_section_description
|
7
|
+
if description?
|
8
|
+
h.content_tag(:p, h.markdown(description), :class => 'menu_section_description')
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def admin_show_section_img
|
13
|
+
if section_image?
|
14
|
+
h.image_tag image.url(:thumb), :class => 'menu_img_thumb'
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
module ChiliPepper
|
2
|
+
module ApplicationHelper
|
3
|
+
def markdown(text)
|
4
|
+
renderer = Redcarpet::Render::HTML.new(hard_wrap: true, filter_html: true)
|
5
|
+
options = {
|
6
|
+
autolink: true,
|
7
|
+
no_intra_emphasis: true
|
8
|
+
}
|
9
|
+
rtxt = Redcarpet::Markdown.new(renderer, options).render(text)
|
10
|
+
return Regexp.new(/\A<p>(.*)<\/p>\Z/m).match(rtxt)[1].html_safe
|
11
|
+
end
|
12
|
+
|
13
|
+
def cache_or_admin(fragment_name, &block_to_be_executed)
|
14
|
+
if !admin_signed_in?
|
15
|
+
cache(fragment_name) do
|
16
|
+
block_to_be_executed.call
|
17
|
+
end
|
18
|
+
else
|
19
|
+
block_to_be_executed.call
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|