kuhsaft 1.1.1 → 1.2.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +28 -12
- data/app/assets/javascripts/kuhsaft/cms/application.js.coffee +48 -0
- data/app/assets/stylesheets/kuhsaft/cms/application.css.sass +14 -0
- data/app/controllers/kuhsaft/cms/pages_controller.rb +6 -8
- data/app/helpers/kuhsaft/cms/pages_helper.rb +6 -2
- data/app/models/kuhsaft/accordion_brick.rb +4 -0
- data/app/models/kuhsaft/brick.rb +10 -0
- data/app/models/kuhsaft/brick_type.rb +2 -1
- data/app/models/kuhsaft/brick_type_filter.rb +20 -0
- data/app/models/kuhsaft/image_brick.rb +4 -0
- data/app/models/kuhsaft/link_brick.rb +4 -0
- data/app/models/kuhsaft/page.rb +12 -0
- data/app/models/kuhsaft/placeholder_brick.rb +4 -0
- data/app/models/kuhsaft/slider_brick.rb +4 -0
- data/app/models/kuhsaft/text_brick.rb +4 -0
- data/app/models/kuhsaft/video_brick.rb +4 -0
- data/app/views/kuhsaft/cms/admin/_brick_type_dropdown.html.haml +14 -10
- data/app/views/kuhsaft/cms/admin/_flash.html.haml +4 -0
- data/app/views/kuhsaft/cms/admin/_main_navigation.html.haml +1 -1
- data/app/views/kuhsaft/cms/bricks/_brick_item.html.haml +1 -0
- data/app/views/kuhsaft/cms/pages/_branch.html.haml +1 -1
- data/app/views/kuhsaft/cms/pages/_form.html.haml +1 -1
- data/app/views/kuhsaft/cms/pages/edit.html.haml +0 -1
- data/app/views/layouts/kuhsaft/cms/application.html.haml +2 -0
- data/config/locales/views/kuhsaft/cms/admin/de.yml +1 -0
- data/config/locales/views/layouts/de.yml +3 -1
- data/lib/kuhsaft.rb +3 -3
- data/lib/kuhsaft/brick_list.rb +15 -0
- data/lib/kuhsaft/version.rb +1 -1
- data/spec/lib/brick_list_spec.rb +11 -0
- data/spec/models/accordion_brick_spec.rb +6 -0
- data/spec/models/brick_spec.rb +15 -0
- data/spec/models/brick_type_filter_spec.rb +64 -0
- data/spec/models/image_brick_spec.rb +6 -0
- data/spec/models/link_brick_spec.rb +6 -0
- data/spec/models/page_spec.rb +15 -0
- data/spec/models/placeholder_brick_spec.rb +6 -0
- data/spec/models/slider_brick_spec.rb +6 -0
- data/spec/models/text_brick_spec.rb +6 -0
- data/spec/models/video_brick_spec.rb +6 -0
- metadata +27 -7
- data/app/assets/javascripts/kuhsaft/cms/application.js +0 -23
data/README.md
CHANGED
@@ -66,8 +66,10 @@ Kuhsaft itself does not ship with any form of authentication. However, it is fai
|
|
66
66
|
|
67
67
|
```ruby
|
68
68
|
# config/initializers/kuhsaft.rb
|
69
|
-
|
70
|
-
|
69
|
+
Rails.application.config.to_prepare do
|
70
|
+
Kuhsaft::Cms::AdminController.class_eval do
|
71
|
+
before_filter :authenticate_user!
|
72
|
+
end
|
71
73
|
end
|
72
74
|
```
|
73
75
|
|
@@ -103,9 +105,11 @@ As defined in the rails docs, load the helpers from our isolated Kuhsaft engine
|
|
103
105
|
|
104
106
|
Create an initializer file in your app inside `config/initializers` and set the `sublime_video_token`:
|
105
107
|
|
106
|
-
|
107
|
-
|
108
|
-
|
108
|
+
Rails.application.config.to_prepare do
|
109
|
+
Kuhsaft::Engine.configure do
|
110
|
+
# Get the token from the MySites section on the sublime video site
|
111
|
+
config.sublime_video_token = '123abcd'
|
112
|
+
end
|
109
113
|
end
|
110
114
|
|
111
115
|
Require the sublime javascript with the following helper:
|
@@ -119,23 +123,29 @@ Require the sublime javascript with the following helper:
|
|
119
123
|
The image brick can process uploaded images into specific sizes. These sizes can be configured inside the engine configuration. You can also use the built-in default sizes:
|
120
124
|
|
121
125
|
# your_app/config/initializers/kuhsaft.rb
|
122
|
-
|
123
|
-
|
126
|
+
Rails.application.config.to_prepare do
|
127
|
+
Kuhsaft::Engine.configure do
|
128
|
+
config.image_sizes.build_defaults! # creates 960x540 and 320x180 sizes
|
129
|
+
end
|
124
130
|
end
|
125
131
|
|
126
132
|
You can also remove the default sizes:
|
127
133
|
|
128
134
|
# your_app/config/initializers/kuhsaft.rb
|
129
|
-
|
130
|
-
|
135
|
+
Rails.application.config.to_prepare do
|
136
|
+
Kuhsaft::Engine.configure do
|
137
|
+
config.image_sizes.clear! # .all is now empty
|
138
|
+
end
|
131
139
|
end
|
132
140
|
|
133
141
|
And most importantly, you can add custom sizes:
|
134
142
|
|
135
143
|
# your_app/config/initializers/kuhsaft.rb
|
136
|
-
|
137
|
-
|
138
|
-
|
144
|
+
Rails.application.config.to_prepare do
|
145
|
+
Kuhsaft::Engine.configure do
|
146
|
+
config.image_sizes.add(:side_box_vertical, 180, 460)
|
147
|
+
config.image_sizes.add(:footer_teaser, 320, 220)
|
148
|
+
end
|
139
149
|
end
|
140
150
|
|
141
151
|
The `name` option is a unique identifier, which is also used for translating the dropdown in the brick. You can add your translation by using the translation path:
|
@@ -167,6 +177,12 @@ Finally, add the new translation locale to your `available_locales` inside your
|
|
167
177
|
|
168
178
|
config.available_locales = [:en, :fr]
|
169
179
|
|
180
|
+
## Styling the content
|
181
|
+
|
182
|
+
By default, the text editor lets you add the following tags, for which you should supply some styles in your app:
|
183
|
+
|
184
|
+
p, h1, h2, h3, ul, ol, table, a, strong, em
|
185
|
+
|
170
186
|
## Building a navigation
|
171
187
|
|
172
188
|
Building a navigation is simple, access to the page tree is available through the common methods built into the ancestry gem. Just make sure you are only accessing published pages for your production site, using the `published` scope.
|
@@ -0,0 +1,48 @@
|
|
1
|
+
# This is a manifest file that'll be compiled into including all the files listed below.
|
2
|
+
# Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
|
3
|
+
# be included in the compiled file accessible from http://example.com/assets/application.js
|
4
|
+
# It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
5
|
+
# the compiled file.
|
6
|
+
#
|
7
|
+
#= require jquery
|
8
|
+
#= require jquery-ui
|
9
|
+
#= require jquery_ujs
|
10
|
+
#= require redactor
|
11
|
+
#= require bootstrap
|
12
|
+
#= require_tree .
|
13
|
+
|
14
|
+
loadTextEditor = (elem) ->
|
15
|
+
elem.find(".js-editor").redactor(
|
16
|
+
buttons: ['html', '|', 'formatting', '|', 'bold', 'italic', 'deleted', '|', 'unorderedlist', 'orderedlist', 'outdent', 'indent', '|', 'table', 'link']
|
17
|
+
formattingTags: ['h1', 'h2', 'h3', 'p']
|
18
|
+
)
|
19
|
+
|
20
|
+
checkPageType = ->
|
21
|
+
redirect_url_input = $('#page_url')
|
22
|
+
if ($('#page_page_type option:selected').val() == 'redirect')
|
23
|
+
redirect_url_input.removeAttr('disabled')
|
24
|
+
else
|
25
|
+
redirect_url_input.attr('disabled', 'disabled')
|
26
|
+
|
27
|
+
sortableBrick = ->
|
28
|
+
$(".brick-list").each (idx, elem) ->
|
29
|
+
$(elem).sortable(
|
30
|
+
handle: '.brick-item-header',
|
31
|
+
axis: "y",
|
32
|
+
update: (event, ui) ->
|
33
|
+
$(this).find(".brick-item").each (idx, elem) ->
|
34
|
+
$(this).find("input.position-field").val(idx+1)
|
35
|
+
$(this).children('form').trigger('submit')
|
36
|
+
)
|
37
|
+
|
38
|
+
$(document).ajaxSuccess ->
|
39
|
+
loadTextEditor($("body"))
|
40
|
+
sortableBrick()
|
41
|
+
|
42
|
+
$(document).ready ->
|
43
|
+
loadTextEditor($(document))
|
44
|
+
checkPageType()
|
45
|
+
sortableBrick()
|
46
|
+
$('#page_page_type').change ->
|
47
|
+
checkPageType()
|
48
|
+
|
@@ -15,6 +15,10 @@ $borderRadiusSmall: 0px
|
|
15
15
|
|
16
16
|
// base styles
|
17
17
|
|
18
|
+
body
|
19
|
+
// disable page skipping when changing tabs in page form
|
20
|
+
overflow: scroll
|
21
|
+
|
18
22
|
h1
|
19
23
|
margin-top: 1em
|
20
24
|
margin-bottom: 0.5em
|
@@ -109,6 +113,12 @@ form
|
|
109
113
|
border-bottom: 1px solid #ccc
|
110
114
|
padding: 0.35em 0
|
111
115
|
|
116
|
+
.unpublished
|
117
|
+
background-color: #f1f1f1
|
118
|
+
|
119
|
+
a
|
120
|
+
color: #666
|
121
|
+
|
112
122
|
.branch-group
|
113
123
|
.branch-group
|
114
124
|
.branch-title
|
@@ -122,4 +132,8 @@ form
|
|
122
132
|
.branch-title
|
123
133
|
margin-left: 6em
|
124
134
|
|
135
|
+
#flash
|
136
|
+
p
|
137
|
+
margin: 0
|
138
|
+
|
125
139
|
@import bootstrap-responsive
|
@@ -21,6 +21,7 @@ module Kuhsaft
|
|
21
21
|
@page = Kuhsaft::Page.create params[:page]
|
22
22
|
|
23
23
|
if @page.valid?
|
24
|
+
flash[:success] = t('layouts.kuhsaft.cms.flash.success', :subject => Kuhsaft::Page.model_name.human)
|
24
25
|
respond_with @page, :location => kuhsaft.edit_cms_page_path(@page)
|
25
26
|
else
|
26
27
|
render 'new'
|
@@ -35,15 +36,12 @@ module Kuhsaft
|
|
35
36
|
|
36
37
|
def update
|
37
38
|
@page = Kuhsaft::Page.find(params[:id])
|
38
|
-
@page.update_attributes(params[:page])
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
@page.bricks << params[:page][:page_part_type].constantize.new
|
39
|
+
if @page.update_attributes(params[:page])
|
40
|
+
flash[:success] = t('layouts.kuhsaft.cms.flash.success', :subject => Kuhsaft::Page.model_name.human)
|
41
|
+
respond_with @page, :location => kuhsaft.edit_cms_page_path(@page)
|
42
|
+
else
|
43
|
+
render 'edit'
|
44
44
|
end
|
45
|
-
|
46
|
-
respond_with @page, :location => kuhsaft.edit_cms_page_path(@page)
|
47
45
|
end
|
48
46
|
|
49
47
|
def destroy
|
@@ -3,11 +3,15 @@ module Kuhsaft
|
|
3
3
|
module PagesHelper
|
4
4
|
|
5
5
|
def content_tab_active(page)
|
6
|
-
|
6
|
+
if page.errors.blank?
|
7
|
+
:active if page.persisted?
|
8
|
+
end
|
7
9
|
end
|
8
10
|
|
9
11
|
def metadata_tab_active(page)
|
10
|
-
|
12
|
+
if page.errors.present? || !page.persisted?
|
13
|
+
:active
|
14
|
+
end
|
11
15
|
end
|
12
16
|
end
|
13
17
|
end
|
data/app/models/kuhsaft/brick.rb
CHANGED
@@ -23,12 +23,22 @@ module Kuhsaft
|
|
23
23
|
:brick_list_type,
|
24
24
|
:presence => true
|
25
25
|
|
26
|
+
after_initialize do
|
27
|
+
self.position ||= has_siblings? ? brick_list.bricks.maximum(:position).to_i + 1 : 1
|
28
|
+
end
|
29
|
+
|
26
30
|
def to_edit_partial_path
|
27
31
|
path = self.to_partial_path.split '/'
|
28
32
|
path << 'edit'
|
29
33
|
path.join '/'
|
30
34
|
end
|
31
35
|
|
36
|
+
def has_siblings?
|
37
|
+
if brick_list
|
38
|
+
brick_list.bricks.any?
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
32
42
|
#
|
33
43
|
# The child partial can contain your own implementation
|
34
44
|
# of how the brick renders it's child in the edit form.
|
@@ -2,6 +2,7 @@ module Kuhsaft
|
|
2
2
|
class BrickType < ActiveRecord::Base
|
3
3
|
attr_accessible :disabled, :class_name, :group
|
4
4
|
scope :grouped, order('`group`, `id` asc')
|
5
|
-
scope :enabled, where('disabled IS NOT false')
|
5
|
+
scope :enabled, where('disabled IS NOT "false"')
|
6
|
+
scope :constrained, lambda { |list| where(:class_name => list) }
|
6
7
|
end
|
7
8
|
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
|
2
|
+
module Kuhsaft
|
3
|
+
class BrickTypeFilter < SimpleDelegator
|
4
|
+
|
5
|
+
def empty?
|
6
|
+
!(respond_to?(:user_can_add_childs?) && user_can_add_childs? && !allowed.empty?)
|
7
|
+
end
|
8
|
+
|
9
|
+
def allowed
|
10
|
+
if Kuhsaft::BrickType.enabled.count.zero?
|
11
|
+
[]
|
12
|
+
elsif allowed_brick_types.empty?
|
13
|
+
Kuhsaft::BrickType.enabled
|
14
|
+
else
|
15
|
+
Kuhsaft::BrickType.enabled.constrained(allowed_brick_types)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
20
|
+
end
|
data/app/models/kuhsaft/page.rb
CHANGED
@@ -51,6 +51,14 @@ class Kuhsaft::Page < ActiveRecord::Base
|
|
51
51
|
published == Kuhsaft::PublishState::PUBLISHED
|
52
52
|
end
|
53
53
|
|
54
|
+
def state_class
|
55
|
+
if published?
|
56
|
+
'published'
|
57
|
+
else
|
58
|
+
'unpublished'
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
54
62
|
def redirect?
|
55
63
|
page_type == Kuhsaft::PageType::REDIRECT
|
56
64
|
end
|
@@ -110,4 +118,8 @@ class Kuhsaft::Page < ActiveRecord::Base
|
|
110
118
|
def to_style_class
|
111
119
|
'kuhsaft-page'
|
112
120
|
end
|
121
|
+
|
122
|
+
def allowed_brick_types
|
123
|
+
Kuhsaft::BrickType.enabled.pluck(:class_name) - ['Kuhsaft::AccordionItemBrick']
|
124
|
+
end
|
113
125
|
end
|
@@ -1,10 +1,14 @@
|
|
1
|
-
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
-
|
7
|
-
-
|
8
|
-
|
9
|
-
|
10
|
-
|
1
|
+
- unless brick_list.brick_types.empty?
|
2
|
+
- if brick_list.brick_types.allowed.count > 1
|
3
|
+
%a.btn.btn-small.btn-primary.dropdown-toggle{ 'data-toggle' => 'dropdown', 'href' => '#' }
|
4
|
+
= t('.add_element')
|
5
|
+
%span.caret
|
6
|
+
%ul.dropdown-menu.pull-right
|
7
|
+
- brick_list.brick_types.allowed.grouped.group_by(&:group).each do |group, types|
|
8
|
+
- types.each do |type|
|
9
|
+
%li
|
10
|
+
= link_to type.class_name.constantize.model_name.human, kuhsaft.cms_bricks_path(:brick => { :type => type.class_name, :brick_list_id => brick_list.id, :brick_list_type => brick_list.brick_list_type }), :remote => true, :method => :post
|
11
|
+
.divider
|
12
|
+
- else
|
13
|
+
- brick_list.brick_types.allowed.each do |type|
|
14
|
+
= link_to t('.add_specific_element', :name => type.class_name.constantize.model_name.human), kuhsaft.cms_bricks_path(:brick => { :type => type.class_name, :brick_list_id => brick_list.id, :brick_list_type => brick_list.brick_list_type }), :remote => true, :method => :post, :class => 'btn btn-small btn-primary'
|
@@ -1,5 +1,6 @@
|
|
1
1
|
.brick-item{ :id => brick.to_brick_item_id, :class => brick.to_style_class }
|
2
2
|
= simple_form_for brick, :as => :brick, :url => kuhsaft.cms_brick_path(brick), :remote => true, :html => { :id => nil } do |form|
|
3
|
+
= form.hidden_field :position, :class => 'position-field'
|
3
4
|
.brick-item-header.clearfix
|
4
5
|
.pull-left
|
5
6
|
- if brick.caption.present?
|
@@ -1,7 +1,7 @@
|
|
1
1
|
- unless pages.blank?
|
2
2
|
- pages.each do |page|
|
3
3
|
.branch-group{ :'data-id' => page.id, :'data-put-url' => kuhsaft.cms_page_path(page) }
|
4
|
-
.row-fluid.branch
|
4
|
+
.row-fluid.branch{ :class => page.state_class }
|
5
5
|
.span9
|
6
6
|
.branch-title
|
7
7
|
= link_to page.title.presence, kuhsaft.edit_cms_page_path(page), :class => 'btn btn-link'
|
@@ -11,7 +11,7 @@
|
|
11
11
|
= form.input :slug, :required => false, :input_html => { :class => :span5 }
|
12
12
|
= form.input :parent_id, :collection => Kuhsaft::Page.flat_tree, :label_method => :nesting_name, :selected => params[:parent_id].presence || @page.parent_id.presence, :prompt => 'None', :input_html => { :class => :span3 }
|
13
13
|
= form.input :page_type, :collection => Kuhsaft::PageType.all, :prompt => false, :input_html => { :class => :span3 }
|
14
|
-
= form.input :url, :as => :string
|
14
|
+
= form.input :url, :as => :string
|
15
15
|
= form.input :keywords, :input_html => { :class => :span5 }
|
16
16
|
= form.input :description, :as => :text, :input_html => { :class => :span5, :rows => 4 }
|
17
17
|
= form.input :published, :as => :boolean
|
data/lib/kuhsaft.rb
CHANGED
@@ -1,6 +1,3 @@
|
|
1
|
-
require 'kuhsaft/engine'
|
2
|
-
require 'compass-rails'
|
3
|
-
|
4
1
|
module Kuhsaft
|
5
2
|
require 'kuhsaft/engine'
|
6
3
|
require 'kuhsaft/orderable'
|
@@ -11,6 +8,9 @@ module Kuhsaft
|
|
11
8
|
require 'carrierwave'
|
12
9
|
require 'rdiscount'
|
13
10
|
require 'compass'
|
11
|
+
require 'compass-rails'
|
12
|
+
require 'jquery-rails'
|
14
13
|
require 'ancestry'
|
15
14
|
require 'bootstrap-sass'
|
15
|
+
require 'haml'
|
16
16
|
end
|
data/lib/kuhsaft/brick_list.rb
CHANGED
@@ -67,5 +67,20 @@ module Kuhsaft
|
|
67
67
|
end
|
68
68
|
end
|
69
69
|
|
70
|
+
#
|
71
|
+
# Return a list of classnames which can be added as childs
|
72
|
+
# Return an empty array if you want no constraints
|
73
|
+
#
|
74
|
+
def allowed_brick_types
|
75
|
+
[]
|
76
|
+
end
|
77
|
+
|
78
|
+
#
|
79
|
+
# Returns all possible brick types which can be added as child to this brick list instance
|
80
|
+
#
|
81
|
+
def brick_types
|
82
|
+
@brick_types ||= Kuhsaft::BrickTypeFilter.new(self)
|
83
|
+
end
|
84
|
+
|
70
85
|
end
|
71
86
|
end
|
data/lib/kuhsaft/version.rb
CHANGED
data/spec/lib/brick_list_spec.rb
CHANGED
@@ -36,4 +36,15 @@ describe Kuhsaft::BrickList do
|
|
36
36
|
end
|
37
37
|
end
|
38
38
|
|
39
|
+
describe '#allowed_brick_types' do
|
40
|
+
it 'returns an array of possible classes as strings' do
|
41
|
+
brick.allowed_brick_types.should be_a(Array)
|
42
|
+
end
|
43
|
+
end
|
44
|
+
|
45
|
+
describe '#brick_types' do
|
46
|
+
it 'returns a Kuhsaft::BrickTypeFilter' do
|
47
|
+
brick.brick_types.should be_a(Kuhsaft::BrickTypeFilter)
|
48
|
+
end
|
49
|
+
end
|
39
50
|
end
|
@@ -29,4 +29,10 @@ describe Kuhsaft::AccordionBrick do
|
|
29
29
|
accordion_brick.to_style_class.should == 'kuhsaft-accordion-brick accordion'
|
30
30
|
end
|
31
31
|
end
|
32
|
+
|
33
|
+
describe '#allowed_brick_types' do
|
34
|
+
it 'only allows AccordionItems' do
|
35
|
+
accordion_brick.allowed_brick_types.should == %w(Kuhsaft::AccordionItemBrick)
|
36
|
+
end
|
37
|
+
end
|
32
38
|
end
|
data/spec/models/brick_spec.rb
CHANGED
@@ -70,6 +70,21 @@ describe Kuhsaft::Brick do
|
|
70
70
|
end
|
71
71
|
end
|
72
72
|
|
73
|
+
describe '#has_siblings?' do
|
74
|
+
it 'returns false if the brick has no siblings' do
|
75
|
+
brick = Kuhsaft::Brick.new
|
76
|
+
brick.has_siblings?.should be_false
|
77
|
+
end
|
78
|
+
|
79
|
+
it 'returns true if the brick has siblings' do
|
80
|
+
item1, item2, item3 = mock, mock, Kuhsaft::Brick.new
|
81
|
+
item1.stub(:bricks).and_return([item2, item3])
|
82
|
+
item2.stub(:brick_list).and_return(item1)
|
83
|
+
item3.stub(:brick_list).and_return(item1)
|
84
|
+
item3.has_siblings?.should be_true
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
73
88
|
describe '#to_edit_childs_partial_path' do
|
74
89
|
it 'returns the path to the form partial' do
|
75
90
|
Kuhsaft::TextBrick.new.to_edit_childs_partial_path.should == 'kuhsaft/text_bricks/text_brick/childs'
|
@@ -0,0 +1,64 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Kuhsaft::BrickTypeFilter do
|
4
|
+
let :brick_list do
|
5
|
+
Kuhsaft::Page.new
|
6
|
+
end
|
7
|
+
|
8
|
+
let :brick_type_filter do
|
9
|
+
Kuhsaft::BrickTypeFilter.new(brick_list)
|
10
|
+
end
|
11
|
+
|
12
|
+
describe '#empty?' do
|
13
|
+
context 'when the user cant add childs' do
|
14
|
+
before do
|
15
|
+
brick_list.stub(:user_can_add_childs?).and_return(false)
|
16
|
+
end
|
17
|
+
|
18
|
+
it 'returns true' do
|
19
|
+
brick_type_filter.empty?.should be_true
|
20
|
+
end
|
21
|
+
end
|
22
|
+
|
23
|
+
context 'when there are no bricks to be added' do
|
24
|
+
before do
|
25
|
+
brick_type_filter.stub(:allowed).and_return([])
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'returns true' do
|
29
|
+
brick_type_filter.empty?.should be_true
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
describe '#allowed' do
|
35
|
+
context 'when no brick types are registered' do
|
36
|
+
it 'returns an empty array' do
|
37
|
+
Kuhsaft::BrickType.stub_chain(:count, :zero?).and_return(true)
|
38
|
+
brick_type_filter.allowed.should be_empty
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
context 'when brick types are registered' do
|
43
|
+
before do
|
44
|
+
Kuhsaft::BrickType.stub_chain(:enabled, :count, :zero?).and_return(false)
|
45
|
+
end
|
46
|
+
|
47
|
+
context 'when there are no constraints' do
|
48
|
+
it 'returns all enabled brick types' do
|
49
|
+
brick_list.stub(:allowed_brick_types).and_return([])
|
50
|
+
Kuhsaft::BrickType.should_receive(:enabled)
|
51
|
+
brick_type_filter.allowed
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
context 'when there are constraints' do
|
56
|
+
it 'constrains the enabled types' do
|
57
|
+
brick_list.stub(:allowed_brick_types).and_return(['Kuhsaft::TextBrick'])
|
58
|
+
Kuhsaft::BrickType.enabled.should_receive(:constrained).with(['Kuhsaft::TextBrick'])
|
59
|
+
brick_type_filter.allowed
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
64
|
+
end
|
data/spec/models/page_spec.rb
CHANGED
@@ -72,6 +72,21 @@ describe Kuhsaft::Page do
|
|
72
72
|
end
|
73
73
|
end
|
74
74
|
|
75
|
+
describe "#state_class" do
|
76
|
+
|
77
|
+
let(:page) { Kuhsaft::Page.new }
|
78
|
+
|
79
|
+
it 'returns publsihed as string when page is published' do
|
80
|
+
page.published == Kuhsaft::PublishState::PUBLISHED
|
81
|
+
page.state_class == 'published'
|
82
|
+
end
|
83
|
+
|
84
|
+
it 'returns unpublsihed as string when page is unpublished' do
|
85
|
+
page.published == Kuhsaft::PublishState::UNPUBLISHED
|
86
|
+
page.state_class == 'unpublished'
|
87
|
+
end
|
88
|
+
end
|
89
|
+
|
75
90
|
describe '#without_self' do
|
76
91
|
it 'returns pages but not itself' do
|
77
92
|
2.times { create(:page) }
|
@@ -17,4 +17,10 @@ describe Kuhsaft::SliderBrick do
|
|
17
17
|
slider_brick.to_style_class.should == 'kuhsaft-slider-brick carousel slide'
|
18
18
|
end
|
19
19
|
end
|
20
|
+
|
21
|
+
describe '#allowed_brick_types' do
|
22
|
+
it 'only allows ImageBricks and VideoBricks' do
|
23
|
+
slider_brick.allowed_brick_types.should == %w(Kuhsaft::ImageBrick Kuhsaft::VideoBrick)
|
24
|
+
end
|
25
|
+
end
|
20
26
|
end
|
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.
|
4
|
+
version: 1.2.0
|
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-02-
|
14
|
+
date: 2013-02-25 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rspec
|
@@ -132,7 +132,7 @@ dependencies:
|
|
132
132
|
requirements:
|
133
133
|
- - ~>
|
134
134
|
- !ruby/object:Gem::Version
|
135
|
-
version:
|
135
|
+
version: 3.2.11
|
136
136
|
type: :runtime
|
137
137
|
prerelease: false
|
138
138
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -140,7 +140,7 @@ dependencies:
|
|
140
140
|
requirements:
|
141
141
|
- - ~>
|
142
142
|
- !ruby/object:Gem::Version
|
143
|
-
version:
|
143
|
+
version: 3.2.11
|
144
144
|
- !ruby/object:Gem::Dependency
|
145
145
|
name: haml
|
146
146
|
requirement: !ruby/object:Gem::Requirement
|
@@ -189,6 +189,22 @@ dependencies:
|
|
189
189
|
- - ! '>='
|
190
190
|
- !ruby/object:Gem::Version
|
191
191
|
version: '0'
|
192
|
+
- !ruby/object:Gem::Dependency
|
193
|
+
name: coffee-rails
|
194
|
+
requirement: !ruby/object:Gem::Requirement
|
195
|
+
none: false
|
196
|
+
requirements:
|
197
|
+
- - ! '>='
|
198
|
+
- !ruby/object:Gem::Version
|
199
|
+
version: '0'
|
200
|
+
type: :runtime
|
201
|
+
prerelease: false
|
202
|
+
version_requirements: !ruby/object:Gem::Requirement
|
203
|
+
none: false
|
204
|
+
requirements:
|
205
|
+
- - ! '>='
|
206
|
+
- !ruby/object:Gem::Version
|
207
|
+
version: '0'
|
192
208
|
- !ruby/object:Gem::Dependency
|
193
209
|
name: simple_form
|
194
210
|
requirement: !ruby/object:Gem::Requirement
|
@@ -292,7 +308,7 @@ extensions: []
|
|
292
308
|
extra_rdoc_files: []
|
293
309
|
files:
|
294
310
|
- app/assets/javascripts/kuhsaft/application.js
|
295
|
-
- app/assets/javascripts/kuhsaft/cms/application.js
|
311
|
+
- app/assets/javascripts/kuhsaft/cms/application.js.coffee
|
296
312
|
- app/assets/javascripts/kuhsaft/cms/customizations.js
|
297
313
|
- app/assets/stylesheets/kuhsaft/application.css.sass
|
298
314
|
- app/assets/stylesheets/kuhsaft/cms/application.css.sass
|
@@ -313,6 +329,7 @@ files:
|
|
313
329
|
- app/models/kuhsaft/asset.rb
|
314
330
|
- app/models/kuhsaft/brick.rb
|
315
331
|
- app/models/kuhsaft/brick_type.rb
|
332
|
+
- app/models/kuhsaft/brick_type_filter.rb
|
316
333
|
- app/models/kuhsaft/cms.rb
|
317
334
|
- app/models/kuhsaft/column_brick.rb
|
318
335
|
- app/models/kuhsaft/image_brick.rb
|
@@ -336,6 +353,7 @@ files:
|
|
336
353
|
- app/views/kuhsaft/cms/admin/_brick_type_dropdown.html.haml
|
337
354
|
- app/views/kuhsaft/cms/admin/_content_language_switch.html.haml
|
338
355
|
- app/views/kuhsaft/cms/admin/_empty_state.html.haml
|
356
|
+
- app/views/kuhsaft/cms/admin/_flash.html.haml
|
339
357
|
- app/views/kuhsaft/cms/admin/_main_navigation.html.haml
|
340
358
|
- app/views/kuhsaft/cms/assets/_form.html.haml
|
341
359
|
- app/views/kuhsaft/cms/assets/_list.html.haml
|
@@ -460,6 +478,7 @@ files:
|
|
460
478
|
- spec/models/accordion_item_brick_spec.rb
|
461
479
|
- spec/models/asset_spec.rb
|
462
480
|
- spec/models/brick_spec.rb
|
481
|
+
- spec/models/brick_type_filter_spec.rb
|
463
482
|
- spec/models/column_brick_spec.rb
|
464
483
|
- spec/models/image_brick_spec.rb
|
465
484
|
- spec/models/image_size_spec.rb
|
@@ -487,7 +506,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
487
506
|
version: '0'
|
488
507
|
segments:
|
489
508
|
- 0
|
490
|
-
hash: -
|
509
|
+
hash: -1611496846059765268
|
491
510
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
492
511
|
none: false
|
493
512
|
requirements:
|
@@ -496,7 +515,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
496
515
|
version: '0'
|
497
516
|
segments:
|
498
517
|
- 0
|
499
|
-
hash: -
|
518
|
+
hash: -1611496846059765268
|
500
519
|
requirements: []
|
501
520
|
rubyforge_project: kuhsaft
|
502
521
|
rubygems_version: 1.8.24
|
@@ -547,6 +566,7 @@ test_files:
|
|
547
566
|
- spec/models/accordion_item_brick_spec.rb
|
548
567
|
- spec/models/asset_spec.rb
|
549
568
|
- spec/models/brick_spec.rb
|
569
|
+
- spec/models/brick_type_filter_spec.rb
|
550
570
|
- spec/models/column_brick_spec.rb
|
551
571
|
- spec/models/image_brick_spec.rb
|
552
572
|
- spec/models/image_size_spec.rb
|
@@ -1,23 +0,0 @@
|
|
1
|
-
// This is a manifest file that'll be compiled into including all the files listed below.
|
2
|
-
// Add new JavaScript/Coffee code in separate files in this directory and they'll automatically
|
3
|
-
// be included in the compiled file accessible from http://example.com/assets/application.js
|
4
|
-
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
5
|
-
// the compiled file.
|
6
|
-
//
|
7
|
-
//= require jquery
|
8
|
-
//= require jquery_ujs
|
9
|
-
//= require redactor
|
10
|
-
//= require bootstrap
|
11
|
-
//= require_tree .
|
12
|
-
|
13
|
-
function loadTextEditor(elem){
|
14
|
-
elem.find(".js-editor").redactor({})
|
15
|
-
}
|
16
|
-
|
17
|
-
$(function(){
|
18
|
-
loadTextEditor($("body"))
|
19
|
-
})
|
20
|
-
|
21
|
-
$("body").ajaxSuccess(function(){
|
22
|
-
loadTextEditor($("body"))
|
23
|
-
})
|