trusty-cms 3.1.11 → 3.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (128) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +9 -14
  3. data/Gemfile.lock +84 -70
  4. data/README.md +4 -0
  5. data/app/assets/images/admin/add.png +0 -0
  6. data/app/assets/images/admin/archive_icon.png +0 -0
  7. data/app/assets/images/admin/audio_icon.png +0 -0
  8. data/app/assets/images/admin/audio_thumbnail.png +0 -0
  9. data/app/assets/images/admin/c_icon.png +0 -0
  10. data/app/assets/images/admin/copy.png +0 -0
  11. data/app/assets/images/admin/css_icon.png +0 -0
  12. data/app/assets/images/admin/database_icon.png +0 -0
  13. data/app/assets/images/admin/delete.png +0 -0
  14. data/app/assets/images/admin/document_icon.png +0 -0
  15. data/app/assets/images/admin/document_thumbnail.png +0 -0
  16. data/app/assets/images/admin/flash_icon.png +0 -0
  17. data/app/assets/images/admin/flash_thumbnail.png +0 -0
  18. data/app/assets/images/admin/font_icon.png +0 -0
  19. data/app/assets/images/admin/gzip_icon.png +0 -0
  20. data/app/assets/images/admin/html_icon.png +0 -0
  21. data/app/assets/images/admin/image_icon.png +0 -0
  22. data/app/assets/images/admin/image_thumbnail.png +0 -0
  23. data/app/assets/images/admin/java_icon.png +0 -0
  24. data/app/assets/images/admin/page_edit.png +0 -0
  25. data/app/assets/images/admin/pdf_icon.png +0 -0
  26. data/app/assets/images/admin/pdf_thumbnail.png +0 -0
  27. data/app/assets/images/admin/perl_icon.png +0 -0
  28. data/app/assets/images/admin/php_icon.png +0 -0
  29. data/app/assets/images/admin/presentation_icon.png +0 -0
  30. data/app/assets/images/admin/python_icon.png +0 -0
  31. data/app/assets/images/admin/reorder_assets.png +0 -0
  32. data/app/assets/images/admin/ruby_icon.png +0 -0
  33. data/app/assets/images/admin/script_icon.png +0 -0
  34. data/app/assets/images/admin/spinner.gif +0 -0
  35. data/app/assets/images/admin/spreadsheet_icon.png +0 -0
  36. data/app/assets/images/admin/tar_icon.png +0 -0
  37. data/app/assets/images/admin/unknown_icon.png +0 -0
  38. data/app/assets/images/admin/unknown_thumbnail.png +0 -0
  39. data/app/assets/images/admin/video_icon.png +0 -0
  40. data/app/assets/images/admin/video_thumbnail.png +0 -0
  41. data/app/assets/images/admin/xml_icon.png +0 -0
  42. data/app/assets/images/admin/zip_icon.png +0 -0
  43. data/app/assets/javascripts/admin/assets.js +268 -0
  44. data/app/assets/javascripts/admin/assets_admin.js +16 -0
  45. data/app/assets/javascripts/admin/jquery.fileupload.js +1457 -0
  46. data/app/assets/javascripts/admin/jquery.iframe-transport.js +214 -0
  47. data/app/assets/javascripts/admin/jquery.ui.widget.js +558 -0
  48. data/app/assets/stylesheets/admin/assets.scss +283 -0
  49. data/app/controllers/admin/assets_controller.rb +88 -0
  50. data/app/controllers/admin/page_attachments_controller.rb +23 -0
  51. data/app/helpers/admin/assets_helper.rb +16 -0
  52. data/app/helpers/admin/page_attachments_helper.rb +2 -0
  53. data/app/models/asset.rb +251 -0
  54. data/app/models/asset_type.rb +239 -0
  55. data/app/models/old_page_attachment.rb +26 -0
  56. data/app/models/page_attachment.rb +20 -0
  57. data/app/views/admin/assets/_asset.html.haml +12 -0
  58. data/app/views/admin/assets/_asset_table.html.haml +30 -0
  59. data/app/views/admin/assets/_errors.html.haml +3 -0
  60. data/app/views/admin/assets/_form.html.haml +18 -0
  61. data/app/views/admin/assets/_page_assets.html.haml +12 -0
  62. data/app/views/admin/assets/_search.html.haml +17 -0
  63. data/app/views/admin/assets/_search_results.html.haml +17 -0
  64. data/app/views/admin/assets/edit.html.haml +40 -0
  65. data/app/views/admin/assets/index.html.haml +15 -0
  66. data/app/views/admin/assets/new.html.haml +24 -0
  67. data/app/views/admin/assets/refresh.html.haml +14 -0
  68. data/app/views/admin/assets/remove.html.haml +16 -0
  69. data/app/views/admin/configuration/_clipped_edit.html.haml +8 -0
  70. data/app/views/admin/configuration/_clipped_show.html.haml +12 -0
  71. data/app/views/admin/page_attachments/_attachment.html.haml +25 -0
  72. data/app/views/admin/pages/_asset_popups.html.haml +37 -0
  73. data/app/views/admin/pages/_assets.html.haml +13 -0
  74. data/app/views/admin/removed/_assets_bucket.html.haml +8 -0
  75. data/app/views/admin/removed/_assets_container.html.haml +54 -0
  76. data/app/views/admin/removed/_bucket.html.haml +11 -0
  77. data/app/views/admin/removed/_bucket_asset.html.haml +9 -0
  78. data/app/views/admin/removed/_show_bucket_link.html.haml +4 -0
  79. data/app/views/admin/removed/_upload_to_page.html.haml +12 -0
  80. data/app/views/admin/removed/bucket/_iframe.html.haml +1 -0
  81. data/config/application.rb +0 -37
  82. data/config/initializers/assets.rb +1 -0
  83. data/config/initializers/interpolation.rb +6 -0
  84. data/config/initializers/kraken.rb +7 -0
  85. data/config/initializers/trusty_cms_config.rb +67 -0
  86. data/config/locales/en.yml +101 -0
  87. data/config/routes.rb +14 -3
  88. data/coverage/index.html +26 -26
  89. data/db/migrate/028_create_assets.rb +12 -0
  90. data/db/migrate/029_create_paperclip_attributes.rb +13 -0
  91. data/db/migrate/030_create_user_observer.rb +13 -0
  92. data/db/migrate/031_create_page_attachments.rb +19 -0
  93. data/db/migrate/032_rename_users.rb +13 -0
  94. data/db/migrate/20110513205050_asset_uuid.rb +11 -0
  95. data/db/migrate/20110606111250_update_configuration.rb +34 -0
  96. data/db/migrate/20110609101438_dimensions.rb +13 -0
  97. data/lib/trusty_cms.rb +1 -1
  98. data/spec/dummy/db/schema.rb +22 -0
  99. data/spec/dummy/log/test.log +95620 -0
  100. data/spec/dummy/tmp/cache/747/A70/TrustyCms%3A%3AConfig +0 -0
  101. data/spec/dummy/tmp/cache/85C/FA0/TrustyCms.cache_mtime +0 -0
  102. data/spec/dummy/tmp/capybara/capybara-20180312152412265881245.html +262 -0
  103. data/spec/dummy/tmp/capybara/capybara-201803121526139973682798.html +149 -0
  104. data/spec/factories/layout.rb +1 -1
  105. data/spec/factories/page.rb +3 -3
  106. data/spec/factories/page_part.rb +1 -1
  107. data/spec/factories/user.rb +1 -1
  108. data/spec/models/layout_spec.rb +6 -6
  109. data/spec/spec_helper.rb +4 -4
  110. data/trusty_cms.gemspec +27 -22
  111. data/vendor/extensions/clipped-extension/clipped_extension.rb +40 -0
  112. data/vendor/extensions/clipped-extension/lib/asset_tags.rb +346 -0
  113. data/vendor/extensions/clipped-extension/lib/clipped/engine.rb +11 -0
  114. data/vendor/extensions/clipped-extension/lib/clipped_admin_ui.rb +28 -0
  115. data/vendor/extensions/clipped-extension/lib/generators/templates/clipped_config.rb +53 -0
  116. data/vendor/extensions/clipped-extension/lib/page_asset_associations.rb +13 -0
  117. data/vendor/extensions/clipped-extension/lib/paperclip/frame_grab.rb +73 -0
  118. data/vendor/extensions/clipped-extension/lib/paperclip/geometry_transformation.rb +80 -0
  119. data/vendor/extensions/clipped-extension/lib/tasks/clipped_extension_tasks.rake +124 -0
  120. data/vendor/extensions/clipped-extension/lib/tasks/paperclip_tasks.rake +79 -0
  121. data/vendor/extensions/clipped-extension/lib/trusty-clipped-extension.rb +2 -0
  122. data/vendor/extensions/clipped-extension/lib/trusty_cms_clipped_extension/cloud.rb +41 -0
  123. metadata +219 -67
  124. data/config/initializers/ckeditor.rb +0 -3
  125. data/config/initializers/haml.rb +0 -2
  126. data/config/initializers/rails_patch.rb +0 -2
  127. data/config/initializers/string_extensions.rb +0 -1
  128. data/config/initializers/symbol_extensions.rb +0 -1
