chili_pepper 0.0.2 → 0.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/assets/javascripts/chili_pepper/layout.js.coffee +2 -0
- data/app/assets/javascripts/chili_pepper/menus.js.coffee +20 -0
- data/app/controllers/chili_pepper/dishes_controller.rb +1 -1
- data/app/controllers/chili_pepper/menus_controller.rb +2 -1
- data/app/decorators/chili_pepper/item_decorator.rb +6 -0
- data/app/helpers/chili_pepper/application_helper.rb +24 -15
- data/app/models/chili_pepper/annotation.rb +7 -0
- data/app/models/chili_pepper/item.rb +1 -0
- data/app/models/chili_pepper/menu.rb +3 -0
- data/app/views/chili_pepper/dishes/_form.html.haml +1 -1
- data/app/views/chili_pepper/items/_item.html.haml +1 -1
- data/app/views/chili_pepper/menus/_annotation_fields.haml +5 -0
- data/app/views/chili_pepper/menus/_form.html.haml +8 -8
- data/db/migrate/20140810170249_create_chili_pepper_annotations.rb +11 -0
- data/db/migrate/20140810170608_add_annotation_id_to_items.rb +5 -0
- data/lib/chili_pepper/version.rb +1 -1
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a2cc9fbae80c7d653e65073069858aae7fc85a56
|
4
|
+
data.tar.gz: 1b135bb9920088588544dfa0814c031ce1b6f428
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4571c0de0c25107aa800b93373fd75486e83f2110b58fe1bd085a3b2df94798c280a4e974bab5f09cbacb378d51a256210075712b0327e06ed9f94690ac6ba59
|
7
|
+
data.tar.gz: c8849f2f6a703977c9bbcc48bb2c48b3dd2b4dc794c03fa9c6df0750a2f2f3097f01ff5924b939dbaa59ce63fd4b476e5c8c7e8d800885947ede37cbf99431f4
|
@@ -0,0 +1,20 @@
|
|
1
|
+
@MenuForm =
|
2
|
+
init: ->
|
3
|
+
$('.admin_form form').on 'click', '.remove_fields', (event) ->
|
4
|
+
$(this).prev('ul').find('li input[type=hidden]').val('1')
|
5
|
+
$(this).parent('li').hide()
|
6
|
+
event.preventDefault()
|
7
|
+
$('.admin_form form').on 'click', '.add_fields', (event) ->
|
8
|
+
time = new Date().getTime()
|
9
|
+
regexp = new RegExp($(this).data('id'), 'g')
|
10
|
+
$(this).parent('li').before($(this).data('fields').replace(regexp, time))
|
11
|
+
event.preventDefault()
|
12
|
+
|
13
|
+
# @MenusAdminControls =
|
14
|
+
# init_sort: ->
|
15
|
+
# $('#menu_nav ul').removeClass('regular').addClass('sortable').sortable(
|
16
|
+
# axis: 'x'
|
17
|
+
# update: ->
|
18
|
+
# $.post($(this).data('update-url'), $(this).sortable('serialize'))
|
19
|
+
# )
|
20
|
+
|
@@ -24,6 +24,12 @@ module ChiliPepper
|
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
27
|
+
def show_annotation
|
28
|
+
if annotation.present?
|
29
|
+
h.content_tag(:span, annotation.description, class: 'annotation')
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
27
33
|
def show_description
|
28
34
|
if dish.description?
|
29
35
|
h.content_tag(:p, h.markdown(dish.description), class: 'dish_description')
|
@@ -1,23 +1,32 @@
|
|
1
1
|
module ChiliPepper
|
2
2
|
module ApplicationHelper
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
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
12
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
block_to_be_executed.call
|
17
|
-
end
|
18
|
-
else
|
13
|
+
def cache_or_admin(fragment_name, &block_to_be_executed)
|
14
|
+
if !admin_signed_in?
|
15
|
+
cache(fragment_name) do
|
19
16
|
block_to_be_executed.call
|
20
17
|
end
|
18
|
+
else
|
19
|
+
block_to_be_executed.call
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
def link_to_add_fields(name, f, association)
|
24
|
+
new_object = f.object.send(association).klass.new
|
25
|
+
id = new_object.object_id
|
26
|
+
fields = f.fields_for(association, new_object, child_index: id) do |builder|
|
27
|
+
render(association.to_s.singularize + "_fields", f: builder)
|
21
28
|
end
|
29
|
+
link_to(name, '#', class: "add_fields", data: {id: id, fields: fields.gsub("\n", "")})
|
30
|
+
end
|
22
31
|
end
|
23
32
|
end
|
@@ -16,6 +16,7 @@ module ChiliPepper
|
|
16
16
|
class Item < ActiveRecord::Base
|
17
17
|
belongs_to :dish, class_name: 'ChiliPepper::Dish'
|
18
18
|
belongs_to :section, class_name: 'ChiliPepper::Section'
|
19
|
+
belongs_to :annotation, class_name: 'ChiliPepper::Annotation'
|
19
20
|
validates :section, presence: true
|
20
21
|
acts_as_list scope: :section
|
21
22
|
after_destroy :check_dish_relevance
|
@@ -32,6 +32,9 @@ module ChiliPepper
|
|
32
32
|
extend FriendlyId
|
33
33
|
friendly_id :name, use: :slugged
|
34
34
|
|
35
|
+
has_many :annotations, dependent: :destroy
|
36
|
+
accepts_nested_attributes_for :annotations, allow_destroy: true
|
37
|
+
|
35
38
|
has_attached_file :image,
|
36
39
|
styles: {
|
37
40
|
medium: ChiliPepper.menu_medium_image,
|
@@ -19,7 +19,7 @@
|
|
19
19
|
%fieldset
|
20
20
|
= item_form.input :section_id, :as => :hidden, :input_html => { :value => @item.section_id}
|
21
21
|
= item_form.input :column, :as => :hidden, :input_html => { :value => @item.column}
|
22
|
-
|
22
|
+
= item_form.association :annotation, :collection => @menu.annotations, :value_method => lambda {|x| x.id}, :label_method => lambda {|x| x.description}
|
23
23
|
= hidden_field_tag 'section_id', @section.id
|
24
24
|
- if @item.present?
|
25
25
|
= hidden_field_tag 'item_id', @item.id
|
@@ -13,14 +13,14 @@
|
|
13
13
|
= f.input :image
|
14
14
|
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
16
|
+
%fieldset.menu_notes
|
17
|
+
%p.form_tag
|
18
|
+
Menu Notes
|
19
|
+
%ul
|
20
|
+
= f.simple_fields_for :annotations do |note_builder|
|
21
|
+
= render 'annotation_fields', f: note_builder
|
22
|
+
%li.add_annotation
|
23
|
+
= link_to_add_fields "Add note", f, :annotations
|
24
24
|
|
25
25
|
|
26
26
|
|
data/lib/chili_pepper/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: chili_pepper
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Loic Seigland
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-08-
|
11
|
+
date: 2014-08-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -381,6 +381,7 @@ files:
|
|
381
381
|
- app/helpers/chili_pepper/menus_helper.rb
|
382
382
|
- app/helpers/chili_pepper/sections_helper.rb
|
383
383
|
- app/models/chili_pepper/admin.rb
|
384
|
+
- app/models/chili_pepper/annotation.rb
|
384
385
|
- app/models/chili_pepper/dish.rb
|
385
386
|
- app/models/chili_pepper/item.rb
|
386
387
|
- app/models/chili_pepper/menu.rb
|
@@ -389,6 +390,7 @@ files:
|
|
389
390
|
- app/views/chili_pepper/dishes/edit.html.haml
|
390
391
|
- app/views/chili_pepper/dishes/new.html.haml
|
391
392
|
- app/views/chili_pepper/items/_item.html.haml
|
393
|
+
- app/views/chili_pepper/menus/_annotation_fields.haml
|
392
394
|
- app/views/chili_pepper/menus/_form.html.haml
|
393
395
|
- app/views/chili_pepper/menus/_navigation.html.haml
|
394
396
|
- app/views/chili_pepper/menus/edit.html.haml
|
@@ -431,6 +433,8 @@ files:
|
|
431
433
|
- db/migrate/20140616162854_add_pictures_to_dishes.rb
|
432
434
|
- db/migrate/20140616163025_add_attachements_to_menus.rb
|
433
435
|
- db/migrate/20140616163238_add_attachments_to_sections.rb
|
436
|
+
- db/migrate/20140810170249_create_chili_pepper_annotations.rb
|
437
|
+
- db/migrate/20140810170608_add_annotation_id_to_items.rb
|
434
438
|
- lib/chili_pepper.rb
|
435
439
|
- lib/chili_pepper/configuration.rb
|
436
440
|
- lib/chili_pepper/engine.rb
|