kuhsaft 2.0.2 → 2.0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: eecde1b2e276afa2b521baaf04bd0312a4ec74d9
4
- data.tar.gz: 257ed6496e7b45df88df4f8d556875164eef0013
3
+ metadata.gz: dece1070f1406b31773243d2f070e48387f15a27
4
+ data.tar.gz: 22cb559490bc2b7e86eb92a475eb1ef9f7939d06
5
5
  SHA512:
6
- metadata.gz: 8ed475ede79f506ecfb728f9eefa525e9116f2cb956949cbf661ff13dd3953fa957e4285e38e44868a7acec6934ce2bec7c64f046f5613eaac217c3ca52ace7c
7
- data.tar.gz: 131744bc047b4d30e1626f4c69b90d4f3c221f1f9ce6488ba59db4ad0371873676edf54c6d734ee18c3f4c5fc8b26ccc650754636d581fbad4f2b4bbd6a867b9
6
+ metadata.gz: b0ba82b69049bbaa1ca7a62fa0d2c156f86908b4114a891e35db58320c7455b774e46c706bcb5df9a8244aef26b9ab97d25a14a002948f6a97a4b5489e5c0f6a
7
+ data.tar.gz: a6c5464e5cbeea1fc505bc53582fab6bfde81cba649d7bd4cfcee16f3c8c052243d56b934452eb40a9ddea2f14162fa65de87a590bef53dcaad5e91ce0d99f7e
data/README.md CHANGED
@@ -225,6 +225,15 @@ Building a navigation is simple, access to the page tree is available through th
225
225
  end
226
226
  end
227
227
 
228
+ ## Use the `page_title` attribute in your app
229
+
230
+ Kuhsaft::Pages will provide a `%title` tag containing its `page_title`
231
+ (or the required `title`if no title is present). Simply yield for
232
+ `:head` in your `application.html` to use it.
233
+
234
+ %head
235
+ = yield(:head)
236
+
228
237
  ## Modifying the backend navigation
229
238
 
230
239
  Simply override the default partial for the main navigation in your app with your own file at `kuhsaft/cms/admin/_main_navigation.html.haml`
@@ -10,6 +10,10 @@ module Kuhsaft
10
10
  I18n.locale = params[:content_locale]
11
11
  end
12
12
  end
13
+
14
+ def url_options
15
+ { content_locale: I18n.locale }.merge(super)
16
+ end
13
17
  end
14
18
  end
15
19
  end
@@ -5,14 +5,14 @@ module Kuhsaft
5
5
  respond_to :html, :js
6
6
 
7
7
  def create
8
- @brick = params[:brick][:type].constantize.new(params[:brick])
8
+ @brick = params[:brick][:type].constantize.new(brick_params)
9
9
  @brick.image_size = ImageSize.all.first.name.to_s
10
10
  @brick.save(:validate => false)
11
11
  end
12
12
 
13
13
  def update
14
14
  @brick = Kuhsaft::Brick.find(params[:id])
15
- @brick.update_attributes(params[:brick])
15
+ @brick.update_attributes(brick_params)
16
16
 
17
17
  #
18
18
  # rails will fall back to html if ajax can't be used
@@ -40,6 +40,11 @@ module Kuhsaft
40
40
  render :nothing => true
41
41
  end
42
42
 
43
+ private
44
+
45
+ def brick_params
46
+ params.require(:brick).permit!
47
+ end
43
48
  end
44
49
  end
45
50
  end
@@ -20,7 +20,7 @@ module Kuhsaft
20
20
  end
21
21
 
22
22
  def create
23
- @page = Kuhsaft::Page.create params[:page]
23
+ @page = Kuhsaft::Page.create(page_params)
24
24
 
25
25
  if @page.valid?
26
26
  flash[:success] = t('layouts.kuhsaft.cms.flash.success', :subject => Kuhsaft::Page.model_name.human)
@@ -38,7 +38,7 @@ module Kuhsaft
38
38
 
39
39
  def update
40
40
  @page = Kuhsaft::Page.find(params[:id])
