trusty-cms 2.0.2 → 2.0.3.pre.beta
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +13 -5
- data/.gitignore +0 -2
- data/CONTRIBUTORS.md +1 -3
- data/Gemfile +1 -6
- data/Gemfile.lock +80 -100
- data/INSTALL.md +6 -7
- data/README.md +1 -3
- data/Rakefile +4 -24
- data/app/assets/javascripts/admin/jquery-ui.js +2339 -3787
- data/app/assets/javascripts/admin/page-edit.js +3 -3
- data/app/assets/javascripts/admin/tabcontrol.js.erb +16 -16
- data/app/assets/javascripts/admin/treetable.js +2 -4
- data/app/assets/stylesheets/admin/_base.scss +4 -4
- data/app/assets/stylesheets/admin/modules/_links.scss +1 -1
- data/app/assets/stylesheets/admin/partials/_content.scss +2 -9
- data/app/assets/stylesheets/admin/partials/_forms.scss +29 -97
- data/app/assets/stylesheets/admin/partials/_header.scss +3 -2
- data/app/assets/stylesheets/admin/partials/_index.scss +6 -9
- data/app/assets/stylesheets/admin/partials/_layout.scss +2 -1
- data/app/assets/stylesheets/admin/partials/_popup.scss +11 -0
- data/app/assets/stylesheets/admin/partials/_tabcontrol.scss +4 -4
- data/app/assets/stylesheets/admin/partials/_typography.scss +0 -4
- data/app/controllers/admin/pages_controller.rb +1 -9
- data/app/controllers/admin/references_controller.rb +1 -8
- data/app/controllers/admin/users_controller.rb +1 -1
- data/app/controllers/admin/welcome_controller.rb +3 -3
- data/app/controllers/application_controller.rb.rails2 +113 -0
- data/app/controllers/site_controller.rb +1 -1
- data/app/helpers/admin/node_helper.rb +4 -4
- data/app/helpers/application_helper.rb.rails2 +242 -0
- data/app/models/trusty_cms/config.rb +1 -2
- data/app/views/admin/configuration/edit.html.haml +2 -2
- data/app/views/admin/configuration/show.html.haml +1 -1
- data/app/views/admin/layouts/_form.html.haml +1 -1
- data/app/views/admin/layouts/remove.html.haml +1 -1
- data/app/views/admin/pages/_fields.html.haml +1 -1
- data/app/views/admin/pages/_node.html.haml +2 -2
- data/app/views/admin/pages/edit.html.haml +1 -1
- data/app/views/admin/pages/remove.html.haml +2 -2
- data/app/views/admin/preferences/edit.html.haml +36 -36
- data/app/views/admin/users/_form.html.haml +1 -1
- data/app/views/admin/users/_password_fields.html.haml +1 -1
- data/app/views/admin/users/remove.html.haml +1 -1
- data/app/views/admin/welcome/login.html.haml +1 -1
- data/app/views/layouts/application.html.haml +16 -18
- data/config/application.rb +1 -2
- data/config/boot.rb +1 -0
- data/config/database.mysql.yml +3 -3
- data/{spec/dummy/config/database.yml → config/database.yml.rails2} +4 -4
- data/config/environment.rb.rails2 +89 -0
- data/config/environments/development.rb +0 -1
- data/config/environments/development.rb.rails2 +17 -0
- data/config/environments/production.rb.rails2 +24 -0
- data/config/environments/test.rb +4 -2
- data/config/initializers/trusty_cms_config.rb +0 -1
- data/config/routes.rb +0 -1
- data/config/routes.rb.rails2 +41 -0
- data/db/migrate/001_create_radiant_tables.rb +0 -1
- data/db/migrate/003_rename_behavior_column.rb +9 -0
- data/db/migrate/019_add_salt_to_users.rb +11 -0
- data/db/migrate/20100805155020_convert_page_metas.rb +13 -0
- data/db/migrate/20110902203823_add_allowed_children_cache_to_pages.rb +4 -0
- data/db/migrate/20120209231801_change_pages_allowed_children_cache_to_text.rb +1 -0
- data/lib/generators/instance/templates/databases/mysql.yml +3 -3
- data/lib/generators/instance/templates/instance_gemfile +2 -2
- data/lib/generators/trusty_cms/templates/database.yml.erb +4 -4
- data/lib/generators/trusty_cms/templates/routes.rb.erb +1 -0
- data/lib/login_system.rb +1 -1
- data/lib/tasks/database.rake +3 -1
- data/lib/tasks/framework.rake +1 -1
- data/lib/trusty_cms/admin_ui.rb +0 -2
- data/lib/trusty_cms/extension_migrator.rb +2 -1
- data/lib/trusty_cms/initializer.rb +1 -1
- data/lib/trusty_cms/setup.rb +1 -1
- data/lib/trusty_cms.rb +1 -1
- data/public/stylesheets/admin/main.css +1 -0
- data/{spec/dummy/config/routes.rb → public/stylesheets/admin/overrides.css} +0 -0
- data/spec/ci/database.mysql.yml +1 -1
- data/spec/features/pages_spec.rb +2 -2
- data/spec/helpers/regions_helper_spec.rb +16 -0
- data/spec/rails_helper.rb +4 -3
- data/spec/spec_helper.rb +77 -13
- data/spec/support/custom_actions.rb +0 -1
- data/test/test_helper.rb.rails2 +64 -0
- data/tmp/cache/747/A70/TrustyCms%3A%3AConfig +0 -0
- data/tmp/cache/85C/FA0/TrustyCms.cache_mtime +0 -0
- data/tmp/cache_files_test/a.txt +1 -0
- data/tmp/cache_files_test/all.txt +3 -0
- data/tmp/cache_files_test/b.txt +1 -0
- data/tmp/config/radiant_config.yml +27 -0
- data/tmp/sass-cache/1a137f46a4706893cc07b2aa949a92cf851d936f/_boxes.sassc +0 -0
- data/tmp/sass-cache/1a137f46a4706893cc07b2aa949a92cf851d936f/_gradients.sassc +0 -0
- data/tmp/sass-cache/1a137f46a4706893cc07b2aa949a92cf851d936f/_links.sassc +0 -0
- data/tmp/sass-cache/28de5f95620abb7d2385166aed681f8b13104764/_appearance.scssc +0 -0
- data/tmp/sass-cache/28de5f95620abb7d2385166aed681f8b13104764/_background-clip.scssc +0 -0
- data/tmp/sass-cache/28de5f95620abb7d2385166aed681f8b13104764/_background-origin.scssc +0 -0
- data/tmp/sass-cache/28de5f95620abb7d2385166aed681f8b13104764/_background-size.scssc +0 -0
- data/tmp/sass-cache/28de5f95620abb7d2385166aed681f8b13104764/_border-radius.scssc +0 -0
- data/tmp/sass-cache/28de5f95620abb7d2385166aed681f8b13104764/_box-shadow.scssc +0 -0
- data/tmp/sass-cache/28de5f95620abb7d2385166aed681f8b13104764/_box-sizing.scssc +0 -0
- data/tmp/sass-cache/28de5f95620abb7d2385166aed681f8b13104764/_box.scssc +0 -0
- data/tmp/sass-cache/28de5f95620abb7d2385166aed681f8b13104764/_columns.scssc +0 -0
- data/tmp/sass-cache/28de5f95620abb7d2385166aed681f8b13104764/_filter.scssc +0 -0
- data/tmp/sass-cache/28de5f95620abb7d2385166aed681f8b13104764/_font-face.scssc +0 -0
- data/tmp/sass-cache/28de5f95620abb7d2385166aed681f8b13104764/_hyphenation.scssc +0 -0
- data/tmp/sass-cache/28de5f95620abb7d2385166aed681f8b13104764/_images.scssc +0 -0
- data/tmp/sass-cache/28de5f95620abb7d2385166aed681f8b13104764/_inline-block.scssc +0 -0
- data/tmp/sass-cache/28de5f95620abb7d2385166aed681f8b13104764/_opacity.scssc +0 -0
- data/tmp/sass-cache/28de5f95620abb7d2385166aed681f8b13104764/_regions.scssc +0 -0
- data/tmp/sass-cache/28de5f95620abb7d2385166aed681f8b13104764/_shared.scssc +0 -0
- data/tmp/sass-cache/28de5f95620abb7d2385166aed681f8b13104764/_text-shadow.scssc +0 -0
- data/tmp/sass-cache/28de5f95620abb7d2385166aed681f8b13104764/_transform.scssc +0 -0
- data/tmp/sass-cache/28de5f95620abb7d2385166aed681f8b13104764/_transition.scssc +0 -0
- data/tmp/sass-cache/28de5f95620abb7d2385166aed681f8b13104764/_user-interface.scssc +0 -0
- data/tmp/sass-cache/2f4278d4f2cc4f21f31aa67430e462fbca6b47a0/_actions.sassc +0 -0
- data/tmp/sass-cache/2f4278d4f2cc4f21f31aa67430e462fbca6b47a0/_avatars.sassc +0 -0
- data/tmp/sass-cache/2f4278d4f2cc4f21f31aa67430e462fbca6b47a0/_content.sassc +0 -0
- data/tmp/sass-cache/2f4278d4f2cc4f21f31aa67430e462fbca6b47a0/_dateinput.sassc +0 -0
- data/tmp/sass-cache/2f4278d4f2cc4f21f31aa67430e462fbca6b47a0/_deprecated.sassc +0 -0
- data/tmp/sass-cache/2f4278d4f2cc4f21f31aa67430e462fbca6b47a0/_dropdown.sassc +0 -0
- data/tmp/sass-cache/2f4278d4f2cc4f21f31aa67430e462fbca6b47a0/_footer.sassc +0 -0
- data/tmp/sass-cache/2f4278d4f2cc4f21f31aa67430e462fbca6b47a0/_forms.sassc +0 -0
- data/tmp/sass-cache/2f4278d4f2cc4f21f31aa67430e462fbca6b47a0/_header.sassc +0 -0
- data/tmp/sass-cache/2f4278d4f2cc4f21f31aa67430e462fbca6b47a0/_index.sassc +0 -0
- data/tmp/sass-cache/2f4278d4f2cc4f21f31aa67430e462fbca6b47a0/_layout.sassc +0 -0
- data/tmp/sass-cache/2f4278d4f2cc4f21f31aa67430e462fbca6b47a0/_messages.sassc +0 -0
- data/tmp/sass-cache/2f4278d4f2cc4f21f31aa67430e462fbca6b47a0/_popup.sassc +0 -0
- data/tmp/sass-cache/2f4278d4f2cc4f21f31aa67430e462fbca6b47a0/_tabcontrol.sassc +0 -0
- data/tmp/sass-cache/2f4278d4f2cc4f21f31aa67430e462fbca6b47a0/_toolbar.sassc +0 -0
- data/tmp/sass-cache/2f4278d4f2cc4f21f31aa67430e462fbca6b47a0/_typography.sassc +0 -0
- data/tmp/sass-cache/2f4278d4f2cc4f21f31aa67430e462fbca6b47a0/_validations.sassc +0 -0
- data/tmp/sass-cache/33c9f77b54ab77293741bf5159eedff124a39fc1/_color.scssc +0 -0
- data/tmp/sass-cache/33c9f77b54ab77293741bf5159eedff124a39fc1/_general.scssc +0 -0
- data/tmp/sass-cache/33c9f77b54ab77293741bf5159eedff124a39fc1/_sprites.scssc +0 -0
- data/tmp/sass-cache/33c9f77b54ab77293741bf5159eedff124a39fc1/_tables.scssc +0 -0
- data/tmp/sass-cache/5683573556a6b271b3ffade55f4ff32a60e7c0f0/_base.scssc +0 -0
- data/tmp/sass-cache/5683573556a6b271b3ffade55f4ff32a60e7c0f0/_sprite-img.scssc +0 -0
- data/tmp/sass-cache/6159fdf943b5ffc54b901a34cdfcfc7e6f736834/_alternating-rows-and-columns.scssc +0 -0
- data/tmp/sass-cache/6159fdf943b5ffc54b901a34cdfcfc7e6f736834/_borders.scssc +0 -0
- data/tmp/sass-cache/6159fdf943b5ffc54b901a34cdfcfc7e6f736834/_scaffolding.scssc +0 -0
- data/tmp/sass-cache/81fb0626d3f9dbbcc1f43df416db1c97b6ad512a/_links.scssc +0 -0
- data/tmp/sass-cache/81fb0626d3f9dbbcc1f43df416db1c97b6ad512a/_lists.scssc +0 -0
- data/tmp/sass-cache/81fb0626d3f9dbbcc1f43df416db1c97b6ad512a/_text.scssc +0 -0
- data/tmp/sass-cache/81fb0626d3f9dbbcc1f43df416db1c97b6ad512a/_vertical_rhythm.scssc +0 -0
- data/tmp/sass-cache/87c1de4edf14dc5f527f65e2080e0faa325354aa/_hover-link.scssc +0 -0
- data/tmp/sass-cache/87c1de4edf14dc5f527f65e2080e0faa325354aa/_link-colors.scssc +0 -0
- data/tmp/sass-cache/87c1de4edf14dc5f527f65e2080e0faa325354aa/_unstyled-link.scssc +0 -0
- data/tmp/sass-cache/8b412a89f899813981285eadb5f08e52b94dfb65/_css3.scssc +0 -0
- data/tmp/sass-cache/8b412a89f899813981285eadb5f08e52b94dfb65/_support.scssc +0 -0
- data/tmp/sass-cache/8b412a89f899813981285eadb5f08e52b94dfb65/_typography.scssc +0 -0
- data/tmp/sass-cache/8b412a89f899813981285eadb5f08e52b94dfb65/_utilities.scssc +0 -0
- data/tmp/sass-cache/92844cd19a320f87ef960171cea4f33d1a07339c/_contrast.scssc +0 -0
- data/tmp/sass-cache/a97de1041408f914478b9e7943c5c6c2d221d4c0/_ellipsis.scssc +0 -0
- data/tmp/sass-cache/a97de1041408f914478b9e7943c5c6c2d221d4c0/_force-wrap.scssc +0 -0
- data/tmp/sass-cache/a97de1041408f914478b9e7943c5c6c2d221d4c0/_nowrap.scssc +0 -0
- data/tmp/sass-cache/a97de1041408f914478b9e7943c5c6c2d221d4c0/_replacement.scssc +0 -0
- data/tmp/sass-cache/b3d80baefd48593d8c08815ba2d83e209f5dad6f/_grid-background.scssc +0 -0
- data/tmp/sass-cache/b92bfc773efa04d930ffa0b3331244a1f378caa7/_compass.scssc +0 -0
- data/tmp/sass-cache/c055a2360b102aff9247707235d9dce9214f6c4f/_clearfix.scssc +0 -0
- data/tmp/sass-cache/c055a2360b102aff9247707235d9dce9214f6c4f/_float.scssc +0 -0
- data/tmp/sass-cache/c055a2360b102aff9247707235d9dce9214f6c4f/_hacks.scssc +0 -0
- data/tmp/sass-cache/c055a2360b102aff9247707235d9dce9214f6c4f/_min.scssc +0 -0
- data/tmp/sass-cache/c055a2360b102aff9247707235d9dce9214f6c4f/_reset.scssc +0 -0
- data/tmp/sass-cache/c055a2360b102aff9247707235d9dce9214f6c4f/_tag-cloud.scssc +0 -0
- data/tmp/sass-cache/c3fa060b99d9ed1d9740af472ecc747182e2ea93/_base.sassc +0 -0
- data/tmp/sass-cache/c3fa060b99d9ed1d9740af472ecc747182e2ea93/main.sassc +0 -0
- data/tmp/sass-cache/c3fa060b99d9ed1d9740af472ecc747182e2ea93/overrides.sassc +0 -0
- data/tmp/sass-cache/d2bf234de18cb20fe8238c9224b9863ed5d268c6/_bullets.scssc +0 -0
- data/tmp/sass-cache/d2bf234de18cb20fe8238c9224b9863ed5d268c6/_horizontal-list.scssc +0 -0
- data/tmp/sass-cache/d2bf234de18cb20fe8238c9224b9863ed5d268c6/_inline-block-list.scssc +0 -0
- data/tmp/sass-cache/d2bf234de18cb20fe8238c9224b9863ed5d268c6/_inline-list.scssc +0 -0
- data/tmp/sass-cache/dc9647e96d50c02214aff50e88308a74bf56d1d7/_utilities.scssc +0 -0
- data/trusty_cms.gemspec +2 -4
- metadata +180 -171
- data/spec/dummy/README.rdoc +0 -28
- data/spec/dummy/Rakefile +0 -5
- data/spec/dummy/bin/bundle +0 -3
- data/spec/dummy/bin/rails +0 -4
- data/spec/dummy/bin/rake +0 -4
- data/spec/dummy/bin/setup +0 -29
- data/spec/dummy/config/application.rb +0 -152
- data/spec/dummy/config/boot.rb +0 -6
- data/spec/dummy/config/environment.rb +0 -5
- data/spec/dummy/config/environments/development.rb +0 -49
- data/spec/dummy/config/environments/production.rb +0 -79
- data/spec/dummy/config/environments/test.rb +0 -42
- data/spec/dummy/config/initializers/assets.rb +0 -11
- data/spec/dummy/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/dummy/config/initializers/cookies_serializer.rb +0 -3
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +0 -4
- data/spec/dummy/config/initializers/inflections.rb +0 -16
- data/spec/dummy/config/initializers/mime_types.rb +0 -4
- data/spec/dummy/config/initializers/session_store.rb +0 -3
- data/spec/dummy/config/initializers/trusty_cms_config.rb +0 -20
- data/spec/dummy/config/initializers/wrap_parameters.rb +0 -14
- data/spec/dummy/config/locales/en.yml +0 -23
- data/spec/dummy/config/secrets.yml +0 -22
- data/spec/dummy/config.ru +0 -4
- data/spec/dummy/db/schema.rb +0 -122
- data/spec/dummy/log/test.log +0 -25081
- data/spec/dummy/public/404.html +0 -67
- data/spec/dummy/public/422.html +0 -67
- data/spec/dummy/public/500.html +0 -66
- data/spec/dummy/public/favicon.ico +0 -0
- data/spec/dummy/tmp/cache/747/A70/TrustyCms%3A%3AConfig +0 -0
- data/spec/dummy/tmp/cache/85C/FA0/TrustyCms.cache_mtime +0 -0
- data/spec/dummy/tmp/radiant_config_cache.txt +0 -0
@@ -0,0 +1,113 @@
|
|
1
|
+
require_dependency 'trusty_cms'
|
2
|
+
|
3
|
+
class ApplicationController < ActionController::Base
|
4
|
+
include LoginSystem
|
5
|
+
|
6
|
+
filter_parameter_logging :password, :password_confirmation
|
7
|
+
|
8
|
+
protect_from_forgery
|
9
|
+
|
10
|
+
before_filter :set_current_user
|
11
|
+
before_filter :set_timezone
|
12
|
+
before_filter :set_user_locale
|
13
|
+
before_filter :set_javascripts_and_stylesheets
|
14
|
+
before_filter :force_utf8_params if RUBY_VERSION =~ /1\.9/
|
15
|
+
before_filter :set_standard_body_style, :only => [:new, :edit, :update, :create]
|
16
|
+
|
17
|
+
attr_accessor :config, :cache
|
18
|
+
attr_reader :pagination_parameters
|
19
|
+
helper_method :pagination_parameters
|
20
|
+
|
21
|
+
def initialize
|
22
|
+
super
|
23
|
+
@config = TrustyCms::Config
|
24
|
+
end
|
25
|
+
|
26
|
+
# helpers to include additional assets from actions or views
|
27
|
+
helper_method :include_stylesheet, :include_javascript
|
28
|
+
|
29
|
+
def include_stylesheet(sheet)
|
30
|
+
@stylesheets << sheet
|
31
|
+
end
|
32
|
+
|
33
|
+
def include_javascript(script)
|
34
|
+
@javascripts << script
|
35
|
+
end
|
36
|
+
|
37
|
+
def template_name
|
38
|
+
case self.action_name
|
39
|
+
when 'index'
|
40
|
+
'index'
|
41
|
+
when 'new','create'
|
42
|
+
'new'
|
43
|
+
when 'show'
|
44
|
+
'show'
|
45
|
+
when 'edit', 'update'
|
46
|
+
'edit'
|
47
|
+
when 'remove', 'destroy'
|
48
|
+
'remove'
|
49
|
+
else
|
50
|
+
self.action_name
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
54
|
+
def rescue_action_in_public(exception)
|
55
|
+
case exception
|
56
|
+
when ActiveRecord::RecordNotFound, ActionController::UnknownController, ActionController::UnknownAction, ActionController::RoutingError
|
57
|
+
render :template => "site/not_found", :status => 404
|
58
|
+
else
|
59
|
+
super
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
private
|
64
|
+
|
65
|
+
def set_current_user
|
66
|
+
UserActionObserver.instance.current_user = current_user
|
67
|
+
end
|
68
|
+
|
69
|
+
def set_user_locale
|
70
|
+
I18n.locale = current_user && !current_user.locale.blank? ? current_user.locale : TrustyCms::Config['default_locale']
|
71
|
+
end
|
72
|
+
|
73
|
+
def set_timezone
|
74
|
+
Time.zone = TrustyCms::Config['local.timezone'] || Time.zone_default
|
75
|
+
end
|
76
|
+
|
77
|
+
def set_javascripts_and_stylesheets
|
78
|
+
@stylesheets ||= []
|
79
|
+
@stylesheets.concat %w(admin/main)
|
80
|
+
@javascripts ||= []
|
81
|
+
end
|
82
|
+
|
83
|
+
def set_standard_body_style
|
84
|
+
@body_classes ||= []
|
85
|
+
@body_classes.concat(%w(reversed))
|
86
|
+
end
|
87
|
+
|
88
|
+
# When using TrustyCms with Ruby 1.9, the strings that come in from forms are ASCII-8BIT encoded.
|
89
|
+
# That causes problems, especially when using special chars and with certain DBs, like DB2
|
90
|
+
# That's why we force the encoding of the params to UTF-8
|
91
|
+
# That's what's happening in Rails 3, too: https://github.com/rails/rails/commit/25215d7285db10e2c04d903f251b791342e4dd6a
|
92
|
+
#
|
93
|
+
# See http://stackoverflow.com/questions/8268778/rails-2-3-9-encoding-of-query-parameters
|
94
|
+
# See https://rails.lighthouseapp.com/projects/8994/tickets/4807
|
95
|
+
# See http://jasoncodes.com/posts/ruby19-rails2-encodings (thanks for the following code, Jason!)
|
96
|
+
def force_utf8_params
|
97
|
+
traverse = lambda do |object, block|
|
98
|
+
if object.kind_of?(Hash)
|
99
|
+
object.each_value { |o| traverse.call(o, block) }
|
100
|
+
elsif object.kind_of?(Array)
|
101
|
+
object.each { |o| traverse.call(o, block) }
|
102
|
+
else
|
103
|
+
block.call(object)
|
104
|
+
end
|
105
|
+
object
|
106
|
+
end
|
107
|
+
force_encoding = lambda do |o|
|
108
|
+
o.force_encoding(Encoding::UTF_8) if o.respond_to?(:force_encoding)
|
109
|
+
end
|
110
|
+
traverse.call(params, force_encoding)
|
111
|
+
end
|
112
|
+
|
113
|
+
end
|
@@ -1,18 +1,18 @@
|
|
1
1
|
module Admin::NodeHelper
|
2
2
|
|
3
|
-
def render_nodes(page, starting_index, parent_index = nil
|
3
|
+
def render_nodes(page, starting_index, parent_index = nil)
|
4
4
|
@rendered_html = ""
|
5
|
-
render_node page, starting_index, parent_index
|
5
|
+
render_node page, starting_index, parent_index
|
6
6
|
@rendered_html
|
7
7
|
end
|
8
8
|
|
9
|
-
def render_node(page, index, parent_index = nil
|
9
|
+
def render_node(page, index, parent_index = nil)
|
10
10
|
|
11
11
|
@current_node = prepare_page(page)
|
12
12
|
|
13
13
|
@rendered_html += (render :partial => 'admin/pages/node',
|
14
14
|
:locals => {level: index, index: index, parent_index: parent_index,
|
15
|
-
page: page, simple:
|
15
|
+
page: page, simple: false, branch: (page.children.count > 0) })
|
16
16
|
index
|
17
17
|
end
|
18
18
|
|
@@ -0,0 +1,242 @@
|
|
1
|
+
module ApplicationHelper
|
2
|
+
include LocalTime
|
3
|
+
include Admin::RegionsHelper
|
4
|
+
|
5
|
+
def config
|
6
|
+
TrustyCms::Config
|
7
|
+
end
|
8
|
+
|
9
|
+
def default_page_title
|
10
|
+
title + ' - ' + subtitle
|
11
|
+
end
|
12
|
+
|
13
|
+
def title
|
14
|
+
config['admin.title'] || 'TrustyCms CMS'
|
15
|
+
end
|
16
|
+
|
17
|
+
def subtitle
|
18
|
+
config['admin.subtitle'] || 'Publishing for Small Teams'
|
19
|
+
end
|
20
|
+
|
21
|
+
def logged_in?
|
22
|
+
!current_user.nil?
|
23
|
+
end
|
24
|
+
|
25
|
+
def onsubmit_status(model)
|
26
|
+
model.new_record? ? t('creating_status', :model => t(model.class.name.downcase)) : "#{I18n.t('saving_changes')}…"
|
27
|
+
end
|
28
|
+
|
29
|
+
def save_model_button(model, options = {})
|
30
|
+
model_name = model.class.name.underscore
|
31
|
+
human_model_name = model_name.humanize.titlecase
|
32
|
+
options[:label] ||= model.new_record? ?
|
33
|
+
t('buttons.create', :name => t(model_name, :default => human_model_name), :default => 'Create ' + human_model_name) :
|
34
|
+
t('buttons.save_changes', :default => 'Save Changes')
|
35
|
+
options[:class] ||= "button"
|
36
|
+
options[:accesskey] ||= 'S'
|
37
|
+
submit_tag options.delete(:label), options
|
38
|
+
end
|
39
|
+
|
40
|
+
def save_model_and_continue_editing_button(model)
|
41
|
+
submit_tag t('buttons.save_and_continue'), :name => 'continue', :class => 'button', :accesskey => "s"
|
42
|
+
end
|
43
|
+
|
44
|
+
def current_item?(item)
|
45
|
+
if item.tab && item.tab.many? {|i| current_url?(i.relative_url) }
|
46
|
+
# Accept only stricter URL matches if more than one matches
|
47
|
+
current_page?(item.url)
|
48
|
+
else
|
49
|
+
current_url?(item.relative_url)
|
50
|
+
end
|
51
|
+
end
|
52
|
+
|
53
|
+
def current_tab?(tab)
|
54
|
+
@current_tab ||= tab if tab.any? {|item| current_url?(item.relative_url) }
|
55
|
+
@current_tab == tab
|
56
|
+
end
|
57
|
+
|
58
|
+
def current_url?(options)
|
59
|
+
url = case options
|
60
|
+
when Hash
|
61
|
+
url_for options
|
62
|
+
else
|
63
|
+
options.to_s
|
64
|
+
end
|
65
|
+
request.request_uri =~ Regexp.new('^' + Regexp.quote(clean(url)))
|
66
|
+
end
|
67
|
+
|
68
|
+
def clean(url)
|
69
|
+
uri = URI.parse(url)
|
70
|
+
uri.path.gsub(%r{/+}, '/').gsub(%r{/$}, '')
|
71
|
+
end
|
72
|
+
|
73
|
+
def nav_link_to(name, options)
|
74
|
+
if current_url?(options)
|
75
|
+
%{<strong>#{ link_to translate_with_default(name), options }</strong>}
|
76
|
+
else
|
77
|
+
link_to translate_with_default(name), options
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def admin?
|
82
|
+
current_user and current_user.admin?
|
83
|
+
end
|
84
|
+
|
85
|
+
def designer?
|
86
|
+
current_user and (current_user.designer? or current_user.admin?)
|
87
|
+
end
|
88
|
+
|
89
|
+
def focus(field_name)
|
90
|
+
javascript_tag "Field.activate('#{field_name}');"
|
91
|
+
end
|
92
|
+
|
93
|
+
def updated_stamp(model)
|
94
|
+
unless model.new_record?
|
95
|
+
updated_by = (model.updated_by || model.created_by)
|
96
|
+
name = updated_by ? updated_by.name : nil
|
97
|
+
time = (model.updated_at || model.created_at)
|
98
|
+
if name or time
|
99
|
+
html = %{<p class="updated_line">#{t('timestamp.last_updated')} }
|
100
|
+
html << %{#{t('timestamp.by')} <strong>#{name}</strong> } if name
|
101
|
+
html << %{#{t('timestamp.at')} #{timestamp(time)}} if time
|
102
|
+
html << %{</p>}
|
103
|
+
html
|
104
|
+
end
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
def timestamp(time)
|
109
|
+
# time.strftime("%I:%M %p on %B %e, %Y").sub("AM", 'am').sub("PM", 'pm')
|
110
|
+
I18n.localize(time, :format => :timestamp)
|
111
|
+
end
|
112
|
+
|
113
|
+
def meta_visible(symbol)
|
114
|
+
v = case symbol
|
115
|
+
when :meta_more
|
116
|
+
not meta_errors?
|
117
|
+
when :meta, :meta_less
|
118
|
+
meta_errors?
|
119
|
+
end
|
120
|
+
v ? {} : {:style => "display: none"}
|
121
|
+
end
|
122
|
+
|
123
|
+
def meta_errors?
|
124
|
+
false
|
125
|
+
end
|
126
|
+
|
127
|
+
def meta_label
|
128
|
+
meta_errors? ? 'Less' : 'More'
|
129
|
+
end
|
130
|
+
|
131
|
+
def toggle_javascript_for(id)
|
132
|
+
"Element.toggle('#{id}'); Element.toggle('more-#{id}'); Element.toggle('less-#{id}'); return false;"
|
133
|
+
end
|
134
|
+
|
135
|
+
def image(name, options = {})
|
136
|
+
image_tag(append_image_extension("admin/#{name}"), options)
|
137
|
+
end
|
138
|
+
|
139
|
+
def image_submit(name, options = {})
|
140
|
+
image_submit_tag(append_image_extension("admin/#{name}"), options)
|
141
|
+
end
|
142
|
+
|
143
|
+
def admin
|
144
|
+
TrustyCms::AdminUI.instance
|
145
|
+
end
|
146
|
+
|
147
|
+
def filter_options_for_select(selected=nil)
|
148
|
+
options_for_select([[t('select.none'), '']] + TextFilter.descendants_names, selected)
|
149
|
+
end
|
150
|
+
|
151
|
+
def body_classes
|
152
|
+
@body_classes ||= []
|
153
|
+
end
|
154
|
+
|
155
|
+
def nav_tabs
|
156
|
+
admin.nav
|
157
|
+
end
|
158
|
+
|
159
|
+
def translate_with_default(name)
|
160
|
+
t(name.underscore.downcase, :default => name)
|
161
|
+
end
|
162
|
+
|
163
|
+
def available_locales_select
|
164
|
+
[[t('select.default'),'']] + TrustyCms::AvailableLocales.locales
|
165
|
+
end
|
166
|
+
|
167
|
+
def stylesheet_and_javascript_overrides
|
168
|
+
overrides = ''
|
169
|
+
if File.exist?("#{Rails.root}/public/stylesheets/admin/overrides.css") || File.exist?("#{Rails.root}/public/stylesheets/sass/admin/overrides.sass")
|
170
|
+
overrides << stylesheet_link_tag('admin/overrides')
|
171
|
+
end
|
172
|
+
if File.exist?("#{Rails.root}/public/javascripts/admin/overrides.js")
|
173
|
+
overrides << javascript_include_tag('admin/overrides')
|
174
|
+
end
|
175
|
+
overrides
|
176
|
+
end
|
177
|
+
|
178
|
+
# Returns a Gravatar URL associated with the email parameter.
|
179
|
+
# See: http://douglasfshearer.com/blog/gravatar-for-ruby-and-ruby-on-rails
|
180
|
+
def gravatar_url(email, options={})
|
181
|
+
# Default to highest rating. Rating can be one of G, PG, R X.
|
182
|
+
options[:rating] ||= "G"
|
183
|
+
|
184
|
+
# Default size of the image.
|
185
|
+
options[:size] ||= "32px"
|
186
|
+
|
187
|
+
# Default image url to be used when no gravatar is found
|
188
|
+
# or when an image exceeds the rating parameter.
|
189
|
+
local_avatar_url = "/images/admin/avatar_#{([options[:size].to_i] * 2).join('x')}.png"
|
190
|
+
default_avatar_url = "#{request.protocol}#{request.host_with_port}#{ActionController::Base.relative_url_root}#{local_avatar_url}"
|
191
|
+
options[:default] ||= default_avatar_url
|
192
|
+
|
193
|
+
unless email.blank?
|
194
|
+
# Build the Gravatar url.
|
195
|
+
url = '//gravatar.com/avatar/'
|
196
|
+
url << "#{Digest::MD5.new.update(email)}?"
|
197
|
+
url << "rating=#{options[:rating]}" if options[:rating]
|
198
|
+
url << "&size=#{options[:size]}" if options[:size]
|
199
|
+
url << "&default=#{options[:default]}" if options[:default]
|
200
|
+
# Test the Gravatar url
|
201
|
+
require 'open-uri'
|
202
|
+
begin; open "http:#{url}", :proxy => true
|
203
|
+
rescue; local_avatar_url
|
204
|
+
else; url
|
205
|
+
end
|
206
|
+
else
|
207
|
+
local_avatar_url
|
208
|
+
end
|
209
|
+
end
|
210
|
+
|
211
|
+
# returns the usual set of pagination links.
|
212
|
+
# options are passed through to will_paginate
|
213
|
+
# and a 'show all' depagination link is added if relevant.
|
214
|
+
def pagination_for(list, options={})
|
215
|
+
if list.respond_to? :total_pages
|
216
|
+
options = {
|
217
|
+
:max_per_page => config['pagination.max_per_page'] || 500,
|
218
|
+
:depaginate => true
|
219
|
+
}.merge(options.symbolize_keys)
|
220
|
+
depaginate = options.delete(:depaginate) # supply :depaginate => false to omit the 'show all' link
|
221
|
+
depagination_limit = options.delete(:max_per_page) # supply :max_per_page => false to include the 'show all' link no matter how large the collection
|
222
|
+
html = will_paginate(list, will_paginate_options.merge(options))
|
223
|
+
if depaginate && list.total_pages > 1 && (!depagination_limit.blank? || list.total_entries <= depagination_limit.to_i)
|
224
|
+
html << content_tag(:div, link_to(t('show_all'), :pp => 'all'), :class => 'depaginate')
|
225
|
+
elsif depaginate && list.total_entries > depagination_limit.to_i
|
226
|
+
html = content_tag(:div, link_to("paginate", :p => 1), :class => 'pagination')
|
227
|
+
end
|
228
|
+
html
|
229
|
+
end
|
230
|
+
end
|
231
|
+
|
232
|
+
private
|
233
|
+
|
234
|
+
def append_image_extension(name)
|
235
|
+
unless name =~ /\.(.*?)$/
|
236
|
+
name + '.png'
|
237
|
+
else
|
238
|
+
name
|
239
|
+
end
|
240
|
+
end
|
241
|
+
|
242
|
+
end
|
@@ -71,7 +71,6 @@ module TrustyCms
|
|
71
71
|
self.table_name = "config"
|
72
72
|
after_save :update_cache
|
73
73
|
attr_reader :definition
|
74
|
-
attr_accessible :key
|
75
74
|
|
76
75
|
class ConfigError < RuntimeError; end
|
77
76
|
|
@@ -89,7 +88,7 @@ module TrustyCms
|
|
89
88
|
|
90
89
|
def []=(key, value)
|
91
90
|
if table_exists?
|
92
|
-
setting =
|
91
|
+
setting = find_or_initialize_by(key: key)
|
93
92
|
setting.value = value
|
94
93
|
end
|
95
94
|
end
|
@@ -6,7 +6,7 @@
|
|
6
6
|
%h1 Configuration
|
7
7
|
|
8
8
|
- main.edit_form do
|
9
|
-
= form_for :trusty_config, :url =>
|
9
|
+
= form_for :trusty_config, :url => admin_configuration_url, :html => {"data-onsubmit_status"=>"Saving changes…", :method => :put} do |f|
|
10
10
|
= render_region :form_top
|
11
11
|
- render_region :form do |form|
|
12
12
|
- form.edit_site do
|
@@ -35,4 +35,4 @@
|
|
35
35
|
.buttons
|
36
36
|
%input.button{:type=>"submit", :value=>"Save Changes"}/
|
37
37
|
or
|
38
|
-
= link_to "Cancel",
|
38
|
+
= link_to "Cancel", admin_configuration_url
|
@@ -39,7 +39,7 @@
|
|
39
39
|
%h3
|
40
40
|
- if admin?
|
41
41
|
.actions
|
42
|
-
= button_to t("edit_configuration"),
|
42
|
+
= button_to t("edit_configuration"), edit_admin_configuration_url, :method => :get
|
43
43
|
Configuration
|
44
44
|
- TrustyCms.config.site_settings.each do |site_setting|
|
45
45
|
%p.ruled
|
@@ -57,7 +57,7 @@
|
|
57
57
|
= save_model_and_continue_editing_button(@page)
|
58
58
|
= submit_tag(t('preview', :default => 'Preview'), :class => 'button', :id => 'show-preview')
|
59
59
|
= t('or')
|
60
|
-
= link_to t('cancel'), admin_pages_url
|
60
|
+
= link_to t('cancel'), admin_pages_url
|
61
61
|
#preview_panel.fullcover.grey_out{:style => 'display: none;'}
|
62
62
|
%iframe{:id => 'page-preview', :class => 'fullcover', :name => 'page-preview', :src => ActionController::Base.relative_url_root.to_s + '/loading-iframe.html', :frameborder => 0, :scrolling => "auto"}
|
63
63
|
.preview_tools
|
@@ -7,7 +7,7 @@
|
|
7
7
|
= icon
|
8
8
|
= node_title
|
9
9
|
- else
|
10
|
-
= (link_to("#{icon} #{node_title}".html_safe,
|
10
|
+
= (link_to("#{icon} #{node_title}".html_safe, edit_admin_page_url(page), :title => page.path)).html_safe
|
11
11
|
= page_type
|
12
12
|
= spinner
|
13
13
|
- node.status_column do
|
@@ -18,4 +18,4 @@
|
|
18
18
|
- unless simple
|
19
19
|
%td.actions
|
20
20
|
= page.add_child_option
|
21
|
-
= page.remove_option
|
21
|
+
= page.remove_option
|
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
- render_region :main do |main|
|
4
4
|
- main.edit_header do
|
5
|
-
%h1= ''
|
5
|
+
%h1= t('edit_page')
|
6
6
|
- main.edit_form do
|
7
7
|
= form_for @page, :as => :page, :url => admin_page_path(@page), :html => {:method => :put, :multipart => true, :id => 'edit_page', 'data-onsubmit_status'=>t('saving_changes')} do |fields|
|
8
8
|
= render :partial => "fields", :object => fields
|
@@ -9,11 +9,11 @@
|
|
9
9
|
.inset
|
10
10
|
%table.index#site_map
|
11
11
|
%tbody
|
12
|
-
- render_nodes @page, @page.id
|
12
|
+
- render_nodes @page, @page.id
|
13
13
|
= @rendered_html.html_safe
|
14
14
|
|
15
15
|
= form_for [:admin, @page.becomes(Page)], :html => {:method => :delete, 'data-onsubmit_status'=>"Removing pages…"} do
|
16
16
|
.buttons
|
17
17
|
%input.button{:type=>"submit", :value => t('delete_pages', :pages => pages) }/
|
18
18
|
= t('or')
|
19
|
-
= link_to t('cancel'),
|
19
|
+
= link_to t('cancel'), admin_pages_url
|
@@ -6,39 +6,39 @@
|
|
6
6
|
%h1= t('personal_preferences')
|
7
7
|
|
8
8
|
- main.edit_form do
|
9
|
-
= form_for @user, :url =>
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
9
|
+
= form_for @user, :url => admin_preferences_url, :html => { :method => :put, 'data-onsubmit_status' => "#{t('saving_preferences')}…" } do |f|
|
10
|
+
|
11
|
+
= render :partial => 'admin/users/avatar'
|
12
|
+
|
13
|
+
= render_region :form_top, :locals => {:f => f}
|
14
|
+
|
15
|
+
- render_region :form, :locals => {:f => f} do |form|
|
16
|
+
- form.edit_name do
|
17
|
+
%p
|
18
|
+
= f.label :name, t("name")
|
19
|
+
= f.text_field :name, :class => "textbox", :size => 32, :maxlength => 100
|
20
|
+
|
21
|
+
- form.edit_email do
|
22
|
+
%p
|
23
|
+
= f.label :email, t("email_address"), :class => "optional"
|
24
|
+
= f.text_field "email", :class => 'textbox', :size => 32, :maxlength => 255
|
25
|
+
|
26
|
+
- form.edit_username do
|
27
|
+
%p
|
28
|
+
= f.label :login, t("username")
|
29
|
+
= f.text_field "login", :class => "textbox", :size => 32, :maxlength => 40, :required => true
|
30
|
+
|
31
|
+
- form.edit_password do
|
32
|
+
= render "admin/users/password_fields", :f => f
|
33
|
+
|
34
|
+
- form.edit_locale do
|
35
|
+
%p
|
36
|
+
= f.label :locale, t('language')
|
37
|
+
= f.select "locale", available_locales_select
|
38
|
+
|
39
|
+
- render_region :form_bottom, :locals => {:f => f} do |form_bottom|
|
40
|
+
- form_bottom.edit_buttons do
|
41
|
+
.buttons
|
42
|
+
= save_model_button @user
|
43
|
+
= t('or')
|
44
|
+
= link_to t('cancel'), admin_url
|
@@ -13,6 +13,6 @@
|
|
13
13
|
- unless @user.new_record?
|
14
14
|
%span
|
15
15
|
= t('or')
|
16
|
-
%a{:href=>"#", :
|
16
|
+
%a{:href=>"#", :onclick=>" $('#display_password').show(); $('#change_password').hide()"}= t('cancel')
|
17
17
|
|
18
18
|
|
@@ -3,7 +3,7 @@
|
|
3
3
|
#single_form
|
4
4
|
%h1= t('please_login')
|
5
5
|
|
6
|
-
= form_tag
|
6
|
+
= form_tag login_url do
|
7
7
|
%p
|
8
8
|
%label{:for=>"username_or_email"}= t('username_or_email')
|
9
9
|
= text_field_tag "username_or_email", @username_or_email, :class => 'textbox', :maxlength => 40, :size => 40
|
@@ -31,24 +31,22 @@
|
|
31
31
|
#page
|
32
32
|
#header
|
33
33
|
- if logged_in?
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
%li= link_to translate_with_default(sub_item.name), sub_item.relative_url, :class=>('current' if current_item?(sub_item))
|
51
|
-
= yield :toolbar
|
34
|
+
#site_links
|
35
|
+
= %{#{t('logged_in_as')} #{link_to h(current_user.name), edit_admin_preferences_path} (#{link_to t('log_out'), logout_path})}.html_safe
|
36
|
+
|
37
|
+
= link_to t('view_site'), root_path, :id=>"view_site"
|
38
|
+
%ul#navigation
|
39
|
+
- nav_tabs.each do |tab|
|
40
|
+
- if tab.visible?(current_user)
|
41
|
+
%li{:class=>('current ' if current_tab?(tab)).to_s}
|
42
|
+
= link_to translate_with_default(tab.name), (tab.first.relative_url if tab.first)
|
43
|
+
#toolbar
|
44
|
+
- if @current_tab and @current_tab.size > 1
|
45
|
+
%ul#secondary_navigation
|
46
|
+
- @current_tab.each do |sub_item|
|
47
|
+
- if sub_item.visible?(current_user)
|
48
|
+
%li= link_to translate_with_default(sub_item.name), sub_item.relative_url, :class=>('current' if current_item?(sub_item))
|
49
|
+
= yield :toolbar
|
52
50
|
#main
|
53
51
|
- if flash[:notice]
|
54
52
|
#notice
|
data/config/application.rb
CHANGED
@@ -8,8 +8,6 @@ require 'trusty_cms/extension_loader'
|
|
8
8
|
require 'trusty_cms/initializer'
|
9
9
|
require 'compass'
|
10
10
|
require 'rack/cache'
|
11
|
-
require 'trustygems'
|
12
|
-
|
13
11
|
|
14
12
|
if defined?(Bundler)
|
15
13
|
# If you precompile assets before deploying to production, use this line
|
@@ -119,6 +117,7 @@ module TrustyCms
|
|
119
117
|
html
|
120
118
|
end
|
121
119
|
end
|
120
|
+
|
122
121
|
config.after_initialize do
|
123
122
|
extension_loader.load_extensions
|
124
123
|
extension_loader.load_extension_initalizers
|