adva 0.1.4 → 0.2.1
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 -57
- 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/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 +71 -144
- 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,106 +0,0 @@
|
|
1
|
-
# FIXME Suggest a core patch for splitting render like this:
|
2
|
-
module ActionView
|
3
|
-
module Renderable #:nodoc:
|
4
|
-
def render(view, local_assigns = {})
|
5
|
-
compile(local_assigns)
|
6
|
-
|
7
|
-
view.with_template self do
|
8
|
-
view.send(:_evaluate_assigns_and_ivars)
|
9
|
-
view.send(:_set_controller_content_type, mime_type) if respond_to?(:mime_type)
|
10
|
-
|
11
|
-
view.send(method_name(local_assigns), local_assigns, &content_assignments_proc(view))
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
def content_assignments_proc(view)
|
16
|
-
Proc.new do |*names|
|
17
|
-
ivar = :@_proc_for_layout
|
18
|
-
if !view.instance_variable_defined?(:"@content_for_#{names.first}") && view.instance_variable_defined?(ivar) && (proc = view.instance_variable_get(ivar))
|
19
|
-
view.capture(*names, &proc)
|
20
|
-
elsif view.instance_variable_defined?(ivar = :"@content_for_#{names.first || :layout}")
|
21
|
-
view.instance_variable_get(ivar)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
ActionView::Renderable.module_eval do
|
29
|
-
prepend Module.new {
|
30
|
-
def content_assignments_proc(view)
|
31
|
-
Proc.new do |*names|
|
32
|
-
if view.controller.registered_contents
|
33
|
-
contents = view.controller.registered_contents.select { |id, content| content.target == names.first }
|
34
|
-
contents.each do |id, content|
|
35
|
-
# content_for always appends the new content. we might want to have
|
36
|
-
# more finegrained control over that.
|
37
|
-
view.content_for(names.first, content.render(view))
|
38
|
-
end
|
39
|
-
end
|
40
|
-
super(view).call(*names)
|
41
|
-
end
|
42
|
-
end
|
43
|
-
}
|
44
|
-
end
|
45
|
-
|
46
|
-
|
47
|
-
ActionController::Base.class_eval do
|
48
|
-
class_attribute :registered_contents
|
49
|
-
self.registered_contents = ActiveSupport::OrderedHash.new
|
50
|
-
|
51
|
-
class << self
|
52
|
-
def content_for(target, id, *args, &block)
|
53
|
-
self.registered_contents[id] = RegisteredContent.new(id, target, *args, &block)
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
|
58
|
-
class RegisteredContent
|
59
|
-
attr_reader :id, :target, :content, :options
|
60
|
-
|
61
|
-
def initialize(id, target, *args, &block)
|
62
|
-
@id = id
|
63
|
-
@target = target
|
64
|
-
@options = args.extract_options!
|
65
|
-
@content = block_given? ? block : args.first
|
66
|
-
|
67
|
-
normalize_options!
|
68
|
-
end
|
69
|
-
|
70
|
-
def render(view)
|
71
|
-
view.content_for(target, eval_content(view)) if applies?(view)
|
72
|
-
end
|
73
|
-
|
74
|
-
def applies?(view)
|
75
|
-
included = options[:only] ? condition_applies?(:only, view) : true
|
76
|
-
excluded = options[:except] ? condition_applies?(:except, view) : false
|
77
|
-
included and not excluded
|
78
|
-
end
|
79
|
-
|
80
|
-
private
|
81
|
-
|
82
|
-
def eval_content(view)
|
83
|
-
content.is_a?(Proc) ? view.instance_eval(&content) : content
|
84
|
-
end
|
85
|
-
|
86
|
-
def condition_applies?(type, view)
|
87
|
-
proc = lambda do |condition, value|
|
88
|
-
condition = options[type][condition]
|
89
|
-
condition.is_a?(Proc) ? condition.call(view.controller) : value.in?(condition)
|
90
|
-
end
|
91
|
-
proc.call(:controller, view.controller.controller_path.to_sym) or
|
92
|
-
proc.call(:action, view.controller.action_name.to_sym) or
|
93
|
-
proc.call(:format, view.template_format.to_sym)
|
94
|
-
end
|
95
|
-
|
96
|
-
def normalize_options!
|
97
|
-
@options.each do |type, condition|
|
98
|
-
condition.each do |key, value|
|
99
|
-
case value
|
100
|
-
when Array; @options[type][key] = value.map(&:to_sym)
|
101
|
-
when String; @options[type][key] = value.to_sym
|
102
|
-
end
|
103
|
-
end
|
104
|
-
end
|
105
|
-
end
|
106
|
-
end
|
@@ -1,23 +0,0 @@
|
|
1
|
-
ActionController::Base.class_eval do
|
2
|
-
def expire_pages(pages)
|
3
|
-
pages.each { |page| expire_page(page.url) if page.url }
|
4
|
-
CachedPage.expire_pages(pages)
|
5
|
-
end
|
6
|
-
|
7
|
-
def expire_site_page_cache
|
8
|
-
# FIXME
|
9
|
-
# We can not simply kill the whole cache dir.
|
10
|
-
# The following misses assets (like stylesheets) from themes though
|
11
|
-
# because they are not referenced as cached, yet. Do we need to expire
|
12
|
-
# these assets at all though?
|
13
|
-
expire_pages CachedPage.find_all_by_site_id(@site.id)
|
14
|
-
|
15
|
-
# cache_dir = page_cache_directory
|
16
|
-
# if cache_dir.gsub('/', '') =~ /public$/
|
17
|
-
# expire_pages CachedPage.find_all_by_site_id(@site.id)
|
18
|
-
# else
|
19
|
-
# @site.cached_pages.delete_all
|
20
|
-
# Pathname.new(cache_dir).rmtree rescue Errno::ENOENT
|
21
|
-
# end
|
22
|
-
end
|
23
|
-
end
|
@@ -1,46 +0,0 @@
|
|
1
|
-
# Module containing the methods useful for child IFRAME to parent window communication
|
2
|
-
module RespondsToParent
|
3
|
-
# Executes the response body as JavaScript in the context of the parent window.
|
4
|
-
# Use this method of you are posting a form to a hidden IFRAME or if you would like
|
5
|
-
# to use IFRAME base RPC.
|
6
|
-
def responds_to_parent(&block)
|
7
|
-
yield
|
8
|
-
|
9
|
-
if performed?
|
10
|
-
# We're returning HTML instead of JS or XML now
|
11
|
-
response.headers['Content-Type'] = 'text/html; charset=UTF-8'
|
12
|
-
|
13
|
-
# Either pull out a redirect or the request body
|
14
|
-
script = if location = erase_redirect_results
|
15
|
-
"document.location.href = #{location.to_s.inspect}"
|
16
|
-
else
|
17
|
-
response.body
|
18
|
-
end
|
19
|
-
|
20
|
-
# Escape quotes, linebreaks and slashes, maintaining previously escaped slashes
|
21
|
-
# Suggestions for improvement?
|
22
|
-
script = (script || '').
|
23
|
-
gsub('\\', '\\\\\\').
|
24
|
-
gsub(/\r\n|\r|\n/, '\\n').
|
25
|
-
gsub(/['"]/, '\\\\\&').
|
26
|
-
gsub('</script>','</scr"+"ipt>')
|
27
|
-
|
28
|
-
# Clear out the previous render to prevent double render
|
29
|
-
erase_results
|
30
|
-
|
31
|
-
# Eval in parent scope and replace document location of this frame
|
32
|
-
# so back button doesn't replay action on targeted forms
|
33
|
-
# loc = document.location to be set after parent is updated for IE
|
34
|
-
# with(window.parent) - pull in variables from parent window
|
35
|
-
# setTimeout - scope the execution in the windows parent for safari
|
36
|
-
# window.eval - legal eval for Opera
|
37
|
-
render :text => "<html><body><script type='text/javascript' charset='utf-8'>
|
38
|
-
var loc = document.location;
|
39
|
-
with(window.parent) { setTimeout(function() { window.eval('#{script}'); loc.replace('about:blank'); }, 1) }
|
40
|
-
</script></body></html>"
|
41
|
-
end
|
42
|
-
end
|
43
|
-
alias respond_to_parent responds_to_parent
|
44
|
-
end
|
45
|
-
|
46
|
-
ActionController::Base.send :include, RespondsToParent
|
@@ -1,35 +0,0 @@
|
|
1
|
-
# http://coderrr.wordpress.com/2008/04/22/building-the-right-class-with-sti-in-rails/
|
2
|
-
|
3
|
-
module ActiveRecord::StiInstantiation
|
4
|
-
module ActMacro
|
5
|
-
def instantiates_with_sti
|
6
|
-
include InstanceMethods
|
7
|
-
extend ClassMethods
|
8
|
-
instantiates_with_sti?
|
9
|
-
end
|
10
|
-
|
11
|
-
def instantiates_with_sti?
|
12
|
-
included_modules.include?(ActiveRecord::StiInstantiation::InstanceMethods)
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
module InstanceMethods
|
17
|
-
end
|
18
|
-
|
19
|
-
module ClassMethods
|
20
|
-
def new(*args, &block)
|
21
|
-
options = args.first.is_a?(Hash) ? args.first : {}
|
22
|
-
type = options[:type] || options['type']
|
23
|
-
klass = type.is_a?(Class) ? type : type.constantize if type
|
24
|
-
|
25
|
-
if type and klass != self
|
26
|
-
raise "STI instantiation error: class #{klass.name} should be a descendant of #{self.name}" unless klass < self
|
27
|
-
klass.new(*args, &block)
|
28
|
-
else
|
29
|
-
super
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
ActiveRecord::Base.send :extend, ActiveRecord::StiInstantiation::ActMacro
|
@@ -1,30 +0,0 @@
|
|
1
|
-
# This stops the record from forgetting changes when the record
|
2
|
-
# is saved.
|
3
|
-
#
|
4
|
-
# If you're interested in changes between subsequent saves
|
5
|
-
# you can call #clear_changes! to clear them.
|
6
|
-
|
7
|
-
# ActiveRecord::Base.class_eval do
|
8
|
-
# alias :save :save_without_dirty
|
9
|
-
# alias :save! :save_without_dirty!
|
10
|
-
#
|
11
|
-
# def clear_changes! # TODO figure out a better name
|
12
|
-
# changed_attributes.clear
|
13
|
-
# end
|
14
|
-
#
|
15
|
-
# def state_changes
|
16
|
-
# if frozen?
|
17
|
-
# [:deleted]
|
18
|
-
# elsif just_created?
|
19
|
-
# [:created]
|
20
|
-
# elsif changed?
|
21
|
-
# [:updated]
|
22
|
-
# else
|
23
|
-
# []
|
24
|
-
# end
|
25
|
-
# end
|
26
|
-
#
|
27
|
-
# def just_created?
|
28
|
-
# !!changes['id'] and changes['id'].first.nil?
|
29
|
-
# end
|
30
|
-
# end
|
@@ -1,58 +0,0 @@
|
|
1
|
-
# - keep track of plugins in Rails.plugins
|
2
|
-
# - allow engines to ship their own vendor/plugins
|
3
|
-
# - add observers to plugin.app_paths
|
4
|
-
# - add an alias to register_[asset]_expansion to plugins
|
5
|
-
Rails::Configuration.class_eval do
|
6
|
-
def default_plugin_loader
|
7
|
-
Rails::Plugin::RegisteringLoader
|
8
|
-
end
|
9
|
-
|
10
|
-
def default_plugin_locators
|
11
|
-
locators = []
|
12
|
-
locators << Rails::Plugin::GemLocator if defined? Gem
|
13
|
-
locators << Rails::Plugin::NestedFileSystemLocator
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
module Rails
|
18
|
-
class << self
|
19
|
-
def plugins
|
20
|
-
@@plugins ||= ActiveSupport::OrderedHash.new
|
21
|
-
end
|
22
|
-
|
23
|
-
def plugin?(name)
|
24
|
-
plugins.keys.include?(name.to_sym)
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
class Plugin
|
29
|
-
class RegisteringLoader < Rails::Plugin::Loader # ummm, what's a better name?
|
30
|
-
def register_plugin_as_loaded(plugin)
|
31
|
-
Rails.plugins[plugin.name.to_sym] = plugin
|
32
|
-
super
|
33
|
-
end
|
34
|
-
end
|
35
|
-
|
36
|
-
def app_paths
|
37
|
-
['models', 'helpers', 'observers'].map { |path| File.join(directory, 'app', path) } << controller_path << metal_path
|
38
|
-
end
|
39
|
-
|
40
|
-
def register_javascript_expansion(*args)
|
41
|
-
ActionView::Helpers::AssetTagHelper.register_javascript_expansion *args
|
42
|
-
end
|
43
|
-
|
44
|
-
def register_stylesheet_expansion(*args)
|
45
|
-
ActionView::Helpers::AssetTagHelper.register_stylesheet_expansion *args
|
46
|
-
end
|
47
|
-
|
48
|
-
class NestedFileSystemLocator < FileSystemLocator
|
49
|
-
def locate_plugins_under(base_path)
|
50
|
-
plugins = super
|
51
|
-
Dir["{#{plugins.map(&:directory).join(',')}}/vendor/plugins"].each do |path|
|
52
|
-
plugins.concat super(path)
|
53
|
-
end unless plugins.empty?
|
54
|
-
plugins
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
58
|
-
end
|
@@ -1,72 +0,0 @@
|
|
1
|
-
module Rails
|
2
|
-
class Plugin
|
3
|
-
module Configurable
|
4
|
-
class Config < ActiveRecord::Base
|
5
|
-
self.table_name = 'plugin_configs'
|
6
|
-
serialize :options, Hash
|
7
|
-
belongs_to :owner, :polymorphic => true
|
8
|
-
|
9
|
-
after_initialize do
|
10
|
-
write_attribute(:options, {}) if read_attribute(:options).nil?
|
11
|
-
end
|
12
|
-
end
|
13
|
-
|
14
|
-
attr_accessor :owner
|
15
|
-
|
16
|
-
def option_definitions
|
17
|
-
@option_definitions ||= {}
|
18
|
-
end
|
19
|
-
|
20
|
-
def option(name, default, type = :string)
|
21
|
-
define_option_accessors(name, default)
|
22
|
-
option_definitions[name.to_sym] = { :default => default, :type => type }
|
23
|
-
end
|
24
|
-
|
25
|
-
def options=(options)
|
26
|
-
# FIXME symbolize_keys and slice defined options
|
27
|
-
config.options = options
|
28
|
-
end
|
29
|
-
|
30
|
-
def id
|
31
|
-
name
|
32
|
-
end
|
33
|
-
|
34
|
-
def to_param
|
35
|
-
name
|
36
|
-
end
|
37
|
-
|
38
|
-
def save!
|
39
|
-
config.save!
|
40
|
-
end
|
41
|
-
|
42
|
-
def destroy
|
43
|
-
config.destroy
|
44
|
-
@config = nil
|
45
|
-
end
|
46
|
-
|
47
|
-
private
|
48
|
-
|
49
|
-
def define_option_accessors(name, default)
|
50
|
-
raise "can't use #{name.inspect} as an option name" if respond_to? name
|
51
|
-
instance_eval <<-END, __FILE__, __LINE__
|
52
|
-
def #{name}
|
53
|
-
config.options[#{name.inspect}] || #{default.inspect}
|
54
|
-
end
|
55
|
-
def #{name}=(value)
|
56
|
-
config.options[#{name.inspect}] = value
|
57
|
-
end
|
58
|
-
END
|
59
|
-
end
|
60
|
-
|
61
|
-
def config
|
62
|
-
@config ||= begin
|
63
|
-
raise 'undefined @owner for plugin config' unless @owner
|
64
|
-
Config.find_by_name_and_owner_type_and_owner_id(self.name, @owner.class.name, @owner.id) ||
|
65
|
-
Config.new(:name => self.name, :owner => @owner)
|
66
|
-
end
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
Rails::Plugin.send :include, Rails::Plugin::Configurable
|
data/lib/registry.rb
DELETED
@@ -1,49 +0,0 @@
|
|
1
|
-
class Registry < Hash
|
2
|
-
class << self
|
3
|
-
def instance
|
4
|
-
@@instance ||= new
|
5
|
-
end
|
6
|
-
|
7
|
-
def get(*args)
|
8
|
-
instance.get *args
|
9
|
-
end
|
10
|
-
|
11
|
-
def set(*args)
|
12
|
-
instance.set *args
|
13
|
-
end
|
14
|
-
|
15
|
-
def clear
|
16
|
-
instance.clear
|
17
|
-
end
|
18
|
-
end
|
19
|
-
|
20
|
-
def initialize
|
21
|
-
blk = lambda {|h,k| h[k] = Registry.new(&blk)}
|
22
|
-
super &blk
|
23
|
-
end
|
24
|
-
|
25
|
-
def set(*args)
|
26
|
-
value, last_key = args.pop, args.pop
|
27
|
-
target = args.inject(self){|result, key| result[key] }
|
28
|
-
value = to_registry(value) if value.is_a?(Hash)
|
29
|
-
target[last_key] = value
|
30
|
-
end
|
31
|
-
|
32
|
-
def get(*keys)
|
33
|
-
keys.inject self do |result, key|
|
34
|
-
return nil unless result.has_key?(key)
|
35
|
-
result[key]
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
protected
|
40
|
-
|
41
|
-
def to_registry(hash)
|
42
|
-
registry = Registry.new
|
43
|
-
hash.each do |key, value|
|
44
|
-
value = to_registry(value) if value.is_a?(Hash)
|
45
|
-
registry[key] = value
|
46
|
-
end
|
47
|
-
registry
|
48
|
-
end
|
49
|
-
end
|
data/lib/tasks/translation.rake
DELETED
@@ -1,69 +0,0 @@
|
|
1
|
-
namespace :adva do
|
2
|
-
namespace :i18n do
|
3
|
-
#Define locales root
|
4
|
-
language_root = Rails.root.join("vendor/plugins/adva_cms/locale/adva_cms/")
|
5
|
-
base_language = "en"
|
6
|
-
|
7
|
-
desc "Check differences in locale files"
|
8
|
-
task :check do
|
9
|
-
base = YAML::load_file("#{language_root}#{base_language}.yml")
|
10
|
-
base_keys = all_keys(base, base_language)
|
11
|
-
|
12
|
-
Dir["#{language_root}*.yml"].each do |f|
|
13
|
-
language = File.basename(f,".yml")
|
14
|
-
next if language == base_language
|
15
|
-
|
16
|
-
comp = YAML::load_file("#{language_root}#{language}.yml")
|
17
|
-
comp_keys = all_keys(comp, language)
|
18
|
-
|
19
|
-
puts "MISSING KEYS IN #{language.upcase!}"
|
20
|
-
puts base_keys - comp_keys
|
21
|
-
puts "EXTRA KEYS IN #{language}"
|
22
|
-
puts comp_keys - base_keys
|
23
|
-
end
|
24
|
-
end
|
25
|
-
|
26
|
-
desc "Migrate section and category titles. Specify e.g., LOCALE=de if app locale isn't en."
|
27
|
-
task :migrate_titles => :environment do
|
28
|
-
locale = ENV['locale'] || 'en'
|
29
|
-
connection = ActiveRecord::Base.connection
|
30
|
-
sql = %{
|
31
|
-
INSERT INTO section_translations (section_id, locale, title, created_at, updated_at)
|
32
|
-
SELECT sections.id, "#{locale}", sections.title, sections.published_at, sections.published_at
|
33
|
-
FROM sections
|
34
|
-
}
|
35
|
-
connection.insert sql, "migrating sections to globalize"
|
36
|
-
connection.remove_column 'sections', 'title'
|
37
|
-
|
38
|
-
t = ActiveRecord::Base.default_timezone == :utc ? Time.now.utc : Time.now
|
39
|
-
qt = connection.quote(t)
|
40
|
-
sql = %{
|
41
|
-
INSERT INTO category_translations (category_id, locale, title, created_at, updated_at)
|
42
|
-
SELECT categories.id, #{connection.quote(locale)}, categories.title, #{qt}, #{qt}
|
43
|
-
FROM categories
|
44
|
-
}
|
45
|
-
connection.insert sql, "migrating categories to globalize"
|
46
|
-
connection.remove_column 'categories', 'title'
|
47
|
-
|
48
|
-
Rake::Task['db:schema:dump'].invoke
|
49
|
-
end
|
50
|
-
end
|
51
|
-
end
|
52
|
-
|
53
|
-
def all_keys(h, language)
|
54
|
-
r_keys(h[language]).flatten! # we exclude the top level key
|
55
|
-
end
|
56
|
-
|
57
|
-
# Returns all keys in a hash recursively, prepending the previous key name
|
58
|
-
def r_keys(h,prev = "")
|
59
|
-
keys = []
|
60
|
-
if h.is_a?(Hash)
|
61
|
-
h.each do |k,v|
|
62
|
-
key = prev.blank? ? k : "#{prev}:#{k}"
|
63
|
-
keys << key
|
64
|
-
sub = r_keys(v, key)
|
65
|
-
keys << sub unless sub.empty?
|
66
|
-
end
|
67
|
-
end
|
68
|
-
keys
|
69
|
-
end
|
data/lib/time_hacks.rb
DELETED
@@ -1,57 +0,0 @@
|
|
1
|
-
class Time
|
2
|
-
class << self
|
3
|
-
def extract_from_attributes!(attrs, field, method = :local)
|
4
|
-
parse_from_attributes(attrs, field, method).tap do |time|
|
5
|
-
attrs.delete_if { |k, v| k.to_s =~ /^#{field}.+/ }
|
6
|
-
end unless attrs.blank?
|
7
|
-
end
|
8
|
-
|
9
|
-
# Used for getting multifield attributes like those generated by a
|
10
|
-
# select_datetime into a new Time object. For example if you have
|
11
|
-
# following <tt>params={:meetup=>{:"time(1i)=>..."}}</tt> just do
|
12
|
-
# following:
|
13
|
-
#
|
14
|
-
# <tt>Time.parse_from_attributes(params[:meetup], :time)</tt>
|
15
|
-
def parse_from_attributes(attrs, field, method = :local)
|
16
|
-
attrs = attrs.keys.sort.grep(/^#{field.to_s}\(.+\)$/).map { |k| attrs[k] }
|
17
|
-
attrs.any? ? Time.zone.send(method, *attrs) : nil
|
18
|
-
end
|
19
|
-
|
20
|
-
def delta(year, month = nil, day = nil)
|
21
|
-
from = Time.zone.local(year, month || 1, day || 1)
|
22
|
-
to =
|
23
|
-
if !day.blank?
|
24
|
-
from.advance :days => 1
|
25
|
-
elsif !month.blank?
|
26
|
-
from.advance :months => 1
|
27
|
-
else
|
28
|
-
from.advance :years => 1
|
29
|
-
end
|
30
|
-
return [from.midnight, to.midnight-1]
|
31
|
-
end
|
32
|
-
end
|
33
|
-
|
34
|
-
def to_delta(delta_type = :day)
|
35
|
-
case delta_type
|
36
|
-
when :year then self.class.delta(year)
|
37
|
-
when :month then self.class.delta(year, month)
|
38
|
-
else self.class.delta(year, month, day)
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
# Time.now.to_ordinalized_s :long
|
43
|
-
# => "February 28th, 2006 21:10"
|
44
|
-
def to_ordinalized_s(format = :default)
|
45
|
-
format = DATE_FORMATS[format]
|
46
|
-
return to_default_s if format.nil?
|
47
|
-
strftime(format.gsub(/%d/, '_%d_')).gsub(/_(\d+)_/) { |s| s.to_i.ordinalize }
|
48
|
-
end
|
49
|
-
|
50
|
-
DATE_FORMATS.update \
|
51
|
-
:standard => '%B %d, %Y @ %I:%M %p',
|
52
|
-
:stub => '%B %d',
|
53
|
-
:time_only => '%I:%M %p',
|
54
|
-
:plain => '%B %d %I:%M %p',
|
55
|
-
:mdy => '%B %d, %Y',
|
56
|
-
:my => '%B %Y'
|
57
|
-
end
|
data/lib/webrat_patch.rb
DELETED
data/test/meta_tags_test.rb
DELETED
@@ -1,42 +0,0 @@
|
|
1
|
-
$:.unshift File.expand_path(File.dirname(__FILE__) + '/../app/helpers')
|
2
|
-
$:.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
|
3
|
-
require 'meta_tags_helper'
|
4
|
-
|
5
|
-
require 'rubygems'
|
6
|
-
require 'action_controller'
|
7
|
-
require 'action_view'
|
8
|
-
require 'action_view/test_case'
|
9
|
-
|
10
|
-
class RailsExtTest < ActionView::TestCase
|
11
|
-
class MetaTagThingy
|
12
|
-
attr_accessor :meta_author, :meta_geourl, :meta_copyright, :meta_keywords, :meta_description
|
13
|
-
def initialize(*args)
|
14
|
-
@meta_author, @meta_geourl, @meta_copyright, @meta_keywords, @meta_description = *args
|
15
|
-
end
|
16
|
-
end
|
17
|
-
|
18
|
-
class MetaTagThingyController
|
19
|
-
def current_resource
|
20
|
-
MetaTagThingy.new("the author", "the geourl", "the copyright", "the keywords", "the description")
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
tests MetaTagsHelper
|
25
|
-
|
26
|
-
def setup
|
27
|
-
super
|
28
|
-
@controller = MetaTagThingyController.new
|
29
|
-
@resource = MetaTagThingy.new("the author", "the geourl", "the copyright", "the keywords", "the description")
|
30
|
-
@tags = meta_tags(@resource).split(/\n/)
|
31
|
-
end
|
32
|
-
|
33
|
-
test "returns meta tags as expected" do
|
34
|
-
assert Array === @tags
|
35
|
-
assert_equal 5, @tags.size
|
36
|
-
assert_equal '<meta content="the author" name="author" />', @tags.first
|
37
|
-
end
|
38
|
-
|
39
|
-
test "#meta_value_from returns first non-blank value" do
|
40
|
-
assert_equal 'foo', meta_value_from(nil, '', 'foo')
|
41
|
-
end
|
42
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
Copyright (c) 2012 Micah Geisel
|
2
|
-
|
3
|
-
MIT License
|
4
|
-
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
-
a copy of this software and associated documentation files (the
|
7
|
-
"Software"), to deal in the Software without restriction, including
|
8
|
-
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
-
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
-
permit persons to whom the Software is furnished to do so, subject to
|
11
|
-
the following conditions:
|
12
|
-
|
13
|
-
The above copyright notice and this permission notice shall be
|
14
|
-
included in all copies or substantial portions of the Software.
|
15
|
-
|
16
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
-
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
-
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
-
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
-
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
-
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
-
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
@@ -1,20 +0,0 @@
|
|
1
|
-
Copyright (c) 2008 Sven Fuchs
|
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.
|