41
- if @page.update_attributes(params[:page])
41
+ if @page.update_attributes(page_params)
42
42
  flash[:success] = t('layouts.kuhsaft.cms.flash.success', :subject => Kuhsaft::Page.model_name.human)
43
43
  respond_with @page, :location => kuhsaft.edit_cms_page_path(@page)
44
44
  else
@@ -55,6 +55,23 @@ module Kuhsaft
55
55
  def sort
56
56
  Kuhsaft::PageTree.update(params[:page_tree])
57
57
  end
58
+
59
+ private
60
+
61
+ def page_params
62
+ safe_params = [:title,
63
+ :page_title,
64
+ :slug,
65
+ :redirect_url,
66
+ :url,
67
+ :page_type,
68
+ :parent_id,
69
+ :keywords,
70
+ :description,
71
+ :published,
72
+ :position]
73
+ params.require(:page).permit(*safe_params)
74
+ end
58
75
  end
59
76
  end
60
77
  end
@@ -1,9 +1,5 @@
1
1
  module Kuhsaft
2
2
  class AccordionBrick < ColumnBrick
3
- attr_accessible :caption
4
-
5
- # TODO: validate only accept AccordionItem as child
6
-
7
3
  def user_can_delete?
8
4
  true
9
5
  end
@@ -1,6 +1,5 @@
1
1
  module Kuhsaft
2
2
  class AccordionItemBrick < ColumnBrick
3
- attr_accessible :caption
4
3
  validates :caption, :presence => true
5
4
 
6
5
  def user_can_delete?
@@ -1,7 +1,5 @@
1
1
  module Kuhsaft
2
2
  class AnchorBrick < Brick
3
- attr_accessible :caption
4
-
5
3
  validates :caption, :presence => true
6
4
 
7
5
  def user_can_add_childs?
@@ -1,7 +1,5 @@
1
1
  module Kuhsaft
2
2
  class AssetBrick < Brick
3
- attr_accessible :caption, :link_style, :asset
4
-
5
3
  mount_uploader :asset, Kuhsaft::AssetBrickAssetUploader
6
4
 
7
5
  validates :caption, :asset, :presence => true
@@ -9,13 +9,6 @@ module Kuhsaft
9
9
 
10
10
  serialize :display_styles, Array
11
11
 
12
- attr_accessible :locale,
13
- :position,
14
- :type,
15
- :brick_list_id,
16
- :brick_list_type,
17
- :display_styles
18
-
19
12
  before_validation :set_position
20
13
 
21
14
  validates :locale,
@@ -1,6 +1,5 @@
1
1
  module Kuhsaft
2
2
  class BrickType < ActiveRecord::Base
3
- attr_accessible :disabled, :class_name, :group
4
3
  scope :grouped, -> { order('`group`, `id` asc') }
5
4
  scope :enabled, -> { where(:enabled => true) }
6
5
  scope :constrained, ->(list) { where(:class_name => list) }
@@ -1,6 +1,5 @@
1
1
  module Kuhsaft
2
2
  class ImageBrick < Brick
3
- attr_accessible :image, :caption, :href, :image_size
4
3
  mount_uploader :image, Kuhsaft::ImageBrickImageUploader
5
4
 
6
5
  validates :image, :presence => true
@@ -1,7 +1,5 @@
1
1
  module Kuhsaft
2
2
  class LinkBrick < Brick
3
- attr_accessible :href, :caption, :link_style, :open_in_new_window
4
-
5
3
  validates :href, :caption, :presence => true
6
4
 
7
5
  def self.styles
@@ -9,6 +9,7 @@ class Kuhsaft::Page < ActiveRecord::Base
9
9
  acts_as_brick_list
10
10
 
11
11
  translate :title,
12
+ :page_title,
12
13
  :slug,
13
14
  :keywords,
14
15
  :description,
@@ -16,17 +17,6 @@ class Kuhsaft::Page < ActiveRecord::Base
16
17
  :redirect_url,
17
18
  :url
18
19
 
19
- attr_accessible :title,
20
- :slug,
21
- :redirect_url,
22
- :url,
23
- :page_type,
24
- :parent_id,
25
- :keywords,
26
- :description,
27
- :published,
28
- :position
29
-
30
20
  default_scope { order('position ASC') }
