kuhsaft 1.8.6 → 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (48) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +3 -8
  3. data/Rakefile +4 -25
  4. data/app/assets/javascripts/kuhsaft/cms/application.js.coffee +2 -2
  5. data/app/assets/stylesheets/kuhsaft/cms/application.css.sass +4 -8
  6. data/app/controllers/kuhsaft/cms/admin_controller.rb +4 -4
  7. data/app/controllers/kuhsaft/pages_controller.rb +1 -2
  8. data/app/models/kuhsaft/asset.rb +2 -2
  9. data/app/models/kuhsaft/brick_type.rb +3 -3
  10. data/app/models/kuhsaft/page.rb +5 -7
  11. data/app/uploaders/kuhsaft/asset_brick_asset_uploader.rb +1 -1
  12. data/app/uploaders/kuhsaft/image_brick_image_uploader.rb +1 -1
  13. data/app/views/kuhsaft/cms/pages/_form.html.haml +0 -1
  14. data/app/views/kuhsaft/pages/show.html.haml +2 -7
  15. data/config/locales/kuhsaft.de.yml +1 -4
  16. data/config/locales/kuhsaft.en.yml +0 -3
  17. data/config/locales/models/kuhsaft/page/de.yml +0 -1
  18. data/config/routes.rb +1 -1
  19. data/lib/kuhsaft.rb +3 -2
  20. data/lib/kuhsaft/searchable.rb +1 -3
  21. data/lib/kuhsaft/version.rb +1 -1
  22. data/spec/controllers/kuhsaft/pages_controller_spec.rb +25 -13
  23. data/spec/dummy/app/assets/javascripts/kuhsaft/cms/customizations.js.coffee +0 -0
  24. data/spec/dummy/app/assets/stylesheets/kuhsaft/cms/customizations.css.sass +0 -0
  25. data/spec/dummy/app/views/layouts/application.html.erb +1 -1
  26. data/spec/dummy/bin/bundle +3 -0
  27. data/spec/dummy/bin/rails +4 -0
  28. data/spec/dummy/bin/rake +4 -0
  29. data/spec/dummy/config/application.rb +6 -52
  30. data/spec/dummy/config/boot.rb +3 -9
  31. data/spec/dummy/config/environment.rb +2 -2
  32. data/spec/dummy/config/environments/development.rb +11 -19
  33. data/spec/dummy/config/environments/production.rb +41 -27
  34. data/spec/dummy/config/environments/test.rb +13 -14
  35. data/spec/dummy/config/initializers/filter_parameter_logging.rb +4 -0
  36. data/spec/dummy/config/initializers/inflections.rb +6 -5
  37. data/spec/dummy/config/initializers/kuhsaft.rb +5 -0
  38. data/spec/dummy/config/initializers/secret_token.rb +7 -2
  39. data/spec/dummy/config/initializers/session_store.rb +0 -5
  40. data/spec/dummy/config/initializers/wrap_parameters.rb +6 -6
  41. data/spec/dummy/config/locales/en.yml +20 -2
  42. data/spec/dummy/config/routes.rb +1 -1
  43. data/spec/features/search_spec.rb +2 -2
  44. data/spec/spec_helper.rb +10 -0
  45. metadata +72 -49
  46. data/db/migrate/13_add_page_title_to_pages.rb +0 -7
  47. data/db/migrate/14_move_kuhsaft_assets.rb +0 -22
  48. data/spec/support/default_url_options.rb +0 -36
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 48c854f81cbe7f88f0a9512cd2f5cc2c2ba080a2
4
- data.tar.gz: 4027155e3d1457db220d0eb760f52532861b2f36
3
+ metadata.gz: cdb395046c4e56187d9f092401a4f1d5ed4c1680
4
+ data.tar.gz: 72d98cdb63209815fbcc094935b9cbec4cfc24b2
5
5
  SHA512:
