trusty-cms 3.8.1 → 3.8.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: dcbafa19380e5c137beb9176eb345e496c317f5ae02af29dbf9596b4a946d7f4
4
- data.tar.gz: 572ea0682bc3a4ae42aed982fc60da02a3df5d215e69d666c7807a737ec76b6e
3
+ metadata.gz: 3692c255ff72ea8bacc0f457e1d9ec4d17e24f6fbc42898a00e5af4d5d64fd1b
4
+ data.tar.gz: f09cdfa8786b2a032f9200a1e0d7537b6fb527a784412bac003c38f543f3ee1d
5
5
  SHA512:
6
- metadata.gz: 836536ed680bb4bcdb6ac7d8e24a3af19c988ba8e81e9ca328388c73e9dafae2002f54d42eb61ec82c48f7c396465054a76fd82757fc1b680e42be4f7736a102
7
- data.tar.gz: 14151229fe62788b174582850649b94697d914bfe97311e2acf30cf26fbea5fc105e07b4d92774e8f5037aadce6d4d181a573cd1d420546bda3fe285dbe942d8
6
+ metadata.gz: 4416a9fcb0f24f337fee5f589a0881cc0376bbddf6a9ca77ffe615a21eccf48e541c9ca9d37b0e18733d869a48c9b75d533b6d738c7c6449883c9e15af05b98b
7
+ data.tar.gz: 955e197762b016537768a1d4ed93f19a49547d33d67c893b387f09be44f70a5abce0afd9ba9527dd6b0304911d5db4c86febd9491eda4469766700fdbfefa040
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- trusty-cms (3.8.1)
4
+ trusty-cms (3.8.2)
5
5
  RedCloth (= 4.3.2)
6
6
  acts_as_list (~> 0.9.5)
7
7
  acts_as_tree (>= 2.6.1, < 2.9.0)
@@ -155,7 +155,7 @@ GEM
155
155
  multipart-post
156
156
  launchy (2.4.3)
157
157
  addressable (~> 2.3)
158
- libv8 (7.3.492.27.1)
158
+ libv8 (7.3.492.27.1-x86_64-linux)
159
159
  loofah (2.4.0)
160
160
  crass (~> 1.0.2)
161
161
  nokogiri (>= 1.5.9)
@@ -749,7 +749,7 @@ module StandardTags
749
749
  url << "&default=#{default_avatar_url}" unless request.host_with_port == 'testhost.tld'
750
750
  # Test the Gravatar url
751
751
  require 'open-uri'
752
- begin; open "http:#{url}", :proxy => true
752
+ begin; open "http:#{sanitize(url)}", :proxy => true
753
753
  rescue; local_avatar_url
754
754
  else; url
755
755
  end
@@ -177,7 +177,7 @@ Devise.setup do |config|
177
177
 
178
178
  # ==> Configuration for :validatable
179
179
  # Range for password length.
180
- # config.password_length = 12..128
180
+ config.password_length = 12..128
181
181
 
182
182
  # Email regex used to validate email formats. It simply asserts that
183
183
  # one (and only one) @ exists in the given string. This is mainly
@@ -4,13 +4,16 @@
4
4
  namespace :import do
5
5
  desc 'Imports the legacy user data into the Devise Admin table'
6
6
  task admins: :environment do
7
+ CHARS = ('0'..'9').to_a + ('A'..'Z').to_a + ('a'..'z').to_a + (1..9).to_a + ['`', '~', '!', '@', '#', '$', '%', '^', '&', '*']
8
+ password = CHARS.sort_by { rand }.join[0...15]
9
+
7
10
  LegacyUser.all.each do |legacy|
