kuhsaft 0.3.6 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.md +127 -77
- data/Rakefile +15 -10
- data/app/assets/javascripts/kuhsaft/application.js +2 -0
- data/app/assets/javascripts/kuhsaft/cms/application.js +16 -4
- data/app/assets/javascripts/kuhsaft/cms/customizations.js +1 -0
- data/app/assets/stylesheets/kuhsaft/application.css.sass +4 -0
- data/app/assets/stylesheets/kuhsaft/cms/application.css.sass +125 -0
- data/app/assets/stylesheets/kuhsaft/cms/customizations.css.sass +1 -0
- data/app/controllers/kuhsaft/application_controller.rb +5 -0
- data/app/controllers/kuhsaft/cms/admin_controller.rb +8 -10
- data/app/controllers/kuhsaft/cms/bricks_controller.rb +35 -0
- data/app/controllers/kuhsaft/cms/pages_controller.rb +16 -19
- data/app/controllers/kuhsaft/pages_controller.rb +4 -10
- data/app/helpers/cms_helper.rb +3 -3
- data/app/helpers/kuhsaft/application_helper.rb +21 -0
- data/app/helpers/kuhsaft/cms/application_helper.rb +10 -0
- data/app/helpers/kuhsaft/cms/pages_helper.rb +14 -0
- data/app/helpers/pages_helper.rb +18 -21
- data/app/models/kuhsaft/accordion_brick.rb +16 -0
- data/app/models/kuhsaft/accordion_item_brick.rb +22 -0
- data/app/models/kuhsaft/brick.rb +85 -0
- data/app/models/kuhsaft/brick_type.rb +7 -0
- data/app/models/kuhsaft/cms.rb +7 -0
- data/app/models/kuhsaft/cms/admin.rb +20 -0
- data/app/models/kuhsaft/column_brick.rb +23 -0
- data/app/models/kuhsaft/image_brick.rb +19 -0
- data/app/models/kuhsaft/image_size.rb +52 -0
- data/app/models/kuhsaft/link_brick.rb +19 -0
- data/app/models/kuhsaft/page.rb +83 -101
- data/app/models/kuhsaft/partition.rb +18 -0
- data/app/models/kuhsaft/placeholder_brick.rb +11 -0
- data/app/models/kuhsaft/slider_brick.rb +16 -0
- data/app/models/kuhsaft/text_brick.rb +9 -0
- data/app/models/kuhsaft/two_column_brick.rb +50 -0
- data/app/models/kuhsaft/video_brick.rb +20 -0
- data/app/uploaders/kuhsaft/asset_uploader.rb +2 -2
- data/app/uploaders/kuhsaft/image_brick_image_uploader.rb +63 -0
- data/app/views/kuhsaft/accordion_bricks/_accordion_brick.html.haml +3 -0
- data/app/{assets/stylesheets/kuhsaft/cms/base/partials/_forms.css.sass → views/kuhsaft/accordion_bricks/accordion_brick/_edit.html.haml} +0 -0
- data/app/views/kuhsaft/accordion_item_bricks/_accordion_item_brick.html.haml +8 -0
- data/app/views/kuhsaft/accordion_item_bricks/accordion_item_brick/_edit.html.haml +1 -0
- data/app/views/kuhsaft/cms/admin/_brick_type_dropdown.html.haml +10 -0
- data/app/views/kuhsaft/cms/admin/_content_language_switch.html.haml +7 -0
- data/app/views/kuhsaft/cms/admin/_empty_state.html.haml +5 -0
- data/app/views/kuhsaft/cms/admin/_main_navigation.html.haml +6 -0
- data/app/views/kuhsaft/cms/assets/index.html.haml +2 -2
- data/app/views/kuhsaft/cms/bricks/_brick_item.html.haml +38 -0
- data/app/views/kuhsaft/cms/bricks/_brick_list.html.haml +4 -0
- data/app/views/kuhsaft/cms/bricks/create.js.haml +1 -0
- data/app/views/kuhsaft/cms/bricks/destroy.js.haml +7 -0
- data/app/views/kuhsaft/cms/bricks/update.js.haml +2 -0
- data/app/views/kuhsaft/cms/pages/_branch.html.haml +17 -9
- data/app/views/kuhsaft/cms/pages/_form.html.haml +25 -60
- data/app/views/kuhsaft/cms/pages/edit.html.haml +14 -8
- data/app/views/kuhsaft/cms/pages/index.html.haml +8 -8
- data/app/views/kuhsaft/cms/pages/new.html.haml +1 -10
- data/app/views/kuhsaft/column_bricks/_column_brick.html.haml +3 -0
- data/app/views/kuhsaft/{cms/page_parts/edit.html.haml → column_bricks/column_brick/_edit.html.haml} +0 -0
- data/app/views/kuhsaft/image_bricks/_image_brick.html.haml +9 -0
- data/app/views/kuhsaft/image_bricks/image_brick/_edit.html.haml +10 -0
- data/app/views/kuhsaft/link_bricks/_link_brick.html.haml +3 -0
- data/app/views/kuhsaft/link_bricks/link_brick/_edit.html.haml +3 -0
- data/app/views/kuhsaft/pages/show.html.haml +5 -3
- data/app/views/kuhsaft/placeholder_bricks/_placeholder_brick.html.haml +2 -0
- data/app/views/kuhsaft/placeholder_bricks/placeholder_brick/_edit.html.haml +1 -0
- data/app/views/kuhsaft/slider_bricks/_slider_brick.html.haml +10 -0
- data/app/views/kuhsaft/{cms/page_parts/index.html.haml → slider_bricks/slider_brick/_edit.html.haml} +0 -0
- data/app/views/kuhsaft/text_bricks/_text_brick.html.haml +12 -0
- data/app/views/kuhsaft/text_bricks/text_brick/_edit.html.haml +2 -0
- data/app/views/kuhsaft/two_column_bricks/_two_column_brick.html.haml +3 -0
- data/app/views/kuhsaft/two_column_bricks/two_column_brick/_childs.html.haml +5 -0
- data/app/views/kuhsaft/two_column_bricks/two_column_brick/_edit.html.haml +1 -0
- data/app/views/kuhsaft/video_bricks/_video_brick.html.haml +9 -0
- data/app/views/kuhsaft/video_bricks/video_brick/_edit.html.haml +8 -0
- data/app/views/layouts/kuhsaft/cms/application.html.haml +20 -0
- data/config/initializers/devise.rb +231 -0
- data/config/initializers/simple_form.rb +142 -0
- data/config/initializers/simple_form_bootstrap.rb +45 -0
- data/config/locales/kuhsaft.en.yml +4 -1
- data/config/locales/models/kuhsaft/accordion_brick/de.yml +4 -0
- data/config/locales/models/kuhsaft/accordion_item_brick/de.yml +7 -0
- data/config/locales/models/kuhsaft/column_brick/de.yml +6 -0
- data/config/locales/models/kuhsaft/image_brick/de.yml +10 -0
- data/config/locales/models/kuhsaft/image_size/de.yml +13 -0
- data/config/locales/models/kuhsaft/link_brick/de.yml +9 -0
- data/config/locales/models/kuhsaft/page/de.yml +17 -0
- data/config/locales/models/kuhsaft/placeholder_brick/de.yml +8 -0
- data/config/locales/models/kuhsaft/slider_brick/de.yml +4 -0
- data/config/locales/models/kuhsaft/text_brick/de.yml +8 -0
- data/config/locales/models/kuhsaft/two_column_brick/de.yml +7 -0
- data/config/locales/models/kuhsaft/video_brick/de.yml +9 -0
- data/config/locales/simple_form.en.yml +26 -0
- data/config/locales/views/kuhsaft/cms/admin/de.yml +10 -0
- data/config/locales/views/kuhsaft/cms/bricks/de.yml +8 -0
- data/config/locales/views/kuhsaft/cms/pages/de.yml +9 -0
- data/config/locales/views/kuhsaft/cms/video_bricks/de.yml +7 -0
- data/config/locales/views/kuhsaft/text_brick/de.yml +6 -0
- data/config/locales/views/layouts/de.yml +6 -0
- data/config/routes.rb +10 -11
- data/db/migrate/01_create_kuhsaft_pages.rb +31 -0
- data/db/migrate/02_create_kuhsaft_bricks.rb +23 -0
- data/db/migrate/03_create_kuhsaft_brick_types.rb +12 -0
- data/db/migrate/04_create_kuhsaft_assets.rb +10 -0
- data/db/migrate/05_create_kuhsaft_cms_admins.rb +46 -0
- data/db/migrate/06_add_template_name_to_kuhsaft_bricks.rb +7 -0
- data/db/seeds.rb +14 -0
- data/lib/generators/kuhsaft/translations/add_generator.rb +26 -0
- data/lib/kuhsaft.rb +8 -1
- data/lib/kuhsaft/brick_list.rb +71 -0
- data/lib/kuhsaft/engine.rb +17 -12
- data/lib/kuhsaft/partial_extractor.rb +21 -0
- data/lib/kuhsaft/translatable.rb +40 -0
- data/lib/kuhsaft/version.rb +1 -1
- data/lib/tasks/kuhsaft_tasks.rake +10 -0
- data/lib/templates/kuhsaft/translations/add_translation.html.erb +13 -0
- data/spec/dummy/Rakefile +1 -1
- data/spec/dummy/app/assets/javascripts/application.js +9 -3
- data/spec/dummy/app/assets/stylesheets/application.css +11 -5
- data/spec/dummy/app/controllers/application_controller.rb +0 -6
- data/spec/dummy/app/views/layouts/application.html.erb +1 -1
- data/spec/dummy/config/application.rb +24 -7
- data/spec/dummy/config/boot.rb +3 -2
- data/spec/dummy/config/database.yml +6 -3
- data/spec/dummy/config/environments/development.rb +8 -1
- data/spec/dummy/config/environments/production.rb +9 -2
- data/spec/dummy/config/environments/test.rb +4 -9
- data/spec/dummy/config/initializers/inflections.rb +5 -0
- data/spec/dummy/config/initializers/secret_token.rb +1 -1
- data/spec/dummy/config/initializers/session_store.rb +1 -1
- data/spec/dummy/config/initializers/wrap_parameters.rb +1 -1
- data/spec/dummy/config/locales/en.yml +2 -2
- data/spec/dummy/config/routes.rb +2 -57
- data/spec/dummy/db/{migrate/.gitkeep → .gitkeep} +0 -0
- data/spec/dummy/public/500.html +0 -1
- data/spec/dummy/{lib/tasks → public/stylesheets}/.gitkeep +0 -0
- data/spec/factories.rb +11 -17
- data/spec/features/cms_auth_spec.rb +9 -0
- data/spec/features/cms_pages_spec.rb +23 -0
- data/spec/helpers/kuhsaft/cms/application_helper_spec.rb +25 -0
- data/spec/lib/brick_list_spec.rb +39 -0
- data/spec/lib/engine_spec.rb +25 -0
- data/spec/lib/translatable_spec.rb +85 -0
- data/spec/models/accordion_brick_spec.rb +32 -0
- data/spec/models/accordion_item_brick_spec.rb +50 -0
- data/spec/models/asset_spec.rb +25 -23
- data/spec/models/brick_spec.rb +110 -0
- data/spec/models/cms/admin_spec.rb +26 -0
- data/spec/models/column_brick_spec.rb +32 -0
- data/spec/models/image_brick_spec.rb +36 -0
- data/spec/models/image_size_spec.rb +36 -0
- data/spec/models/link_brick_spec.rb +45 -0
- data/spec/models/page_spec.rb +262 -281
- data/spec/models/placeholder_brick_spec.rb +40 -0
- data/spec/models/slider_brick_spec.rb +20 -0
- data/spec/models/text_brick_spec.rb +14 -0
- data/spec/models/two_column_brick_spec.rb +72 -0
- data/spec/models/video_brick_spec.rb +26 -0
- data/spec/spec_helper.rb +60 -51
- data/spec/support/kuhsaft_spec_helper.rb +4 -28
- data/spec/support/request_macros.rb +19 -0
- data/vendor/assets/javascripts/redactor.min.js +12 -0
- data/vendor/assets/stylesheets/redactor.css +692 -0
- metadata +402 -346
- data/.gitignore +0 -19
- data/.rspec +0 -2
- data/.rvmrc +0 -47
- data/CHANGELOG.md +0 -81
- data/Gemfile +0 -2
- data/Guardfile +0 -25
- data/LICENSE +0 -7
- data/app/assets/images/kuhsaft/add-child-page.png +0 -0
- data/app/assets/images/kuhsaft/closedhand.cur +0 -0
- data/app/assets/images/kuhsaft/delete.png +0 -0
- data/app/assets/images/kuhsaft/header-bg.jpg +0 -0
- data/app/assets/images/kuhsaft/module-nav-tab-bg.png +0 -0
- data/app/assets/images/kuhsaft/openhand.cur +0 -0
- data/app/assets/images/kuhsaft/page-edit-icon.png +0 -0
- data/app/assets/images/kuhsaft/page-new-icon.png +0 -0
- data/app/assets/images/kuhsaft/page-part-draggable-area.png +0 -0
- data/app/assets/images/kuhsaft/page-tree-breadcrumb-arrow.png +0 -0
- data/app/assets/images/kuhsaft/pages-breadcrumb-icon.png +0 -0
- data/app/assets/images/kuhsaft/tab-bg.png +0 -0
- data/app/assets/images/kuhsaft/toggle-arrow-closed.png +0 -0
- data/app/assets/images/kuhsaft/toggle-arrow-open.png +0 -0
- data/app/assets/images/kuhsaft/wrapper-bg.png +0 -0
- data/app/assets/javascripts/kuhsaft/cms/backend.js +0 -34
- data/app/assets/javascripts/kuhsaft/cms/jquery-ui-1.8.12.custom.min.js +0 -192
- data/app/assets/javascripts/kuhsaft/cms/jquery.elastic.source.js +0 -161
- data/app/assets/javascripts/kuhsaft/cms/jquery.min.js +0 -18
- data/app/assets/javascripts/kuhsaft/cms/jquery_ujs.js +0 -336
- data/app/assets/stylesheets/kuhsaft/cms/application.css +0 -6
- data/app/assets/stylesheets/kuhsaft/cms/base/base.css.sass +0 -9
- data/app/assets/stylesheets/kuhsaft/cms/base/partials/_assets.css.sass +0 -15
- data/app/assets/stylesheets/kuhsaft/cms/base/partials/_buttons.css.sass +0 -34
- data/app/assets/stylesheets/kuhsaft/cms/base/partials/_generic.css.sass +0 -342
- data/app/assets/stylesheets/kuhsaft/cms/base/partials/_simple_form.css.sass +0 -76
- data/app/controllers/kuhsaft/cms/page_parts_controller.rb +0 -34
- data/app/models/kuhsaft/localized_page.rb +0 -81
- data/app/models/kuhsaft/page_part.rb +0 -12
- data/app/models/kuhsaft/page_part/content.rb +0 -76
- data/app/models/kuhsaft/page_part/markdown.rb +0 -8
- data/app/views/kuhsaft/cms/page_parts/destroy.js.haml +0 -1
- data/app/views/kuhsaft/cms/page_parts/new.html.haml +0 -0
- data/app/views/kuhsaft/cms/page_parts/show.html.haml +0 -0
- data/app/views/kuhsaft/cms/page_parts/update.js.haml +0 -0
- data/app/views/kuhsaft/page_part/markdowns/_edit_markdown.html.haml +0 -1
- data/app/views/kuhsaft/page_part/markdowns/_show_markdown.html.haml +0 -1
- data/app/views/kuhsaft/pages/index.html.haml +0 -0
- data/app/views/layouts/kuhsaft/admin.html.haml +0 -35
- data/config/initializers/generators.rb +0 -7
- data/config/initializers/page_parts.rb +0 -17
- data/kuhsaft.gemspec +0 -39
- data/lib/generators/kuhsaft/install/assets_generator.rb +0 -12
- data/lib/generators/kuhsaft/install/migrations_generator.rb +0 -43
- data/lib/templates/kuhsaft/install/acts_as_taggable_on_migration.rb +0 -37
- data/lib/templates/kuhsaft/install/add_fulltext_to_localized_page.rb +0 -9
- data/lib/templates/kuhsaft/install/add_page_type_to_localized_pages.rb +0 -9
- data/lib/templates/kuhsaft/install/add_published_at_to_localized_pages.rb +0 -9
- data/lib/templates/kuhsaft/install/add_tags_to_page_part_contents.rb +0 -9
- data/lib/templates/kuhsaft/install/add_type_to_page_part_contents.rb +0 -9
- data/lib/templates/kuhsaft/install/add_url_to_localized_pages.rb +0 -9
- data/lib/templates/kuhsaft/install/create_assets.rb +0 -12
- data/lib/templates/kuhsaft/install/create_kuhsaft_localized_pages.rb +0 -19
- data/lib/templates/kuhsaft/install/create_kuhsaft_pages.rb +0 -14
- data/lib/templates/kuhsaft/install/create_page_part_contents.rb +0 -14
- data/spec/controllers/cms_assets_controller_spec.rb +0 -26
- data/spec/controllers/cms_pages_controller_spec.rb +0 -65
- data/spec/controllers/page_parts_controller_spec.rb +0 -60
- data/spec/controllers/pages_controller_spec.rb +0 -30
- data/spec/dummy/app/assets/images/rails.png +0 -0
- data/spec/helpers/cms_helper_spec.rb +0 -22
- data/spec/helpers/pages_helper_spec.rb +0 -119
- data/spec/integration/navigation_spec.rb +0 -9
- data/spec/models/localized_page_spec.rb +0 -266
- data/spec/models/page_part_content_spec.rb +0 -95
- data/spec/models/page_part_spec.rb +0 -17
- data/spec/requests/cms_pages_spec.rb +0 -27
- data/spec/routing/assets_routing_spec.rb +0 -63
- data/spec/routing/page_part_routing_spec.rb +0 -70
- data/spec/routing/pages_routing_spec.rb +0 -74
@@ -0,0 +1,26 @@
|
|
1
|
+
require 'rails/generators'
|
2
|
+
require 'rails/generators/migration'
|
3
|
+
require 'rails/generators/active_record'
|
4
|
+
|
5
|
+
module Kuhsaft
|
6
|
+
module Translations
|
7
|
+
class Add < Rails::Generators::Base
|
8
|
+
include Rails::Generators::Migration
|
9
|
+
|
10
|
+
source_root(File.join(Kuhsaft::Engine.root, '/lib/templates/kuhsaft/translations'))
|
11
|
+
argument :locale, :type => :string
|
12
|
+
|
13
|
+
def self.next_migration_number(dirname)
|
14
|
+
ActiveRecord::Generators::Base.next_migration_number(dirname)
|
15
|
+
end
|
16
|
+
|
17
|
+
def get_locale
|
18
|
+
locale.downcase.underscore
|
19
|
+
end
|
20
|
+
def create_locale_migration_file
|
21
|
+
migration_template('add_translation.html.erb', Rails.root.join('db', 'migrate', "add_#{get_locale}_translation.rb"))
|
22
|
+
end
|
23
|
+
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
data/lib/kuhsaft.rb
CHANGED
@@ -1,9 +1,16 @@
|
|
1
|
+
require "kuhsaft/engine"
|
2
|
+
|
1
3
|
module Kuhsaft
|
2
4
|
require 'kuhsaft/engine'
|
3
5
|
require 'kuhsaft/orderable'
|
6
|
+
require 'kuhsaft/translatable'
|
7
|
+
require 'kuhsaft/brick_list'
|
8
|
+
require 'kuhsaft/partial_extractor'
|
4
9
|
require 'simple_form'
|
5
10
|
require 'carrierwave'
|
6
11
|
require 'rdiscount'
|
7
12
|
require 'compass'
|
8
|
-
require '
|
13
|
+
require 'ancestry'
|
14
|
+
require 'devise'
|
15
|
+
require 'bootstrap-sass'
|
9
16
|
end
|
@@ -0,0 +1,71 @@
|
|
1
|
+
module Kuhsaft
|
2
|
+
module BrickList
|
3
|
+
|
4
|
+
def self.included(base)
|
5
|
+
def base.acts_as_brick_list
|
6
|
+
self.has_many :bricks, :class_name => 'Kuhsaft::Brick', :dependent => :destroy, :as => :brick_list
|
7
|
+
end
|
8
|
+
end
|
9
|
+
|
10
|
+
def to_brick_item_id
|
11
|
+
"brick-item-#{id}-#{self.class.to_s.underscore.gsub('/', '_')}"
|
12
|
+
end
|
13
|
+
|
14
|
+
def to_brick_list_id
|
15
|
+
"brick-list-#{id}-#{self.class.to_s.underscore.gsub('/', '_')}"
|
16
|
+
end
|
17
|
+
|
18
|
+
#
|
19
|
+
# See TwoColumnBrick as an example, which can only have to ColumBricks
|
20
|
+
# and the User should not be able to add more
|
21
|
+
#
|
22
|
+
def user_can_add_childs?
|
23
|
+
true
|
24
|
+
end
|
25
|
+
|
26
|
+
#
|
27
|
+
# return true if the user should be able to delete the brick through the UI.
|
28
|
+
# return false if not.
|
29
|
+
# See ColumnBrick, which should not be deleted inside the TwoColumnBrick
|
30
|
+
#
|
31
|
+
def user_can_delete?
|
32
|
+
true
|
33
|
+
end
|
34
|
+
|
35
|
+
#
|
36
|
+
# Return true if the user can hit the save button
|
37
|
+
# Return false if not
|
38
|
+
# See column brick, which has no data on its own except childs, therefore no button is needed
|
39
|
+
#
|
40
|
+
def user_can_save?
|
41
|
+
true
|
42
|
+
end
|
43
|
+
|
44
|
+
#
|
45
|
+
# When true, the brick must implement the rendering of its childs by itself
|
46
|
+
# by using the _childs partial
|
47
|
+
# When false, the default BrickList rendering is used
|
48
|
+
# See _brick_item partial
|
49
|
+
#
|
50
|
+
def renders_own_childs?
|
51
|
+
false
|
52
|
+
end
|
53
|
+
|
54
|
+
#
|
55
|
+
# Return relevant fulltext information for this brick (e.g: it's name, description etc ).
|
56
|
+
# It will be stored in the related Page.
|
57
|
+
# Implement how you see fit.
|
58
|
+
#
|
59
|
+
def collect_fulltext
|
60
|
+
if respond_to?(:bricks)
|
61
|
+
bricks.localized.inject('') do |text, brick|
|
62
|
+
text << brick.collect_fulltext
|
63
|
+
text
|
64
|
+
end
|
65
|
+
else
|
66
|
+
''
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
end
|
71
|
+
end
|
data/lib/kuhsaft/engine.rb
CHANGED
@@ -1,18 +1,23 @@
|
|
1
|
-
require 'rails'
|
2
1
|
module Kuhsaft
|
3
|
-
class Engine < Rails::Engine
|
4
|
-
initializer 'kuhsaft.init_stylesheets' do |app|
|
5
|
-
Sass::Plugin.add_template_location File.join(Kuhsaft::Engine.root, 'app', 'stylesheets'), File.join(Rails.root, 'public', 'stylesheets')
|
6
|
-
end
|
7
2
|
|
8
|
-
|
9
|
-
|
3
|
+
class ImageSizeDelegator
|
4
|
+
def method_missing(method, *args, &block)
|
5
|
+
Kuhsaft::ImageSize.send(method, *args, &block)
|
6
|
+
rescue NoMethodError
|
7
|
+
super
|
10
8
|
end
|
9
|
+
end
|
11
10
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
11
|
+
class Engine < ::Rails::Engine
|
12
|
+
isolate_namespace Kuhsaft
|
13
|
+
|
14
|
+
config.i18n.fallbacks = [:de]
|
15
|
+
config.i18n.load_path += Dir[Kuhsaft::Engine.root.join('config', 'locales', '**', '*.{yml}').to_s]
|
16
|
+
|
17
|
+
# defaults to nil
|
18
|
+
config.sublime_video_token = nil
|
19
|
+
|
20
|
+
# delegate image size config to ImageSize class
|
21
|
+
config.image_sizes = ImageSizeDelegator.new
|
17
22
|
end
|
18
23
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Kuhsaft
|
2
|
+
class PartialExtractor
|
3
|
+
def extract_filenames(partial_paths)
|
4
|
+
partials = []
|
5
|
+
partial_paths.each do |partial|
|
6
|
+
filename = File.basename(partial).split('.', 0).first
|
7
|
+
filename.slice!(0)
|
8
|
+
partials << filename
|
9
|
+
end
|
10
|
+
partials.collect {|d| [I18n.t(d), d]}
|
11
|
+
end
|
12
|
+
|
13
|
+
def collect_partials(path)
|
14
|
+
extract_filenames(Dir.glob("#{Rails.root}#{path}"))
|
15
|
+
end
|
16
|
+
|
17
|
+
def partials(path)
|
18
|
+
@partials = collect_partials(path)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,40 @@
|
|
1
|
+
module Kuhsaft
|
2
|
+
module Translatable
|
3
|
+
|
4
|
+
def self.included(base)
|
5
|
+
base.extend ClassMethods
|
6
|
+
end
|
7
|
+
|
8
|
+
module ClassMethods
|
9
|
+
def translate *args
|
10
|
+
args.each do |attr_name|
|
11
|
+
define_method attr_name do
|
12
|
+
send "#{attr_name}_#{I18n.locale}"
|
13
|
+
end
|
14
|
+
|
15
|
+
define_method "#{attr_name}?" do
|
16
|
+
send "#{attr_name}_#{I18n.locale}?"
|
17
|
+
end
|
18
|
+
|
19
|
+
define_method "#{attr_name}=" do |val|
|
20
|
+
send "#{attr_name}_#{I18n.locale}=", val
|
21
|
+
end
|
22
|
+
|
23
|
+
define_method "find_by_#{attr_name}" do |val|
|
24
|
+
send "find_by_#{attr_name}_#{I18n.locale}", val
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
def locale_attr attr_name
|
30
|
+
"#{attr_name}_#{I18n.locale}"
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
def locale_attr attr_name
|
35
|
+
"#{attr_name}_#{I18n.locale}"
|
36
|
+
end
|
37
|
+
|
38
|
+
|
39
|
+
end
|
40
|
+
end
|
data/lib/kuhsaft/version.rb
CHANGED
@@ -0,0 +1,13 @@
|
|
1
|
+
class Add<%= get_locale.classify %>Translation < ActiveRecord::Migration
|
2
|
+
|
3
|
+
def change
|
4
|
+
add_column :kuhsaft_pages, :title_<%= get_locale %>, :string
|
5
|
+
add_column :kuhsaft_pages, :slug_<%= get_locale %>, :string
|
6
|
+
add_column :kuhsaft_pages, :keywords_<%= get_locale %>, :string
|
7
|
+
add_column :kuhsaft_pages, :description_<%= get_locale %>, :text
|
8
|
+
add_column :kuhsaft_pages, :body_<%= get_locale %>, :text
|
9
|
+
add_column :kuhsaft_pages, :url_<%= get_locale %>, :text
|
10
|
+
add_column :kuhsaft_pages, :fulltext_<%= get_locale %>, :text
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
data/spec/dummy/Rakefile
CHANGED
@@ -1,7 +1,7 @@
|
|
1
|
+
#!/usr/bin/env rake
|
1
2
|
# Add your own tasks in files placed in lib/tasks ending in .rake,
|
2
3
|
# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
|
3
4
|
|
4
5
|
require File.expand_path('../config/application', __FILE__)
|
5
|
-
require 'rake'
|
6
6
|
|
7
7
|
Dummy::Application.load_tasks
|
@@ -1,9 +1,15 @@
|
|
1
|
-
// This is a manifest file that'll be compiled into
|
2
|
-
//
|
3
|
-
//
|
1
|
+
// This is a manifest file that'll be compiled into application.js, which will include all the files
|
2
|
+
// listed below.
|
3
|
+
//
|
4
|
+
// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
|
5
|
+
// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
|
6
|
+
//
|
4
7
|
// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
|
5
8
|
// the compiled file.
|
6
9
|
//
|
10
|
+
// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
|
11
|
+
// GO AFTER THE REQUIRES BELOW.
|
12
|
+
//
|
7
13
|
//= require jquery
|
8
14
|
//= require jquery_ujs
|
9
15
|
//= require_tree .
|
@@ -1,7 +1,13 @@
|
|
1
1
|
/*
|
2
|
-
* This is a manifest file that'll
|
3
|
-
*
|
4
|
-
*
|
2
|
+
* This is a manifest file that'll be compiled into application.css, which will include all the files
|
3
|
+
* listed below.
|
4
|
+
*
|
5
|
+
* Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
|
6
|
+
* or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
|
7
|
+
*
|
8
|
+
* You're free to add application-wide styles to this file and they'll appear at the top of the
|
9
|
+
* compiled file, but it's generally better to create a new file per style scope.
|
10
|
+
*
|
5
11
|
*= require_self
|
6
|
-
*= require_tree .
|
7
|
-
*/
|
12
|
+
*= require_tree .
|
13
|
+
*/
|
@@ -1,9 +1,3 @@
|
|
1
1
|
class ApplicationController < ActionController::Base
|
2
2
|
protect_from_forgery
|
3
|
-
before_filter :available_locales
|
4
|
-
|
5
|
-
def available_locales
|
6
|
-
Kuhsaft::Page.translation_locales = ['de', 'en', 'fr']
|
7
|
-
Kuhsaft::Page.current_translation_locale = params[:locale] if params[:locale].present?
|
8
|
-
end
|
9
3
|
end
|
@@ -1,13 +1,15 @@
|
|
1
1
|
require File.expand_path('../boot', __FILE__)
|
2
2
|
|
3
|
-
|
3
|
+
# Pick the frameworks you want:
|
4
|
+
require "active_record/railtie"
|
5
|
+
require "action_controller/railtie"
|
6
|
+
require "action_mailer/railtie"
|
7
|
+
require "active_resource/railtie"
|
8
|
+
require "sprockets/railtie"
|
9
|
+
# require "rails/test_unit/railtie"
|
4
10
|
|
5
|
-
|
6
|
-
|
7
|
-
Bundler.require *Rails.groups(:assets => %w(development test))
|
8
|
-
# If you want your assets lazily compiled in production, use this line
|
9
|
-
# Bundler.require(:default, :assets, Rails.env)
|
10
|
-
end
|
11
|
+
Bundler.require
|
12
|
+
require "kuhsaft"
|
11
13
|
|
12
14
|
module Dummy
|
13
15
|
class Application < Rails::Application
|
@@ -39,6 +41,20 @@ module Dummy
|
|
39
41
|
# Configure sensitive parameters which will be filtered from the log file.
|
40
42
|
config.filter_parameters += [:password]
|
41
43
|
|
44
|
+
# Enable escaping HTML in JSON.
|
45
|
+
config.active_support.escape_html_entities_in_json = true
|
46
|
+
|
47
|
+
# Use SQL instead of Active Record's schema dumper when creating the database.
|
48
|
+
# This is necessary if your schema can't be completely dumped by the schema dumper,
|
49
|
+
# like if you have constraints or database-specific column types
|
50
|
+
# config.active_record.schema_format = :sql
|
51
|
+
|
52
|
+
# Enforce whitelist mode for mass assignment.
|
53
|
+
# This will create an empty whitelist of attributes available for mass-assignment for all models
|
54
|
+
# in your app. As such, your models will need to explicitly whitelist or blacklist accessible
|
55
|
+
# parameters by using an attr_accessible or attr_protected declaration.
|
56
|
+
config.active_record.whitelist_attributes = true
|
57
|
+
|
42
58
|
# Enable the asset pipeline
|
43
59
|
config.assets.enabled = true
|
44
60
|
|
@@ -46,3 +62,4 @@ module Dummy
|
|
46
62
|
config.assets.version = '1.0'
|
47
63
|
end
|
48
64
|
end
|
65
|
+
|
data/spec/dummy/config/boot.rb
CHANGED
@@ -3,7 +3,8 @@ gemfile = File.expand_path('../../../../Gemfile', __FILE__)
|
|
3
3
|
|
4
4
|
if File.exist?(gemfile)
|
5
5
|
ENV['BUNDLE_GEMFILE'] = gemfile
|
6
|
-
require 'bundler
|
6
|
+
require 'bundler'
|
7
|
+
Bundler.setup
|
7
8
|
end
|
8
9
|
|
9
|
-
$:.unshift File.expand_path('../../../../lib', __FILE__)
|
10
|
+
$:.unshift File.expand_path('../../../../lib', __FILE__)
|
@@ -1,5 +1,8 @@
|
|
1
1
|
# SQLite version 3.x
|
2
|
-
# gem install sqlite3
|
2
|
+
# gem install sqlite3
|
3
|
+
#
|
4
|
+
# Ensure the SQLite 3 gem is defined in your Gemfile
|
5
|
+
# gem 'sqlite3'
|
3
6
|
development:
|
4
7
|
adapter: sqlite3
|
5
8
|
database: db/development.sqlite3
|
@@ -12,8 +15,8 @@ development:
|
|
12
15
|
test:
|
13
16
|
adapter: sqlite3
|
14
17
|
database: db/test.sqlite3
|
15
|
-
pool:
|
16
|
-
timeout:
|
18
|
+
pool: 5
|
19
|
+
timeout: 5000
|
17
20
|
|
18
21
|
production:
|
19
22
|
adapter: sqlite3
|
@@ -2,7 +2,7 @@ Dummy::Application.configure do
|
|
2
2
|
# Settings specified here will take precedence over those in config/application.rb
|
3
3
|
|
4
4
|
# In the development environment your application's code is reloaded on
|
5
|
-
# every request.
|
5
|
+
# every request. This slows down response time but is perfect for development
|
6
6
|
# since you don't have to restart the web server when you make code changes.
|
7
7
|
config.cache_classes = false
|
8
8
|
|
@@ -22,6 +22,13 @@ Dummy::Application.configure do
|
|
22
22
|
# Only use best-standards-support built into browsers
|
23
23
|
config.action_dispatch.best_standards_support = :builtin
|
24
24
|
|
25
|
+
# Raise exception on mass assignment protection for Active Record models
|
26
|
+
config.active_record.mass_assignment_sanitizer = :strict
|
27
|
+
|
28
|
+
# Log the query plan for queries taking more than this (works
|
29
|
+
# with SQLite, MySQL, and PostgreSQL)
|
30
|
+
config.active_record.auto_explain_threshold_in_seconds = 0.5
|
31
|
+
|
25
32
|
# Do not compress assets
|
26
33
|
config.assets.compress = false
|
27
34
|
|
@@ -20,7 +20,7 @@ Dummy::Application.configure do
|
|
20
20
|
# Generate digests for assets URLs
|
21
21
|
config.assets.digest = true
|
22
22
|
|
23
|
-
# Defaults to
|
23
|
+
# Defaults to nil and saved in location specified by config.assets.prefix
|
24
24
|
# config.assets.manifest = YOUR_PATH
|
25
25
|
|
26
26
|
# Specifies the header that your server uses for sending files
|
@@ -33,8 +33,11 @@ Dummy::Application.configure do
|
|
33
33
|
# See everything in the log (default is :info)
|
34
34
|
# config.log_level = :debug
|
35
35
|
|
36
|
+
# Prepend all log lines with the following tags
|
37
|
+
# config.log_tags = [ :subdomain, :uuid ]
|
38
|
+
|
36
39
|
# Use a different logger for distributed setups
|
37
|
-
# config.logger = SyslogLogger.new
|
40
|
+
# config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
|
38
41
|
|
39
42
|
# Use a different cache store in production
|
40
43
|
# config.cache_store = :mem_cache_store
|
@@ -57,4 +60,8 @@ Dummy::Application.configure do
|
|
57
60
|
|
58
61
|
# Send deprecation notices to registered listeners
|
59
62
|
config.active_support.deprecation = :notify
|
63
|
+
|
64
|
+
# Log the query plan for queries taking more than this (works
|
65
|
+
# with SQLite, MySQL, and PostgreSQL)
|
66
|
+
# config.active_record.auto_explain_threshold_in_seconds = 0.5
|
60
67
|
end
|