@@ -0,0 +1,124 @@
1
+ namespace :radiant do
2
+ namespace :extensions do
3
+ namespace :clipped do
4
+
5
+ desc "Runs the migration of the Clipped extension"
6
+ task :migrate => :environment do
7
+ require 'radiant/extension_migrator'
8
+ if ActiveRecord::Base.connection.select_values("SELECT version FROM #{ActiveRecord::Migrator.schema_migrations_table_name} WHERE version = 'Assets-20110513205050'").any?
9
+ puts "Assimilating Assets extension migration 20110513205050"
10
+ ClippedExtension.migrator.new(:up, ClippedExtension.migrations_path).send(:assume_migrated_upto_version, '20110513205050')
11
+ end
12
+
13
+ if ENV["VERSION"]
14
+ ClippedExtension.migrator.migrate(ENV["VERSION"].to_i)
15
+ Rake::Task['db:schema:dump'].invoke
16
+ else
17
+ ClippedExtension.migrator.migrate
18
+ Rake::Task['db:schema:dump'].invoke
19
+ end
20
+ end
21
+
22
+ desc "Copies public assets of the Clipped extension to the instance public/ directory."
23
+ task :update => [:environment, :initialize] do
24
+ is_svn_or_dir = proc {|path| path =~ /\.svn/ || File.directory?(path) }
25
+ puts "Copying assets from ClippedExtension"
26
+ Dir[ClippedExtension.root + "/public/**/*"].reject(&is_svn_or_dir).each do |file|
27
+ path = file.sub(ClippedExtension.root, '')
28
+ directory = File.dirname(path)
29
+ mkdir_p Rails.root + directory, :verbose => false
30
+ cp_r file, Rails.root + path, :verbose => false
31
+ end
32
+
33
+ desc "Syncs all available translations for this ext to the English ext master"
34
+ task :sync => :environment do
35
+ # The main translation root, basically where English is kept
36
+ language_root = ClippedExtension.get_translation_keys(language_root)
37
+
38
+ Dir["#{language_root}/*.yml"].each do |filename|
39
+ next if filename.match('_available_tags')
40
+ basename = File.basename(filename, '.yml')
41
+ puts "Syncing #{basename}"
42
+ (comments, other) = TranslationSupport.read_file(filename, basename)
43
+ words.each { |k,v| other[k] ||= words[k] } # Initializing hash variable as empty if it does not exist
44
+ other.delete_if { |k,v| !words[k] } # Remove if not defined in en.yml
45
+ TranslationSupport.write_file(filename, basename, comments, other)
46
+ end
47
+ end
48
+ end
49
+
50
+ desc "Exports assets from database to assets directory"
51
+ task :export => :environment do
52
+ asset_path = File.join(Rails.root, "assets")
53
+ mkdir_p asset_path
54
+ Asset.find(:all).each do |asset|
55
+ puts "Exporting #{asset.asset_file_name}"
56
+ cp asset.asset.path, File.join(asset_path, asset.asset_file_name)
57
+ end
58
+ puts "Done."
59
+ end
60
+
61
+ desc "Imports assets to database from assets directory"
62
+ task :import => :environment do
63
+ asset_path = File.join(Rails.root, "assets")
64
+ if File.exist?(asset_path) && File.stat(asset_path).directory?
65
+ Dir.glob("#{asset_path}/*").each do |file_with_path|
66
+ if File.stat(file_with_path).file?
67
+ new_asset = File.new(file_with_path)
68
+ puts "Creating #{File.basename(file_with_path)}"
69
+ Asset.create :asset => new_asset
70
+ end
71
+ end
72
+ end
73
+ end
74
+
75
+ desc "Migrates page attachments from the original page attachments extension into new Assets"
76
+ task :migrate_from_page_attachments => :environment do
77
+ puts "This task can clean up traces of the page_attachments (think table records and files currently in /public/page_attachments).
78
+ If you would like to use this mode type \"yes\", type \"no\" or just hit enter to leave them untouched for now."
79
+ answer = STDIN.gets.chomp
80
+ erase_tracks = answer.eql?('yes') ? true : false
81
+ OldPageAttachment.find_all_by_parent_id(nil).each do |opa|
82
+ asset = opa.create_paperclipped_record
83
+ # move the actual file
84
+ old_dir = "#{Rails.root}/public/page_attachments/0000/#{opa.id.to_s.rjust(4,'0')}"
85
+ new_dir = "#{Rails.root}/public/assets/#{asset.id}"
86
+ puts "Copying #{old_dir.gsub(Rails.root, '')}/#{opa.filename} to #{new_dir.gsub(Rails.root, '')}/#{opa.filename}..."
87
+ mkdir_p new_dir
88
+ cp old_dir + "/#{opa.filename}", new_dir + "/#{opa.filename}"
89
+ # remove old record and remainings
90
+ if erase_tracks
91
+ rm_rf old_dir
92
+ end
93
+ end
94
+ # regenerate thumbnails
95
+ puts "Regenerating asset thumbnails"
96
+ ENV['CLASS'] = 'Asset'
97
+ Rake::Task['paperclip:refresh'].invoke
98
+ puts "Done."
99
+ end
100
+
101
+ desc "Migrates from old 'assets' extension."
102
+ task :migrate_from_assets => :environment do
103
+ Asset.delete_all("thumbnail IS NOT NULL OR parent_id IS NOT NULL")
104
+ ActiveRecord::Base.connection.tap do |c|
105
+ c.rename_column :assets, :filename, :asset_file_name
106
+ c.rename_column :assets, :content_type, :asset_content_type
107
+ c.rename_column :assets, :size, :asset_file_size
108
+ c.remove_column :assets, :parent_id
109
+ c.remove_column :assets, :thumbnail
110
+ end
111
+
112
+ ClippedExtension.migrator.new(:up, ClippedExtension.migrations_path).send(:assume_migrated_upto_version, 3)
113
+ ClippedExtension.migrator.migrate
114
+ end
115
+
116
+ desc "Generate an example initializer"
117
+ task :initialize do
118
+ puts "Copying initializer from ClippedExtension"
119
+ cp ClippedExtension.root + "/lib/generators/templates/clipped_config.rb", Rails.root + "/config/initializers/", :verbose => false
120
+ end
121
+
122
+ end
123
+ end
124
+ end
@@ -0,0 +1,79 @@
1
+ def obtain_class
2
+ class_name = ENV['CLASS'] || ENV['class']
3
+ raise "Must specify CLASS" unless class_name
4
+ @klass = Object.const_get(class_name)
5
+ end
6
+
7
+ def obtain_attachments
8
+ name = ENV['ATTACHMENT'] || ENV['attachment']
9
+ raise "Class #{@klass.name} has no attachments specified" unless @klass.respond_to?(:attachment_definitions)
10
+ if !name.blank? && @klass.attachment_definitions.keys.include?(name)
11
+ [ name ]
12
+ else
13
+ @klass.attachment_definitions.keys
14
+ end
15
+ end
16
+
17
+ def for_all_attachments
18
+ klass = obtain_class
19
+ names = obtain_attachments
20
+ ids = klass.connection.select_values(klass.send(:construct_finder_sql, :select => 'id'))
21
+
22
+ ids.each do |id|
23
+ instance = klass.find(id)
24
+ names.each do |name|
25
+ result = if instance.send("#{ name }?")
26
+ yield(instance, name)
27
+ else
28
+ true
29
+ end
30
+ print result ? "." : "x"; $stdout.flush
31
+ end
32
+ end
33
+ puts " Done."
34
+ end
35
+
36
+ namespace :paperclip do
37
+ desc "Refreshes both metadata and thumbnails."
38
+ task :refresh => ["paperclip:refresh:metadata", "paperclip:refresh:thumbnails"]
39
+
40
+ namespace :refresh do
41
+ desc "Regenerates thumbnails for a given CLASS (and optional ATTACHMENT)."
42
+ task :thumbnails => :environment do
43
+ errors = []
44
+ for_all_attachments do |instance, name|
45
+ result = instance.send(name).reprocess!
46
+ errors << [instance.id, instance.errors] unless instance.errors.blank?
47
+ result
48
+ end
49
+ errors.each{|e| puts "#{e.first}: #{e.last.full_messages.inspect}" }
50
+ end
51
+
52
+ desc "Regenerates content_type/size metadata for a given CLASS (and optional ATTACHMENT)."
53
+ task :metadata => :environment do
54
+ for_all_attachments do |instance, name|
55
+ if file = instance.send(name).to_file
56
+ instance.send("#{name}_file_name=", instance.send("#{name}_file_name").strip)
57
+ instance.send("#{name}_content_type=", file.content_type.strip)
58
+ instance.send("#{name}_file_size=", file.size) if instance.respond_to?("#{name}_file_size")
59
+ instance.save(false)
60
+ else
61
+ true
62
+ end
63
+ end
64
+ end
65
+ end
66
+
67
+ desc "Cleans out invalid attachments. Useful after you've added new validations."
68
+ task :clean => :environment do
69
+ for_all_attachments do |instance, name|
70
+ instance.send(name).send(:validate)
71
+ if instance.send(name).valid?
72
+ true
73
+ else
74
+ instance.send("#{name}=", nil)
75
+ instance.save
76
+ end
77
+ end
78
+ end
79
+ end
@@ -0,0 +1,2 @@
1
+ module TrustyCmsClippedExtension
2
+ end
@@ -0,0 +1,41 @@
1
+ module TrustyCmsClippedExtension
2
+
3
+ module Cloud
4
+
5
+ def self.credentials
6
+ case TrustyCms.config["paperclip.fog.provider"]
7
+ when "AWS"
8
+ {
9
+ :provider => "AWS",
10
+ :aws_access_key_id => TrustyCms.config["paperclip.s3.key"],
11
+ :aws_secret_access_key => TrustyCms.config["paperclip.s3.secret"],
12
+ :region => TrustyCms.config["paperclip.s3.region"],
13
+ }
14
+ when "Google"
15
+ {
16
+ :provider => "Google",
17
+ :rackspace_username => TrustyCms.config["paperclip.google_storage.access_key_id"],
18
+ :rackspace_api_key => TrustyCms.config["paperclip.google_storage.secret_access_key"]
19
+ }
20
+ when "Rackspace"
21
+ {
22
+ :provider => "Rackspace",
23
+ :rackspace_username => TrustyCms.config["paperclip.rackspace.username"],
24
+ :rackspace_api_key => TrustyCms.config["paperclip.rackspace.api_key"]
25
+ }
26
+ end
27
+ end
28
+
29
+ def self.host
30
+ return TrustyCms.config["paperclip.fog.host"] if TrustyCms.config["paperclip.fog.host"]
31
+ case TrustyCms.config["paperclip.fog.provider"]
32
+ when "AWS"
33
+ "http://#{TrustyCms.config['paperclip.fog.directory']}.s3.amazonaws.com"
34
+ else
35
+ nil
36
+ end
37
+ end
38
+
39
+ end
40
+
41
+ end