kuhsaft 1.2.4 → 1.2.5
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +8 -0
- data/app/assets/javascripts/kuhsaft/cms/application.js.coffee +8 -2
- data/app/assets/stylesheets/kuhsaft/cms/application.css.sass +14 -0
- data/app/controllers/kuhsaft/cms/bricks_controller.rb +9 -0
- data/app/helpers/pages_helper.rb +3 -3
- data/app/models/kuhsaft/brick.rb +10 -2
- data/app/views/kuhsaft/cms/bricks/_brick_item.html.haml +10 -3
- data/app/views/kuhsaft/cms/bricks/_sort_form.html.haml +3 -0
- data/app/views/kuhsaft/cms/bricks/create.js.haml +5 -0
- data/app/views/kuhsaft/cms/bricks/update.js.haml +1 -1
- data/app/views/kuhsaft/cms/pages/_form.html.haml +2 -0
- data/app/views/kuhsaft/cms/pages/index.html.haml +7 -2
- data/app/views/layouts/kuhsaft/cms/application.html.haml +2 -2
- data/config/routes.rb +4 -1
- data/db/migrate/8_add_display_styles_to_bricks.rb +5 -0
- data/lib/kuhsaft/brick_list.rb +4 -0
- data/lib/kuhsaft/version.rb +1 -1
- data/spec/dummy/config/application.rb +6 -0
- data/spec/models/brick_spec.rb +6 -0
- data/spec/models/image_brick_spec.rb +6 -0
- metadata +6 -4
data/README.md
CHANGED
@@ -152,6 +152,14 @@ The `name` option is a unique identifier, which is also used for translating the
|
|
152
152
|
|
153
153
|
activerecord.attributes.kuhsaft/image_size.sizes.#{name}
|
154
154
|
|
155
|
+
## Configuring custom styles for bricks
|
156
|
+
|
157
|
+
Implement the `available_display_styles` on a brick model and return an array of css classnames: `['module-big', 'module-small']`. These styles can be applied to a brick instance through the UI. In the frontend, use `to_style_class` to get the configured styles:
|
158
|
+
|
159
|
+
%my-brick{ :class => brick.to_style_class}
|
160
|
+
= brick.text # ... etc
|
161
|
+
|
162
|
+
|
155
163
|
## Adding custom templates with placeholder bricks
|
156
164
|
|
157
165
|
* Save your partial in `views/kuhsaft/placeholder_bricks/partials/_your_partial.html.haml`
|
@@ -30,9 +30,15 @@ sortableBrick = ->
|
|
30
30
|
handle: '.brick-item-header',
|
31
31
|
axis: "y",
|
32
32
|
update: (event, ui) ->
|
33
|
-
|
33
|
+
idList = $(this).find("> .brick-item")
|
34
|
+
.each (idx, elem) ->
|
34
35
|
$(this).find("input.position-field").val(idx+1)
|
35
|
-
|
36
|
+
.map ->
|
37
|
+
$(this).data('id')
|
38
|
+
|
39
|
+
sortForm = $('#bricks-sort-form form')
|
40
|
+
sortForm.find('input[name="bricks[ids]"]').val(idList.toArray().join(','))
|
41
|
+
sortForm.trigger('submit')
|
36
42
|
)
|
37
43
|
|
38
44
|
window.initSubmitLinks = (selector = null)->
|
@@ -120,6 +120,12 @@ form
|
|
120
120
|
a
|
121
121
|
color: #666
|
122
122
|
|
123
|
+
.pages-list
|
124
|
+
> .branch-group
|
125
|
+
> .branch
|
126
|
+
.branch-title
|
127
|
+
font-weight: bold
|
128
|
+
|
123
129
|
.branch-group
|
124
130
|
.branch-group
|
125
131
|
.branch-title
|
@@ -137,4 +143,12 @@ form
|
|
137
143
|
p
|
138
144
|
margin: 0
|
139
145
|
|
146
|
+
.dropdown-menu
|
147
|
+
> li
|
148
|
+
> .control-group
|
149
|
+
padding: 3px 20px
|
150
|
+
|
151
|
+
.control-label
|
152
|
+
font-weight: bold
|
153
|
+
|
140
154
|
@import bootstrap-responsive
|
@@ -30,6 +30,15 @@ module Kuhsaft
|
|
30
30
|
@brick.destroy
|
31
31
|
end
|
32
32
|
|
33
|
+
def sort
|
34
|
+
if params[:bricks].present?
|
35
|
+
params[:bricks][:ids].split(',').each_with_index do |id, idx|
|
36
|
+
Kuhsaft::Brick.find(id).update_attribute(:position, idx.to_i + 1)
|
37
|
+
end
|
38
|
+
end
|
39
|
+
render :nothing => true
|
40
|
+
end
|
41
|
+
|
33
42
|
end
|
34
43
|
end
|
35
44
|
end
|
data/app/helpers/pages_helper.rb
CHANGED
@@ -60,9 +60,9 @@ module PagesHelper
|
|
60
60
|
end
|
61
61
|
|
62
62
|
def read_more_link(id)
|
63
|
-
link_to(id, :'data-toggle' => 'collapse', :'data-target' => id, :class => 'button button-read-more') do
|
64
|
-
@content = content_tag(:p, t('.read_more'), :class => 'read-more-text')
|
65
|
-
@content << content_tag(:p, t('.read_less'), :class => 'read-less-text')
|
63
|
+
link_to(id, :'data-toggle' => 'collapse', :'data-target' => id, :class => 'collapsed button button-read-more') do
|
64
|
+
@content = content_tag(:p, t('kuhsaft.text_bricks.text_brick.read_more'), :class => 'read-more-text')
|
65
|
+
@content << content_tag(:p, t('kuhsaft.text_bricks.text_brick.read_less'), :class => 'read-less-text')
|
66
66
|
end
|
67
67
|
end
|
68
68
|
end
|
data/app/models/kuhsaft/brick.rb
CHANGED
@@ -7,11 +7,14 @@ module Kuhsaft
|
|
7
7
|
scope :localized, lambda { where(:locale => I18n.locale) }
|
8
8
|
default_scope order('position ASC').localized
|
9
9
|
|
10
|
+
serialize :display_styles, Array
|
11
|
+
|
10
12
|
attr_accessible :locale,
|
11
13
|
:position,
|
12
14
|
:type,
|
13
15
|
:brick_list_id,
|
14
|
-
:brick_list_type
|
16
|
+
:brick_list_type,
|
17
|
+
:display_styles
|
15
18
|
|
16
19
|
before_validation :set_locale
|
17
20
|
before_validation :set_position
|
@@ -81,7 +84,7 @@ module Kuhsaft
|
|
81
84
|
|
82
85
|
# Returns a css classname suitable for use in the frontend
|
83
86
|
def to_style_class
|
84
|
-
self.class.to_s.underscore.dasherize.gsub('/', '-')
|
87
|
+
([self.class.to_s.underscore.dasherize.gsub('/', '-')] + self.display_styles).join(' ')
|
85
88
|
end
|
86
89
|
|
87
90
|
# Returns a unique DOM id suitable for use in the frontend
|
@@ -89,6 +92,11 @@ module Kuhsaft
|
|
89
92
|
"#{self.class.to_s.underscore.dasherize.gsub('/', '-')}-#{id}"
|
90
93
|
end
|
91
94
|
|
95
|
+
# return a list of css classnames that can be applied to the brick
|
96
|
+
def available_display_styles
|
97
|
+
[]
|
98
|
+
end
|
99
|
+
|
92
100
|
def backend_label(options = {})
|
93
101
|
label = self.class.model_name.human
|
94
102
|
if options[:parenthesis] == true
|
@@ -1,5 +1,5 @@
|
|
1
|
-
.brick-item{ :id => brick.to_brick_item_id, :class => brick.to_style_class }
|
2
|
-
= simple_form_for brick, :as => :brick, :url => kuhsaft.cms_brick_path(brick), :remote =>
|
1
|
+
.brick-item{ :id => brick.to_brick_item_id, :class => brick.to_style_class, 'data-id' => brick.id }
|
2
|
+
= simple_form_for brick, :as => :brick, :url => kuhsaft.cms_brick_path(brick), :remote => !brick.uploader?, :html => { :id => nil } do |form|
|
3
3
|
= form.hidden_field :position, :class => 'position-field'
|
4
4
|
.brick-item-header.clearfix
|
5
5
|
.pull-left
|
@@ -15,6 +15,14 @@
|
|
15
15
|
= link_to kuhsaft.cms_brick_path(brick), :class => 'btn btn-small btn-danger', :confirm => t('kuhsaft.cms.bricks.brick_item.confirm'), :method => :delete, :remote => true do
|
16
16
|
%i.icon-trash.icon-white
|
17
17
|
|
18
|
+
- # possible styles
|
19
|
+
- unless brick.available_display_styles.empty?
|
20
|
+
%a.btn.btn-small.dropdown-toggle{ 'data-toggle' => 'dropdown', 'href' => '#' }
|
21
|
+
%i.icon-tint
|
22
|
+
%ul.dropdown-menu.pull-right
|
23
|
+
%li
|
24
|
+
= form.input :display_styles, :collection => brick.available_display_styles, :as => :check_boxes
|
25
|
+
|
18
26
|
- # addable child dropdown menu
|
19
27
|
- if brick.respond_to?(:brick_list)
|
20
28
|
= render 'brick_type_dropdown', :brick_list => brick
|
@@ -30,7 +38,6 @@
|
|
30
38
|
%a.submit{ :href => '#', :class => 'btn btn-success btn-small ', 'data-title' => '', 'data-content' => t('.saved') }
|
31
39
|
= t('.save')
|
32
40
|
|
33
|
-
|
34
41
|
- if brick.renders_own_childs?
|
35
42
|
.brick-item-childs
|
36
43
|
= render brick.to_edit_childs_partial_path, :brick => brick
|
@@ -1 +1,6 @@
|
|
1
1
|
$("##{@brick.brick_list.to_brick_list_id}.brick-list").append("#{j(render('kuhsaft/cms/bricks/brick_item', :brick => @brick))}").find("> .empty-state").remove()
|
2
|
+
|
3
|
+
- # need a reference to the new dom node, so a new query is needed here
|
4
|
+
var newlyInsertedBrick = $("##{@brick.to_brick_item_id}")
|
5
|
+
initSavePopover(newlyInsertedBrick)
|
6
|
+
initSubmitLinks(newlyInsertedBrick)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
$("##{@brick.to_brick_item_id}").replaceWith("#{j(render('kuhsaft/cms/bricks/brick_item', :brick => @brick))}")
|
2
2
|
|
3
|
-
|
3
|
+
- # need a reference to the new dom node, so a new query is needed here
|
4
4
|
var newlyInsertedBrick = $("##{@brick.to_brick_item_id}")
|
5
5
|
initSavePopover(newlyInsertedBrick)
|
6
6
|
initSubmitLinks(newlyInsertedBrick)
|
@@ -1,8 +1,13 @@
|
|
1
1
|
%h1= controller.request.host
|
2
2
|
.actions.row
|
3
|
-
.
|
3
|
+
.span5
|
4
4
|
.span3
|
5
5
|
= link_to kuhsaft.new_cms_page_path, :class => 'btn btn-primary' do
|
6
6
|
%i.icon-plus-sign.icon-white
|
7
7
|
= t('.add_page')
|
8
|
-
|
8
|
+
.span4
|
9
|
+
|
10
|
+
.row
|
11
|
+
.span8.pages-list
|
12
|
+
= render :partial => 'branch', :locals => { :pages => @pages }
|
13
|
+
.span4
|
data/config/routes.rb
CHANGED
@@ -1,7 +1,10 @@
|
|
1
1
|
Kuhsaft::Engine.routes.draw do
|
2
2
|
namespace :cms do
|
3
3
|
resources :pages, :except => :show
|
4
|
-
resources :bricks, :except => [:new, :edit, :index]
|
4
|
+
resources :bricks, :except => [:new, :edit, :index] do
|
5
|
+
post :sort, :on => :collection
|
6
|
+
end
|
7
|
+
|
5
8
|
resources :assets
|
6
9
|
root :to => 'pages#index'
|
7
10
|
end
|
data/lib/kuhsaft/brick_list.rb
CHANGED
data/lib/kuhsaft/version.rb
CHANGED
@@ -60,6 +60,12 @@ module Dummy
|
|
60
60
|
|
61
61
|
# Version of your assets, change this if you want to expire all your assets
|
62
62
|
config.assets.version = '1.0'
|
63
|
+
|
64
|
+
config.to_prepare do
|
65
|
+
Kuhsaft::Engine.configure do
|
66
|
+
config.image_sizes.build_defaults! # creates 960x540 and 320x180 sizes
|
67
|
+
end
|
68
|
+
end
|
63
69
|
end
|
64
70
|
end
|
65
71
|
|
data/spec/models/brick_spec.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: kuhsaft
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.2.
|
4
|
+
version: 1.2.5
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2013-
|
14
|
+
date: 2013-03-01 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rspec
|
@@ -367,6 +367,7 @@ files:
|
|
367
367
|
- app/views/kuhsaft/cms/assets/new.html.haml
|
368
368
|
- app/views/kuhsaft/cms/bricks/_brick_item.html.haml
|
369
369
|
- app/views/kuhsaft/cms/bricks/_brick_list.html.haml
|
370
|
+
- app/views/kuhsaft/cms/bricks/_sort_form.html.haml
|
370
371
|
- app/views/kuhsaft/cms/bricks/create.js.haml
|
371
372
|
- app/views/kuhsaft/cms/bricks/destroy.js.haml
|
372
373
|
- app/views/kuhsaft/cms/bricks/update.js.haml
|
@@ -427,6 +428,7 @@ files:
|
|
427
428
|
- db/migrate/06_add_template_name_to_kuhsaft_bricks.rb
|
428
429
|
- db/migrate/07_add_default_value_to_brick_type_enabled.rb
|
429
430
|
- db/migrate/20130206141601_remove_cms_admin.rb
|
431
|
+
- db/migrate/8_add_display_styles_to_bricks.rb
|
430
432
|
- db/seeds.rb
|
431
433
|
- lib/generators/kuhsaft/translations/add_generator.rb
|
432
434
|
- lib/kuhsaft/brick_list.rb
|
@@ -514,7 +516,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
514
516
|
version: '0'
|
515
517
|
segments:
|
516
518
|
- 0
|
517
|
-
hash:
|
519
|
+
hash: 2608277375441050996
|
518
520
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
519
521
|
none: false
|
520
522
|
requirements:
|
@@ -523,7 +525,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
523
525
|
version: '0'
|
524
526
|
segments:
|
525
527
|
- 0
|
526
|
-
hash:
|
528
|
+
hash: 2608277375441050996
|
527
529
|
requirements: []
|
528
530
|
rubyforge_project: kuhsaft
|
529
531
|
rubygems_version: 1.8.24
|