sunrise-cms 0.6.2 → 0.6.3

Sign up to get free protection for your applications and to get access to all the features.
Files changed (88) hide show
  1. data/CHANGELOG.rdoc +5 -0
  2. data/README.md +11 -0
  3. data/app/assets/stylesheets/devise/application.css +6 -0
  4. data/app/assets/stylesheets/devise/style.css +171 -0
  5. data/app/assets/stylesheets/sunrise/customize.css +19 -1
  6. data/app/views/layouts/sunrise/devise.html.erb +19 -0
  7. data/app/views/sunrise/manager/_controls.html.erb +0 -0
  8. data/app/views/sunrise/manager/_header_show.html.erb +42 -0
  9. data/app/views/sunrise/manager/structures/thumbs/_record.html.erb +2 -2
  10. data/app/views/sunrise/manager/structures/tree/_record.html.erb +3 -3
  11. data/app/views/sunrise/manager/table/_model_filter.html.erb +2 -2
  12. data/app/views/sunrise/manager/table/_record.html.erb +2 -2
  13. data/app/views/sunrise/manager/thumbs/_model_filter.html.erb +2 -2
  14. data/app/views/sunrise/manager/thumbs/_record.html.erb +7 -5
  15. data/lib/sunrise/version.rb +1 -1
  16. data/spec/dummy/log/test.log +6032 -0
  17. data/spec/dummy/public/uploads/avatar/content_rails.png +0 -0
  18. data/spec/dummy/public/uploads/avatar/rails.png +0 -0
  19. data/spec/dummy/public/uploads/avatar/thumb_rails.png +0 -0
  20. data/spec/dummy/public/uploads/tmp/20130328-1652-10572-0194/silicon_valley.jpg +0 -0
  21. data/spec/dummy/public/uploads/tmp/20130328-1652-10572-0194/small_silicon_valley.jpg +0 -0
  22. data/spec/dummy/public/uploads/tmp/20130328-1652-10572-0194/thumb_silicon_valley.jpg +0 -0
  23. data/spec/dummy/public/uploads/tmp/20130328-1652-10572-2067/rails.png +0 -0
  24. data/spec/dummy/public/uploads/tmp/20130328-1652-10572-3421/rails.png +0 -0
  25. data/spec/dummy/public/uploads/tmp/20130328-1652-10572-3421/small_rails.png +0 -0
  26. data/spec/dummy/public/uploads/tmp/20130328-1652-10572-3421/thumb_rails.png +0 -0
  27. data/spec/dummy/public/uploads/tmp/20130328-1652-10572-4629/rails.png +0 -0
  28. data/spec/dummy/public/uploads/tmp/20130328-1652-10572-7745/rails.png +0 -0
  29. data/spec/dummy/public/uploads/tmp/20130328-1652-10572-8054/rails.png +0 -0
  30. data/spec/dummy/public/uploads/tmp/20130328-1652-10572-8054/small_rails.png +0 -0
  31. data/spec/dummy/public/uploads/tmp/20130328-1652-10572-8054/thumb_rails.png +0 -0
  32. data/spec/dummy/public/uploads/tmp/20130328-1652-10572-9023/rails.png +0 -0
  33. data/spec/dummy/public/uploads/tmp/20130328-1652-10572-9287/rails.png +0 -0
  34. data/spec/dummy/public/uploads/tmp/20130328-1652-10572-9287/small_rails.png +0 -0
  35. data/spec/dummy/public/uploads/tmp/20130328-1652-10572-9287/thumb_rails.png +0 -0
  36. data/spec/dummy/public/uploads/tmp/20130328-1652-10572-9992/rails.png +0 -0
  37. data/spec/dummy/public/uploads/tmp/20130328-1817-13734-0058/silicon_valley.jpg +0 -0
  38. data/spec/dummy/public/uploads/tmp/20130328-1817-13734-0058/small_silicon_valley.jpg +0 -0
  39. data/spec/dummy/public/uploads/tmp/20130328-1817-13734-0058/thumb_silicon_valley.jpg +0 -0
  40. data/spec/dummy/public/uploads/tmp/20130328-1817-13734-0280/rails.png +0 -0
  41. data/spec/dummy/public/uploads/tmp/20130328-1817-13734-0319/rails.png +0 -0
  42. data/spec/dummy/public/uploads/tmp/20130328-1817-13734-1339/rails.png +0 -0
  43. data/spec/dummy/public/uploads/tmp/20130328-1817-13734-3744/rails.png +0 -0
  44. data/spec/dummy/public/uploads/tmp/20130328-1817-13734-6109/rails.png +0 -0
  45. data/spec/dummy/public/uploads/tmp/20130328-1817-13734-6109/small_rails.png +0 -0
  46. data/spec/dummy/public/uploads/tmp/20130328-1817-13734-6109/thumb_rails.png +0 -0
  47. data/spec/dummy/public/uploads/tmp/20130328-1817-13734-7542/rails.png +0 -0
  48. data/spec/dummy/public/uploads/tmp/20130328-1817-13734-7542/small_rails.png +0 -0
  49. data/spec/dummy/public/uploads/tmp/20130328-1817-13734-7542/thumb_rails.png +0 -0
  50. data/spec/dummy/public/uploads/tmp/20130328-1817-13734-7559/rails.png +0 -0
  51. data/spec/dummy/public/uploads/tmp/20130328-1817-13734-7855/rails.png +0 -0
  52. data/spec/dummy/public/uploads/tmp/20130328-1817-13734-7855/small_rails.png +0 -0
  53. data/spec/dummy/public/uploads/tmp/20130328-1817-13734-7855/thumb_rails.png +0 -0
  54. data/spec/tmp/app/models/defaults/ability.rb +18 -0
  55. data/spec/tmp/app/models/defaults/asset.rb +7 -0
  56. data/spec/tmp/app/models/defaults/attachment_file.rb +5 -0
  57. data/spec/tmp/app/models/defaults/avatar.rb +7 -0
  58. data/spec/tmp/app/models/defaults/picture.rb +7 -0
  59. data/spec/tmp/app/models/defaults/position_type.rb +7 -0
  60. data/spec/tmp/app/models/defaults/role_type.rb +8 -0
  61. data/spec/tmp/app/models/defaults/settings.rb +6 -0
  62. data/spec/tmp/app/models/defaults/structure.rb +10 -0
  63. data/spec/tmp/app/models/defaults/structure_type.rb +9 -0
  64. data/spec/tmp/app/models/defaults/user.rb +14 -0
  65. data/spec/tmp/app/models/sunrise/sunrise_navigation.rb +14 -0
  66. data/spec/tmp/app/models/sunrise/sunrise_page.rb +10 -0
  67. data/spec/tmp/app/models/sunrise/sunrise_structure.rb +35 -0
  68. data/spec/tmp/app/models/sunrise/sunrise_user.rb +50 -0
  69. data/spec/tmp/app/uploaders/attachment_file_uploader.rb +5 -0
  70. data/spec/tmp/app/uploaders/avatar_uploader.rb +15 -0
  71. data/spec/tmp/app/uploaders/picture_uploader.rb +15 -0
  72. data/spec/tmp/app/views/layouts/application.html.erb +22 -0
  73. data/spec/tmp/app/views/pages/show.html.erb +2 -0
  74. data/spec/tmp/app/views/shared/_notice.html.erb +17 -0
  75. data/spec/tmp/config/application.rb +63 -0
  76. data/spec/tmp/config/database.yml.sample +34 -0
  77. data/spec/tmp/config/initializers/sunrise.rb +51 -0
  78. data/spec/tmp/config/logrotate-config.sample +9 -0
  79. data/spec/tmp/config/nginx-config.sample +67 -0
  80. data/spec/tmp/config/routes.rb +10 -0
  81. data/spec/tmp/db/seeds.rb +30 -0
  82. data/spec/tmp/spec/controllers/pages_controller_spec.rb +22 -0
  83. data/spec/tmp/spec/controllers/welcome_controller_spec.rb +18 -0
  84. data/spec/tmp/spec/factories/structure_factory.rb +22 -0
  85. data/spec/tmp/spec/factories/user_factory.rb +61 -0
  86. data/spec/tmp/spec/spec_helper.rb +37 -0
  87. data/spec/tmp/spec/support/helpers/controller_macros.rb +52 -0
  88. metadata +150 -4
