adva 0.1.3 → 0.2.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/adva.gemspec +3 -0
- data/app/assets/config/manifest.js +6 -0
- data/app/assets/javascripts/adva_cms/ckeditor.js.erb +12 -0
- data/app/assets/javascripts/adva_cms/concat_main_menus.js +13 -0
- data/app/assets/javascripts/adva_cms/jquery.table_tree.js +704 -0
- data/app/assets/javascripts/adva_cms.js +7 -0
- data/app/assets/javascripts/ckeditor/config.js.erb +94 -0
- data/app/assets/stylesheets/adva_cms/admin/common.scss +15 -1
- data/app/assets/stylesheets/adva_cms/admin/projection.scss +2 -5
- data/app/assets/stylesheets/adva_cms/admin/sidebar.scss +30 -9
- data/app/assets/stylesheets/adva_cms/admin.scss +1 -1
- data/app/controllers/admin/base_controller.rb +10 -24
- data/app/controllers/admin/page/articles_controller.rb +8 -27
- data/app/controllers/admin/page/categories_controller.rb +6 -9
- data/app/controllers/admin/page/links_controller.rb +6 -9
- data/app/controllers/admin/sections_controller.rb +7 -9
- data/app/controllers/admin/sites_controller.rb +9 -12
- data/app/controllers/admin/users_controller.rb +6 -9
- data/app/controllers/articles_controller.rb +30 -52
- data/app/controllers/base_controller.rb +8 -8
- data/app/controllers/password_controller.rb +3 -5
- data/app/controllers/session_controller.rb +3 -5
- data/app/helpers/activities_helper.rb +9 -20
- data/app/helpers/admin/base_helper.rb +4 -22
- data/app/helpers/base_helper.rb +1 -1
- data/app/helpers/content_helper.rb +7 -5
- data/app/helpers/resource_helper.rb +4 -5
- data/app/helpers/users_helper.rb +1 -1
- data/app/models/activity.rb +3 -0
- data/app/models/article.rb +0 -11
- data/app/models/category.rb +3 -3
- data/app/models/content.rb +10 -39
- data/app/models/link.rb +0 -1
- data/app/models/password_mailer.rb +6 -9
- data/app/models/section.rb +6 -7
- data/app/models/site.rb +0 -2
- data/app/models/user.rb +1 -2
- data/app/views/activity_notifier/new_content_notification.html.erb +5 -5
- data/app/views/admin/activities/_activities.html.erb +4 -4
- data/app/views/admin/activities/_comment.html.erb +21 -21
- data/app/views/admin/activities/_content.html.erb +4 -3
- data/app/views/admin/activities/_topic.html.erb +5 -5
- data/app/views/admin/install/confirmation.html.erb +3 -3
- data/app/views/admin/install/index.html.erb +14 -14
- data/app/views/admin/page/articles/_form.html.erb +28 -25
- data/app/views/admin/page/articles/_options.html.erb +3 -4
- data/app/views/admin/page/articles/edit.html.erb +3 -3
- data/app/views/admin/page/articles/new.html.erb +4 -4
- data/app/views/admin/page/categories/edit.html.erb +9 -9
- data/app/views/admin/page/categories/index.html.erb +16 -16
- data/app/views/admin/page/categories/new.html.erb +5 -3
- data/app/views/admin/page/contents/index.html.erb +3 -18
- data/app/views/admin/page/links/_form.html.erb +17 -17
- data/app/views/admin/page/links/_options.html.erb +16 -19
- data/app/views/admin/page/links/edit.html.erb +3 -3
- data/app/views/admin/page/links/new.html.erb +3 -3
- data/app/views/admin/sections/_form.html.haml +5 -5
- data/app/views/admin/sections/edit.html.haml +2 -2
- data/app/views/admin/sections/index.html.erb +18 -18
- data/app/views/admin/sections/new.html.erb +15 -13
- data/app/views/admin/sections/settings/_page.html.haml +4 -6
- data/app/views/admin/shared/_header.html.erb +5 -4
- data/app/views/admin/shared/_section_tree.html.erb +2 -2
- data/app/views/admin/sites/_email_notifications.html.erb +6 -7
- data/app/views/admin/sites/_form.html.erb +7 -7
- data/app/views/admin/sites/_recent_users.html.erb +4 -2
- data/app/views/admin/sites/_unapproved_comments.html.erb +1 -1
- data/app/views/admin/sites/index.html.erb +1 -1
- data/app/views/admin/sites/new.html.erb +2 -2
- data/app/views/admin/sites/show.html.erb +7 -8
- data/app/views/admin/users/edit.html.erb +1 -1
- data/app/views/admin/users/index.html.erb +10 -10
- data/app/views/admin/users/new.html.erb +1 -1
- data/app/views/admin/users/show.html.erb +7 -7
- data/app/views/layouts/admin.html.haml +3 -5
- data/app/views/layouts/login.html.erb +1 -1
- data/app/views/password/edit.html.erb +12 -5
- data/app/views/password/new.html.erb +7 -7
- data/app/views/password_mailer/reset_password_email.html.erb +21 -1
- data/app/views/password_mailer/updated_password_email.html.erb +3 -1
- data/app/views/session/new.html.erb +9 -9
- data/app/views/shared/_flash.html.erb +2 -2
- data/app/views/shared/_sidebar.html.erb +2 -2
- data/config/initializers/ckeditor.rb +61 -0
- data/config/initializers/menus.rb +1 -1
- data/config/initializers/time_format.rb +2 -0
- data/lib/adva/authenticate_user.rb +193 -0
- data/lib/{active_record → adva}/belongs_to_author.rb +4 -4
- data/lib/adva/event.rb +34 -0
- data/lib/adva/extensible_forms.rb +285 -0
- data/lib/{has_options.rb → adva/has_options.rb} +5 -7
- data/lib/adva/has_permalink.rb +36 -0
- data/lib/adva/version.rb +1 -1
- data/lib/adva.rb +10 -36
- data/lib/rails_ext/action_controller/event_helper.rb +1 -1
- data/lib/rails_ext.rb +0 -9
- data/vendor/gems/cacheable_flash/.gitignore +8 -0
- data/vendor/gems/cacheable_flash/Gemfile +8 -0
- data/vendor/gems/cacheable_flash/README.md +35 -0
- data/vendor/gems/cacheable_flash/Rakefile +4 -0
- data/vendor/gems/cacheable_flash/bin/console +15 -0
- data/vendor/gems/cacheable_flash/bin/setup +8 -0
- data/vendor/gems/cacheable_flash/cacheable_flash.gemspec +38 -0
- data/vendor/gems/cacheable_flash/lib/cacheable_flash/controller.rb +29 -0
- data/vendor/gems/cacheable_flash/lib/cacheable_flash/javascript.js +19 -0
- data/vendor/gems/cacheable_flash/lib/cacheable_flash/middleware.rb +30 -0
- data/vendor/gems/cacheable_flash/lib/cacheable_flash/version.rb +5 -0
- data/vendor/gems/cacheable_flash/lib/cacheable_flash.rb +12 -0
- data/vendor/gems/simple_taggable/lib/tag_list.rb +1 -1
- data/vendor/gems/tags/lib/menu.rb +1 -1
- data/vendor/gems/tags/lib/tags/tag.rb +1 -1
- metadata +72 -145
- data/app/assets/javascripts/adva_cms/admin/jquery.admin.js +0 -23
- data/app/assets/javascripts/adva_cms/admin/jquery.article.js +0 -22
- data/app/assets/javascripts/adva_cms/admin/jquery.cached_pages.js +0 -14
- data/app/assets/javascripts/adva_cms/admin/jquery.table_tree.js +0 -7
- data/app/assets/javascripts/adva_cms/application.js +0 -13
- data/app/assets/javascripts/adva_cms/base.js +0 -4
- data/app/assets/javascripts/adva_cms/cookie.js +0 -49
- data/app/assets/javascripts/adva_cms/jquery/jquery-lowpro.js +0 -224
- data/app/assets/javascripts/adva_cms/jquery/jquery.qtip.js +0 -2085
- data/app/assets/javascripts/adva_cms/jquery/jquery.table_tree.js +0 -307
- data/app/assets/javascripts/adva_cms/jquery/jquery.tablednd_0_5.js +0 -386
- data/app/assets/javascripts/adva_cms/jquery.common.js +0 -41
- data/app/assets/javascripts/adva_cms/jquery.dates.js +0 -51
- data/app/assets/javascripts/adva_cms/jquery.flash.js +0 -59
- data/app/assets/javascripts/adva_cms/jquery.roles.js +0 -25
- data/app/assets/javascripts/adva_cms/json.js +0 -139
- data/app/controllers/admin/base_account_controller.rb +0 -13
- data/app/controllers/admin/install_controller.rb +0 -61
- data/app/controllers/admin/plugins_controller.rb +0 -38
- data/app/helpers/meta_tags_helper.rb +0 -30
- data/app/models/account.rb +0 -7
- data/app/models/event.rb +0 -34
- data/app/views/admin/articles/_meta_tags.html.erb +0 -7
- data/app/views/admin/cached_pages/_filter.html.erb +0 -8
- data/app/views/admin/cached_pages/destroy.js.erb +0 -18
- data/app/views/admin/cached_pages/index.html.erb +0 -26
- data/app/views/admin/plugins/_form.html.erb +0 -11
- data/app/views/admin/plugins/index.html.erb +0 -16
- data/app/views/admin/plugins/show.html.erb +0 -43
- data/app/views/admin/shared/_language_select.html.erb +0 -6
- data/app/views/admin/shared/_section_summary.html.erb +0 -23
- data/app/views/admin/sites/_meta_tags.html.erb +0 -15
- data/app/views/layouts/default.html.erb +0 -38
- data/app/views/layouts/simple.html.erb +0 -22
- data/app/views/shared/_footer.html.erb +0 -4
- data/app/views/shared/messages/insufficient_permissions.html.erb +0 -4
- data/config/initializers/article.rb +0 -8
- data/config/initializers/has_options.rb +0 -2
- data/config/initializers/has_permalink.rb +0 -2
- data/config/initializers/site.rb +0 -8
- data/config/locales/en.yml +0 -1319
- data/lib/action_controller/authenticate_anonymous.rb +0 -69
- data/lib/action_controller/authenticate_user.rb +0 -203
- data/lib/core_ext.rb +0 -7
- data/lib/extensible_forms.rb +0 -284
- data/lib/has_permalink.rb +0 -33
- data/lib/login/helper_integration.rb +0 -11
- data/lib/login/mail_config.rb +0 -39
- data/lib/rails_ext/action_controller/cacheable_flash.rb +0 -30
- data/lib/rails_ext/action_controller/content_for_assignments.rb +0 -106
- data/lib/rails_ext/action_controller/page_caching.rb +0 -23
- data/lib/rails_ext/action_controller/responds_to_parent.rb +0 -46
- data/lib/rails_ext/active_record/exists.rb +0 -5
- data/lib/rails_ext/active_record/sti_instantiation.rb +0 -35
- data/lib/rails_ext/active_record/sticky_changes.rb +0 -30
- data/lib/rails_ext/railties/plugin.rb +0 -58
- data/lib/rails_ext/railties/plugin_configuration.rb +0 -72
- data/lib/registry.rb +0 -49
- data/lib/tasks/translation.rake +0 -69
- data/lib/time_hacks.rb +0 -57
- data/lib/webrat_patch.rb +0 -11
- data/test/meta_tags_test.rb +0 -42
- data/vendor/gems/has_counter/.gitignore +0 -17
- data/vendor/gems/has_counter/Gemfile +0 -4
- data/vendor/gems/has_counter/LICENSE +0 -22
- data/vendor/gems/has_counter/MIT-LICENSE +0 -20
- data/vendor/gems/has_counter/README.markdown +0 -64
- data/vendor/gems/has_counter/README.md +0 -29
- data/vendor/gems/has_counter/Rakefile +0 -2
- data/vendor/gems/has_counter/db/migrate/20080601194338_create_counters_table.rb.rb +0 -13
- data/vendor/gems/has_counter/has_counter.gemspec +0 -17
- data/vendor/gems/has_counter/lib/active_record/has_counter.rb +0 -67
- data/vendor/gems/has_counter/lib/counter.rb +0 -23
- data/vendor/gems/has_counter/lib/has_counter/version.rb +0 -3
- data/vendor/gems/has_counter/lib/has_counter.rb +0 -4
- data/vendor/gems/has_counter/spec/has_counter.sqlite3.db +0 -0
- data/vendor/gems/has_counter/spec/has_counter_spec.rb +0 -55
- data/vendor/gems/has_counter/spec/spec_helper.rb +0 -117
- data/vendor/gems/has_filter/.gitignore +0 -17
- data/vendor/gems/has_filter/Gemfile +0 -4
- data/vendor/gems/has_filter/LICENSE +0 -22
- data/vendor/gems/has_filter/README.md +0 -29
- data/vendor/gems/has_filter/Rakefile +0 -2
- data/vendor/gems/has_filter/app/assets/images/has_filter/filter_add.png +0 -0
- data/vendor/gems/has_filter/app/assets/images/has_filter/filter_button_left.png +0 -0
- data/vendor/gems/has_filter/app/assets/images/has_filter/filter_button_right.png +0 -0
- data/vendor/gems/has_filter/app/assets/images/has_filter/filter_remove.png +0 -0
- data/vendor/gems/has_filter/app/assets/javascripts/has_filter/filter.js +0 -35
- data/vendor/gems/has_filter/app/assets/javascripts/has_filter/jquery.filter.js +0 -23
- data/vendor/gems/has_filter/app/assets/stylesheets/has_filter/alternate/filter.scss +0 -102
- data/vendor/gems/has_filter/app/assets/stylesheets/has_filter/filter.scss +0 -100
- data/vendor/gems/has_filter/app/helpers/filter_helper.rb +0 -3
- data/vendor/gems/has_filter/has_filter.gemspec +0 -17
- data/vendor/gems/has_filter/init.rb +0 -3
- data/vendor/gems/has_filter/lib/has_filter/active_record/act_macro.rb +0 -102
- data/vendor/gems/has_filter/lib/has_filter/filter/base.rb +0 -67
- data/vendor/gems/has_filter/lib/has_filter/filter/categorized.rb +0 -24
- data/vendor/gems/has_filter/lib/has_filter/filter/chain.rb +0 -45
- data/vendor/gems/has_filter/lib/has_filter/filter/set.rb +0 -80
- data/vendor/gems/has_filter/lib/has_filter/filter/state.rb +0 -25
- data/vendor/gems/has_filter/lib/has_filter/filter/tagged.rb +0 -22
- data/vendor/gems/has_filter/lib/has_filter/filter/text.rb +0 -55
- data/vendor/gems/has_filter/lib/has_filter/filter.rb +0 -17
- data/vendor/gems/has_filter/lib/has_filter/version.rb +0 -3
- data/vendor/gems/has_filter/lib/has_filter.rb +0 -22
- data/vendor/gems/has_filter/test/db/setup.rb +0 -45
- data/vendor/gems/has_filter/test/db/test.sqlite3.db +0 -0
- data/vendor/gems/has_filter/test/fixtures.rb +0 -15
- data/vendor/gems/has_filter/test/has_filter/filter_chain_test.rb +0 -41
- data/vendor/gems/has_filter/test/has_filter/filter_scopes_test.rb +0 -102
- data/vendor/gems/has_filter/test/has_filter/filter_tags_test.rb +0 -113
- data/vendor/gems/has_filter/test/has_filter/integration.rb +0 -15
- data/vendor/gems/has_filter/test/has_filter/scopes_test.rb +0 -48
- data/vendor/gems/has_filter/test/log/test.log +0 -34346
- data/vendor/gems/has_filter/test/models.rb +0 -23
- data/vendor/gems/has_filter/test/templates/has_filter/test/index.html.erb +0 -5
- data/vendor/gems/has_filter/test/test_helper.rb +0 -66
- data/vendor/gems/xss_terminate/.gitignore +0 -17
- data/vendor/gems/xss_terminate/Gemfile +0 -4
- data/vendor/gems/xss_terminate/LICENSE +0 -22
- data/vendor/gems/xss_terminate/MIT-LICENSE +0 -20
- data/vendor/gems/xss_terminate/README +0 -94
- data/vendor/gems/xss_terminate/README.md +0 -29
- data/vendor/gems/xss_terminate/Rakefile +0 -23
- data/vendor/gems/xss_terminate/lib/html5lib_sanitize.rb +0 -2453
- data/vendor/gems/xss_terminate/lib/rails_sanitize.rb +0 -8
- data/vendor/gems/xss_terminate/lib/xss_terminate/version.rb +0 -3
- data/vendor/gems/xss_terminate/lib/xss_terminate.rb +0 -141
- data/vendor/gems/xss_terminate/tasks/xss_terminate_tasks.rake +0 -7
- data/vendor/gems/xss_terminate/test/models/comment.rb +0 -5
- data/vendor/gems/xss_terminate/test/models/entry.rb +0 -7
- data/vendor/gems/xss_terminate/test/models/message.rb +0 -3
- data/vendor/gems/xss_terminate/test/models/person.rb +0 -5
- data/vendor/gems/xss_terminate/test/models/review.rb +0 -5
- data/vendor/gems/xss_terminate/test/schema.rb +0 -34
- data/vendor/gems/xss_terminate/test/setup_test.rb +0 -16
- data/vendor/gems/xss_terminate/test/xss_terminate_test.rb +0 -50
- data/vendor/gems/xss_terminate/xss_terminate.gemspec +0 -17
- /data/lib/tasks/{adva_cms.rake → adva.rake} +0 -0
@@ -1,79 +1,57 @@
|
|
1
1
|
class ArticlesController < BaseController
|
2
|
-
before_action :set_section
|
3
|
-
before_action :adjust_action
|
4
|
-
before_action :set_category, :only => :index
|
5
|
-
before_action :set_tags, :only => :index
|
6
|
-
before_action :set_articles, :only => :index
|
7
|
-
before_action :set_article, :only => :show
|
8
|
-
|
9
|
-
authenticates_anonymous_user
|
10
|
-
|
11
2
|
def index
|
12
|
-
@article =
|
3
|
+
@article = articles.first
|
13
4
|
if !@article
|
14
5
|
raise ActiveRecord::RecordNotFound
|
15
|
-
elsif @article.is_a?(Link)
|
16
|
-
redirect_to @article.body
|
17
6
|
else
|
18
7
|
show
|
19
8
|
end
|
20
9
|
end
|
21
10
|
|
22
11
|
def show
|
23
|
-
|
24
|
-
|
12
|
+
@article ||= section.articles.find_by_permalink!(params[:permalink])
|
13
|
+
if @article.draft?
|
14
|
+
raise ActiveRecord::RecordNotFound unless current_user.admin?
|
25
15
|
end
|
26
|
-
|
16
|
+
return redirect_to @article.body if @article.is_a?(Link)
|
27
17
|
|
28
|
-
|
29
|
-
|
30
|
-
def current_resource
|
31
|
-
@section.try(:single_article_mode) ? @section : @article || @section
|
18
|
+
if stale?([*@article.cells, @article, section, site], public: true)
|
19
|
+
render template: "#{section.type.tableize}/articles/show"
|
32
20
|
end
|
21
|
+
end
|
33
22
|
|
34
|
-
|
35
|
-
def adjust_action
|
36
|
-
if params[:action] == 'index' and @section.try(:single_article_mode)
|
37
|
-
# ... but only if there is one published article
|
38
|
-
unless @section.contents.blank? || (@section.contents.first.draft? && current_user.admin?)
|
39
|
-
@action_name = @_params[:action] = request.parameters['action'] = 'show'
|
40
|
-
end
|
41
|
-
end
|
42
|
-
end
|
23
|
+
private
|
43
24
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
@section.contents.first
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
def set_articles
|
53
|
-
scope = @category ? @category.all_contents : @section.contents
|
54
|
-
scope = scope.tagged(@tags) if @tags.present?
|
25
|
+
helper_method def articles
|
26
|
+
@articles ||= begin
|
27
|
+
scope = category ? category.all_contents : section.contents
|
28
|
+
scope = scope.tagged(tags) if tags.any?
|
55
29
|
scope = scope.published
|
56
|
-
|
30
|
+
scope.paginate(page: current_page).limit(section.contents_per_page.to_i)
|
57
31
|
end
|
32
|
+
end
|
58
33
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
raise ActiveRecord::RecordNotFound unless @category
|
63
|
-
end
|
34
|
+
helper_method def category
|
35
|
+
if !defined?(@category)
|
36
|
+
@category = params[:category_id] ? section.categories.find(params[:category_id]) : nil
|
64
37
|
end
|
38
|
+
@category
|
39
|
+
end
|
65
40
|
|
66
|
-
|
67
|
-
|
41
|
+
helper_method def tags
|
42
|
+
if !defined?(@tags)
|
43
|
+
@tags = if params[:tags]
|
68
44
|
names = params[:tags].split('+')
|
69
45
|
@tags = Tag.where(name: names).pluck(:name)
|
70
46
|
raise ActiveRecord::RecordNotFound unless @tags.size == names.size
|
47
|
+
else
|
48
|
+
[]
|
71
49
|
end
|
72
50
|
end
|
51
|
+
@tags
|
52
|
+
end
|
73
53
|
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
end
|
78
|
-
end
|
54
|
+
helper_method def current_resource
|
55
|
+
section.try(:single_article_mode) ? section : @article || section
|
56
|
+
end
|
79
57
|
end
|
@@ -1,18 +1,19 @@
|
|
1
|
+
require "adva/authenticate_user"
|
2
|
+
|
1
3
|
class BaseController < ApplicationController
|
2
4
|
class SectionRoutingError < ActionController::RoutingError; end
|
3
|
-
helper :base, :resource, :content
|
4
|
-
helper HasFilter::Helper
|
5
|
+
helper :base, :resource, :content
|
5
6
|
helper TableBuilder
|
6
7
|
|
7
8
|
include CacheableFlash
|
8
9
|
include ContentHelper
|
9
10
|
include ResourceHelper
|
10
11
|
|
12
|
+
include Adva::AuthenticateUser
|
13
|
+
|
11
14
|
before_action :set_site, :set_timezone
|
12
15
|
attr_accessor :site, :section
|
13
16
|
|
14
|
-
layout 'default'
|
15
|
-
|
16
17
|
def site
|
17
18
|
@site ||= Site.find_by_host!(request.host)
|
18
19
|
end
|
@@ -21,12 +22,11 @@ class BaseController < ApplicationController
|
|
21
22
|
|
22
23
|
alias :set_site :site
|
23
24
|
|
24
|
-
def sections
|
25
|
+
helper_method def sections
|
25
26
|
@sections ||= site.sections
|
26
27
|
end
|
27
|
-
helper_method :sections
|
28
28
|
|
29
|
-
def
|
29
|
+
helper_method def section
|
30
30
|
@section ||= begin
|
31
31
|
if params.key?(:section_permalink)
|
32
32
|
sections.find_by_permalink!(params[:section_permalink])
|
@@ -37,7 +37,7 @@ class BaseController < ApplicationController
|
|
37
37
|
raise ActiveRecord::RecordNotFound unless @section.published?(true) || current_user.admin?
|
38
38
|
@section
|
39
39
|
end
|
40
|
-
alias :
|
40
|
+
alias :set_section :section
|
41
41
|
|
42
42
|
def set_timezone
|
43
43
|
Time.zone = @site.timezone if @site
|
@@ -6,12 +6,11 @@ class PasswordController < BaseController
|
|
6
6
|
end
|
7
7
|
|
8
8
|
def create
|
9
|
-
flash[:notice] = t(:'adva.passwords.flash.create.notification')
|
10
9
|
if user = User.find_by_email(params[:user][:email])
|
11
10
|
token = user.assign_token 'password'
|
12
11
|
user.save!
|
13
12
|
trigger_event user, :password_reset_requested, :token => "#{user.id};#{token}"
|
14
|
-
redirect_to edit_password_url
|
13
|
+
redirect_to edit_password_url, notice: "If the given email address exists in our system, we have just sent you an email with information on how to reset your password."
|
15
14
|
else
|
16
15
|
render :action => :new
|
17
16
|
end
|
@@ -23,12 +22,11 @@ class PasswordController < BaseController
|
|
23
22
|
def update
|
24
23
|
if current_user && current_user.update(params[:user].slice(:password))
|
25
24
|
trigger_event current_user, :password_updated
|
26
|
-
flash[:notice] = t(:'adva.passwords.flash.update.success')
|
27
25
|
authenticate_user(:email => current_user.email, :password => params[:user][:password])
|
28
|
-
redirect_to "/"
|
26
|
+
redirect_to "/", notice: "Your password was changed successfully."
|
29
27
|
else
|
30
28
|
params[:token] = nil # ugh
|
31
|
-
flash
|
29
|
+
flash.now.alert = "Your password could not be changed."
|
32
30
|
render :action => :edit
|
33
31
|
end
|
34
32
|
end
|
@@ -12,19 +12,17 @@ class SessionController < BaseController
|
|
12
12
|
def create
|
13
13
|
if authenticate_user(params[:user])
|
14
14
|
remember_me! if params[:user][:remember_me]
|
15
|
-
|
16
|
-
redirect_to return_from(:login)
|
15
|
+
redirect_to return_from(:login), notice: "Logged in successfully."
|
17
16
|
else
|
18
17
|
@user = User.new(:email => params[:user][:email])
|
19
18
|
@remember_me = params[:user][:remember_me]
|
20
|
-
flash.now
|
19
|
+
flash.now.alert = "Could not login with this email and password."
|
21
20
|
render :action => 'new'
|
22
21
|
end
|
23
22
|
end
|
24
23
|
|
25
24
|
def destroy
|
26
25
|
logout
|
27
|
-
|
28
|
-
redirect_to return_from(:logout)
|
26
|
+
redirect_to return_from(:logout), notice: "Logged out successfully."
|
29
27
|
end
|
30
28
|
end
|
@@ -6,7 +6,7 @@ module ActivitiesHelper
|
|
6
6
|
:locals => { :activity => activity, :recent => recent }
|
7
7
|
end.join
|
8
8
|
else
|
9
|
-
html = %(<li class="empty shade"
|
9
|
+
html = %(<li class="empty shade">Nothing happened.</li>)
|
10
10
|
end
|
11
11
|
raw %(<ul class="activities">#{html}</ul>)
|
12
12
|
end
|
@@ -19,34 +19,22 @@ module ActivitiesHelper
|
|
19
19
|
|
20
20
|
def activity_datetime(activity, short = false)
|
21
21
|
if activity.from and short
|
22
|
-
from = activity.from.
|
23
|
-
to = activity.to.
|
22
|
+
from = activity.from.to_fs(:time_only)
|
23
|
+
to = activity.to.to_fs(:time_only)
|
24
24
|
"#{from} - #{to}"
|
25
25
|
elsif activity.from and activity.from.to_date != activity.to.to_date
|
26
|
-
from = activity.from.
|
27
|
-
to = activity.to.
|
26
|
+
from = activity.from.to_fs(:long_ordinalized)
|
27
|
+
to = activity.to.to_fs(:long_ordinal)
|
28
28
|
"#{from} - #{to}"
|
29
29
|
elsif activity.from
|
30
|
-
from = activity.from.
|
31
|
-
to = activity.to.
|
30
|
+
from = activity.from.to_fs(:long_ordinal)
|
31
|
+
to = activity.to.to_fs(:time_only)
|
32
32
|
"#{from} - #{to}"
|
33
33
|
else
|
34
|
-
activity.created_at.
|
34
|
+
activity.created_at.to_fs(short ? :time_only : :long_ordinal)
|
35
35
|
end
|
36
36
|
end
|
37
37
|
|
38
|
-
# def activity_datetime(activity, short = false)
|
39
|
-
# from, to = if activity.from && short
|
40
|
-
# [l(activity.from, :format => :time), l(activity.to, :format => :time)]
|
41
|
-
# elsif activity.from && activity.from.to_date != activity.to.to_date
|
42
|
-
# [l(activity.from, :format => :short), l(activity.to, :format => :short)]
|
43
|
-
# elsif activity.from
|
44
|
-
# [l(activity.from, :format => :short), l(activity.to, :format => :time)]
|
45
|
-
# end
|
46
|
-
|
47
|
-
# t(:'adva.activity.from_to', :from => from, :to => to)
|
48
|
-
# end
|
49
|
-
|
50
38
|
def activity_object_edit_url(activity)
|
51
39
|
type = activity.object_attributes['type'] || activity.object_type
|
52
40
|
send "edit_admin_#{type}_path".downcase, activity.site_id, activity.section_id, activity.object_id
|
@@ -71,3 +59,4 @@ module ActivitiesHelper
|
|
71
59
|
end
|
72
60
|
end
|
73
61
|
end
|
62
|
+
|
@@ -1,8 +1,8 @@
|
|
1
1
|
module Admin::BaseHelper
|
2
2
|
def save_or_cancel_links(builder, options = {})
|
3
|
-
save_text = options.delete(:save_text) ||
|
4
|
-
or_text = options.delete(:or_text) ||
|
5
|
-
cancel_text = options.delete(:cancel_text) ||
|
3
|
+
save_text = options.delete(:save_text) || "Save"
|
4
|
+
or_text = options.delete(:or_text) || "or"
|
5
|
+
cancel_text = options.delete(:cancel_text) || "Cancel"
|
6
6
|
cancel_url = options.delete(:cancel_url)
|
7
7
|
|
8
8
|
save_options = options.delete(:save) || {}
|
@@ -18,29 +18,11 @@ module Admin::BaseHelper
|
|
18
18
|
end
|
19
19
|
|
20
20
|
def link_to_profile(options = {})
|
21
|
-
name = options[:name].nil? ?
|
21
|
+
name = options[:name].nil? ? "Profile" : options[:name]
|
22
22
|
path = admin_user_path(current_user)
|
23
23
|
link_to(name, path)
|
24
24
|
end
|
25
25
|
|
26
|
-
def links_to_content_translations(content, &block)
|
27
|
-
return '' if content.new_record?
|
28
|
-
block = Proc.new { |locale| link_to_edit(locale, content, :cl => locale) } unless block
|
29
|
-
locales = content.translated_locales.map { |locale| block.call(locale.to_s) }
|
30
|
-
content_tag(:span, :class => 'content_translations') do
|
31
|
-
t(:"adva.#{content[:type].tableize}.translation_links", :locales => locales.join(', ')) +
|
32
|
-
"<p class=\"hint\" for=\"content_translations\">#{t(:'adva.hints.content_translations')}</p>"
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def link_to_clear_cached_pages(site)
|
37
|
-
link_to(t(:'adva.cached_pages.links.clear_all'), admin_cached_pages_path(site), :method => :delete)
|
38
|
-
end
|
39
|
-
|
40
|
-
def link_to_restore_plugin_defaults(site, plugin)
|
41
|
-
link_to(t(:'adva.titles.restore_defaults'), admin_plugin_path(site, plugin), :data => { :confirm => t(:'adva.plugins.confirm_reset') })
|
42
|
-
end
|
43
|
-
|
44
26
|
# FIXME: translations
|
45
27
|
def page_cached_at(page)
|
46
28
|
if Date.today == page.updated_at.to_date
|
data/app/helpers/base_helper.rb
CHANGED
@@ -34,7 +34,7 @@ module BaseHelper
|
|
34
34
|
def filter_options
|
35
35
|
FilteredColumn.filters.keys.inject([]) do |arr, key|
|
36
36
|
arr << [FilteredColumn.filters[key].filter_name, key.to_s]
|
37
|
-
end.unshift [
|
37
|
+
end.unshift ["Plain HTML", '']
|
38
38
|
end
|
39
39
|
|
40
40
|
def author_options(users)
|
@@ -31,7 +31,7 @@ module ContentHelper
|
|
31
31
|
def content_status(content)
|
32
32
|
return "<span> </span>" unless content.respond_to?(:published?)
|
33
33
|
klass = content.published? ? 'published' : 'pending'
|
34
|
-
text = content.published? ?
|
34
|
+
text = content.published? ? "Published" : "Pending"
|
35
35
|
|
36
36
|
"<span title='#{text}' alt='#{text}' class='status #{klass}'>#{text}</span>"
|
37
37
|
end
|
@@ -40,7 +40,7 @@ module ContentHelper
|
|
40
40
|
options = args.extract_options!
|
41
41
|
content, text = *args.reverse
|
42
42
|
|
43
|
-
text ||=
|
43
|
+
text ||= "Preview"
|
44
44
|
url = show_path(content, :cl => content.class.locale, :namespace => nil)
|
45
45
|
|
46
46
|
options.reverse_merge!(:url => url, :class => "preview #{content.class.name.underscore}")
|
@@ -64,8 +64,10 @@ module ContentHelper
|
|
64
64
|
|
65
65
|
def links_to_content_categories(content, key = nil)
|
66
66
|
return if content.categories.empty?
|
67
|
-
links = content.categories.map
|
68
|
-
|
67
|
+
links = content.categories.map do |category|
|
68
|
+
link_to_category content.section, category
|
69
|
+
end
|
70
|
+
raw "in: #{links.join(', ')}"
|
69
71
|
end
|
70
72
|
|
71
73
|
def link_to_tag(*args, &block)
|
@@ -84,7 +86,7 @@ module ContentHelper
|
|
84
86
|
def links_to_content_tags(content, key = nil)
|
85
87
|
return if content.tags.empty?
|
86
88
|
links = content.tags.map { |tag| link_to_tag content.section, tag }
|
87
|
-
|
89
|
+
raw "tagged: #{links.join(', ')}"
|
88
90
|
end
|
89
91
|
|
90
92
|
def content_category_checkbox(content, category)
|
@@ -73,7 +73,7 @@ module ResourceHelper
|
|
73
73
|
|
74
74
|
def resource_link_id(action, type, resource)
|
75
75
|
id = [action, type]
|
76
|
-
id << resource.id if resource.is_a?(ActiveRecord::Base) &&
|
76
|
+
id << resource.id if resource.is_a?(ActiveRecord::Base) && !%i[index name].include?(action)
|
77
77
|
id.join('_')
|
78
78
|
end
|
79
79
|
|
@@ -103,14 +103,14 @@ module ResourceHelper
|
|
103
103
|
def normalize_resource_link_options(options, action, type, resource)
|
104
104
|
options[:class] ||= "#{action} #{type}"
|
105
105
|
options[:id] ||= resource_link_id(action, type, resource)
|
106
|
-
options[:title] ||=
|
106
|
+
options[:title] ||= action.to_s.titleize
|
107
107
|
options.reverse_merge!(resource_delete_options(type, options)) if action == :delete
|
108
108
|
options
|
109
109
|
end
|
110
110
|
|
111
111
|
def normalize_resource_link_text(text, action, type)
|
112
112
|
type = type.to_s.gsub('/', '_').pluralize
|
113
|
-
text ||=
|
113
|
+
text ||= action.capitalize
|
114
114
|
text = t(text) if text.is_a?(Symbol)
|
115
115
|
text
|
116
116
|
end
|
@@ -118,8 +118,7 @@ module ResourceHelper
|
|
118
118
|
def resource_delete_options(type, options)
|
119
119
|
type = type.to_s.gsub('/', '_').pluralize
|
120
120
|
message = options.delete(:confirm)
|
121
|
-
message ||=
|
122
|
-
message = t(message) if message.is_a?(Symbol)
|
121
|
+
message ||= "Are you sure you want to delete this #{type}?"
|
123
122
|
{ :data => { :confirm => message }, :method => :delete }
|
124
123
|
end
|
125
124
|
end
|
data/app/helpers/users_helper.rb
CHANGED
data/app/models/activity.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require "adva/belongs_to_author"
|
2
|
+
|
1
3
|
class Activity < ActiveRecord::Base
|
2
4
|
belongs_to :site
|
3
5
|
belongs_to :section
|
@@ -11,6 +13,7 @@ class Activity < ActiveRecord::Base
|
|
11
13
|
end
|
12
14
|
}
|
13
15
|
|
16
|
+
include Adva::BelongsToAuthor
|
14
17
|
belongs_to_author
|
15
18
|
|
16
19
|
serialize :actions
|
data/app/models/article.rb
CHANGED
@@ -1,13 +1,9 @@
|
|
1
1
|
class Article < Content
|
2
2
|
# default_scope :order => "#{self.table_name}.published_at DESC"
|
3
3
|
|
4
|
-
filters_attributes :except => [:excerpt, :excerpt_html, :body, :body_html, :cached_tag_list]
|
5
|
-
|
6
4
|
validates_presence_of :title, :body
|
7
5
|
validates_uniqueness_of :permalink, scope: :section_id, case_sensitive: true
|
8
6
|
|
9
|
-
class_attribute :meta_fields, default: %w(keywords description author copyright geourl)
|
10
|
-
|
11
7
|
class << self
|
12
8
|
def locale
|
13
9
|
"en"
|
@@ -39,11 +35,4 @@ class Article < Content
|
|
39
35
|
date = [:year, :month, :day].map { |key| [key, (published? ? published_at : created_at).send(key)] }.flatten
|
40
36
|
Hash[:permalink, permalink, *date]
|
41
37
|
end
|
42
|
-
|
43
|
-
def default_meta_description
|
44
|
-
sanitizer = defined?(Rails::Html::FullSanitizer) ? Rails::Html::FullSanitizer.new : HTML::FullSanitizer.new
|
45
|
-
sanitized_excerpt = sanitizer.sanitize(excerpt || "").gsub(/\s+/, " ").strip.truncate(160)
|
46
|
-
sanitized_body = sanitizer.sanitize(body || "").gsub(/\s+/, " ").strip.truncate(160)
|
47
|
-
sanitized_excerpt.present? ? sanitized_excerpt : sanitized_body
|
48
|
-
end
|
49
38
|
end
|
data/app/models/category.rb
CHANGED
@@ -1,10 +1,10 @@
|
|
1
1
|
require "awesome_nested_set"
|
2
|
-
require "has_permalink"
|
2
|
+
require "adva/has_permalink"
|
3
3
|
|
4
4
|
class Category < ActiveRecord::Base
|
5
5
|
acts_as_nested_set :scope => :section_id
|
6
6
|
|
7
|
-
include HasPermalink
|
7
|
+
include Adva::HasPermalink
|
8
8
|
has_permalink :title, :url_attribute => :permalink, :sync_url => true, :only_when_blank => true, :scope => :section_id
|
9
9
|
|
10
10
|
belongs_to :section, :foreign_key => 'section_id'
|
@@ -26,7 +26,7 @@ class Category < ActiveRecord::Base
|
|
26
26
|
end
|
27
27
|
|
28
28
|
def all_contents
|
29
|
-
Content.by_category(self)
|
29
|
+
Content.by_category(self).order(published_at: :desc)
|
30
30
|
end
|
31
31
|
|
32
32
|
protected
|
data/app/models/content.rb
CHANGED
@@ -1,23 +1,22 @@
|
|
1
|
+
require "adva/has_permalink"
|
2
|
+
require "adva/belongs_to_author"
|
3
|
+
|
1
4
|
class Content < ActiveRecord::Base
|
2
5
|
acts_as_nested_set :scope => :section_id
|
3
6
|
|
4
|
-
# TODO is this needed?
|
5
|
-
class Version < ActiveRecord::Base
|
6
|
-
filters_attributes :none => true
|
7
|
-
end
|
8
|
-
|
9
|
-
has_filter :tagged, :categorized,
|
10
|
-
:text => { :attributes => [:title, :body, :excerpt] },
|
11
|
-
:state => { :states => [:published, :unpublished] }
|
12
|
-
|
13
7
|
acts_as_taggable
|
14
8
|
|
15
|
-
|
9
|
+
include Adva::HasPermalink
|
16
10
|
has_permalink :title, :url_attribute => :permalink, :sync_url => true, :only_when_blank => true, :scope => :section_id
|
17
|
-
|
11
|
+
|
12
|
+
filtered_column :body, :excerpt # TODO rm all of this and the associated _html columns
|
13
|
+
|
14
|
+
has_cells :body, :excerpt if respond_to?(:has_cells)
|
18
15
|
|
19
16
|
belongs_to :site
|
20
17
|
belongs_to :section, :touch => true
|
18
|
+
|
19
|
+
include Adva::BelongsToAuthor
|
21
20
|
belongs_to_author :validate => true
|
22
21
|
|
23
22
|
has_many :asset_assignments # TODO :dependent => :delete_all?
|
@@ -63,34 +62,6 @@ class Content < ActiveRecord::Base
|
|
63
62
|
permalink
|
64
63
|
end
|
65
64
|
|
66
|
-
def cache_key(*timestamp_names)
|
67
|
-
if new_record?
|
68
|
-
"#{model_name.cache_key}/new"
|
69
|
-
else
|
70
|
-
timestamp_names = [:updated_at, :cells_updated_at] if timestamp_names.none?
|
71
|
-
timestamp = timestamp_names.map { |attr| send(attr) }.compact.map(&:to_time).max
|
72
|
-
timestamp = timestamp.utc.to_s(cache_timestamp_format)
|
73
|
-
"#{model_name.cache_key}/#{id}-#{timestamp}"
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
def cells_updated_at
|
78
|
-
if defined?(OutputFilter::Cells)
|
79
|
-
OutputFilter::Cells.new(nil).send(:cells, body_html).values.map do |name, state, attrs|
|
80
|
-
attrs = HashWithIndifferentAccess.new(attrs)
|
81
|
-
cell = "#{name.camelize}Cell".constantize.new
|
82
|
-
args = [state]
|
83
|
-
attrs.delete "class" # ignore styling class
|
84
|
-
attrs[:format] = :timestamp
|
85
|
-
args << attrs unless attrs.empty?
|
86
|
-
begin
|
87
|
-
cell.render_state *args
|
88
|
-
rescue ArgumentError
|
89
|
-
end
|
90
|
-
end.select { |response| response.is_a?(Time) }.max
|
91
|
-
end
|
92
|
-
end
|
93
|
-
|
94
65
|
def owners
|
95
66
|
owner.owners << owner
|
96
67
|
end
|
data/app/models/link.rb
CHANGED
@@ -1,8 +1,4 @@
|
|
1
|
-
require "login/mail_config"
|
2
|
-
|
3
1
|
class PasswordMailer < ActionMailer::Base
|
4
|
-
include Login::MailConfig
|
5
|
-
|
6
2
|
class << self
|
7
3
|
def handle_user_password_reset_requested!(event)
|
8
4
|
reset_password_email(
|
@@ -22,9 +18,9 @@ class PasswordMailer < ActionMailer::Base
|
|
22
18
|
|
23
19
|
private
|
24
20
|
|
25
|
-
|
26
|
-
|
27
|
-
|
21
|
+
def password_reset_link(controller, token)
|
22
|
+
controller.send(:url_for, :action => 'edit', :token => token)
|
23
|
+
end
|
28
24
|
end
|
29
25
|
|
30
26
|
def reset_password_email(attributes = {})
|
@@ -34,7 +30,7 @@ class PasswordMailer < ActionMailer::Base
|
|
34
30
|
mail({
|
35
31
|
to: attributes[:user].email,
|
36
32
|
from: attributes[:from],
|
37
|
-
subject:
|
33
|
+
subject: "Forgotten Password",
|
38
34
|
})
|
39
35
|
end
|
40
36
|
|
@@ -43,7 +39,8 @@ class PasswordMailer < ActionMailer::Base
|
|
43
39
|
mail({
|
44
40
|
to: attributes[:user].email,
|
45
41
|
from: attributes[:from],
|
46
|
-
subject:
|
42
|
+
subject: "Password Updated",
|
47
43
|
})
|
48
44
|
end
|
49
45
|
end
|
46
|
+
|
data/app/models/section.rb
CHANGED
@@ -1,12 +1,8 @@
|
|
1
|
-
require "has_options"
|
2
|
-
require "has_permalink"
|
1
|
+
require "adva/has_options"
|
2
|
+
require "adva/has_permalink"
|
3
3
|
require "awesome_nested_set"
|
4
|
-
require "rails_ext/active_record/sti_instantiation"
|
5
4
|
|
6
5
|
class Section < ActiveRecord::Base
|
7
|
-
include HasOptions
|
8
|
-
include HasPermalink
|
9
|
-
|
10
6
|
default_scope -> { order(:lft) }
|
11
7
|
|
12
8
|
class_attribute :types, default: ["Page"]
|
@@ -16,11 +12,14 @@ class Section < ActiveRecord::Base
|
|
16
12
|
|
17
13
|
serialize :permissions
|
18
14
|
|
15
|
+
include Adva::HasOptions
|
19
16
|
has_option :contents_per_page, :default => 15
|
17
|
+
|
18
|
+
include Adva::HasPermalink
|
20
19
|
has_permalink :title, :url_attribute => :permalink, :sync_url => true,
|
21
20
|
:only_when_blank => true, :scope => [ :site_id, :parent_id ]
|
21
|
+
|
22
22
|
acts_as_nested_set :scope => :site_id
|
23
|
-
instantiates_with_sti
|
24
23
|
|
25
24
|
belongs_to :site, :touch => true
|
26
25
|
has_many :categories, -> { order(:lft) }, dependent: :destroy do
|
data/app/models/site.rb
CHANGED
@@ -28,8 +28,6 @@ class Site < ActiveRecord::Base
|
|
28
28
|
|
29
29
|
cattr_accessor :multi_sites_enabled, :cache_sweeper_logging
|
30
30
|
|
31
|
-
class_attribute :meta_fields, default: %w(keywords description author copyright geourl)
|
32
|
-
|
33
31
|
class << self
|
34
32
|
def find_by_host!(host)
|
35
33
|
return Site.first if count == 1 && !multi_sites_enabled
|
data/app/models/user.rb
CHANGED
@@ -7,12 +7,11 @@ class User < ActiveRecord::Base
|
|
7
7
|
|
8
8
|
scope :verified, -> { where.not(verified_at: nil) }
|
9
9
|
|
10
|
-
belongs_to :account
|
11
10
|
has_many :memberships, :dependent => :delete_all
|
12
11
|
has_many :sites, :through => :memberships
|
13
12
|
|
14
13
|
validates_presence_of :first_name, :email
|
15
|
-
validates_uniqueness_of :email, case_sensitive: false
|
14
|
+
validates_uniqueness_of :email, case_sensitive: false
|
16
15
|
validates_length_of :first_name, :within => 1..40
|
17
16
|
validates_length_of :last_name, :allow_nil => true, :within => 0..40
|
18
17
|
validates_format_of :email, :allow_nil => true,
|
@@ -1,5 +1,5 @@
|
|
1
|
-
<%=
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
1
|
+
<%= @activity.author_name %>
|
2
|
+
<%= @activity.author_email %>
|
3
|
+
just posted a new <%= @activity.object.class %>
|
4
|
+
on <%= @activity.site.name %>
|
5
|
+
in section <%= @activity.section.title %>
|