sunrise-core 0.1.3 → 0.1.4
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.
- data/MIT-LICENSE +20 -0
- data/README.rdoc +20 -22
- data/Rakefile +17 -13
- data/app/controllers/manage/assets_controller.rb +3 -20
- data/app/controllers/manage/structures_controller.rb +1 -1
- data/app/controllers/manage/users_controller.rb +1 -11
- data/{lib/generators/sunrise/templates → app}/sweepers/page_sweeper.rb +1 -2
- data/{lib/generators/sunrise/templates → app}/sweepers/structure_sweeper.rb +1 -9
- data/app/views/kaminari/manage/_first_page.html.erb +11 -0
- data/app/views/kaminari/manage/_gap.html.erb +8 -0
- data/app/views/kaminari/manage/_last_page.html.erb +11 -0
- data/app/views/kaminari/manage/_next_page.html.erb +9 -0
- data/app/views/kaminari/manage/_page.html.erb +15 -0
- data/app/views/kaminari/manage/_paginator.html.erb +23 -0
- data/app/views/kaminari/manage/_prev_page.html.erb +10 -0
- data/app/views/layouts/manage.html.erb +1 -1
- data/app/views/manage/shared/_locale.html.erb +1 -1
- data/app/views/manage/users/_model_filter.html.erb +2 -0
- data/app/views/manage/users/index.html.erb +1 -1
- data/config/locales/defaults/en.yml +1 -1
- data/config/locales/manage/en.yml +3 -0
- data/config/locales/manage/ru.yml +3 -0
- data/config/locales/manage/uk.yml +3 -0
- data/lib/generators/sunrise/install_generator.rb +3 -7
- data/lib/generators/sunrise/templates/models/defaults/avatar.rb +1 -0
- data/lib/generators/sunrise/templates/models/defaults/picture.rb +1 -0
- data/lib/generators/sunrise/templates/models/defaults/structure.rb +0 -2
- data/lib/generators/sunrise/templates/views/layouts/application.html.erb +1 -1
- data/lib/sunrise/core.rb +4 -16
- data/lib/sunrise/engine.rb +9 -3
- data/lib/sunrise/models/role_type.rb +4 -0
- data/lib/sunrise/models/structure.rb +3 -0
- data/lib/sunrise/models/user.rb +2 -2
- data/lib/sunrise/nested_set/depth.rb +50 -0
- data/lib/sunrise/nested_set/descendants.rb +25 -0
- data/lib/sunrise/plugin.rb +14 -3
- data/lib/sunrise/utils.rb +29 -0
- data/lib/sunrise/version.rb +1 -1
- metadata +825 -47
- data/lib/generators/sunrise/templates/sweepers/user_sweeper.rb +0 -17
data/MIT-LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright 2011 Aimbulance
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
CHANGED
@@ -1,7 +1,10 @@
|
|
1
1
|
= SunRise CMS
|
2
2
|
|
3
3
|
== Install
|
4
|
+
|
5
|
+
=== Include gems:
|
4
6
|
|
7
|
+
gem "mysql2", "~> 0.2.10"
|
5
8
|
gem 'inherited_resources'
|
6
9
|
gem 'paperclip'
|
7
10
|
gem 'mime-types'
|
@@ -10,37 +13,32 @@
|
|
10
13
|
gem 'cancan_namespace'
|
11
14
|
gem 'devise'
|
12
15
|
gem 'simple_form'
|
13
|
-
gem 'ckeditor'
|
14
|
-
|
15
|
-
gem 'enum_field', :git => 'git://github.com/galetahub/enum_field.git'
|
16
|
-
gem 'awesome_nested_set', :git => 'git://github.com/galetahub/awesome_nested_set.git'
|
17
|
-
gem 'salty_slugs', :git => 'git://github.com/galetahub/salty_slugs.git'
|
18
|
-
gem 'attach_file_field', :git => 'git://github.com/galetahub/attach_file_field.git'
|
16
|
+
gem 'ckeditor'
|
19
17
|
|
20
|
-
gem 'sunrise'
|
18
|
+
gem 'sunrise-cms'
|
21
19
|
|
22
|
-
|
23
|
-
|
24
|
-
Feature for Rails 3.1: copy migrations from all plugins, engins:
|
20
|
+
=== Generate all your need:
|
25
21
|
|
26
|
-
|
22
|
+
rails generate sunrise:install
|
27
23
|
|
28
|
-
|
24
|
+
It's run all dependent generators:
|
29
25
|
|
30
|
-
|
26
|
+
* simple_form:install
|
27
|
+
* sunrise:file_upload:install
|
28
|
+
* devise:install
|
31
29
|
|
32
|
-
|
33
|
-
|
34
|
-
rails generate simple_form:install
|
30
|
+
=== Configuration
|
35
31
|
|
36
|
-
|
32
|
+
cp config/database.yml.sample config/database.yml
|
33
|
+
cp config/application.yml.sample config/application.yml
|
37
34
|
|
38
|
-
|
39
|
-
|
40
|
-
Migrate database:
|
35
|
+
=== Database
|
41
36
|
|
37
|
+
rake db:create
|
42
38
|
rake db:migrate
|
43
39
|
|
44
|
-
|
40
|
+
== Tests
|
41
|
+
|
42
|
+
rake spec
|
45
43
|
|
46
|
-
|
44
|
+
Copyright (c) 2011 Aimbulance, released under the MIT license
|
data/Rakefile
CHANGED
@@ -1,26 +1,30 @@
|
|
1
|
-
# encoding:
|
1
|
+
# encoding: UTF-8
|
2
|
+
require 'rubygems'
|
3
|
+
begin
|
4
|
+
require 'bundler/setup'
|
5
|
+
rescue LoadError
|
6
|
+
puts 'You must `gem install bundler` and `bundle install` to run rake tasks'
|
7
|
+
end
|
8
|
+
|
2
9
|
require 'rake'
|
3
|
-
require '
|
4
|
-
require 'rake/rdoctask'
|
10
|
+
require 'rdoc/task'
|
5
11
|
require File.join(File.dirname(__FILE__), 'lib', 'sunrise', 'version')
|
6
12
|
|
7
|
-
|
8
|
-
|
13
|
+
require 'rspec/core'
|
14
|
+
require 'rspec/core/rake_task'
|
9
15
|
|
10
|
-
|
11
|
-
|
12
|
-
t.libs << 'lib'
|
13
|
-
t.libs << 'test'
|
14
|
-
t.pattern = 'test/**/*_test.rb'
|
15
|
-
t.verbose = true
|
16
|
+
RSpec::Core::RakeTask.new(:spec) do |t|
|
17
|
+
t.rspec_opts = ['--options', "spec/spec.opts"]
|
16
18
|
end
|
17
19
|
|
20
|
+
task :default => :spec
|
21
|
+
|
18
22
|
desc 'Generate documentation for the sunrise plugin.'
|
19
|
-
|
23
|
+
RDoc::Task.new do |rdoc|
|
20
24
|
rdoc.rdoc_dir = 'rdoc'
|
21
25
|
rdoc.title = 'Sunrise Core'
|
22
26
|
rdoc.options << '--line-numbers' << '--inline-source'
|
23
|
-
rdoc.rdoc_files.include('README')
|
27
|
+
rdoc.rdoc_files.include('README.rdoc')
|
24
28
|
rdoc.rdoc_files.include('lib/**/*.rb')
|
25
29
|
end
|
26
30
|
|
@@ -7,12 +7,12 @@ class Manage::AssetsController < Manage::BaseController
|
|
7
7
|
authorize_resource
|
8
8
|
|
9
9
|
def create
|
10
|
-
@asset
|
10
|
+
@asset = @klass.new(params[:asset])
|
11
11
|
|
12
12
|
@asset.assetable_type = params[:assetable_type]
|
13
13
|
@asset.assetable_id = params[:assetable_id] || 0
|
14
14
|
@asset.guid = params[:guid]
|
15
|
-
@asset.data = params[:
|
15
|
+
@asset.data = params[:data]
|
16
16
|
@asset.user = current_user
|
17
17
|
@asset.save
|
18
18
|
|
@@ -27,6 +27,7 @@ class Manage::AssetsController < Manage::BaseController
|
|
27
27
|
|
28
28
|
respond_with(@asset) do |format|
|
29
29
|
format.html { head :ok }
|
30
|
+
format.xml { render :xml => @asset.to_xml }
|
30
31
|
end
|
31
32
|
end
|
32
33
|
|
@@ -47,24 +48,6 @@ class Manage::AssetsController < Manage::BaseController
|
|
47
48
|
end
|
48
49
|
|
49
50
|
def find_klass
|
50
|
-
c_names = []
|
51
|
-
c_values = []
|
52
|
-
|
53
|
-
unless params[:assetable_id].blank?
|
54
|
-
c_names << "assetable_id = ?"
|
55
|
-
c_values << params[:assetable_id].to_i
|
56
|
-
|
57
|
-
c_names << "assetable_type = ?"
|
58
|
-
c_values << params[:assetable_type]
|
59
|
-
else
|
60
|
-
c_names << "guid = ?"
|
61
|
-
c_values << params[:guid]
|
62
|
-
end
|
63
|
-
|
64
51
|
@klass = params[:klass].blank? ? Asset : params[:klass].classify.constantize
|
65
|
-
|
66
|
-
if params[:collection].blank?
|
67
|
-
@asset = @klass.where([c_names.join(' AND ')] + c_values).first
|
68
|
-
end
|
69
52
|
end
|
70
53
|
end
|
@@ -31,7 +31,7 @@ class Manage::StructuresController < Manage::BaseController
|
|
31
31
|
protected
|
32
32
|
|
33
33
|
def find_root
|
34
|
-
@structure ||= Structure.with_kind(StructureType.main).
|
34
|
+
@structure ||= Structure.with_kind(StructureType.main).roots.find(:first)
|
35
35
|
@structure
|
36
36
|
end
|
37
37
|
|
@@ -7,16 +7,12 @@ class Manage::UsersController < Manage::BaseController
|
|
7
7
|
before_filter :make_filter, :only=>[:index]
|
8
8
|
before_filter :check_params, :only => [:create, :update]
|
9
9
|
|
10
|
-
cache_sweeper :user_sweeper, :only=>[:update, :destroy]
|
11
|
-
|
12
10
|
def create
|
13
|
-
@user =
|
14
|
-
@user.roles_attributes = @roles
|
11
|
+
@user.attributes = params[:user]
|
15
12
|
create! { manage_users_path }
|
16
13
|
end
|
17
14
|
|
18
15
|
def update
|
19
|
-
@user.roles_attributes = @roles
|
20
16
|
update!{ manage_users_path }
|
21
17
|
end
|
22
18
|
|
@@ -61,8 +57,6 @@ class Manage::UsersController < Manage::BaseController
|
|
61
57
|
|
62
58
|
def check_params
|
63
59
|
unless params[:user].blank?
|
64
|
-
@roles = params[:user].delete(:roles_attributes)
|
65
|
-
|
66
60
|
if params[:user][:password].blank?
|
67
61
|
params[:user].delete(:password)
|
68
62
|
params[:user].delete(:password_confirmation)
|
@@ -71,8 +65,4 @@ class Manage::UsersController < Manage::BaseController
|
|
71
65
|
@user.accessible = :all
|
72
66
|
end
|
73
67
|
end
|
74
|
-
|
75
|
-
def find_user
|
76
|
-
@user = User.find(params[:id])
|
77
|
-
end
|
78
68
|
end
|
@@ -13,17 +13,9 @@ class StructureSweeper < ActionController::Caching::Sweeper
|
|
13
13
|
expire(item)
|
14
14
|
end
|
15
15
|
|
16
|
-
# Clear all orders cache files
|
17
|
-
def self.sweep!
|
18
|
-
cache_store = Rails.application.config.action_controller.cache_store
|
19
|
-
cache_store.clear if cache_store
|
20
|
-
|
21
|
-
Rails.logger.info("StructureSweeper clear all cache")
|
22
|
-
end
|
23
|
-
|
24
16
|
private
|
25
17
|
|
26
18
|
def expire(item=nil)
|
27
|
-
|
19
|
+
Sunrise::Utils.clear_cache
|
28
20
|
end
|
29
21
|
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<%# Link to the "First" page
|
2
|
+
- available local variables
|
3
|
+
url: url to the first page
|
4
|
+
current_page: a page object for the currently displayed page
|
5
|
+
num_pages: total number of pages
|
6
|
+
per_page: number of items to fetch per page
|
7
|
+
remote: data-remote
|
8
|
+
-%>
|
9
|
+
<span class="first">
|
10
|
+
<%= link_to_unless current_page.first?, raw(t 'views.pagination.first'), url, :remote => remote %>
|
11
|
+
</span>
|
@@ -0,0 +1,8 @@
|
|
1
|
+
<%# Non-link tag that stands for skipped pages...
|
2
|
+
- available local variables
|
3
|
+
current_page: a page object for the currently displayed page
|
4
|
+
num_pages: total number of pages
|
5
|
+
per_page: number of items to fetch per page
|
6
|
+
remote: data-remote
|
7
|
+
-%>
|
8
|
+
<span class="page gap"><%= raw(t 'views.pagination.truncate') %></span>
|
@@ -0,0 +1,11 @@
|
|
1
|
+
<%# Link to the "Last" page
|
2
|
+
- available local variables
|
3
|
+
url: url to the last page
|
4
|
+
current_page: a page object for the currently displayed page
|
5
|
+
num_pages: total number of pages
|
6
|
+
per_page: number of items to fetch per page
|
7
|
+
remote: data-remote
|
8
|
+
-%>
|
9
|
+
<span class="last">
|
10
|
+
<%= link_to_unless current_page.last?, raw(t 'views.pagination.last'), url, {:remote => remote} %>
|
11
|
+
</span>
|
@@ -0,0 +1,9 @@
|
|
1
|
+
<%# Link to the "Next" page
|
2
|
+
- available local variables
|
3
|
+
url: url to the next page
|
4
|
+
current_page: a page object for the currently displayed page
|
5
|
+
num_pages: total number of pages
|
6
|
+
per_page: number of items to fetch per page
|
7
|
+
remote: data-remote
|
8
|
+
-%>
|
9
|
+
<%= link_to_unless_span current_page.last?, image_tag('manage/page_next_arr.gif', :alt => t('views.pagination.next')), url, :rel => 'next', :remote => remote, :class => "next_page disabled" %>
|
@@ -0,0 +1,15 @@
|
|
1
|
+
<%# Link showing page number
|
2
|
+
- available local variables
|
3
|
+
page: a page object for "this" page
|
4
|
+
url: url to this page
|
5
|
+
current_page: a page object for the currently displayed page
|
6
|
+
num_pages: total number of pages
|
7
|
+
per_page: number of items to fetch per page
|
8
|
+
remote: data-remote
|
9
|
+
-%>
|
10
|
+
|
11
|
+
<% unless page.current? %>
|
12
|
+
<%= link_to page, url, opts = {:remote => remote, :rel => page.next? ? 'next' : page.prev? ? 'prev' : nil} %>
|
13
|
+
<% else -%>
|
14
|
+
<%= content_tag(:span, page)%>
|
15
|
+
<% end -%>
|
@@ -0,0 +1,23 @@
|
|
1
|
+
<%# The container tag
|
2
|
+
- available local variables
|
3
|
+
current_page: a page object for the currently displayed page
|
4
|
+
num_pages: total number of pages
|
5
|
+
per_page: number of items to fetch per page
|
6
|
+
remote: data-remote
|
7
|
+
paginator: the paginator that renders the pagination tags inside
|
8
|
+
-%>
|
9
|
+
<%= paginator.render do -%>
|
10
|
+
<div class="pagination">
|
11
|
+
<%#= first_page_tag unless current_page.first? %>
|
12
|
+
<%= prev_page_tag %>
|
13
|
+
<% each_page do |page| -%>
|
14
|
+
<% if page.left_outer? || page.right_outer? || page.inside_window? -%>
|
15
|
+
<%= page_tag page %>
|
16
|
+
<% elsif !page.was_truncated? -%>
|
17
|
+
<%= gap_tag %>
|
18
|
+
<% end -%>
|
19
|
+
<% end -%>
|
20
|
+
<%= next_page_tag %>
|
21
|
+
<%#= last_page_tag unless current_page.last? %>
|
22
|
+
</div>
|
23
|
+
<% end -%>
|
@@ -0,0 +1,10 @@
|
|
1
|
+
<%# Link to the "Previous" page
|
2
|
+
- available local variables
|
3
|
+
url: url to the previous page
|
4
|
+
current_page: a page object for the currently displayed page
|
5
|
+
num_pages: total number of pages
|
6
|
+
per_page: number of items to fetch per page
|
7
|
+
remote: data-remote
|
8
|
+
-%>
|
9
|
+
|
10
|
+
<%= link_to_unless_span current_page.first?, image_tag('manage/page_prev_arr.gif', :alt => t('views.pagination.previous')), url, :rel => 'prev', :remote => remote, :class => "prev_page disabled" %>
|
@@ -11,7 +11,7 @@
|
|
11
11
|
<script src="https://www.google.com/jsapi?key=" type="text/javascript"></script>
|
12
12
|
<script language="Javascript" type="text/javascript">
|
13
13
|
//<![CDATA[
|
14
|
-
google.load("jquery", "1.
|
14
|
+
google.load("jquery", "1.6.2");
|
15
15
|
google.load("jqueryui", "1.8.13");
|
16
16
|
//]]>
|
17
17
|
</script>
|
@@ -1,6 +1,6 @@
|
|
1
1
|
<% param ||= "s"%>
|
2
2
|
<ul class="lang-tabs" id="lang_tab_ul_<%=param%>">
|
3
|
-
<%
|
3
|
+
<% Sunrise.available_locales.each do |locale| %>
|
4
4
|
<%= content_tag(:li, :class=>(I18n.locale.to_s == locale.to_s ? 'active' : 'not-active')) do %>
|
5
5
|
<span><%= link_to_function t("manage.locale.#{locale}"), 'TabPanel.click(event)', :class=>locale, :id=>"#{param + locale.to_s}" %></span>
|
6
6
|
<% end %>
|
@@ -2,6 +2,8 @@
|
|
2
2
|
<div class="filt-bl">
|
3
3
|
<%= link_to_function t('manage.model_filter.title'), "Manage.toggle_element('block_filter')", :class=>"dark-arr" %>
|
4
4
|
|
5
|
+
<%= t('manage.model_filter.total_count') %>: <%= @users.total_count %>
|
6
|
+
|
5
7
|
<%= cookie_content_tag(:div, :id=>"block_filter", :class=>"filt") do %>
|
6
8
|
<%= form_for @search, :as => :search, :url=>manage_users_path, :html=>{:method=>:get} do |f| %>
|
7
9
|
<%= f.label :email, t('activerecord.attributes.user.email') %>
|
@@ -145,5 +145,5 @@ en:
|
|
145
145
|
less_than_or_equal_to: "must be less than or equal to %{count}"
|
146
146
|
odd: "must be odd"
|
147
147
|
even: "must be even"
|
148
|
-
record_invalid: "Validation failed: {
|
148
|
+
record_invalid: "Validation failed: %{errors}"
|
149
149
|
# Append your own errors here or at the model/attributes scope.
|
@@ -126,6 +126,7 @@ en:
|
|
126
126
|
filter: "Filter"
|
127
127
|
search: "Search"
|
128
128
|
clear: "Clean"
|
129
|
+
total_count: "Total"
|
129
130
|
|
130
131
|
position:
|
131
132
|
down: "Lower down"
|
@@ -206,6 +207,8 @@ en:
|
|
206
207
|
_: "-"
|
207
208
|
created_at_desc: "by date descending"
|
208
209
|
created_at_asc: "date ascending"
|
210
|
+
updated_at_desc: "updating descending"
|
211
|
+
updated_at_asc: "updating ascending"
|
209
212
|
title_desc: "by title descending"
|
210
213
|
title_asc: "by title ascending"
|
211
214
|
name_desc: "by name descending"
|
@@ -126,6 +126,7 @@ ru:
|
|
126
126
|
filter: "Фильтр"
|
127
127
|
search: "Поиск"
|
128
128
|
clear: "Очистить"
|
129
|
+
total_count: "Всего"
|
129
130
|
|
130
131
|
position:
|
131
132
|
down: "Опустить вниз"
|
@@ -206,6 +207,8 @@ ru:
|
|
206
207
|
_: "-"
|
207
208
|
created_at_desc: "по дате по убыванию"
|
208
209
|
created_at_asc: "по дате по возрастанию"
|
210
|
+
updated_at_desc: "обновление по убыванию"
|
211
|
+
updated_at_asc: "обновление по возрастанию"
|
209
212
|
title_desc: "по названию по убыванию"
|
210
213
|
title_asc: "по названию по возрастанию"
|
211
214
|
name_desc: "по названию по убыванию"
|
@@ -126,6 +126,7 @@ uk:
|
|
126
126
|
filter: "Фільтр"
|
127
127
|
search: "Пошук"
|
128
128
|
clear: "Очистити"
|
129
|
+
total_count: "Всього"
|
129
130
|
|
130
131
|
position:
|
131
132
|
down: "Опустити вниз"
|
@@ -206,6 +207,8 @@ uk:
|
|
206
207
|
_: "-"
|
207
208
|
created_at_desc: "за датою за спаданням"
|
208
209
|
created_at_asc: "за датою за зростанням"
|
210
|
+
updated_at_desc: "за датою оновлення за спаданням"
|
211
|
+
updated_at_asc: "за датою оновлення за зростанням"
|
209
212
|
title_desc: "за назвою за спаданням"
|
210
213
|
title_asc: "за назвою за зростанням"
|
211
214
|
name_desc: "за назвою за спаданням"
|