sunrise-cms 0.5.3 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (95) hide show
  1. data/CHANGELOG.rdoc +6 -0
  2. data/README.md +1 -1
  3. data/app/assets/javascripts/sunrise/manage.js.coffee +13 -1
  4. data/app/controllers/sunrise/application_controller.rb +2 -0
  5. data/app/controllers/sunrise/dashboard_controller.rb +4 -3
  6. data/app/helpers/sunrise/dashboard_helper.rb +36 -0
  7. data/app/views/sunrise/dashboard/_activity.html.erb +16 -0
  8. data/app/views/sunrise/dashboard/index.html.erb +32 -32
  9. data/config/locales/sunrise/en.yml +10 -2
  10. data/config/locales/sunrise/ru.yml +10 -6
  11. data/config/locales/sunrise/uk.yml +10 -6
  12. data/db/migrate/20111216144915_create_structures.rb +4 -3
  13. data/lib/generators/sunrise/templates/config/nginx-config +1 -1
  14. data/lib/generators/sunrise/templates/config/seeds.rb +2 -3
  15. data/lib/generators/sunrise/templates/config/sunrise.rb +43 -10
  16. data/lib/generators/sunrise/templates/models/active_record/asset.rb +1 -1
  17. data/lib/generators/sunrise/templates/models/active_record/settings.rb +3 -0
  18. data/lib/generators/sunrise/templates/models/active_record/structure.rb +2 -1
  19. data/lib/generators/sunrise/templates/models/active_record/user.rb +2 -1
  20. data/lib/generators/sunrise/templates/models/mongoid/asset.rb +2 -1
  21. data/lib/generators/sunrise/templates/models/mongoid/settings.rb +3 -0
  22. data/lib/generators/sunrise/templates/models/mongoid/structure.rb +2 -2
  23. data/lib/generators/sunrise/templates/models/mongoid/user.rb +2 -2
  24. data/lib/generators/sunrise/templates/models/sunrise/sunrise_structure.rb +2 -2
  25. data/lib/sunrise/config.rb +2 -10
  26. data/lib/sunrise/models/ability.rb +1 -1
  27. data/lib/sunrise/models/structure.rb +6 -5
  28. data/lib/sunrise/utils.rb +3 -3
  29. data/lib/sunrise/version.rb +1 -1
  30. data/spec/controllers/sunrise/dashboard_controller_spec.rb +4 -2
  31. data/spec/controllers/sunrise/manager_controller_spec.rb +1 -1
  32. data/spec/dummy/app/helpers/application_helper.rb +10 -0
  33. data/spec/dummy/app/models/active_record/post.rb +4 -0
  34. data/spec/dummy/app/models/mongoid/post.rb +2 -2
  35. data/spec/dummy/app/views/public_activity/post/_create.html.erb +5 -0
  36. data/spec/dummy/app/views/public_activity/post/_destroy.html.erb +5 -0
  37. data/spec/dummy/app/views/public_activity/post/_update.html.erb +5 -0
  38. data/spec/dummy/config/routes.rb +1 -0
  39. data/spec/dummy/db/migrate/20130214090723_create_activities.rb +23 -0
  40. data/spec/dummy/log/development.log +1 -0
  41. data/spec/dummy/log/test.log +30059 -0
  42. data/spec/models/structure_spec.rb +1 -1
  43. data/spec/orm/active_record.rb +0 -3
  44. data/spec/orm/mongoid.rb +12 -1
  45. data/spec/requests/dashboard_spec.rb +5 -2
  46. data/spec/requests/manager/default/create_spec.rb +2 -2
  47. data/spec/requests/manager/default/edit_spec.rb +2 -2
  48. data/spec/requests/manager/default/new_spec.rb +1 -1
  49. data/spec/requests/manager/default/update_spec.rb +2 -2
  50. data/vendor/assets/images/gravatar-140.png +0 -0
  51. data/vendor/assets/images/sunrise/audit/{action.png → key.png} +0 -0
  52. data/vendor/assets/images/sunrise/audit/{user.png → owner.png} +0 -0
  53. data/vendor/assets/images/sunrise/audit/{auditable.png → trackable.png} +0 -0
  54. data/vendor/assets/images/sunrise/icons/commented.svg +8 -0
  55. data/vendor/assets/images/sunrise/icons/create.svg +3 -0
  56. data/vendor/assets/images/sunrise/icons/destroy.svg +7 -0
  57. data/vendor/assets/images/sunrise/icons/update.svg +10 -0
  58. metadata +39 -79
  59. data/app/views/sunrise/dashboard/_event.html.erb +0 -15
  60. data/lib/generators/sunrise/templates/models/mongoid/history_tracker.rb +0 -31
  61. data/spec/factories/audit_factory.rb +0 -24
  62. data/spec/tmp/app/models/defaults/ability.rb +0 -18
  63. data/spec/tmp/app/models/defaults/asset.rb +0 -7
  64. data/spec/tmp/app/models/defaults/attachment_file.rb +0 -5
  65. data/spec/tmp/app/models/defaults/avatar.rb +0 -7
  66. data/spec/tmp/app/models/defaults/picture.rb +0 -7
  67. data/spec/tmp/app/models/defaults/position_type.rb +0 -7
  68. data/spec/tmp/app/models/defaults/role_type.rb +0 -8
  69. data/spec/tmp/app/models/defaults/settings.rb +0 -3
  70. data/spec/tmp/app/models/defaults/structure.rb +0 -9
  71. data/spec/tmp/app/models/defaults/structure_type.rb +0 -9
  72. data/spec/tmp/app/models/defaults/user.rb +0 -13
  73. data/spec/tmp/app/models/sunrise/sunrise_navigation.rb +0 -14
  74. data/spec/tmp/app/models/sunrise/sunrise_page.rb +0 -10
  75. data/spec/tmp/app/models/sunrise/sunrise_structure.rb +0 -35
  76. data/spec/tmp/app/models/sunrise/sunrise_user.rb +0 -50
  77. data/spec/tmp/app/uploaders/attachment_file_uploader.rb +0 -5
  78. data/spec/tmp/app/uploaders/avatar_uploader.rb +0 -15
  79. data/spec/tmp/app/uploaders/picture_uploader.rb +0 -15
  80. data/spec/tmp/app/views/layouts/application.html.erb +0 -22
  81. data/spec/tmp/app/views/pages/show.html.erb +0 -2
  82. data/spec/tmp/app/views/shared/_notice.html.erb +0 -17
  83. data/spec/tmp/config/application.rb +0 -63
  84. data/spec/tmp/config/database.yml.sample +0 -34
  85. data/spec/tmp/config/initializers/sunrise.rb +0 -18
  86. data/spec/tmp/config/logrotate-config.sample +0 -9
  87. data/spec/tmp/config/nginx-config.sample +0 -99
  88. data/spec/tmp/config/routes.rb +0 -9
  89. data/spec/tmp/db/seeds.rb +0 -31
  90. data/spec/tmp/spec/controllers/pages_controller_spec.rb +0 -22
  91. data/spec/tmp/spec/controllers/welcome_controller_spec.rb +0 -18
  92. data/spec/tmp/spec/factories/structure_factory.rb +0 -22
  93. data/spec/tmp/spec/factories/user_factory.rb +0 -61
  94. data/spec/tmp/spec/spec_helper.rb +0 -37
  95. data/spec/tmp/spec/support/helpers/controller_macros.rb +0 -52
