wagn 1.16.8 → 1.16.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/features/attach.feature +43 -7
- data/features/autonaming.feature +0 -5
- data/features/step_definitions/wagn_steps.rb +12 -0
- data/lib/wagn/generators/wagn/templates/Gemfile +1 -1
- data/lib/wagn/tasks/test.rake +5 -3
- data/lib/wagn/tasks/wagn.rake +121 -120
- data/rails/controllers/card_controller.rb +1 -1
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e2d535153a197b92c0822ab179707b0682c4bf0
|
4
|
+
data.tar.gz: 61a2241a28124f1ffbe02b07988de44ecdccd85d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 164ead08ce3191ec24b18852e3248638e0caf1719816792fc63669e7211a950d8660229a38ede7c4065b1a2d3b93b876e3c00963e9471dd4e56cb68be37e8ef1
|
7
|
+
data.tar.gz: 7eb97223c44d5337b9a4333786a45d76725c38b5cdee516fe5efea2569a1e5d843e5cebe52248846a42829e3b82250111ca9ebb795124813a176884eefd13445
|
data/features/attach.feature
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
@javascript
|
2
|
-
Feature:
|
2
|
+
Feature: File Upload
|
3
3
|
I want to be able to upload files and images.
|
4
4
|
|
5
5
|
Background:
|
@@ -8,12 +8,12 @@ Feature: Conflict
|
|
8
8
|
Scenario: Uploading a file
|
9
9
|
When I go to new File
|
10
10
|
And I upload the file "file.txt"
|
11
|
-
And I wait
|
11
|
+
And I wait until ajax response done
|
12
12
|
Then I should see "file.txt 9 Bytes"
|
13
13
|
When I press "Delete"
|
14
14
|
Then I should see "Add file..."
|
15
15
|
When I upload the file "file.txt"
|
16
|
-
And I wait
|
16
|
+
And I wait until ajax response done
|
17
17
|
And I fill in "card_name" with "a test file"
|
18
18
|
And I press "Submit"
|
19
19
|
Then I should see "Download a test file"
|
@@ -21,24 +21,60 @@ Feature: Conflict
|
|
21
21
|
Scenario: Uploading and changing an image
|
22
22
|
When I go to new Image
|
23
23
|
And I upload the image "image.png"
|
24
|
-
And I wait
|
24
|
+
And I wait until ajax response done
|
25
25
|
Then I should see "image.png 34.3 KB"
|
26
26
|
And I fill in "card_name" with "a test image"
|
27
27
|
And I press "Submit"
|
28
28
|
Then I should see an image of size "large" and type "png"
|
29
29
|
And I edit "a test image"
|
30
30
|
And I upload the image "image2.jpg"
|
31
|
-
And I wait
|
31
|
+
And I wait until ajax response done
|
32
32
|
Then I should see "image2.jpg 69.8 KB"
|
33
33
|
And I press "Submit"
|
34
34
|
Then I should see an image of size "large" and type "jpg"
|
35
|
+
And I wait until ajax response done
|
35
36
|
|
36
37
|
Scenario: Changing a mod image
|
37
38
|
When I edit "*logo"
|
38
39
|
And I upload the image "image2.jpg"
|
39
|
-
And I wait
|
40
|
+
And I wait until ajax response done
|
40
41
|
Then I should see "image2.jpg 69.8 KB"
|
41
42
|
And I press "Submit"
|
42
|
-
|
43
|
+
And I wait until ajax response done
|
44
|
+
Then I should see a non-mod image of size "large" and type "jpg"
|
45
|
+
|
46
|
+
Scenario: uploading a file as a field in a form
|
47
|
+
When I go to "/new Cardtype"
|
48
|
+
And I fill in "card_name" with "complicated_card"
|
49
|
+
And I press "Submit"
|
50
|
+
And I create HTML card "complicated card+*type+*structure" with content "{{+image}}{{+description}}"
|
51
|
+
And I go to "/new complicated_card"
|
52
|
+
And I fill in "card_name" with "Vignesh has a complicated relationship"
|
53
|
+
And I wait until ajax response done
|
54
|
+
And I upload the image "image.png"
|
55
|
+
And I wait until ajax response done
|
56
|
+
Then I should see "image.png 34.3 KB"
|
57
|
+
And I press "Submit"
|
58
|
+
Then I should see an image of size "medium" and type "png"
|
59
|
+
And I wait until ajax response done
|
60
|
+
|
61
|
+
Scenario: updating a file as a field in a form
|
62
|
+
When I go to "/new Cardtype"
|
63
|
+
And I fill in "card_name" with "complicated_card"
|
64
|
+
And I press "Submit"
|
65
|
+
And I create HTML card "complicated card+*type+*structure" with content "{{+image}}{{+description}}"
|
66
|
+
And I go to "/new complicated_card"
|
67
|
+
And I fill in "card_name" with "Vignesh has a complicated relationship"
|
68
|
+
And I wait until ajax response done
|
69
|
+
And I upload the image "image.png"
|
70
|
+
And I wait until ajax response done
|
71
|
+
And I press "Submit"
|
72
|
+
And I edit "Vignesh has a complicated relationship"
|
73
|
+
And I upload the image "image2.jpg"
|
74
|
+
And I wait until ajax response done
|
75
|
+
Then I should see "image2.jpg 69.8 KB"
|
76
|
+
And I press "Submit"
|
77
|
+
Then I should see an image of size "medium" and type "jpg"
|
78
|
+
And I wait until ajax response done
|
43
79
|
|
44
80
|
|
data/features/autonaming.feature
CHANGED
@@ -154,6 +154,13 @@ When /I wait (\d+) seconds$/ do |period|
|
|
154
154
|
sleep period.to_i
|
155
155
|
end
|
156
156
|
|
157
|
+
When /^I wait until ajax response done$/ do
|
158
|
+
Timeout.timeout(Capybara.default_wait_time) do
|
159
|
+
while page.evaluate_script('jQuery.active') != 0
|
160
|
+
sleep(0.5)
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|
157
164
|
|
158
165
|
Then /what/ do
|
159
166
|
save_and_open_page
|
@@ -326,6 +333,11 @@ Then /^I should see an image of size "(.+)" and type "(.+)"$/ do |size, type|
|
|
326
333
|
find("img[src*='#{size}.#{type}']")
|
327
334
|
end
|
328
335
|
|
336
|
+
Then /^I should see a non-mod image of size "(.+)" and type "(.+)"$/ do |size, type|
|
337
|
+
element = find("img[src*='#{size}.#{type}']")
|
338
|
+
expect(element[:src]).to match(%r(/~\d+/))
|
339
|
+
end
|
340
|
+
|
329
341
|
Then /^I should see "([^\"]*)" in color (.*)$/ do |text, css_class|
|
330
342
|
page.has_css?(".diff-#{css_class}", text: text)
|
331
343
|
end
|
@@ -78,7 +78,7 @@ group :test do
|
|
78
78
|
# CUKES see features dir
|
79
79
|
gem 'cucumber-rails', '~> 1.3', :require=>false # feature-driven-development suite
|
80
80
|
gem 'capybara', '~> 2.4.4'
|
81
|
-
gem 'selenium-webdriver', '~> 2.
|
81
|
+
gem 'selenium-webdriver', '~> 2.47.1'
|
82
82
|
# gem 'capybara-webkit'
|
83
83
|
gem 'launchy' # lets cucumber launch browser windows
|
84
84
|
|
data/lib/wagn/tasks/test.rake
CHANGED
@@ -1,4 +1,6 @@
|
|
1
|
-
TEST_SEED_PATH =
|
1
|
+
TEST_SEED_PATH = File.join(
|
2
|
+
ENV['DECKO_SEED_REPO_PATH'] || [Cardio.gem_root, 'db','seed'], 'test'
|
3
|
+
)
|
2
4
|
|
3
5
|
namespace :test do
|
4
6
|
task :all => :environment do
|
@@ -47,7 +49,7 @@ namespace :test do
|
|
47
49
|
ActiveRecord::Base.establish_connection
|
48
50
|
tables.each do |table_name|
|
49
51
|
i = "000"
|
50
|
-
File.open("#{ TEST_SEED_PATH }/
|
52
|
+
File.open("#{ TEST_SEED_PATH }/fixtures/#{table_name}.yml", 'w') do |file|
|
51
53
|
data = ActiveRecord::Base.connection.select_all(sql % table_name)
|
52
54
|
file.write data.inject({}) { |hash, record|
|
53
55
|
record['trash'] = false if record.has_key? 'trash'
|
@@ -63,7 +65,7 @@ namespace :test do
|
|
63
65
|
task :populate_template_database => :environment do
|
64
66
|
raise "must be test env" unless Rails.env == 'test'
|
65
67
|
puts "populate test data\n"
|
66
|
-
load "#{ TEST_SEED_PATH }/
|
68
|
+
load "#{ TEST_SEED_PATH }/seed.rb"
|
67
69
|
SharedData.add_test_data
|
68
70
|
end
|
69
71
|
|
data/lib/wagn/tasks/wagn.rake
CHANGED
@@ -1,41 +1,43 @@
|
|
1
1
|
require 'wagn/application'
|
2
2
|
|
3
|
-
WAGN_SEED_TABLES = %w{ cards card_actions card_acts card_changes
|
3
|
+
WAGN_SEED_TABLES = %w{ cards card_actions card_acts card_changes
|
4
|
+
card_references }
|
4
5
|
WAGN_SEED_PATH = File.join(
|
5
|
-
ENV['DECKO_SEED_REPO_PATH'] || [Cardio.gem_root, 'db','seed'], 'new'
|
6
|
+
ENV['DECKO_SEED_REPO_PATH'] || [Cardio.gem_root, 'db', 'seed'], 'new'
|
6
7
|
)
|
7
8
|
|
8
|
-
|
9
9
|
def prepare_migration
|
10
10
|
Card::Cache.reset_global
|
11
11
|
Card.config.action_mailer.perform_deliveries = false
|
12
12
|
Card.reset_column_information
|
13
|
-
|
14
|
-
|
13
|
+
# this is needed in production mode to insure core db
|
14
|
+
Card::Reference.reset_column_information
|
15
|
+
# structures are loaded before schema_mode is set
|
15
16
|
end
|
16
17
|
|
17
18
|
namespace :wagn do
|
18
|
-
desc
|
19
|
+
desc 'create a wagn database from scratch, load initial data'
|
19
20
|
task :seed do
|
20
21
|
ENV['SCHEMA'] ||= "#{Cardio.gem_root}/db/schema.rb"
|
21
|
-
puts
|
22
|
-
#
|
22
|
+
puts 'dropping'
|
23
|
+
# FIXME: this should be an option, but should not happen on standard
|
24
|
+
# creates!
|
23
25
|
begin
|
24
26
|
Rake::Task['db:drop'].invoke
|
25
27
|
rescue
|
26
|
-
puts
|
28
|
+
puts 'not dropped'
|
27
29
|
end
|
28
30
|
|
29
|
-
puts
|
31
|
+
puts 'creating'
|
30
32
|
Rake::Task['db:create'].invoke
|
31
33
|
|
32
|
-
puts
|
34
|
+
puts 'loading schema'
|
33
35
|
Rake::Task['db:schema:load'].invoke
|
34
36
|
|
35
37
|
Rake::Task['wagn:load'].invoke
|
36
38
|
end
|
37
39
|
|
38
|
-
desc
|
40
|
+
desc 'clear and load fixtures with existing tables'
|
39
41
|
task :reseed do
|
40
42
|
ENV['SCHEMA'] ||= "#{Cardio.gem_root}/db/schema.rb"
|
41
43
|
|
@@ -44,64 +46,64 @@ namespace :wagn do
|
|
44
46
|
Rake::Task['wagn:load'].invoke
|
45
47
|
end
|
46
48
|
|
47
|
-
desc
|
49
|
+
desc 'empty the card tables'
|
48
50
|
task :clear do
|
49
51
|
conn = ActiveRecord::Base.connection
|
50
52
|
|
51
|
-
puts
|
53
|
+
puts 'delete all data in bootstrap tables'
|
52
54
|
WAGN_SEED_TABLES.each do |table|
|
53
55
|
conn.delete "delete from #{table}"
|
54
56
|
end
|
55
57
|
end
|
56
58
|
|
57
|
-
desc
|
59
|
+
desc 'Load bootstrap data into database'
|
58
60
|
task :load do
|
59
61
|
require 'decko/engine'
|
60
|
-
puts
|
62
|
+
puts 'update card_migrations'
|
61
63
|
Rake::Task['wagn:assume_card_migrations'].invoke
|
62
64
|
|
63
65
|
if Rails.env == 'test' && !ENV['GENERATE_FIXTURES']
|
64
|
-
puts
|
66
|
+
puts 'loading test fixtures'
|
65
67
|
Rake::Task['db:fixtures:load'].invoke
|
66
68
|
else
|
67
|
-
puts
|
69
|
+
puts 'loading bootstrap'
|
68
70
|
Rake::Task['wagn:bootstrap:load'].invoke
|
69
71
|
end
|
70
72
|
|
71
|
-
puts
|
73
|
+
puts 'set symlink for assets'
|
72
74
|
Rake::Task['wagn:update_assets_symlink'].invoke
|
73
75
|
end
|
74
76
|
|
75
|
-
desc
|
77
|
+
desc 'update wagn gems and database'
|
76
78
|
task :update do
|
77
79
|
ENV['NO_RAILS_CACHE'] = 'true'
|
78
|
-
#system 'bundle update'
|
79
|
-
if Wagn.paths[
|
80
|
-
FileUtils.rm_rf Wagn.paths[
|
80
|
+
# system 'bundle update'
|
81
|
+
if Wagn.paths['tmp'].existent
|
82
|
+
FileUtils.rm_rf Wagn.paths['tmp'].first, secure: true
|
81
83
|
end
|
82
|
-
Dir.mkdir Wagn.paths[
|
84
|
+
Dir.mkdir Wagn.paths['tmp'].first
|
83
85
|
Rake::Task['wagn:migrate'].invoke
|
84
86
|
# FIXME remove tmp dir / clear cache
|
85
|
-
puts
|
87
|
+
puts 'set symlink for assets'
|
86
88
|
Rake::Task['wagn:update_assets_symlink'].invoke
|
87
89
|
end
|
88
90
|
|
89
|
-
desc
|
90
|
-
task :
|
91
|
+
desc 'reset cache'
|
92
|
+
task reset_cache: :environment do
|
91
93
|
Card::Cache.reset_global
|
92
94
|
end
|
93
95
|
|
94
|
-
desc
|
96
|
+
desc 'set symlink for assets'
|
95
97
|
task :update_assets_symlink do
|
96
|
-
assets_path = File.join(Rails.public_path,
|
98
|
+
assets_path = File.join(Rails.public_path, 'assets')
|
97
99
|
if Rails.root.to_s != Wagn.gem_root and not File.exists? assets_path
|
98
100
|
FileUtils.rm assets_path if File.symlink? assets_path
|
99
|
-
FileUtils.ln_s(
|
101
|
+
FileUtils.ln_s(Decko::Engine.paths['gem-assets'].first, assets_path)
|
100
102
|
end
|
101
103
|
end
|
102
104
|
|
103
|
-
desc
|
104
|
-
task :
|
105
|
+
desc 'migrate structure and cards'
|
106
|
+
task migrate: :environment do
|
105
107
|
ENV['NO_RAILS_CACHE'] = 'true'
|
106
108
|
ENV['SCHEMA'] ||= "#{Cardio.gem_root}/db/schema.rb"
|
107
109
|
|
@@ -140,14 +142,14 @@ namespace :wagn do
|
|
140
142
|
end
|
141
143
|
|
142
144
|
namespace :migrate do
|
143
|
-
desc
|
144
|
-
task :
|
145
|
+
desc 'migrate cards'
|
146
|
+
task cards: :environment do
|
145
147
|
Rake::Task['wagn:migrate:core_cards'].invoke
|
146
148
|
Rake::Task['wagn:migrate:deck_cards'].execute
|
147
149
|
end
|
148
150
|
|
149
|
-
desc
|
150
|
-
task :
|
151
|
+
desc 'migrate structure'
|
152
|
+
task structure: :environment do
|
151
153
|
ENV['SCHEMA'] ||= "#{Cardio.gem_root}/db/schema.rb"
|
152
154
|
Cardio.schema_mode(:structure) do
|
153
155
|
paths = ActiveRecord::Migrator.migrations_paths = Cardio.migration_paths(:structure)
|
@@ -156,23 +158,26 @@ namespace :wagn do
|
|
156
158
|
end
|
157
159
|
end
|
158
160
|
|
159
|
-
desc
|
160
|
-
task :
|
161
|
+
desc 'migrate core cards'
|
162
|
+
task core_cards: :environment do
|
161
163
|
require 'card/core_migration'
|
162
164
|
|
163
165
|
Card::Cache.reset_global
|
164
166
|
ENV['SCHEMA'] ||= "#{Cardio.gem_root}/db/schema.rb"
|
165
167
|
prepare_migration
|
166
|
-
paths =
|
167
|
-
|
168
|
+
paths = Cardio.migration_paths(:core_cards)
|
169
|
+
verbose = ENV['VERBOSE'] ? ENV['VERBOSE'] == 'true' : true
|
170
|
+
version = ENV['VERSION'] ? ENV['VERSION'].to_i : nil
|
168
171
|
|
169
|
-
|
170
|
-
|
172
|
+
ActiveRecord::Migrator.migrations_paths = paths
|
173
|
+
Cardio.schema_mode :core_cards do
|
174
|
+
ActiveRecord::Migration.verbose = verbose
|
175
|
+
ActiveRecord::Migrator.migrate paths, version
|
171
176
|
end
|
172
177
|
end
|
173
178
|
|
174
|
-
desc
|
175
|
-
task :
|
179
|
+
desc 'migrate deck cards'
|
180
|
+
task deck_cards: :environment do
|
176
181
|
require 'card/migration'
|
177
182
|
|
178
183
|
Card::Cache.reset_global
|
@@ -181,17 +186,18 @@ namespace :wagn do
|
|
181
186
|
paths = ActiveRecord::Migrator.migrations_paths = Cardio.migration_paths(:deck_cards)
|
182
187
|
|
183
188
|
Cardio.schema_mode(:deck_cards) do
|
184
|
-
ActiveRecord::Migration.verbose = ENV[
|
185
|
-
ActiveRecord::Migrator.migrate paths, ENV[
|
189
|
+
ActiveRecord::Migration.verbose = ENV['VERBOSE'] ? ENV['VERBOSE'] == 'true' : true
|
190
|
+
ActiveRecord::Migrator.migrate paths, ENV['VERSION'] ? ENV['VERSION'].to_i : nil
|
186
191
|
end
|
187
192
|
end
|
188
193
|
|
189
|
-
|
194
|
+
# maybe we should move this to a method?
|
195
|
+
desc 'write the version to a file (not usually called directly)'
|
190
196
|
task :stamp, :type do |t, args|
|
191
197
|
ENV['SCHEMA'] ||= "#{Cardio.gem_root}/db/schema.rb"
|
192
198
|
Cardio.config.action_mailer.perform_deliveries = false
|
193
199
|
|
194
|
-
stamp_file = Cardio.schema_stamp_path(
|
200
|
+
stamp_file = Cardio.schema_stamp_path(args[:type])
|
195
201
|
|
196
202
|
Cardio.schema_mode args[:type] do
|
197
203
|
version = ActiveRecord::Migrator.current_version
|
@@ -205,10 +211,10 @@ namespace :wagn do
|
|
205
211
|
|
206
212
|
|
207
213
|
namespace :emergency do
|
208
|
-
task :
|
214
|
+
task rescue_watchers: :environment do
|
209
215
|
follower_hash = Hash.new { |h, v| h[v] = [] }
|
210
216
|
|
211
|
-
Card.where(
|
217
|
+
Card.where('right_id' => 219).each do |watcher_list|
|
212
218
|
watcher_list.include_set_modules
|
213
219
|
if watcher_list.left
|
214
220
|
watching = watcher_list.left.name
|
@@ -218,16 +224,16 @@ namespace :wagn do
|
|
218
224
|
end
|
219
225
|
end
|
220
226
|
|
221
|
-
Card.search(:
|
227
|
+
Card.search(right: {codename: 'following'}).each do |following|
|
222
228
|
Card::Auth.as_bot do
|
223
|
-
following.update_attributes! :
|
229
|
+
following.update_attributes! content: ''
|
224
230
|
end
|
225
231
|
end
|
226
232
|
|
227
233
|
follower_hash.each do |user, items|
|
228
234
|
if card=Card.fetch(user) and card.account
|
229
235
|
Card::Auth.as(user) do
|
230
|
-
following = card.fetch :
|
236
|
+
following = card.fetch trait: 'following', new: {}
|
231
237
|
following.items = items
|
232
238
|
end
|
233
239
|
end
|
@@ -236,57 +242,18 @@ namespace :wagn do
|
|
236
242
|
end
|
237
243
|
|
238
244
|
namespace :bootstrap do
|
239
|
-
desc
|
240
|
-
task :
|
245
|
+
desc 'rid template of unneeded cards, acts, actions, changes, and references'
|
246
|
+
task clean: :environment do
|
241
247
|
Card::Cache.reset_global
|
242
|
-
|
243
|
-
|
244
|
-
# USER related
|
245
|
-
who_and_when = [ Card::WagnBotID, Time.now.utc.to_s(:db) ]
|
246
|
-
card_sql = "update cards set creator_id=%1$s, created_at='%2$s', updater_id=%1$s, updated_at='%2$s'"
|
247
|
-
conn.update( card_sql % who_and_when )
|
248
|
-
conn.update( "update card_acts set actor_id=%s, acted_at='%s'" % who_and_when )
|
249
|
-
|
250
|
-
Card::Auth.as_bot do
|
251
|
-
# delete ignored cards
|
252
|
-
|
253
|
-
if ignoramus = Card['*ignore']
|
254
|
-
ignoramus.item_cards.each do |card|
|
255
|
-
card.delete!
|
256
|
-
end
|
257
|
-
end
|
258
|
-
Card::Cache.reset_global
|
259
|
-
# FIXME: can this be associated with the machine module somehow?
|
260
|
-
%w{ machine_input machine_output }.each do |codename|
|
261
|
-
Card.search(:right=>{:codename=>codename }).each do |card|
|
262
|
-
FileUtils.rm_rf File.join('files', card.id.to_s ), :secure=>true
|
263
|
-
card.delete!
|
264
|
-
end
|
265
|
-
end
|
266
|
-
end
|
267
|
-
|
248
|
+
clear_history
|
249
|
+
delete_unwanted_cards
|
268
250
|
Card.empty_trash
|
269
|
-
|
270
|
-
# FIXME: move this to history
|
271
|
-
# Card::Act.clear_history(:actor_id=>Card::WagnBotID, :card_id=>Card::WagnBotID)
|
272
|
-
Card::Action.delete_old
|
273
|
-
Card::Change.delete_actionless
|
274
|
-
|
275
|
-
conn.execute( "truncate card_acts" )
|
276
|
-
conn.execute( "truncate sessions" )
|
277
|
-
|
278
|
-
|
279
|
-
act = Card::Act.create!(:actor_id=>Card::WagnBotID, :card_id=>Card::WagnBotID)
|
280
|
-
Card::Action.find_each do |action|
|
281
|
-
action.update_attributes!(:card_act_id=>act.id)
|
282
|
-
end
|
283
|
-
|
251
|
+
correct_time_and_user_stamps
|
284
252
|
Card::Cache.reset_global
|
285
|
-
|
286
253
|
end
|
287
254
|
|
288
|
-
desc
|
289
|
-
task :
|
255
|
+
desc 'dump db to bootstrap fixtures'
|
256
|
+
task dump: :environment do
|
290
257
|
Card::Cache.reset_global
|
291
258
|
|
292
259
|
# FIXME temporarily taking this out!!
|
@@ -299,9 +266,11 @@ namespace :wagn do
|
|
299
266
|
# which dumps with slashes that syck can't understand
|
300
267
|
|
301
268
|
WAGN_SEED_TABLES.each do |table|
|
302
|
-
i =
|
269
|
+
i = '000'
|
303
270
|
File.open(File.join(WAGN_SEED_PATH, "#{table}.yml"), 'w') do |file|
|
304
|
-
data = ActiveRecord::Base.connection.select_all(
|
271
|
+
data = ActiveRecord::Base.connection.select_all(
|
272
|
+
"select * from #{table}"
|
273
|
+
)
|
305
274
|
file.write YAML::dump( data.inject({}) do |hash, record|
|
306
275
|
record['trash'] = false if record.has_key? 'trash'
|
307
276
|
record['draft'] = false if record.has_key? 'draft'
|
@@ -317,60 +286,92 @@ namespace :wagn do
|
|
317
286
|
|
318
287
|
end
|
319
288
|
|
320
|
-
desc
|
321
|
-
task :
|
289
|
+
desc 'copy files from template database to standard mod and update cards'
|
290
|
+
task copy_mod_files: :environment do
|
322
291
|
|
323
292
|
source_files_dir = "#{Wagn.root}/files"
|
324
293
|
|
325
294
|
# mark mod files as mod files
|
326
295
|
Card::Auth.as_bot do
|
327
|
-
Card.search(
|
328
|
-
if card.mod_file? || card.codename == 'new_file' ||
|
296
|
+
Card.search(type: ['in', 'Image', 'File'], ne: '').each do |card|
|
297
|
+
if card.mod_file? || card.codename == 'new_file' ||
|
298
|
+
card.codename == 'new_image'
|
329
299
|
puts "skipping #{card.name}: already in code"
|
330
300
|
next
|
331
301
|
else
|
332
302
|
puts "working on #{card.name}"
|
333
303
|
end
|
334
304
|
|
335
|
-
raise
|
305
|
+
raise 'need codename for file' unless card.codename.present?
|
336
306
|
|
337
|
-
files = {:
|
307
|
+
files = {original: card.attachment.path}
|
338
308
|
card.attachment.versions.each_key do |version|
|
339
309
|
files[version] = card.attachment.path(version)
|
340
310
|
end
|
341
311
|
|
342
312
|
# make card a mod file card
|
343
313
|
mod_name = (l = card.left) && l.type_id==Card::SkinID ? '06_bootstrap' : '05_standard'
|
344
|
-
card.update_column :db_content, card.attachment.db_content(:
|
345
|
-
card.last_action.change_for(2).first.update_column :value, card.attachment.db_content(:
|
314
|
+
card.update_column :db_content, card.attachment.db_content(mod: mod_name)
|
315
|
+
card.last_action.change_for(2).first.update_column :value, card.attachment.db_content(mod: mod_name)
|
346
316
|
card.expire
|
347
317
|
card = Card.fetch card.name
|
348
318
|
|
349
319
|
target_dir = card.store_dir
|
350
320
|
|
351
|
-
#FileUtils.remove_dir target_dir, force=true if Dir.exists? target_dir
|
352
|
-
#FileUtils.mkdir_p target_dir
|
353
|
-
|
354
321
|
files.each do |version, path|
|
355
322
|
FileUtils.cp path, card.attachment.path(version)
|
356
323
|
end
|
357
|
-
|
358
324
|
end
|
359
325
|
end
|
360
326
|
end
|
361
327
|
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
#FIXME - shouldn't we be more standard and use seed.rb for this code?
|
328
|
+
desc 'load bootstrap fixtures into db'
|
329
|
+
task load: :environment do
|
330
|
+
# FIXME: shouldn't we be more standard and use seed.rb for this code?
|
366
331
|
Rake.application.options.trace = true
|
367
332
|
puts "bootstrap load starting #{WAGN_SEED_PATH}"
|
368
333
|
require 'active_record/fixtures'
|
369
|
-
|
370
|
-
|
371
|
-
ActiveRecord::Fixtures.create_fixtures WAGN_SEED_PATH, WAGN_SEED_TABLES
|
334
|
+
ActiveRecord::FixtureSet.create_fixtures WAGN_SEED_PATH, WAGN_SEED_TABLES
|
372
335
|
end
|
336
|
+
end
|
337
|
+
end
|
373
338
|
|
339
|
+
def correct_time_and_user_stamps
|
340
|
+
conn = ActiveRecord::Base.connection
|
341
|
+
who_and_when = [ Card::WagnBotID, Time.now.utc.to_s(:db) ]
|
342
|
+
card_sql = "update cards set creator_id=%1$s, created_at='%2$s', updater_id=%1$s, updated_at='%2$s'"
|
343
|
+
conn.update(card_sql % who_and_when)
|
344
|
+
conn.update("update card_acts set actor_id=%s, acted_at='%s'" % who_and_when)
|
345
|
+
end
|
346
|
+
|
347
|
+
def delete_unwanted_cards
|
348
|
+
Card::Auth.as_bot do
|
349
|
+
if ignoramus = Card['*ignore']
|
350
|
+
ignoramus.item_cards.each do |card|
|
351
|
+
card.delete!
|
352
|
+
end
|
353
|
+
end
|
354
|
+
Card::Cache.reset_global
|
355
|
+
# FIXME: can this be associated with the machine module somehow?
|
356
|
+
%w{ machine_input machine_output }.each do |codename|
|
357
|
+
Card.search(:right=>{:codename=>codename }).each do |card|
|
358
|
+
FileUtils.rm_rf File.join('files', card.id.to_s ), :secure=>true
|
359
|
+
card.delete!
|
360
|
+
end
|
361
|
+
end
|
374
362
|
end
|
363
|
+
end
|
375
364
|
|
365
|
+
def clear_history
|
366
|
+
Card::Action.delete_old
|
367
|
+
Card::Change.delete_actionless
|
368
|
+
|
369
|
+
conn = ActiveRecord::Base.connection
|
370
|
+
conn.execute( "truncate card_acts" )
|
371
|
+
conn.execute( "truncate sessions" )
|
372
|
+
act = Card::Act.create! actor_id: Card::WagnBotID,
|
373
|
+
:card_id=>Card::WagnBotID
|
374
|
+
Card::Action.find_each do |action|
|
375
|
+
action.update_attributes!(:card_act_id=>act.id)
|
376
|
+
end
|
376
377
|
end
|
@@ -75,7 +75,7 @@ class CardController < ActionController::Base
|
|
75
75
|
|
76
76
|
def load_id
|
77
77
|
params[:id] ||= case
|
78
|
-
when Card::Auth.needs_setup?
|
78
|
+
when Card::Auth.needs_setup? && Card::Env.html?
|
79
79
|
params[:card] = { type_id: Card.default_accounted_type_id }
|
80
80
|
params[:view] = 'setup'
|
81
81
|
''
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wagn
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.16.
|
4
|
+
version: 1.16.9
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ethan McCutchen
|
@@ -11,7 +11,7 @@ authors:
|
|
11
11
|
autorequire:
|
12
12
|
bindir: bin
|
13
13
|
cert_chain: []
|
14
|
-
date: 2015-10-
|
14
|
+
date: 2015-10-20 00:00:00.000000000 Z
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
17
17
|
name: rails
|
@@ -33,14 +33,14 @@ dependencies:
|
|
33
33
|
requirements:
|
34
34
|
- - '='
|
35
35
|
- !ruby/object:Gem::Version
|
36
|
-
version: 1.16.
|
36
|
+
version: 1.16.9
|
37
37
|
type: :runtime
|
38
38
|
prerelease: false
|
39
39
|
version_requirements: !ruby/object:Gem::Requirement
|
40
40
|
requirements:
|
41
41
|
- - '='
|
42
42
|
- !ruby/object:Gem::Version
|
43
|
-
version: 1.16.
|
43
|
+
version: 1.16.9
|
44
44
|
description: a wiki approach to stuctured data, dynamic interaction, and web design
|
45
45
|
email:
|
46
46
|
- info@wagn.org
|