6
- metadata.gz: bb2ec761d28e18fc45c9859e42b40a19d34f5796638f2ad6856ae3371944fae906e5d61f256336771dafdad1a78e6a03b6c68005612da74024749cd88cd65483
7
- data.tar.gz: cf2f3963a64c2e27e3d6701c58274d379060d92187d8967c21b105d19938290a5092b4fa6e973aae67d25c9181bd3bc2729668d970618a4cfa81bc25c32530f9
6
+ metadata.gz: 7b5f78b5dbe7d069bbcebe544e9736e321a08adac1b7c02b9b88599bba6b44df05ff954e13c37c9ec8b92298f792237f78edc651c398e7bad311457ba7ca023e
7
+ data.tar.gz: a802f2f2ecc7f1b21763d3c0af745a436ab2aa5b22ff92fffd13f96bc52c4dddac923656b9b4ab9a53ae72da65d57d462a8ba570b10a2c1f8ee2f233f4c1cb9f
data/README.md CHANGED
@@ -1,4 +1,6 @@
1
- [![Build Status](https://api.travis-ci.org/screenconcept/kuhsaft.png)](http://travis-ci.org/screenconcept/kuhsaft)
1
+ [![Build Status](https://travis-ci.org/screenconcept/kuhsaft.png)](https://travis-ci.org/screenconcept/kuhsaft)
2
+ [![Code Climate](https://codeclimate.com/github/screenconcept/kuhsaft.png)](https://codeclimate.com/github/screenconcept/kuhsaft)
3
+ [![Gem Version](https://badge.fury.io/rb/kuhsaft.png)](http://badge.fury.io/rb/kuhsaft)
2
4
 
3
5
  # Kuhsaft. A CMS as simple as it could be
4
6
 
@@ -223,13 +225,6 @@ Building a navigation is simple, access to the page tree is available through th
223
225
  end
224
226
  end
225
227
 
226
- ## Use the `page_title` attribute in your app
227
-
228
- Kuhsaft::Pages will provide a `%title` tag containing its `page_title` (or the required `title`if no title is present). Simply yield for `:head` in your `application.html` to use it.
229
-
230
- %head
231
- = yield(:head)
232
-
233
228
  ## Modifying the backend navigation
234
229
 
235
230
  Simply override the default partial for the main navigation in your app with your own file at `kuhsaft/cms/admin/_main_navigation.html.haml`
data/Rakefile CHANGED
@@ -1,19 +1,8 @@
1
- #!/usr/bin/env rake
2
- begin
3
- require 'bundler/setup'
4
- rescue LoadError
5
- puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
6
- end
7
1
 
8
- require 'rspec'
2
+ require "bundler/gem_tasks"
3
+ require 'rake/testtask'
9
4
  require 'rspec/core/rake_task'
10
5
 
11
- RSpec::Core::RakeTask.new(:spec) do |specs|
12
- specs.rspec_opts = %w{--color}
13
- end
14
-
15
- task :default => :spec
16
-
17
6
  begin
18
7
  require 'rdoc/task'
19
8
  rescue LoadError
@@ -23,7 +12,7 @@ rescue LoadError
23
12
  end
24
13
 
25
14
  desc "Run specs"
26
- RSpec::Core::RakeTask.new(:spec => :setup)
15
+ RSpec::Core::RakeTask.new
27
16
 
28
17
  RDoc::Task.new(:rdoc) do |rdoc|
29
18
  rdoc.rdoc_dir = 'rdoc'
@@ -33,14 +22,4 @@ RDoc::Task.new(:rdoc) do |rdoc|
33
22
  rdoc.rdoc_files.include('lib/**/*.rb')
34
23
  end
35
24
 
36
- task :setup do
37
- Dir.chdir('spec/dummy') do
38
- `bundle exec rake kuhsaft:install:migrations`
39
- `bundle exec rails generate kuhsaft:install:assets`
40
- `bundle exec rake db:create`
41
- `bundle exec rake db:migrate`
42
- `bundle exec rake db:test:prepare`
43
- end
44
- end
45
-
46
- Bundler::GemHelper.install_tasks
25
+ task :default => [:spec]
@@ -5,8 +5,8 @@
5
5
  # the compiled file.
6
6
  #
7
7
  #= require jquery
8
- #= require jquery-ui
9
8
  #= require jquery_ujs
9
+ #= require jquery.ui.all
10
10
  #= require bootstrap
11
11
  #= require ckeditor/init
12
12
  #= require jquery.nestable
@@ -90,4 +90,4 @@ $(document).ready ->
90
90
  pageTree = $('.dd').nestable('serialize')
91
91
  url = '/cms/pages/sort'
92
92
  $.post(url, { page_tree: pageTree }, "json")
93
- )
93
+ )
@@ -10,9 +10,6 @@ $borderRadiusLarge: 0px
10
10
  $borderRadiusSmall: 0px
11
11
 
12
12
  @import bootstrap
13
- @import compass/css3
14
- @import nestable
15
-
16
13
  // base styles
17
14
 
18
15
  body
@@ -32,7 +29,7 @@ form
32
29
  .breadcrumb
33
30
  background: #fff
34
31
  opacity: 0.4
35
- +single-transition(all, 0.3s)
32
+ @include transition(all, 0.3s)
36
33
 
37
34
  .breadcrumb:hover
38
35
  opacity: 1
@@ -58,12 +55,12 @@ form
58
55
  padding: 0.5em
59
56
 
60
57
  .btn
61
- +opacity(0)
62
- +single-transition(oapcity, 0.2s)
58
+ opacity: 0
59
+ @include transition(opacity, 0.2s)
63
60
 
64
61
  &:hover
65
62
  .btn
66
- +opacity(1)
63
+ opacity: 1
67
64
 
68
65
  .btn-toolbar
69
66
  margin-top: 0
@@ -163,5 +160,4 @@ textarea.editor
163
160
  .controls
164
161
  min-height: 271px
165
162
 
166
- @import nestable
167
163
  @import bootstrap-responsive
@@ -5,15 +5,15 @@ module Kuhsaft
5
5
  layout 'kuhsaft/cms/application'
6
6
  before_filter :set_content_locale
7
7
 
8
+ def url_options
9
+ { content_locale: I18n.locale }.merge(super)
10
+ end
11
+
8
12
  def set_content_locale
9
13
  if params[:content_locale].present?
10
14
  I18n.locale = params[:content_locale]
11
15
  end
12
16
  end
13
-
14
- def url_options
15
- { content_locale: I18n.locale }.merge(super)
16
- end
17
17
  end
18
18
  end
19
19
  end
@@ -15,8 +15,7 @@ module Kuhsaft
15
15
  @page = Kuhsaft::Page.find_by_url(url)
16
16
 
17
17
  if @page.present? && @page.redirect? && @page.redirect_url.present?
18
- redirect_url = @page.redirect_url.sub(/\A\/+/,'') # remove all preceding slashes
19
- redirect_to "/#{redirect_url}"
18
+ redirect_to "/#{@page.redirect_url}"
20
19
  elsif @page.present?
21
20
  respond_with @page
22
21
  elsif @page.blank? && respond_to?(:handle_404)
@@ -1,5 +1,5 @@
1
1
  class Kuhsaft::Asset < ActiveRecord::Base
2
- scope :by_date, order('updated_at DESC')
2
+ scope :by_date, -> { order('updated_at DESC') }
3
3
  mount_uploader :file, Kuhsaft::AssetUploader
4
4
 
5
5
  def file_type
@@ -23,4 +23,4 @@ class Kuhsaft::Asset < ActiveRecord::Base
23
23
  def filename
24
24
  try(:file).try(:file).try(:filename)
25
25
  end
26
- end
26
+ end
@@ -1,8 +1,8 @@
1
1
  module Kuhsaft
2
2
  class BrickType < ActiveRecord::Base
3
3
  attr_accessible :disabled, :class_name, :group
4
- scope :grouped, order('`group`, `id` asc')
5
- scope :enabled, where(:enabled => true)
6
- scope :constrained, lambda { |list| where(:class_name => list) }
4
+ scope :grouped, -> { order('`group`, `id` asc') }
5
+ scope :enabled, -> { where(:enabled => true) }
6
+ scope :constrained, ->(list) { where(:class_name => list) }
7
7
  end
8
8
  end
@@ -9,7 +9,6 @@ class Kuhsaft::Page < ActiveRecord::Base
9
9
  acts_as_brick_list
10
10
 
11
11
  translate :title,
12
- :page_title,
13
12
  :slug,
14
13
  :keywords,
15
14
  :description,
@@ -18,7 +17,6 @@ class Kuhsaft::Page < ActiveRecord::Base
18
17
  :url
19
18
 
20
19
  attr_accessible :title,
21
- :page_title,
22
20
  :slug,
23
21
  :redirect_url,
24
22
  :url,
@@ -29,16 +27,16 @@ class Kuhsaft::Page < ActiveRecord::Base
29
27
  :published,
30
28
  :position
31
29
 
32
- default_scope order('position ASC')
30
+ default_scope { order('position ASC') }
33
31
 
34
- scope :published, where(:published => Kuhsaft::PublishState::PUBLISHED)
32
+ scope :published, -> { where(:published => Kuhsaft::PublishState::PUBLISHED) }
35
33
 
36
34
  # TODO: cleanup page_types (content pages => nil or PageType::CONTENT
37
- scope :content_page, where(
35
+ scope :content_page, -> { where(
38
36
  ["page_type is NULL or page_type = ?",
39
- Kuhsaft::PageType::CONTENT])
37
+ Kuhsaft::PageType::CONTENT]) }
40
38
 
41
- scope :navigation, lambda{ |slug|
39
+ scope :navigation, ->(slug) {
42
40
  where(locale_attr(:slug) => slug).where(
43
41
  locale_attr(:page_type) => Kuhsaft::PageType::NAVIGATION) }
44
42
 
@@ -13,7 +13,7 @@ class Kuhsaft::AssetBrickAssetUploader < CarrierWave::Uploader::Base
13
13
  # Override the directory where uploaded files will be stored.
14
14
  # This is a sensible default for uploaders that are meant to be mounted:
15
15
  def store_dir
16
- "uploads/#{model.class.name.underscore.gsub(/^kuhsaft/,'cms')}/#{mounted_as}/#{model.id}"
16
+ "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
17
17
  end
18
18
 
19
19
  # Provide a default URL as a default if there hasn't been a file uploaded:
@@ -12,7 +12,7 @@ module Kuhsaft
12
12
  # Override the directory where uploaded files will be stored.
13
13
  # This is a sensible default for uploaders that are meant to be mounted:
14
14
  def store_dir
15
- "uploads/#{model.class.name.underscore.gsub(/^kuhsaft/,'cms')}/#{mounted_as}/#{model.id}"
15
+ "uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
16
16
  end
17
17
 
18
18
  # Provide a default URL as a default if there hasn't been a file uploaded:
@@ -10,7 +10,6 @@
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 }
14
13
  = 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 }
15
14
  = form.input :page_type, :collection => Kuhsaft::PageType.all, :prompt => false, :input_html => { :class => :span3 }
16
15
  = form.input :redirect_url, :as => :string
@@ -1,17 +1,12 @@
1
- = content_for :head do
2
- %title= @page.page_title.present? ? @page.page_title : @page.title
3
-
4
1
  - if @page.bricks.map(&:type).include? "Kuhsaft::PlaceholderBrick"
5
2
  - unless @page.blank?
6
3
  .page-content
7
- -# TODO: refactor into scopes or simplify otherwise:
8
- - @page.bricks.localized.select(&:valid?).each do |brick|
4
+ - @page.bricks.localized.each do |brick|
9
5
  = render brick
10
6
 
11
7
  - else
12
8
  - cache [@page, I18n.locale] do
13
9
  - unless @page.blank?
14
10
  .page-content
15
- -# TODO: refactor into scopes or simplify otherwise:
16
- - @page.bricks.localized.select(&:valid?).each do |brick|
11
+ - @page.bricks.localized.each do |brick|
17
12
  = render brick
@@ -5,9 +5,6 @@ de:
5
5
  admin:
6
6
  pages_nav: 'Seiten'
7
7
  assets_nav: 'Assets'
8
- cms:
9
- flash:
10
- success: 'Seite wurde erfolgreich aktualisiert'
11
8
  kuhsaft:
12
9
  page_part:
13
10
  markdown: 'Formatierter Text'
@@ -47,4 +44,4 @@ de:
47
44
  title: 'Seiten Titel'
48
45
  slug: 'URL Segment'
49
46
  page_part_type: 'Element hinzufügen'
50
- _destroy: 'Diese Element löschen'
47
+ _destroy: 'Diese Element löschen'
@@ -5,9 +5,6 @@ en:
5
5
  admin:
6
6
  pages_nav: 'Pages'
7
7
  assets_nav: 'Assets'
8
- cms:
9
- flash:
10
- success: 'Page was updated successfully'
11
8
  kuhsaft:
12
9
  page_part:
13
10
  markdown: 'Formatted Text'
@@ -8,7 +8,6 @@ de:
8
8
  kuhsaft/page:
9
9
  title: 'Titel'
10
10
  slug: 'URL Name'
11
- page_title: 'Seitentitel (im Browser)'
12
11
  keywords: 'Stichwörter'
13
12
  description: 'Beschreibung'
14
13
  redirect_url: 'Redirect URL'
@@ -15,6 +15,6 @@ Kuhsaft::Engine.routes.draw do
15
15
  resources :pages,
16
16
  :only => [:index],
17
17
  :defaults => { :locale => I18n.locale }
18
- match '(*url)' => 'pages#show', :as => :page
18
+ get '(*url)' => 'pages#show', :as => :page
19
19
  end
20
20
  end
@@ -8,11 +8,12 @@ module Kuhsaft
8
8
  require 'simple_form'
9
9
  require 'carrierwave'
10
10
  require 'rdiscount'
11
- require 'compass'
12
- require 'compass-rails'
11
+ require 'bourbon'
13
12
  require 'jquery-rails'
13
+ require 'jquery-ui-rails'
14
14
  require 'ancestry'
15
15
  require 'bootstrap-sass'
16
16
  require 'haml'
17
17
  require 'ckeditor'
18
+ require 'protected_attributes'
18
19
  end
@@ -33,7 +33,6 @@ module Kuhsaft
33
33
  {
34
34
  :against => {
35
35
  locale_attr(:title) => 'A',
36
- locale_attr(:page_title) => 'A',
37
36
  locale_attr(:keywords) => 'B',
38
37
  locale_attr(:description) => 'C',
39
38
  locale_attr(:fulltext) => 'C',
@@ -62,10 +61,9 @@ module Kuhsaft
62
61
  stmt = ""
63
62
  stmt += "#{locale_attr(:keywords)} LIKE ? OR "
64
63
  stmt += "#{locale_attr(:title)} LIKE ? OR "
65
- stmt += "#{locale_attr(:page_title)} LIKE ? OR "
66
64
  stmt += "#{locale_attr(:description)} LIKE ? OR "
67
65
  stmt += "#{locale_attr(:fulltext)} LIKE ?"
68
- where(stmt, *(["%#{query}%"] * 5))
66
+ where(stmt, *(["%#{query}%"] * 4))
69
67
  end
70
68
  }
71
69
  end
@@ -1,3 +1,3 @@
1
1
  module Kuhsaft
2
- VERSION = "1.8.6"
2
+ VERSION = "2.0.0"
3
3
  end
@@ -22,6 +22,30 @@ describe Kuhsaft::PagesController do
22
22
  end
23
23
 
24
24
  describe '#show' do
25
+ describe 'redirect' do
26
+ around(:each) do |example|
27
+ I18n.with_locale :de do
28
+ example.run
29
+ end
30
+ end
31
+
32
+ context 'when page is not a redirect page' do
33
+ it 'responds with page' do
34
+ page = FactoryGirl.create(:page, :slug => 'dumdidum', :url => 'de/dumdidum')
35
+ get :show, { :url => page.slug, :use_route => :kuhsaft }
36
+ assigns(:page).should eq(page)
37
+ end
38
+ end
39
+
40
+ context 'when page is a redirect page' do
41
+ it 'redirects to the redirected url' do
42
+ page = FactoryGirl.create(:page, :page_type => 'redirect', :slug => 'dumdidum', :url => 'de/dumdidum', :redirect_url => 'de/redirect_page')
43
+ get :show, { :url => page.slug, :use_route => :kuhsaft }
44
+ expect(response).to redirect_to("/de/redirect_page")
45
+ end
46
+ end
47
+ end
48
+
25
49
  describe 'routing' do
26
50
  context 'without url' do
27
51
  before do
@@ -66,19 +90,7 @@ describe Kuhsaft::PagesController do
66
90
  it 'redirects to the redirected url' do
67
91
  page = FactoryGirl.create(:page, :page_type => 'redirect', :slug => 'dumdidum', :url => 'de/dumdidum', :redirect_url => 'de/redirect_page')
68
92
  get :show, { :url => page.slug, :use_route => :kuhsaft }
69
- expect(response).to redirect_to('/de/redirect_page')
70
- end
71
-
72
- it 'redirects to invalid redirect urls with too many preceding slashes' do
73
- page = FactoryGirl.create(:page, :page_type => 'redirect', :slug => 'dumdidum', :url => 'de/dumdidum', :redirect_url => '///de/redirect_page')
74
- get :show, { :url => page.slug, :use_route => :kuhsaft }
75
- expect(response).to redirect_to('/de/redirect_page')
76
- end
77
-
78
- it 'redirects to root' do
79
- page = FactoryGirl.create(:page, :page_type => 'redirect', :slug => 'dumdidum', :url => 'de/dumdidum', :redirect_url => '/')
80
- get :show, { :url => page.slug, :use_route => :kuhsaft }
81
- expect(response).to redirect_to('/')
93
+ expect(response).to redirect_to("/de/redirect_page")
82
94
  end
83
95
  end
84
96
  end
@@ -1,7 +1,7 @@
1
1
  <!DOCTYPE html>
2
2
  <html>
3
3
  <head>
4
- <%= yield(:head) %>
4
+ <title>Dummy</title>
5
5
  <%= stylesheet_link_tag "application", :media => "all" %>
6
6
  <%= javascript_include_tag "application" %>
7
7
  <%= csrf_meta_tags %>
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env ruby
2
+ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3
+ load Gem.bin_path('bundler', 'bundle')
@@ -0,0 +1,4 @@
1
+ #!/usr/bin/env ruby
2
+ APP_PATH = File.expand_path('../../config/application', __FILE__)
3
+ require_relative '../config/boot'
4
+ require 'rails/commands'