8
11
  u = User.new(
9
12
  email: legacy.email,
10
13
  first_name: legacy.name.split(' ')[0],
11
14
  last_name: legacy.name.split(' ')[1],
12
- password: 'PleaseChangeMe1!',
13
- password_confirmation: 'PleaseChangeMe1!',
15
+ password: password,
16
+ password_confirmation: password,
14
17
  admin: legacy.admin,
15
18
  designer: legacy.designer,
16
19
  content_editor: legacy.content_editor,
data/lib/trusty_cms.rb CHANGED
@@ -2,6 +2,6 @@ TRUSTY_CMS_ROOT = File.expand_path(File.join(File.dirname(__FILE__), "..")) unle
2
2
 
3
3
  unless defined? TrustyCms::VERSION
4
4
  module TrustyCms
5
- VERSION = '3.8.1'
5
+ VERSION = '3.8.2'
6
6
  end
7
7
  end
@@ -12,7 +12,7 @@ module TrustyCms
12
12
  end
13
13
 
14
14
  def get_all_versions
15
- ActiveRecord::Base.connection.select_values("SELECT version FROM #{schema_migrations_table_name}").
15
+ ActiveRecord::Base.connection.select_values("SELECT version FROM #{sanitize(schema_migrations_table_name)}").
16
16
  select { |version| version.starts_with?("#{@extension.extension_name}-")}.
17
17
  map { |version| version.sub("#{@extension.extension_name}-", '').to_i }.sort
18
18
  end
@@ -38,17 +38,17 @@ module TrustyCms
38
38
  end
39
39
 
40
40
  def initialize_extension_schema_migrations
41
- current_version = ActiveRecord::Base.connection.select_value("SELECT schema_version FROM extension_meta WHERE name = #{quote(extension_name)}")
41
+ current_version = ActiveRecord::Base.connection.select_value("SELECT schema_version FROM extension_meta WHERE name = #{sanitize(quote(extension_name))}")
42
42
  if current_version
43
43
  assume_migrated_upto_version(current_version.to_i)
44
- ActiveRecord::Base.connection.delete("DELETE FROM extension_meta WHERE name = #{quote(extension_name)}")
44
+ ActiveRecord::Base.connection.delete("DELETE FROM extension_meta WHERE name = #{sanitize(Aquote(extension_name))}")
45
45
  end
46
46
  end
47
47
 
48
48
  def initialize_received_migrations
49
49
  if donors = self.class.extension.migrates_from
50
50
  donors.each do |extension_name, until_migration|
51
- replaced = ActiveRecord::Base.connection.select_values("SELECT version FROM #{ActiveRecord::Migrator.schema_migrations_table_name} WHERE version LIKE '#{extension_name}-%'").map{|v| v.sub(/^#{extension_name}\-/, '').to_i}
51
+ replaced = ActiveRecord::Base.connection.select_values("SELECT version FROM #{sanitize(ActiveRecord::Migrator.schema_migrations_table_name)} WHERE version LIKE '#{extension_name}-%'").map{|v| v.sub(/^#{extension_name}\-/, '').to_i}
52
52
  replaced.delete_if{|v| v > until_migration.to_i} if until_migration
53
53
  assume_migrated_upto_version(replaced.max) if replaced.any?
54
54
  end
@@ -65,7 +65,7 @@ module TrustyCms
65
65
  end
66
66
 
67
67
  unless migrated.include?(version)
68
- ActiveRecord::Base.connection.execute "INSERT INTO #{sm_table} (version) VALUES (#{quote(version_string(version))})"
68
+ ActiveRecord::Base.connection.execute "INSERT INTO #{sm_table} (version) VALUES (#{sanitize(quote(version_string(version)))})"
69
69
  end
70
70
 
71
71
  inserted = Set.new
@@ -73,22 +73,10 @@ module TrustyCms
73
73
  if inserted.include?(v)
74
74
  raise "Duplicate migration #{v}. Please renumber your migrations to resolve the conflict."
75
75
  elsif v < version
76
- ActiveRecord::Base.connection.execute "INSERT INTO #{sm_table} (version) VALUES (#{quote(version_string(v))})"
76
+ ActiveRecord::Base.connection.execute "INSERT INTO #{sm_table} (version) VALUES (#{sanitize(quote(version_string(v)))})"
77
77
  inserted << v
78
78
  end
79
79
  end
80
80
  end
81
-
82
- def record_version_state_after_migrating(version)
83
- sm_table = self.class.schema_migrations_table_name
84
- @migrated_versions ||= []
85
- if down?
86
- @migrated_versions.delete(version.to_i)
87
- ActiveRecord::Base.connection.update("DELETE FROM #{sm_table} WHERE version = #{quote(version_string(version))}")
88
- else
89
- @migrated_versions.add(version.to_i)
90
- ActiveRecord::Base.connection.insert("INSERT INTO #{sm_table} (version) VALUES (#{quote(version_string(version))})")
91
- end
92
- end
93
81
  end
94
82
  end
@@ -71,54 +71,6 @@ namespace :radiant do
71
71
  end
72
72
  end
73
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
74
  end
123
75
  end
124
76
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: trusty-cms
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.8.1
4
+ version: 3.8.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - TrustyCms CMS dev team
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-01-29 00:00:00.000000000 Z
11
+ date: 2020-01-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: acts_as_list
@@ -675,7 +675,6 @@ files:
675
675
  - app/models/layout.rb
676
676
  - app/models/legacy_user.rb
677
677
  - app/models/menu_renderer.rb
678
- - app/models/old_page_attachment.rb
679
678
  - app/models/page.rb
680
679
  - app/models/page_attachment.rb
681
680
  - app/models/page_context.rb
@@ -998,7 +997,6 @@ files:
998
997
  - lib/trusty_cms/config/definition.rb
999
998
  - lib/trusty_cms/engine.rb
1000
999
  - lib/trusty_cms/extension.rb
1001
- - lib/trusty_cms/extension/script.rb
1002
1000
  - lib/trusty_cms/extension_loader.rb
1003
1001
  - lib/trusty_cms/extension_migrator.rb
1004
1002
  - lib/trusty_cms/extension_path.rb
@@ -1,26 +0,0 @@
1
- class OldPageAttachment < ActiveRecord::Base
2
- def create_paperclipped_record
3
- options = {
4
- :asset_file_size => size,
5
- :asset_file_name => filename,
6
- :asset_content_type => content_type,
7
- :created_by_id => created_by
8
- }
9
-
10
- # In newer versions of page_attachments we have title and description fields.
11
- options[:title] = title if respond_to?(:title)
12
- options[:caption] = description if respond_to?(:description)
13
-
14
- a = Asset.new(options)
15
- a.save
16
-
17
- # Re-attach the asset to it's page
18
- page = Page.find(page_id)
19
- p = PageAttachment.create(:asset_id => a.id, :page_id => page.id)
20
-
21
- # Circumvent acts_as_list before_create filter to set the original page_attachment position.
22
- PageAttachment.update_all("position=#{position}", "id=#{p.id}") if respond_to?(:position)
23
-
24
- a
25
- end
26
- end
@@ -1,376 +0,0 @@
1
- require 'active_resource'
2
- require 'tmpdir'
3
- require 'fileutils'
4
- require 'rake'
5
-
6
- module Registry
7
- class Extension < ActiveResource::Base
8
- self.site = ENV['REGISTRY_URL'] || "http://ext.radiantcms.org/"
9
-
10
- def install
11
- Registry.const_get(install_type).new(self).install
12
- end
13
-
14
- def uninstall
15
- Uninstaller.new(self).uninstall
16
- end
17
-
18
- def inspect
19
- %{
20
- Name: #{name}
21
- Description:
22
- #{description}
23
- Author: #{author.name} <#{author.email}>
24
- Source code: #{repository_url}
25
- Download: #{download_url}
26
- Install type: #{install_type}
27
- Supports: TrustyCms #{supports_radiant_version}
28
- }.strip
29
- end
30
- end
31
-
32
- class Action
33
- def rake(command)
34
- puts "rake #{command}"
35
- puts `rake #{command} Rails.env=#{Rails.env}` if tasks_include? command
36
- end
37
-
38
- def tasks_include?(command)
39
- command = command.split(':')
40
- if command.length > 1 && command[0..1] == ['radiant','extensions']
41
- extension = command[2]
42
- task = "radiant:extensions:#{extension}:#{command[3].split[0]}"
43
- else
44
- extension = task = command[0]
45
- end
46
- rake_file = File.join(Rails.root, 'vendor', 'extensions', extension) + '/lib/tasks/' + extension + '_extension_tasks.rake'
47
- load rake_file if File.exist? rake_file
48
- tasks = Rake.application.tasks.map(&:name)
49
- tasks.include? task
50
- end
51
-
52
- def file_utils
53
- FileUtils
54
- end
55
-
56
- delegate :cd, :cp_r, :rm_r, :to => :file_utils
57
- end
58
-
59
- class Installer < Action
60
- attr_accessor :url, :path, :name
61
- def initialize(url, name)
62
- self.url, self.name = url, name
63
- end
64
-
65
- def install
66
- copy_to_vendor_extensions
67
- migrate
68
- update
69
- end
70
-
71
- def copy_to_vendor_extensions
72
- cp_r(self.path, File.expand_path(File.join(Rails.root, 'vendor', 'extensions', name)))
73
- rm_r(self.path)
74
- end
75
-
76
- def migrate
77
- rake "radiant:extensions:#{name}:migrate"
78
- end
79
-
80
- def update
81
- rake "radiant:extensions:#{name}:update"
82
- end
83
- end
84
-
85
- class Uninstaller < Action
86
- attr_accessor :name
87
- def initialize(extension)
88
- self.name = extension.name
89
- end
90
-
91
- def uninstall
92
- migrate_down
93
- remove_extension_directory
94
- end
95
-
96
- def migrate_down
97
- rake "radiant:extensions:#{name}:migrate VERSION=0"
98
- end
99
-
100
- def remove_extension_directory
101
- rm_r(File.join(Rails.root, 'vendor', 'extensions', name))
102
- end
103
- end
104
-
105
- class Checkout < Installer
106
- def initialize(extension)
107
- super(extension.repository_url, extension.name)
108
- end
109
-
110
- def checkout_command
111
- raise "Not Implemented!"
112
- end
113
-
114
- def install
115
- checkout
116
- super
117
- end
118
-
119
- def checkout
120
- self.path = File.join(Dir.tmpdir, name)
121
- cd(Dir.tmpdir) { system "#{checkout_command}" }
122
- end
123
- end
124
-
125
- class Download < Installer
126
- def initialize(extension)
127
- super(extension.download_url, extension.name)
128
- end
129
-
130
- def install
131
- download
132
- unpack
133
- super
134
- end
135
-
136
- def unpack
137
- raise "Not Implemented!"
138
- end
139
-
140
- def filename
141
- File.basename(self.url)
142
- end
143
-
144
- def download
145
- require 'open-uri'
146
- File.open(File.join(Dir.tmpdir, self.filename), 'w') {|f| f.write open(self.url).read }
147
- end
148
- end
149
-
150
- class Git < Checkout
151
- def project_in_git?
152
- @in_git ||= File.directory?(".git")
153
- end
154
-
155
- def checkout_command
156
- "git clone #{url} #{name}"
157
- end
158
-
159
- def checkout
160
- if project_in_git?
161
- system "git submodule add #{url} vendor/extensions/#{name}"
162
- cd(File.join('vendor', 'extensions', name)) do
163
- system "git submodule init && git submodule update"
164
- end
165
- else
166
- super
167
- cd(path) do
168
- system "git submodule init && git submodule update"
169
- end
170
- end
171
- end
172
-
173
- def copy_to_vendor_extensions
174
- super unless project_in_git?
175
- end
176
- end
177
-
178
- class Subversion < Checkout
179
- def checkout_command
180
- "svn checkout #{url} #{name}"
181
- end
182
- end
183
-
184
- class Gem < Download
185
- def gem_name(name)
186
- name.gsub(/-\d+\.\d+\.\d+(.+)?\.gem/, '')
187
- end
188
-
189
- def download
190
- # Don't download the gem if it's already installed
191
- extension = gem_name(filename)
192
- begin
193
- gem extension
194
- rescue ::Gem::LoadError
195
- super
196
- `gem install #{extension}`
197
- end
198
- end
199
-
200
- def unpack
201
- output = nil
202
- cd(Dir.tmpdir) do
203
- output = `gem unpack #{gem_name(filename)}`
204
- end
205
- self.path = output.match(/'(.*)'/)[1]
206
- end
207
- end
208
-
209
- class Tarball < Download
210
- def filename
211
- "#{self.name}.tar"
212
- end
213
-
214
- def unpack
215
- output = nil
216
- cd(Dir.tmpdir) { output = `tar xvf #{filename}` }
217
- self.path = File.join(Dir.tmpdir, output.split(/\n/).first.split('/').first)
218
- end
219
- end
220
-
221
- class Gzip < Tarball
222
- def filename
223
- @unpacked ? super : "#{self.name}.tar.gz"
224
- end
225
-
226
- def unpack
227
- cd(Dir.tmpdir) { system "gunzip #{self.filename}" }
228
- @unpacked = true
229
- super
230
- end
231
- end
232
-
233
- end
234
-
235
- module TrustyCms
236
- class Extension
237
- module Script
238
- class << self
239
- def execute(args)
240
- command = args.shift || 'help'
241
- begin
242
- const_get(command.camelize).new(args)
243
- rescue ArgumentError => e
244
- puts e.message
245
- Help.new [command]
246
- end
247
- end
248
- end
249
-
250
- module Util
251
- attr_accessor :extension_name, :extension
252
-
253
- def to_extension_name(string)
254
- string.to_s.underscore
255
- end
256
-
257
- def installed?
258
- path_match = Regexp.compile("(^|/|\\\\)#{extension_name}$")
259
- extension_paths.any? {|p| p =~ path_match }
260
- end
261
-
262
- def registered?
263
- self.extension
264
- end
265
-
266
- def extension_paths
267
- paths = [Rails.root, TRUSTY_CMS_ROOT].uniq.map { |p| Dir["#{p}/vendor/extensions/*"] }
268
- paths.unshift Dir["#{TRUSTY_CMS_ROOT}/test/fixtures/extensions/*"] if Rails.env == 'test' #nasty
269
- paths.flatten
270
- end
271
-
272
- def load_extensions
273
- Registry::Extension.find(:all)
274
- end
275
-
276
- def find_extension
277
- self.extension = load_extensions.find{|e| e.name == self.extension_name }
278
- end
279
- end
280
-
281
- class Install
282
- include Util
283
-
284
- def initialize(args=[])
285
- raise ArgumentError, "You must specify an extension to install." if args.blank?
286
- self.extension_name = to_extension_name(args.shift)
287
- if installed?
288
- puts "#{extension_name} is already installed."
289
- else
290
- find_extension
291
- if registered?
292
- extension.install
293
- else
294
- raise ArgumentError, "#{extension_name} is not available in the registry."
295
- end
296
- end
297
- end
298
- end
299
-
300
- class Uninstall
301
- include Util
302
-
303
- def initialize(args=[])
304
- raise ArgumentError, "You must specify an extension to uninstall." if args.blank?
305
- self.extension_name = to_extension_name(args.shift)
306
- if installed?
307
- find_extension && extension.uninstall
308
- else
309
- puts "#{extension_name} is not installed."
310
- end
311
- end
312
- end
313
-
314
- class Info
315
- include Util
316
-
317
- def initialize(args=[])
318
- raise ArgumentError, "You must specify an extension to get info on" if args.blank?
319
- self.extension_name = to_extension_name(args.shift)
320
- find_extension and puts extension.inspect
321
- end
322
- end
323
-
324
- class Help
325
- def initialize(args=[])
326
- command = args.shift
327
- command = 'help' unless self.class.instance_methods(false).collect {|im| im.to_s}.include?(command.to_s)
328
- send(command)
329
- end
330
-
331
- def help
332
- $stdout.puts %{Usage: script/extension command [arguments]
333
-
334
- Available commands:
335
- #{command_names}
336
-
337
- For help on an individual command:
338
- script/extension help command
339
-
340
- You may install extensions from another registry by setting the REGISTRY_URL
341
- By default the REGISTRY_URL is set to http://ext.radiantcms.org
342
-
343
- Code for the registry application may be found at:
344
- http://github.com/radiant/radiant-extension-registry/
345
- }
346
- end
347
-
348
- def install
349
- $stdout.puts %{Usage: script/extension install extension_name
350
-
351
- Installs an extension from information in the global registry.
352
- }
353
- end
354
-
355
- def uninstall
356
- $stdout.puts %{Usage: script/extension uninstall extension_name
357
-
358
- Removes a previously installed extension from the current project.
359
- }
360
- end
361
-
362
- def info
363
- $stdout.puts %{Usage: script/extension info extension_name
364
-
365
- Displays registry information about the extension.
366
- }
367
- end
368
-
369
- private
370
- def command_names
371
- (TrustyCms::Extension::Script.constants - ['Util']).sort.map {|n| n.to_s.underscore }.join(", ")
372
- end
373
- end
374
- end
375
- end
376
- end