31
21
 
32
22
  scope :published, -> { where(:published => Kuhsaft::PublishState::PUBLISHED) }
@@ -1,7 +1,5 @@
1
1
  module Kuhsaft
2
2
  class PlaceholderBrick < Brick
3
-
4
- attr_accessible :template_name
5
3
  PARTIAL_PATH = '/app/views/kuhsaft/placeholder_bricks/partials/_*.haml'
6
4
 
7
5
  def self.available_partials
@@ -5,8 +5,6 @@ module Kuhsaft
5
5
  include ActionView::Helpers::SanitizeHelper
6
6
  HTML_ENTITIES = HTMLEntities.new
7
7
 
8
- attr_accessible :text, :read_more_text
9
-
10
8
  def user_can_add_childs?
11
9
  false
12
10
  end
@@ -3,8 +3,6 @@ module Kuhsaft
3
3
 
4
4
  before_create :add_columns
5
5
 
6
- attr_accessible :partitioning
7
-
8
6
  #
9
7
  # Childs should only contain ColumnBricks, therefore we
10
8
  # don't want the user to mess with it
@@ -5,7 +5,6 @@ module Kuhsaft
5
5
  VIMEO = 'vimeo'
6
6
  EXTERNAL = 'external'
7
7
 
8
- attr_accessible :video, :embed_src, :href
9
8
  validates :any_source, :presence => true
10
9
 
11
10
  # a video id, an embed code or a link to a video is required
@@ -10,6 +10,7 @@
10
10
  = simple_form_for @page, :url => url, :html => { :class => 'form-horizontal' } do |form|
11
11
  = form.input :title, :required => false, :input_html => { :class => :span5 }
12
12
  = form.input :slug, :required => false, :input_html => { :class => :span5 }
13
+ = form.input :page_title, :required => false, :input_html => { :class => :span5 }
13
14
  = 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 }
14
15
  = form.input :page_type, :collection => Kuhsaft::PageType.all, :prompt => false, :input_html => { :class => :span3 }
15
16
  = form.input :redirect_url, :as => :string
@@ -1,12 +1,17 @@
1
+ = content_for :head do
2
+ %title= @page.page_title.present? ? @page.page_title : @page.title
3
+
1
4
  - if @page.bricks.map(&:type).include? "Kuhsaft::PlaceholderBrick"
2
5
  - unless @page.blank?
3
6
  .page-content
4
- - @page.bricks.localized.each do |brick|
7
+ -# TODO: refactor into scopes or simplify otherwise:
8
+ - @page.bricks.localized.select(&:valid?).each do |brick|
5
9
  = render brick
6
10
 
7
11
  - else
8
12
  - cache [@page, I18n.locale] do
9
13
  - unless @page.blank?
10
14
  .page-content
11
- - @page.bricks.localized.each do |brick|
15
+ -# TODO: refactor into scopes or simplify otherwise:
16
+ - @page.bricks.localized.select(&:valid?).each do |brick|
12
17
  = render brick
@@ -8,6 +8,7 @@ de:
8
8
  kuhsaft/page:
9
9
  title: 'Titel'
10
10
  slug: 'URL Name'
11
+ page_title: 'Seitentitel (im Browser)'
11
12
  keywords: 'Stichwörter'
12
13
  description: 'Beschreibung'
13
14
  redirect_url: 'Redirect URL'
@@ -0,0 +1,7 @@
1
+ class AddPageTitleToPages < ActiveRecord::Migration
2
+ def change
3
+ I18n.available_locales.each do |locale|
4
+ add_column :kuhsaft_pages, "page_title_#{locale}", :text
5
+ end
6
+ end
7
+ end
@@ -15,5 +15,4 @@ module Kuhsaft
15
15
  require 'bootstrap-sass'
16
16
  require 'haml'
17
17
  require 'ckeditor'
18
- require 'protected_attributes'
19
18
  end
@@ -21,8 +21,6 @@ module Kuhsaft
21
21
 
22
22
  if included_modules.include?(Translatable)
23
23
  translate :fulltext