data/CHANGELOG.rdoc CHANGED
@@ -1,3 +1,9 @@
1
+ == 0.6.0
2
+ * Raname attributes kind and position to structure_type_id and position_type_id
3
+ * Integrate "public_activity" gem
4
+ * Remove "activerecord-audited" and "mongoid-history" gems
5
+ * Fix search class in Utils
6
+
1
7
  == 0.5.0
2
8
  * Integrate "strong_parameters" gem
3
9
  * Add config option "navigational_formats"
data/README.md CHANGED
@@ -10,7 +10,6 @@ List of gems for [active_record](https://gist.github.com/4529926#file-gemfile-ac
10
10
 
11
11
  ```bash
12
12
  $> rails g devise:install
13
- $> rails g audited:install
14
13
  $> rails g sunrise:install --orm=active_record
15
14
  ```
16
15
 
@@ -20,6 +19,7 @@ Copy db migrations files:
20
19
  $> rake sunrise:install:migrations
21
20
  $> rake page_parts_engine:install:migrations
22
21
  $> rake meta_manager_engine:install:migrations
22
+ $> rails g public_activity:migration
23
23
  ```
24
24
 
25
25
  ### Mongoid
@@ -12,6 +12,7 @@ class Sunrise
12
12
  ($ '[data-lang]').lang_tabs()
13
13
 
14
14
  this.init_submit_buttons()
15
+ this.init_group_menus()
15
16
 
16
17
  getParameterByName: (name) ->
17
18
  match = RegExp('[?&]' + name + '=([^&]*)').exec(window.location.search)
@@ -27,7 +28,18 @@ class Sunrise
27
28
 
28
29
  $('#submit-form-button').bind 'click', (evt) ->
29
30
  $('form:first').submit()
30
-
31
+
32
+ init_group_menus: ->
33
+ $(".title-switcher").bind('click', (e) ->
34
+ $(this).parent().find(".padder").toggle()
35
+
36
+ if $(this).hasClass('up')
37
+ $(this).removeClass('up').addClass('down')
38
+ else
39
+ $(this).removeClass('down').addClass('up')
40
+
41
+ return false
42
+ )
31
43
 
32
44
  # Store params: page, per, sort and view for current namespace
33
45
  storeQuery: () ->
@@ -1,5 +1,7 @@
1
1
  module Sunrise
2
2
  class ApplicationController < ::ApplicationController
3
+ include ::PublicActivity::StoreController
4
+
3
5
  prepend_before_filter :authenticate_user!
4
6
  check_authorization
5
7
 
@@ -5,12 +5,13 @@ module Sunrise
5
5
  authorize_resource :class => false
6
6
 
7
7
  def index
8
- per_page = Sunrise::Config.audit_events_per_page
8
+ per_page = Sunrise::Config.activities_per_page
9
9
  cur_page = (params[:page] || 1).to_i
10
10
  offset = (cur_page - 1) * per_page
11
11
 
12
- @events = Sunrise::Config.audit_scope.limit(per_page).offset(offset)
13
-
12
+ @events = PublicActivity::Activity.includes(:owner, :trackable, :recipient)
13
+ @events = @events.limit(per_page).offset(offset)
14
+
14
15
  respond_with(@events) do |format|
15
16
  format.html { render :layout => params[:time].blank? }
16
17
  end
@@ -0,0 +1,36 @@
1
+ module Sunrise
2
+ module DashboardHelper
3
+
4
+ # For generating time tags calculated using jquery.timeago
5
+ def timeago_tag(time, options = {})
6
+ options[:class] ||= "timeago"
7
+ content_tag(:abbr, time.to_s, options.merge(:title => time.getutc.iso8601)) if time
8
+ end
9
+
10
+ def activity_icon_tag(key, options = {})
11
+ icon = key.split('.').last
12
+ image = image_path("sunrise/icons/#{icon}.svg")
13
+
14
+ options = {
15
+ :class => "mega-icon",
16
+ :style => "background-image: url(#{image});"
17
+ }.merge(options)
18
+
19
+ content_tag(:div, nil, options)
20
+ end
21
+
22
+ # Check if object still exists in the database and display a link to it,
23
+ # otherwise display a proper message about it.
24
+ # This is used in activities that can refer to
25
+ # objects which no longer exist, like removed posts.
26
+ def link_to_trackable(object, object_type)
27
+ model_name = object_type.downcase
28
+
29
+ if object
30
+ link_to(model_name, edit_path(:model_name => model_name.pluralize, :id => object.id))
31
+ else
32
+ "a #{model_name} which does not exist anymore"
33
+ end
34
+ end
35
+ end
36
+ end
@@ -0,0 +1,16 @@
1
+ <%= content_tag(:tr, :id => ["activity", activity.id].join("_"), :class => "event") do -%>
2
+ <td><%= I18n.l activity.created_at, :format => "%d.%m.%Y %H:%M" %></td>
3
+ <% if activity.owner -%>
4
+ <td>
5
+ <%= link_to activity.owner.name, edit_path(:model_name => activity.owner_type, :id => activity.owner_id) %>
6
+ </td>
7
+ <% else -%>
8
+ <td>someone</td>
9
+ <% end -%>
10
+ <td><%= activity.key %></td>
11
+ <td>
12
+ <% if ['create', 'update'].include?(activity.key.split('.').last) %>
13
+ <%= link_to_trackable activity.trackable, activity.trackable_type %>
14
+ <% end %>
15
+ </td>
16
+ <% end -%>
@@ -1,37 +1,37 @@
1
1
  <div class="wrapper without-panel">
2
2
  <div class="dbTable">
3
- <table id="events-table" cellpadding="0" cellspacing="0" border="0" width="100%">
4
- <tbody>
5
- <tr class="theader">
6
- <% ["created_at", "user", "action", "auditable", "remote_address"].each do |attr| %>
7
- <th>
8
- <%= image_tag("sunrise/audit/#{attr}.png") %>
9
- <%= t(attr, :scope => [:sunrise, :audit]) %>
10
- </th>
11
- <% end -%>
12
- </tr>
13
- <%= render :partial => 'event', :collection => @events %>
14
- </tbody>
15
- </table>
3
+ <table id="events-table" cellpadding="0" cellspacing="0" border="0" width="100%">
4
+ <tbody>
5
+ <tr class="theader">
6
+ <% ["created_at", "owner", "key", "trackable"].each do |attr| %>
7
+ <th>
8
+ <%= image_tag("sunrise/audit/#{attr}.png") %>
9
+ <%= PublicActivity::Activity.human_attribute_name("activity.#{attr}") %>
10
+ </th>
11
+ <% end -%>
12
+ </tr>
13
+ <%= render :partial => 'activity', :collection => @events %>
14
+ </tbody>
15
+ </table>
16
16
 
17
- <% if @events.count >= Sunrise::Config.audit_events_per_page -%>
18
- <div class="centerBtnHolder">
19
- <a id="events-next" href="#" class="button" style="width: 100px;">Показать еще 50</a>
20
-
21
- <script type="text/javascript">
22
- $(document).ready(function(){
23
- $("#events-table").pagination({
24
- url: '/manage/dashboard',
25
- binder: '#events-next',
26
- event: 'click',
27
- callback: function(data){
28
- var rows = $(data).find("#events-table tr.event");
29
- $('#events-table tbody').append(rows);
30
- }
31
- });
32
- });
33
- </script>
34
- </div>
35
- <% end -%>
17
+ <% if @events.count >= Sunrise::Config.activities_per_page -%>
18
+ <div class="centerBtnHolder">
19
+ <%= link_to t('manage.buttons.next_50'), "#", :class=>"button", :style=>"width:100px;", :id=>"events-next" %>
20
+
21
+ <script type="text/javascript">
22
+ $(document).ready(function(){
23
+ $("#events-table").pagination({
24
+ url: '/manage/dashboard',
25
+ binder: '#events-next',
26
+ event: 'click',
27
+ callback: function(data){
28
+ var rows = $(data).find("#events-table tr.event");
29
+ $('#events-table tbody').append(rows);
30
+ }
31
+ });
32
+ });
33
+ </script>
34
+ </div>
35
+ <% end -%>
36
36
  </div>
37
37
  </div>
@@ -20,9 +20,9 @@ en:
20
20
  title_en: "Name (eng.)"
21
21
  parent_id: "Main Categories"
22
22
  is_visible: "Show?"
23
- kind: "Page Type"
23
+ structure_type_id: "Page Type"
24
24
  redirect_url: "Redirect (URL)"
25
- position: "Position"
25
+ position_type_id: "Position"
26
26
  slug: "Slug"
27
27
 
28
28
  header:
@@ -66,6 +66,13 @@ en:
66
66
  remote_ip: "IP address"
67
67
  user_agent: "Browser Version"
68
68
  message: "Message"
69
+
70
+ activity:
71
+ created_at: "Created at"
72
+ owner: "User"
73
+ key: "Action"
74
+ trackable: "Object"
75
+ remote_address: "IP"
69
76
 
70
77
  manage:
71
78
  title: "System <br /> Management"
@@ -156,6 +163,7 @@ en:
156
163
  edit_profile: "My profile"
157
164
  exit: "Exit"
158
165
  add_nested_field: "+Add"
166
+ next_50: "Show more 50"
159
167
 
160
168
  user:
161
169
  actions: "action"
@@ -20,9 +20,9 @@ ru:
20
20
  title_en: "Название (eng.)"
21
21
  parent_id: "Главная категория"
22
22
  is_visible: "Отображать?"
23
- kind: "Тип страницы"
23
+ structure_type_id: "Тип страницы"
24
24
  redirect_url: "Перенаправление (URL)"
25
- position: "Позиция"
25
+ position_type_id: "Позиция"
26
26
  slug: "URL"
27
27
 
28
28
  header:
@@ -67,11 +67,11 @@ ru:
67
67
  user_agent: "Версия браузера"
68
68
  message: "Сообщение"
69
69
 
70
- audit:
70
+ activity:
71
71
  created_at: "Дата"
72
- user: "Пользователь"
73
- action: "Что"
74
- auditable: "Объект"
72
+ owner: "Пользователь"
73
+ key: "Что"
74
+ trackable: "Объект"
75
75
  remote_address: "IP"
76
76
 
77
77
  manage:
@@ -163,6 +163,7 @@ ru:
163
163
  edit_profile: "Мой профайл"
164
164
  exit: "Выход"
165
165
  add_nested_field: "+Еще"
166
+ next_50: "Показать еще 50"
166
167
 
167
168
  user:
168
169
  actions: "действия"
@@ -259,6 +260,9 @@ ru:
259
260
  edit: "Редактировать"
260
261
  settings: "Настройки"
261
262
  delete: "Удалить"
263
+
264
+ groups:
265
+ meta_tags: "Мета теги"
262
266
 
263
267
  views:
264
268
  pagination:
@@ -20,9 +20,9 @@ uk:
20
20
  title_en: "Назва (eng.)"
21
21
  parent_id: "Головна категорія"
22
22
  is_visible: "Відображати?"
23
- kind: "Тип сторінки"
23
+ structure_type_id: "Тип сторінки"
24
24
  redirect_url: "Перенаправлення (URL)"
25
- position: "Позиція"
25
+ position_type_id: "Позиція"
26
26
  slug: "URL"
27
27
 
28
28
  header:
@@ -67,11 +67,11 @@ uk:
67
67
  user_agent: "Версія браузера"
68
68
  message: "Повідомлення"
69
69
 
70
- audit:
70
+ activity:
71
71
  created_at: "Дата"
72
- user: "Пользователь"
73
- action: "Что"
74
- auditable: "Объект"
72
+ owner: "Пользователь"
73
+ key: "Что"
74
+ trackable: "Объект"
75
75
  remote_address: "IP"
76
76
 
77
77
  manage:
@@ -163,6 +163,7 @@ uk:
163
163
  edit_profile: "Мій профайл"
164
164
  exit: "Вихід"
165
165
  add_nested_field: "+Ще"
166
+ next_50: "Показати ще 50"
166
167
 
167
168
  user:
168
169
  actions: "дії"
@@ -258,6 +259,9 @@ uk:
258
259
  edit: "Редагувати"
259
260
  settings: "Настройки"
260
261
  delete: "Видалити"
262
+
263
+ groups:
264
+ meta_tags: "Мета теги"
261
265
 
262
266
  views:
263
267
  pagination:
@@ -3,8 +3,8 @@ class CreateStructures < ActiveRecord::Migration
3
3
  create_table :structures do |t|
4
4
  t.string :title, :null => false
5
5
  t.string :slug, :null => false, :limit => 25
6
- t.integer :kind, :limit => 1, :default => 0
7
- t.integer :position, :limit => 2, :default => 0
6
+ t.integer :structure_type_id, :limit => 1, :default => 0
7
+ t.integer :position_type_id, :limit => 2, :default => 0
8
8
  t.boolean :is_visible, :default => true
9
9
  t.string :redirect_url
10
10
 
@@ -16,7 +16,8 @@ class CreateStructures < ActiveRecord::Migration
16
16
  t.timestamps
17
17
  end
18
18
 
19
- add_index :structures, [:kind, :slug], :unique => true
19
+ add_index :structures, :structure_type_id
20
+ add_index :structures, :position_type_id
20
21
  add_index :structures, :parent_id
21
22
  add_index :structures, [:lft, :rgt]
22
23
  end
@@ -70,7 +70,7 @@ server {
70
70
  }
71
71
  }
72
72
 
73
- location ~ ^/(assets|ckeditor_assets|images|javascripts|stylesheets)/ {
73
+ location ~ ^/(assets|uploads|images|javascripts|stylesheets)/ {
74
74
  expires 1y;
75
75
  add_header Cache-Control public;
76
76
 
@@ -22,9 +22,8 @@ end
22
22
  def insert_structures
23
23
  Structure.truncate!
24
24
 
25
- main_page = Structure.create!({:title => "Главная страница", :slug => "main-page", :structure_type => StructureType.main, :parent => nil}, :as => :admin)
26
- #Structure.create!({:title => "Трансляции", :slug => "broadcasts", :structure_type => StructureType.broadcasts, :parent => main_page}, :as => :admin)
27
- #Structure.create!({:title => "Прямые репортажи", :slug => "posts", :structure_type => StructureType.posts, :parent => main_page}, :as => :admin)
25
+ main_page = Structure.create!(title: "Главная страница", slug: "main-page", structure_type: StructureType.main, parent: nil)
26
+ # Structure.create!(title: "Трансляции", slug: "broadcasts", structure_type: StructureType.broadcasts, parent: main_page)
28
27
  end
29
28
 
30
29
  insert_user
@@ -1,16 +1,49 @@
1
+ # require 'meta_manager/orm/active_record'
2
+ # require 'page_parts/orm/active_record'
3
+
1
4
  # Use this hook to configure sunrise
2
- if Object.const_defined?("Sunrise")
3
- Sunrise.setup do |config|
4
- # Flash keys
5
- #config.flash_keys = [ :success, :failure ]
6
- end
7
- end
5
+ Sunrise.setup do |config|
6
+ # Paginate records per page (default: 25)
7
+ # config.default_items_per_page = 25
8
+
9
+ # Display audits events on dashboard (default: 50)
10
+ # config.activities_per_page = 50
11
+
12
+ # By default show latest first (default: :desc)
13
+ # config.default_sort_mode = :desc
14
+
15
+ # The display for a model instance (i.e. a single database record).
16
+ # config.label_methods = [:title, :name]
17
+
18
+ # Defailt list template view (default: "thumbs")
19
+ # config.default_list_view = "thumbs"
20
+
21
+ # Avariable lists views (default: [:list, :thumbs, :table])
22
+ # config.available_list_view = [:list, :thumbs, :table]
23
+
24
+ # Defailt list template view (default: "sort_order")
25
+ # config.sort_column = "sort_order"
26
+
27
+ # Find template before rendering (default: true)
28
+ # config.scoped_views = true
29
+
30
+ # Set available locales in app (default: [])
31
+ # config.available_locales = []
8
32
 
9
- # Assuming HistoryTracker is your tracker class
10
- # Mongoid::History.tracker_class_name = :history_tracker
33
+ # Set transliteration for babosa gem
34
+ # more info here: https://github.com/norman/babosa (default: :russian)
35
+ # config.transliteration = :russian
11
36
 
12
- # Assuming you're using devise/authlogic
13
- # Mongoid::History.current_user_method = :current_user
37
+ # Set list toolbar buttons (default: [:delete, :edit, :new, :sort, :export])
38
+ # config.default_toolbar_buttons = [:delete, :edit, :new, :sort, :export]
39
+
40
+ # Lists the formats that should be treated as navigational (default: [:html, :json])
41
+ # config.navigational_formats = [:html, :json]
42
+ end
43
+
44
+ #PublicActivity::Config.set do
45
+ # orm :mongoid
46
+ #end
14
47
 
15
48
  #if Settings.table_exists?
16
49
  # Settings.defaults[:some_setting] = "value"
@@ -1,6 +1,6 @@
1
1
  class Asset < ActiveRecord::Base
2
2
  include Sunrise::Models::Asset
3
-
3
+
4
4
  validates_presence_of :data
5
5
 
6
6
  default_scope order("#{quoted_table_name}.sort_order")