card 1.16.4 → 1.16.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/VERSION +1 -1
- data/db/migrate_core_cards/20150429090551_search_card_context.rb +34 -0
- data/db/migrate_core_cards/20150824135418_update_file_history.rb +10 -5
- data/db/migrate_core_cards/20150910085603_remove_performance_log_card.rb +10 -0
- data/db/seed/new/card_actions.yml +358 -366
- data/db/seed/new/card_acts.yml +1 -1
- data/db/seed/new/card_changes.yml +1379 -1399
- data/db/seed/new/card_references.yml +1109 -710
- data/db/seed/new/cards.yml +1436 -1454
- data/db/seed/test/fixtures/card_actions.yml +1031 -1039
- data/db/seed/test/fixtures/card_acts.yml +155 -155
- data/db/seed/test/fixtures/card_changes.yml +4148 -4168
- data/db/seed/test/fixtures/card_references.yml +1577 -1178
- data/db/seed/test/fixtures/cards.yml +2259 -2277
- data/db/version_core_cards.txt +1 -1
- data/lib/card.rb +3 -2
- data/lib/card/env.rb +66 -0
- data/lib/card/format.rb +3 -38
- data/lib/card/loader.rb +0 -4
- data/lib/card/location.rb +38 -0
- data/lib/card/set.rb +1 -3
- data/lib/card/success.rb +2 -3
- data/mod/01_core/format/html_format.rb +0 -48
- data/mod/01_core/set/all/collection.rb +9 -7
- data/mod/01_core/set/all/initialize.rb +5 -0
- data/mod/01_core/set/all/location_history.rb +10 -0
- data/mod/01_core/set/all/phases.rb +2 -1
- data/mod/01_core/set/all/rules.rb +0 -2
- data/mod/01_core/set/all/trash.rb +3 -2
- data/mod/01_core/set/all/utils.rb +12 -0
- data/mod/01_core/spec/set/all/permissions_spec.rb +8 -8
- data/mod/01_core/spec/set/all/type_spec.rb +14 -14
- data/mod/01_history/set/all/content_history.rb +7 -3
- data/mod/01_history/set/all/history.rb +3 -3
- data/mod/02_basic_types/set/type/pointer.rb +8 -1
- data/mod/03_machines/lib/javascript/wagn_mod.js.coffee +39 -0
- data/mod/03_machines/lib/stylesheets/style_cards.scss +12 -2
- data/mod/03_machines/set/right/machine_output.rb +4 -0
- data/mod/03_machines/set/type/css.rb +1 -1
- data/mod/04_settings/spec/set/right/structure_spec.rb +1 -1
- data/mod/05_email/set/all/observer.rb +5 -5
- data/mod/05_email/set/type_plus_right/user/follow.rb +1 -1
- data/mod/05_standard/file/favicon/image-icon.png +0 -0
- data/mod/05_standard/file/favicon/image-large.png +0 -0
- data/mod/05_standard/file/favicon/image-medium.png +0 -0
- data/mod/05_standard/file/favicon/image-original.png +0 -0
- data/mod/05_standard/file/favicon/image-small.png +0 -0
- data/mod/05_standard/lib/carrier_wave/cardmount.rb +8 -2
- data/mod/05_standard/lib/file_uploader.rb +47 -35
- data/mod/05_standard/set/abstract/attachment.rb +87 -35
- data/mod/05_standard/set/all/error.rb +1 -1
- data/mod/05_standard/set/all/links.rb +1 -0
- data/mod/05_standard/set/self/signin.rb +1 -1
- data/mod/05_standard/set/type/file.rb +16 -1
- data/mod/05_standard/set/type/image.rb +2 -0
- data/mod/05_standard/set/type/search_type.rb +2 -2
- data/mod/05_standard/spec/chunk/link_spec.rb +42 -32
- data/mod/05_standard/spec/set/all/links_spec.rb +15 -0
- data/mod/05_standard/spec/set/self/head_spec.rb +3 -3
- data/mod/05_standard/spec/set/type/email_template_spec.rb +39 -39
- data/mod/05_standard/spec/set/type/file_spec.rb +0 -12
- data/mod/05_standard/spec/set/type/image_spec.rb +26 -2
- data/spec/lib/card/content_spec.rb +169 -154
- data/spec/lib/card/format_spec.rb +7 -7
- data/spec/lib/card/success_spec.rb +1 -1
- metadata +7 -6
- data/lib/card/log.rb +0 -545
- data/mod/05_standard/set/self/performance_log.rb +0 -92
- data/spec/lib/card/log_spec.rb +0 -270
data/db/version_core_cards.txt
CHANGED
@@ -1 +1 @@
|
|
1
|
-
|
1
|
+
20150910085603
|
data/lib/card.rb
CHANGED
@@ -26,13 +26,13 @@ class Card < ActiveRecord::Base
|
|
26
26
|
require_dependency 'card/format'
|
27
27
|
require_dependency 'card/exceptions'
|
28
28
|
require_dependency 'card/auth'
|
29
|
-
require_dependency 'card/log'
|
30
29
|
require_dependency 'card/loader'
|
31
30
|
require_dependency 'card/content'
|
32
31
|
require_dependency 'card/action'
|
33
32
|
require_dependency 'card/act'
|
34
33
|
require_dependency 'card/change'
|
35
34
|
require_dependency 'card/reference'
|
35
|
+
require_dependency 'card/view_cache'
|
36
36
|
|
37
37
|
has_many :references_from, :class_name => :Reference, :foreign_key => :referee_id
|
38
38
|
has_many :references_to, :class_name => :Reference, :foreign_key => :referer_id
|
@@ -54,7 +54,7 @@ class Card < ActiveRecord::Base
|
|
54
54
|
attr_accessor :follower_stash
|
55
55
|
|
56
56
|
|
57
|
-
define_callbacks :prepare, :approve, :store, :stored, :extend, :subsequent, :select_action
|
57
|
+
define_callbacks :prepare, :approve, :store, :stored, :extend, :subsequent, :select_action, :show, :handle
|
58
58
|
|
59
59
|
before_validation :prepare
|
60
60
|
before_validation :approve
|
@@ -65,6 +65,7 @@ class Card < ActiveRecord::Base
|
|
65
65
|
extend CarrierWave::Mount
|
66
66
|
ActiveSupport.run_load_hooks(:card, self)
|
67
67
|
|
68
|
+
|
68
69
|
end
|
69
70
|
|
70
71
|
|
data/lib/card/env.rb
CHANGED
@@ -1,4 +1,7 @@
|
|
1
|
+
|
2
|
+
|
1
3
|
class Card
|
4
|
+
require 'card/location'
|
2
5
|
|
3
6
|
# Card::Env can differ for each request; Card.config should not
|
4
7
|
module Env
|
@@ -12,6 +15,7 @@ class Card
|
|
12
15
|
self[:params] = c.params
|
13
16
|
self[:ip] = c.request.remote_ip
|
14
17
|
self[:ajax] = c.request.xhr? || c.request.params[:simulate_xhr]
|
18
|
+
self[:html] = [nil, 'html'].member?(c.params[:format])
|
15
19
|
self[:host] = Card.config.override_host || c.request.env['HTTP_HOST']
|
16
20
|
self[:protocol] = Card.config.override_protocol || c.request.protocol
|
17
21
|
end
|
@@ -34,11 +38,19 @@ class Card
|
|
34
38
|
self[:session] ||= {}
|
35
39
|
end
|
36
40
|
|
41
|
+
def success cardname=nil
|
42
|
+
self[:success] ||= Card::Success.new(cardname, params[:success])
|
43
|
+
end
|
44
|
+
|
37
45
|
|
38
46
|
def ajax?
|
39
47
|
self[:ajax]
|
40
48
|
end
|
41
49
|
|
50
|
+
def html?
|
51
|
+
!self[:controller] || self[:html]
|
52
|
+
end
|
53
|
+
|
42
54
|
def method_missing method_id, *args
|
43
55
|
case args.length
|
44
56
|
when 0 ; self[ method_id ]
|
@@ -47,6 +59,60 @@ class Card
|
|
47
59
|
end
|
48
60
|
end
|
49
61
|
end
|
62
|
+
|
63
|
+
# session history helpers: we keep a history stack so that in the case of
|
64
|
+
# card removal we can crawl back up to the last un-removed location
|
65
|
+
module LocationHistory
|
66
|
+
#include Card::Location
|
67
|
+
|
68
|
+
def location_history
|
69
|
+
#warn "sess #{session.class}, #{session.object_id}"
|
70
|
+
session[:history] ||= [Card::Location.card_path('')]
|
71
|
+
if session[:history]
|
72
|
+
session[:history].shift if session[:history].size > 5
|
73
|
+
session[:history]
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
def save_location card
|
78
|
+
return if Env.ajax? || !Env.html? || !card.known? || (card.codename == 'signin')
|
79
|
+
discard_locations_for card
|
80
|
+
session[:previous_location] = Card::Location.card_path card.cardname.url_key
|
81
|
+
location_history.push previous_location
|
82
|
+
end
|
83
|
+
|
84
|
+
def previous_location
|
85
|
+
session[:previous_location] ||= location_history.last if location_history
|
86
|
+
end
|
87
|
+
|
88
|
+
def discard_locations_for(card)
|
89
|
+
# quoting necessary because cards have things like "+*" in the names..
|
90
|
+
session[:history] = location_history.reject do |loc|
|
91
|
+
if url_key = url_key_for_location(loc)
|
92
|
+
url_key.to_name.key == card.key
|
93
|
+
end
|
94
|
+
end.compact
|
95
|
+
session[:previous_location] = nil
|
96
|
+
end
|
97
|
+
|
98
|
+
def save_interrupted_action uri
|
99
|
+
session[:interrupted_action] = uri
|
100
|
+
end
|
101
|
+
|
102
|
+
def interrupted_action
|
103
|
+
session.delete :interrupted_action
|
104
|
+
end
|
105
|
+
|
106
|
+
def url_key_for_location(location)
|
107
|
+
location.match( /\/([^\/]*$)/ ) ? $1 : nil
|
108
|
+
end
|
109
|
+
end
|
110
|
+
|
111
|
+
extend LocationHistory
|
112
|
+
|
50
113
|
end
|
114
|
+
|
115
|
+
|
116
|
+
|
51
117
|
Env.reset
|
52
118
|
end
|
data/lib/card/format.rb
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
|
3
3
|
class Card
|
4
4
|
class Format
|
5
|
+
include Card::Location
|
5
6
|
|
6
7
|
DEPRECATED_VIEWS = { :view=>:open, :card=>:open, :line=>:closed, :bare=>:core, :naked=>:core }
|
7
8
|
INCLUSION_MODES = { :closed=>:closed, :closed_content=>:closed, :edit=>:edit,
|
@@ -202,10 +203,8 @@ class Card
|
|
202
203
|
@current_view = view = ok_view canonicalize_view( view ), args
|
203
204
|
args = default_render_args view, args
|
204
205
|
with_inclusion_mode view do
|
205
|
-
Card.
|
206
|
-
|
207
|
-
send "_view_#{ view }", args
|
208
|
-
end
|
206
|
+
Card::ViewCache.fetch(self, view, args) do
|
207
|
+
send "_view_#{ view }", args
|
209
208
|
end
|
210
209
|
end
|
211
210
|
end
|
@@ -519,40 +518,6 @@ class Card
|
|
519
518
|
options[:class] = [ options[:class], klass ].flatten.compact * ' '
|
520
519
|
end
|
521
520
|
|
522
|
-
module Location
|
523
|
-
#
|
524
|
-
# page_path takes a Card::Name, adds the format and query string to url_key (site-absolute)
|
525
|
-
# card_path makes a relative path site-absolute (if not already)
|
526
|
-
# card_url makes it a full url (if not already)
|
527
|
-
|
528
|
-
# TESTME
|
529
|
-
def page_path title, opts={}
|
530
|
-
Rails.logger.warn "Pass only Card::Name to page_path #{title.class}, #{title}" unless Card::Name===title
|
531
|
-
format = opts[:format] ? ".#{opts.delete(:format)}" : ''
|
532
|
-
action = opts[:action] ? "#{opts.delete(:action)}/" : ''
|
533
|
-
query = opts.present? ? "?#{opts.to_param}" : ''
|
534
|
-
card_path "#{action}#{title.to_name.url_key}#{format}#{query}"
|
535
|
-
end
|
536
|
-
|
537
|
-
def card_path rel_path
|
538
|
-
Rails.logger.warn "Pass only strings to card_path: #{rel_path.class}, #{rel_path}" unless String===rel_path
|
539
|
-
if rel_path =~ /^\//
|
540
|
-
rel_path
|
541
|
-
else
|
542
|
-
"#{ Wagn.config.relative_url_root }/#{ rel_path }"
|
543
|
-
end
|
544
|
-
end
|
545
|
-
|
546
|
-
def card_url rel
|
547
|
-
if rel =~ /^https?\:/
|
548
|
-
rel
|
549
|
-
else
|
550
|
-
"#{ Card::Env[:protocol] }#{ Card::Env[:host] }#{ card_path rel }"
|
551
|
-
end
|
552
|
-
end
|
553
|
-
|
554
|
-
end
|
555
|
-
include Location
|
556
521
|
|
557
522
|
def unique_id
|
558
523
|
"#{card.key}-#{Time.now.to_i}-#{rand(3)}"
|
data/lib/card/loader.rb
CHANGED
@@ -0,0 +1,38 @@
|
|
1
|
+
class Card
|
2
|
+
|
3
|
+
module Location
|
4
|
+
#
|
5
|
+
# page_path takes a Card::Name, adds the format and query string to url_key (site-absolute)
|
6
|
+
# card_path makes a relative path site-absolute (if not already)
|
7
|
+
# card_url makes it a full url (if not already)
|
8
|
+
|
9
|
+
# TESTME
|
10
|
+
def page_path title, opts={}
|
11
|
+
Rails.logger.warn "Pass only Card::Name to page_path #{title.class}, #{title}" unless Card::Name===title
|
12
|
+
format = opts[:format] ? ".#{opts.delete(:format)}" : ''
|
13
|
+
action = opts[:action] ? "#{opts.delete(:action)}/" : ''
|
14
|
+
query = opts.present? ? "?#{opts.to_param}" : ''
|
15
|
+
card_path "#{action}#{title.to_name.url_key}#{format}#{query}"
|
16
|
+
end
|
17
|
+
|
18
|
+
def card_path rel_path
|
19
|
+
Rails.logger.warn "Pass only strings to card_path: #{rel_path.class}, #{rel_path}" unless String===rel_path
|
20
|
+
if rel_path =~ /^\//
|
21
|
+
rel_path
|
22
|
+
else
|
23
|
+
"#{ Card.config.relative_url_root }/#{ rel_path }"
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
def card_url rel
|
28
|
+
if rel =~ /^https?\:/
|
29
|
+
rel
|
30
|
+
else
|
31
|
+
"#{ Card::Env[:protocol] }#{ Card::Env[:host] }#{ card_path rel }"
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
extend Location
|
36
|
+
end
|
37
|
+
|
38
|
+
end
|
data/lib/card/set.rb
CHANGED
data/lib/card/success.rb
CHANGED
@@ -1,7 +1,6 @@
|
|
1
1
|
class Card
|
2
2
|
class Success
|
3
|
-
include Card::
|
4
|
-
include Card::HtmlFormat::Location
|
3
|
+
include Card::Location
|
5
4
|
|
6
5
|
attr_accessor :params, :redirect, :id, :name, :card, :name_context
|
7
6
|
|
@@ -87,7 +86,7 @@ class Card
|
|
87
86
|
end
|
88
87
|
|
89
88
|
def target name_context=@name_context
|
90
|
-
card(name_context) || ( @target == :previous ? previous_location : @target ) || Card.fetch(name_context)
|
89
|
+
card(name_context) || ( @target == :previous ? Card::Env.previous_location : @target ) || Card.fetch(name_context)
|
91
90
|
end
|
92
91
|
|
93
92
|
def []= key, value
|
@@ -60,56 +60,8 @@ class Card
|
|
60
60
|
s.to_s.gsub(/&/, "&").gsub(/\'/, "'").gsub(/>/, ">").gsub(/</, "<")
|
61
61
|
end
|
62
62
|
|
63
|
-
#### -------------------- additional helpers ---------------- ###
|
64
|
-
|
65
|
-
# session history helpers: we keep a history stack so that in the case of
|
66
|
-
# card removal we can crawl back up to the last un-removed location
|
67
|
-
|
68
|
-
module Location
|
69
|
-
def location_history
|
70
|
-
#warn "sess #{session.class}, #{session.object_id}"
|
71
|
-
session[:history] ||= [card_path('')]
|
72
|
-
if session[:history]
|
73
|
-
session[:history].shift if session[:history].size > 5
|
74
|
-
session[:history]
|
75
|
-
end
|
76
|
-
end
|
77
|
-
|
78
|
-
def save_location
|
79
|
-
return if ajax? || !html? || !@card.known? || (@card.codename == 'signin')
|
80
|
-
discard_locations_for @card
|
81
|
-
@previous_location = card_path @card.cardname.url_key
|
82
|
-
location_history.push @previous_location
|
83
|
-
end
|
84
63
|
|
85
|
-
def previous_location
|
86
|
-
@previous_location ||= location_history.last if location_history
|
87
|
-
end
|
88
|
-
|
89
|
-
def discard_locations_for(card)
|
90
|
-
# quoting necessary because cards have things like "+*" in the names..
|
91
|
-
session[:history] = location_history.reject do |loc|
|
92
|
-
if url_key = url_key_for_location(loc)
|
93
|
-
url_key.to_name.key == card.key
|
94
|
-
end
|
95
|
-
end.compact
|
96
|
-
@previous_location = nil
|
97
|
-
end
|
98
64
|
|
99
|
-
def save_interrupted_action uri
|
100
|
-
uri = path(uri) if Hash === uri
|
101
|
-
session[:interrupted_action] = uri
|
102
|
-
end
|
103
|
-
|
104
|
-
def interrupted_action
|
105
|
-
session.delete :interrupted_action
|
106
|
-
end
|
107
|
-
|
108
|
-
def url_key_for_location(location)
|
109
|
-
location.match( /\/([^\/]*$)/ ) ? $1 : nil
|
110
|
-
end
|
111
|
-
end
|
112
|
-
include Location
|
113
65
|
|
114
66
|
|
115
67
|
def main?
|
@@ -1,14 +1,16 @@
|
|
1
1
|
|
2
2
|
module ClassMethods
|
3
|
-
def search spec
|
3
|
+
def search spec, &block
|
4
4
|
query = ::Card::Query.new(spec)
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
5
|
+
execute_query query, &block
|
6
|
+
end
|
7
|
+
|
8
|
+
def execute_query query
|
9
|
+
results = query.run
|
10
|
+
if block_given? and Array===results
|
11
|
+
results.each { |result| yield result }
|
11
12
|
end
|
13
|
+
results
|
12
14
|
end
|
13
15
|
|
14
16
|
def count_by_wql(spec)
|
@@ -0,0 +1,10 @@
|
|
1
|
+
event :discard_deleted_locations, :after=>:store, :on=>:delete do
|
2
|
+
Env.discard_locations_for self
|
3
|
+
if success.target == self
|
4
|
+
success.target = :previous
|
5
|
+
end
|
6
|
+
end
|
7
|
+
|
8
|
+
event :save_current_location, :before=>:show, :on=>:read do
|
9
|
+
Env.save_location self
|
10
|
+
end
|
@@ -91,6 +91,7 @@ end
|
|
91
91
|
|
92
92
|
|
93
93
|
def extend
|
94
|
+
|
94
95
|
run_callbacks :extend
|
95
96
|
run_callbacks :subsequent
|
96
97
|
rescue =>e
|
@@ -186,6 +187,6 @@ event :store_subcards, :after=>:store do
|
|
186
187
|
end
|
187
188
|
|
188
189
|
def success
|
189
|
-
Env
|
190
|
+
Env.success(cardname)
|
190
191
|
end
|
191
192
|
|
@@ -25,12 +25,12 @@ event :validate_delete, :before=>:approve, :on=>:delete do
|
|
25
25
|
if !codename.blank?
|
26
26
|
errors.add :delete, "#{name} is is a system card. (#{codename})"
|
27
27
|
end
|
28
|
-
|
28
|
+
|
29
29
|
undeletable_all_rules_tags = %w{ default style layout create read update delete }
|
30
30
|
if junction? and l=left and l.codename == 'all' and undeletable_all_rules_tags.member? right.codename
|
31
31
|
errors.add :delete, "#{name} is an indestructible rule"
|
32
32
|
end
|
33
|
-
|
33
|
+
|
34
34
|
if account && Card::Act.find_by_actor_id( self.id )
|
35
35
|
errors.add :delete, "Edits have been made with #{name}'s user account.\nDeleting this card would mess up our history."
|
36
36
|
end
|
@@ -48,3 +48,4 @@ event :validate_delete_children, :after=>:approve, :on=>:delete do
|
|
48
48
|
end
|
49
49
|
end
|
50
50
|
end
|
51
|
+
|
@@ -7,6 +7,7 @@ module ClassMethods
|
|
7
7
|
Card::Action.delete_cardless
|
8
8
|
Card::Reference.repair_missing_referees
|
9
9
|
Card::Reference.delete_missing_referers
|
10
|
+
Card.delete_tmp_files_of_cached_uploads
|
10
11
|
end
|
11
12
|
|
12
13
|
def delete_trashed_files #deletes any file not associated with a real card.
|
@@ -22,6 +23,17 @@ module ClassMethods
|
|
22
23
|
end
|
23
24
|
end
|
24
25
|
|
26
|
+
def delete_tmp_files_of_cached_uploads
|
27
|
+
actions = Card::Action.find_by_sql "SELECT * FROM card_actions
|
28
|
+
INNER JOIN cards ON card_actions.card_id = cards.id
|
29
|
+
WHERE cards.type_id IN (#{Card::FileID}, #{Card::ImageID}) AND card_actions.draft = true"
|
30
|
+
actions.each do |action|
|
31
|
+
if older_than_five_days? action.created_at && card = action.card # we don't want to delete uploads in progress
|
32
|
+
card.delete_files_for_action action
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
25
37
|
def merge_list attribs, opts={}
|
26
38
|
unmerged = []
|
27
39
|
attribs.each do |row|
|