@@ -0,0 +1,18 @@
1
+ class Ability < Sunrise::Models::Ability
2
+
3
+ def guest
4
+ # TODO
5
+ end
6
+
7
+ def default
8
+ # TODO
9
+ end
10
+
11
+ def redactor
12
+ # TODO
13
+ end
14
+
15
+ def moderator
16
+ # TODO
17
+ end
18
+ end
@@ -0,0 +1,7 @@
1
+ class Asset < ActiveRecord::Base
2
+ include Sunrise::Models::Asset
3
+
4
+ validates_presence_of :data
5
+
6
+ default_scope order("#{quoted_table_name}.sort_order")
7
+ end
@@ -0,0 +1,5 @@
1
+ class AttachmentFile < Asset
2
+ sunrise_uploader AttachmentFileUploader
3
+
4
+ validates_filesize_of :data, :maximum => 100.megabytes.to_i
5
+ end
@@ -0,0 +1,7 @@
1
+ class Avatar < Asset
2
+ sunrise_uploader AvatarUploader
3
+
4
+ validates :data_content_type, :inclusion => {:in => Sunrise::Utils::IMAGE_TYPES }
5
+ validates_integrity_of :data
6
+ validates_filesize_of :data, :maximum => 1.megabytes.to_i
7
+ end
@@ -0,0 +1,7 @@
1
+ class Picture < Asset
2
+ sunrise_uploader PictureUploader
3
+
4
+ validates :data_content_type, :inclusion => {:in => Sunrise::Utils::IMAGE_TYPES }
5
+ validates_integrity_of :data
6
+ validates_filesize_of :data, :maximum => 2.megabytes.to_i
7
+ end
@@ -0,0 +1,7 @@
1
+ class PositionType < Sunrise::Models::PositionType
2
+ define_enum do |builder|
3
+ builder.member :default, :object => new("default")
4
+ builder.member :menu, :object => new("menu")
5
+ builder.member :bottom, :object => new("bottom")
6
+ end
7
+ end
@@ -0,0 +1,8 @@
1
+ class RoleType < Sunrise::Models::RoleType
2
+ define_enum do |builder|
3
+ builder.member :default, :object => new("default")
4
+ builder.member :redactor, :object => new("redactor")
5
+ builder.member :moderator, :object => new("moderator")
6
+ builder.member :admin, :object => new("admin")
7
+ end
8
+ end
@@ -0,0 +1,6 @@
1
+ class Settings < ActiveRecord::Base
2
+ include Sunrise::Models::Settings
3
+ include PublicActivity::Model
4
+
5
+ tracked owner: ->(controller, model) { controller.try(:current_user) }
6
+ end
@@ -0,0 +1,10 @@
1
+ class Structure < ActiveRecord::Base
2
+ include Sunrise::Models::Structure
3
+ include PageParts::Extension
4
+ include MetaManager::Taggable
5
+ include PublicActivity::Model
6
+ include ActiveModel::ForbiddenAttributesProtection
7
+
8
+ tracked owner: ->(controller, model) { controller.try(:current_user) }
9
+ # page_parts :content
10
+ end
@@ -0,0 +1,9 @@
1
+ class StructureType < Sunrise::Models::StructureType
2
+ define_enum do |builder|
3
+ builder.member :page, :object => new("page")
4
+ builder.member :posts, :object => new("posts")
5
+ builder.member :main, :object => new("main")
6
+ builder.member :redirect, :object => new("redirect")
7
+ builder.member :group, :object => new("group")
8
+ end
9
+ end
@@ -0,0 +1,14 @@
1
+ class User < ActiveRecord::Base
2
+ include Sunrise::Models::User
3
+ include PublicActivity::Model
4
+ include ActiveModel::ForbiddenAttributesProtection
5
+
6
+ # Include default devise modules.
7
+ devise :database_authenticatable, :confirmable, :lockable, :timeoutable,
8
+ :recoverable, :rememberable, :trackable, :validatable,
9
+ :encryptable, :encryptor => :sha512
10
+
11
+ fileuploads :avatar
12
+
13
+ tracked owner: ->(controller, model) { controller.try(:current_user) }
14
+ end
@@ -0,0 +1,14 @@
1
+ class SunriseNavigation < Sunrise::Config::Navigation
2
+ navigation :main do |m|
3
+ m.item :dashboard, root_path, :class => "icon1"
4
+ m.item :structures, index_path(:model_name => "structures"), :class => "icon2"
5
+ m.item :users, index_path(:model_name => "users"), :class => "icon3"
6
+ m.item :services, "#", :class => "icon4"
7
+ m.item :settings, edit_settings_path, :class => "icon4"
8
+ end
9
+
10
+ navigation :creates do |c|
11
+ c.item :structures, new_path(:model_name => "structures")
12
+ c.item :users, new_path(:model_name => "users")
13
+ end
14
+ end
@@ -0,0 +1,10 @@
1
+ class SunrisePage < Sunrise::AbstractModel
2
+ self.resource_name = "Structure"
3
+
4
+ list false
5
+
6
+ edit do
7
+ field :main, :as => :text
8
+ field :sidebar, :as => :text
9
+ end
10
+ end
@@ -0,0 +1,35 @@
1
+ # encoding: utf-8
2
+ class SunriseStructure < Sunrise::AbstractModel
3
+ self.resource_name = "Structure"
4
+
5
+ default_list_view :tree
6
+ available_list_view [:tree, :thumbs]
7
+
8
+ list :tree do
9
+ field :title
10
+ field :updated_at
11
+ field :id
12
+ end
13
+
14
+ show do
15
+ field :title
16
+ field :redirect_url
17
+ field :is_visible
18
+ end
19
+
20
+ edit do
21
+ field :title
22
+ field :redirect_url
23
+ field :slug
24
+ field :parent_id, :collection => lambda { Structure.nested_set_options() {|i| "#{'–' * i.depth} #{i.title}"} }, :if => lambda { |s| s.moveable? }
25
+ field :structure_type_id, :collection => lambda { StructureType.all }, :include_blank => false
26
+ field :position_type_id, :collection => lambda { PositionType.all }, :include_blank => false
27
+ field :is_visible
28
+
29
+ group :meta_tags, :holder => :sidebar do
30
+ field :tag_title
31
+ field :tag_keywords
32
+ field :tag_description
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,50 @@
1
+ class SunriseUser < Sunrise::AbstractModel
2
+ self.resource_name = "User"
3
+
4
+ list :table do
5
+ field :email
6
+ field :updated_at
7
+ field :id
8
+
9
+ group :search do
10
+ field :email
11
+ field :name
12
+ end
13
+ end
14
+
15
+ list :thumbs do
16
+ scope { User.includes(:avatar) }
17
+ preview lambda { |user| user.avatar.try(:url, :thumb) }
18
+
19
+ field :email, :label => false
20
+ field :updated_at, :label => false
21
+ field :id
22
+
23
+ group :search do
24
+ field :email
25
+ field :name
26
+ end
27
+ end
28
+
29
+ edit do
30
+ permited_attributes lambda { |user|
31
+ user.admin? ? :all : [:name, :password, :password_confirmation, :avatar_attributes]
32
+ }
33
+
34
+ field :name
35
+ field :email
36
+ field :password
37
+ field :password_confirmation
38
+ field :role_type_id, :collection => lambda { RoleType.all }
39
+
40
+ group :bottom, :holder => :bottom do
41
+ field :avatar, :as => :uploader
42
+ end
43
+ end
44
+
45
+ list :export do
46
+ field :id
47
+ field :name
48
+ field :email
49
+ end
50
+ end
@@ -0,0 +1,5 @@
1
+ class AttachmentFileUploader < Sunrise::CarrierWave::BaseUploader
2
+ def extension_white_list
3
+ %w(pdf doc docx xls xlsx ppt pptx zip rar csv)
4
+ end
5
+ end
@@ -0,0 +1,15 @@
1
+ class AvatarUploader < Sunrise::CarrierWave::BaseUploader
2
+ process :quality => 90
3
+
4
+ version :thumb do
5
+ process :resize_to_fill => [50, 50]
6
+ end
7
+
8
+ version :small do
9
+ process :resize_to_fill => [32, 32]
10
+ end
11
+
12
+ def extension_white_list
13
+ %w(jpg jpeg gif png)
14
+ end
15
+ end
@@ -0,0 +1,15 @@
1
+ class PictureUploader < Sunrise::CarrierWave::BaseUploader
2
+ process :quality => 90
3
+
4
+ version :thumb do
5
+ process :resize_to_fill => [50, 50]
6
+ end
7
+
8
+ version :content do
9
+ process :resize_to_fit => [575, 500]
10
+ end
11
+
12
+ def extension_white_list
13
+ %w(jpg jpeg gif png)
14
+ end
15
+ end
@@ -0,0 +1,22 @@
1
+ <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2
+ <html xmlns="http://www.w3.org/1999/xhtml">
3
+ <head>
4
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5
+ <%= csrf_meta_tag %>
6
+ <%= raw(render_meta_tags(@structure)) %>
7
+ <title><%= render_page_title(@structure) %></title>
8
+ <%= stylesheet_link_tag "application" %>
9
+ <%= javascript_include_tag "application" %>
10
+ <%= yield(:head) %>
11
+ </head>
12
+ <body>
13
+ <%#= render :partial => "manage/shared/panel" if content_manager? %>
14
+ <%= render :partial => 'shared/notice' if flash %>
15
+
16
+ <div class='content'>
17
+ <%= yield %>
18
+ </div>
19
+
20
+ <%= yield(:footer) %>
21
+ </body>
22
+ </html>
@@ -0,0 +1,2 @@
1
+ <h1><%= @structure.title %></h1>
2
+ <%=raw Nokogiri::HTML.fragment(@page.content).to_html %>
@@ -0,0 +1,17 @@
1
+ <% unless flash.keys.empty? %>
2
+ <div class="message" style="display:none;z-index:5000;">
3
+ <div class="alert-container">
4
+ <div class="alert">
5
+ <% flash.each do |key, text| %>
6
+ <%= content_tag(:div, text, :class => "flash_#{key}") %>
7
+ <% end %>
8
+ <%= link_to_function(image_tag("cross_ico.png", :title=>t('label.close')), "$(this).parents('div.message').slideUp()", :class=>"close") %>
9
+ </div>
10
+ </div>
11
+ <script type='text/javascript' charset='UTF-8'>
12
+ $(document).ready(function(){
13
+ $('div.message').slideDown('slow');
14
+ })
15
+ </script>
16
+ </div>
17
+ <% end %>
@@ -0,0 +1,63 @@
1
+ require File.expand_path('../boot', __FILE__)
2
+
3
+ require 'rails/all'
4
+
5
+ unless defined?(SUNRISE_ORM)
6
+ SUNRISE_ORM = (ENV["SUNRISE_ORM"] || :active_record).to_sym
7
+ end
8
+
9
+ if defined?(Bundler)
10
+ # If you precompile assets before deploying to production, use this line
11
+ Bundler.require(*Rails.groups(:assets => %w(development test)))
12
+ # If you want your assets lazily compiled in production, use this line
13
+ Bundler.require(SUNRISE_ORM)
14
+ end
15
+
16
+ require "sunrise-cms"
17
+
18
+ module Dummy
19
+ class Application < Rails::Application
20
+ # Settings in config/environments/* take precedence over those specified here.
21
+ # Application configuration should go into files in config/initializers
22
+ # -- all .rb files in that directory are automatically loaded.
23
+
24
+ # Custom directories with classes and modules you want to be autoloadable.
25
+ config.autoload_paths += %W(
26
+ #{config.root}/../../lib/generators/sunrise/templates/models/#{SUNRISE_ORM}
27
+ #{config.root}/../../lib/generators/sunrise/templates/uploaders
28
+ #{config.root}/../../lib/generators/sunrise/templates/models/sunrise
29
+ #{config.root}/app/models/#{SUNRISE_ORM}
30
+ #{config.root}/app/models/sunrise)
31
+
32
+ # Only load the plugins named here, in the order given (default is alphabetical).
33
+ # :all can be used as a placeholder for all plugins not explicitly named.
34
+ # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
35
+
36
+ # Activate observers that should always be running.
37
+ # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
38
+
39
+ # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
40
+ # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
41
+ # config.time_zone = 'Central Time (US & Canada)'
42
+
43
+ # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
44
+ # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
45
+ # config.i18n.default_locale = :de
46
+
47
+ # Configure the default encoding used in templates for Ruby 1.9.
48
+ config.encoding = "utf-8"
49
+
50
+ # Configure sensitive parameters which will be filtered from the log file.
51
+ config.filter_parameters += [:password]
52
+
53
+ # Enable the asset pipeline
54
+ config.assets.enabled = true
55
+
56
+ # Version of your assets, change this if you want to expire all your assets
57
+ config.assets.version = '1.0'
58
+
59
+ # Disable the default whitelisting that occurs in later versions of Rails
60
+ config.active_record.whitelist_attributes = false
61
+ end
62
+ end
63
+