24
- else
25
- attr_accessible :fulltext
26
24
  end
27
25
 
28
26
  before_validation :update_fulltext
@@ -33,6 +31,7 @@ module Kuhsaft
33
31
  {
34
32
  :against => {
35
33
  locale_attr(:title) => 'A',
34
+ locale_attr(:page_title) => 'A',
36
35
  locale_attr(:keywords) => 'B',
37
36
  locale_attr(:description) => 'C',
38
37
  locale_attr(:fulltext) => 'C',
@@ -61,9 +60,10 @@ module Kuhsaft
61
60
  stmt = ""
62
61
  stmt += "#{locale_attr(:keywords)} LIKE ? OR "
63
62
  stmt += "#{locale_attr(:title)} LIKE ? OR "
63
+ stmt += "#{locale_attr(:page_title)} LIKE ? OR "
64
64
  stmt += "#{locale_attr(:description)} LIKE ? OR "
65
65
  stmt += "#{locale_attr(:fulltext)} LIKE ?"
66
- where(stmt, *(["%#{query}%"] * 4))
66
+ where(stmt, *(["%#{query}%"] * 5))
67
67
  end
68
68
  }
69
69
  end
@@ -1,3 +1,3 @@
1
1
  module Kuhsaft
2
- VERSION = "2.0.2"
2
+ VERSION = "2.0.3"
3
3
  end
@@ -1,7 +1,7 @@
1
1
  <!DOCTYPE html>
2
2
  <html>
3
3
  <head>
4
- <title>Dummy</title>
4
+ <%= yield(:head) %>
5
5
  <%= stylesheet_link_tag "application", :media => "all" %>
6
6
  <%= javascript_include_tag "application" %>
7
7
  <%= csrf_meta_tags %>
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: 2.0.2
4
+ version: 2.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Immanuel Häussermann
@@ -12,7 +12,7 @@ authors:
12
12
  autorequire:
13
13
  bindir: bin
14
14
  cert_chain: []
15
- date: 2013-07-22 00:00:00.000000000 Z
15
+ date: 2013-07-23 00:00:00.000000000 Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: rspec
@@ -32,16 +32,16 @@ dependencies:
32
32
  name: rspec-rails
33
33
  requirement: !ruby/object:Gem::Requirement
34
34
  requirements:
35
- - - ~>
35
+ - - '>='
36
36
  - !ruby/object:Gem::Version
37
- version: '2.13'
37
+ version: '0'
38
38
  type: :development
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
41
41
  requirements:
42
- - - ~>
42
+ - - '>='
43
43
  - !ruby/object:Gem::Version
44
- version: '2.13'
44
+ version: '0'
45
45
  - !ruby/object:Gem::Dependency
46
46
  name: factory_girl_rails
47
47
  requirement: !ruby/object:Gem::Requirement
@@ -280,20 +280,6 @@ dependencies:
280
280
  - - '='
281
281
  - !ruby/object:Gem::Version
282
282
  version: 3.0.0.rc
283
- - !ruby/object:Gem::Dependency
284
- name: protected_attributes
285
- requirement: !ruby/object:Gem::Requirement
286
- requirements:
287
- - - '>='
288
- - !ruby/object:Gem::Version
289
- version: '0'
290
- type: :runtime
291
- prerelease: false
292
- version_requirements: !ruby/object:Gem::Requirement
293
- requirements:
294
- - - '>='
295
- - !ruby/object:Gem::Version
296
- version: '0'
297
283
  - !ruby/object:Gem::Dependency
298
284
  name: jquery-ui-rails
299
285
  requirement: !ruby/object:Gem::Requirement
@@ -463,6 +449,7 @@ files:
463
449
  - db/migrate/10_add_redirect_url_to_kuhsaft_pages.rb
464
450
  - db/migrate/11_update_url_and_redirect_url_value.rb
465
451
  - db/migrate/12_regenerate_fulltext.rb
452
+ - db/migrate/13_add_page_title_to_pages.rb
466
453
  - db/seeds.rb
467
454
  - lib/generators/kuhsaft/assets/install_generator.rb
468
455
  - lib/generators/kuhsaft/translations/add_generator.rb