wagn 1.13.0.pre1 → 1.13.0.pre2
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/app/controllers/card_controller.rb +3 -3
- data/db/migrate_cards/20140307231621_user_data_to_cards.rb +5 -1
- data/lib/card.rb +5 -7
- data/lib/card/chunk.rb +1 -0
- data/lib/card/codename.rb +48 -31
- data/lib/card/env.rb +0 -1
- data/lib/card/exceptions.rb +3 -3
- data/lib/card/format.rb +89 -166
- data/lib/card/generators/set/USAGE +1 -1
- data/lib/card/loader.rb +1 -1
- data/lib/card/set.rb +196 -112
- data/lib/card/set_pattern.rb +37 -71
- data/lib/wagn/cache.rb +8 -7
- data/lib/wagn/commands.rb +1 -1
- data/lib/wagn/config/environments/development.rb +1 -1
- data/lib/wagn/config/initializers/paperclip.rb +1 -0
- data/lib/wagn/generators/wagn/templates/Gemfile +59 -55
- data/lib/wagn/location.rb +2 -2
- data/mods/core/formats/html_format.rb +2 -6
- data/mods/core/formats/text_format.rb +1 -1
- data/mods/core/set_patterns/01_all.rb +0 -5
- data/mods/core/set_patterns/02_all_plus.rb +1 -3
- data/mods/core/set_patterns/07_type_plus_right.rb +0 -1
- data/mods/core/sets/all/active_card.rb +1 -1
- data/mods/core/sets/all/name.rb +3 -2
- data/mods/core/sets/all/pattern.rb +9 -23
- data/mods/core/sets/all/phases.rb +27 -13
- data/mods/core/sets/all/rules.rb +3 -3
- data/mods/core/sets/all/templating.rb +5 -2
- data/mods/core/sets/all/tracked_attributes.rb +2 -1
- data/mods/core/sets/right/structure.rb +13 -0
- data/mods/{standard → core}/sets/type/plain_text.rb +0 -0
- data/mods/standard/formats/email_html_format.rb +1 -1
- data/mods/standard/lib/card/machine.rb +16 -12
- data/mods/standard/lib/card/machine_input.rb +1 -1
- data/mods/standard/sets/all/attach.rb +1 -1
- data/mods/standard/sets/all/base.rb +92 -94
- data/mods/standard/sets/all/follow.rb +1 -1
- data/mods/standard/sets/all/rich_html.rb +5 -3
- data/mods/standard/sets/all/rss.rb +12 -5
- data/mods/standard/sets/right/account.rb +1 -1
- data/mods/standard/sets/right/add_help.rb +3 -1
- data/mods/standard/sets/right/comment.rb +92 -3
- data/mods/standard/sets/right/create.rb +2 -87
- data/mods/standard/sets/right/default.rb +3 -2
- data/mods/standard/sets/right/delete.rb +2 -5
- data/mods/standard/sets/right/help.rb +3 -1
- data/mods/standard/sets/right/machine_output.rb +9 -7
- data/mods/standard/sets/right/read.rb +2 -5
- data/mods/standard/sets/right/style.rb +3 -2
- data/mods/standard/sets/right/update.rb +2 -5
- data/mods/standard/sets/rstar/rules.rb +0 -2
- data/mods/standard/sets/self/head.rb +2 -3
- data/mods/standard/sets/self/navbox.rb +0 -7
- data/mods/standard/sets/self/recent.rb +2 -2
- data/mods/standard/sets/self/search.rb +10 -3
- data/mods/standard/sets/self/signin.rb +3 -3
- data/mods/standard/sets/type/cardtype.rb +2 -2
- data/mods/standard/sets/type/coffee_script.rb +4 -4
- data/mods/standard/sets/type/css.rb +12 -4
- data/mods/standard/sets/type/image.rb +19 -19
- data/mods/standard/sets/type/java_script.rb +1 -1
- data/mods/standard/sets/type/layout_type.rb +3 -2
- data/mods/standard/sets/type/pointer.rb +3 -2
- data/mods/standard/sets/type/scss.rb +6 -34
- data/mods/standard/sets/type/search_type.rb +22 -16
- data/mods/standard/sets/type/set.rb +2 -2
- data/mods/standard/sets/type/setting.rb +2 -2
- data/mods/standard/sets/type/skin.rb +4 -18
- data/spec/controllers/card_controller_spec.rb +2 -2
- data/spec/lib/card/flexmail_spec.rb +1 -0
- data/spec/lib/card/format_spec.rb +9 -9
- data/spec/lib/card/loader_spec.rb +1 -2
- data/spec/lib/card/name_spec.rb +7 -1
- data/spec/lib/card/set_pattern_spec.rb +5 -5
- data/spec/mods/core/sets/all/pattern_spec.rb +0 -9
- data/spec/mods/core/sets/all/phases_spec.rb +2 -1
- data/spec/mods/standard/lib/machine_input_spec.rb +20 -4
- data/spec/mods/standard/lib/machine_spec.rb +64 -14
- data/spec/mods/standard/sets/right/machine_output_spec.rb +2 -17
- data/spec/mods/standard/sets/right/script_spec.rb +9 -5
- data/spec/mods/standard/sets/right/style_spec.rb +11 -5
- data/spec/mods/standard/sets/type/coffeescript_spec.rb +5 -7
- data/spec/mods/standard/sets/type/css_spec.rb +3 -4
- data/spec/mods/standard/sets/type/javascript_spec.rb +3 -5
- data/spec/mods/standard/sets/type/scss_spec.rb +4 -7
- data/spec/mods/standard/sets/type/skin_spec.rb +29 -8
- metadata +5 -4
- data/mods/standard/sets/right/structure.rb +0 -12
File without changes
|
@@ -62,26 +62,27 @@ class Card
|
|
62
62
|
# collect all item cards as input
|
63
63
|
items = [self]
|
64
64
|
new_input = []
|
65
|
-
already_extended =
|
65
|
+
already_extended = {} # avoid loops
|
66
|
+
loop_limit = 5
|
66
67
|
while items.size > 0
|
67
68
|
item = items.shift
|
68
|
-
if item.trash or already_extended.
|
69
|
+
if item.trash or ( already_extended[item.id] and already_extended[item.id] > loop_limit)
|
69
70
|
next
|
70
71
|
elsif item.item_cards == [item] # no pointer card
|
71
72
|
new_input << item
|
72
|
-
already_extended << item
|
73
73
|
else
|
74
74
|
items.insert(0, item.item_cards)
|
75
75
|
items.flatten!
|
76
|
-
|
76
|
+
new_input << item if item != self
|
77
|
+
already_extended[item] = already_extended[item] ? already_extended[item] + 1 : 1
|
77
78
|
end
|
78
79
|
end
|
79
80
|
new_input
|
80
81
|
end
|
82
|
+
|
81
83
|
host_class.prepare_machine_input {}
|
82
84
|
host_class.machine_engine { |input| input }
|
83
|
-
host_class.store_machine_output do |output|
|
84
|
-
tmp_path =
|
85
|
+
host_class.store_machine_output do |output|
|
85
86
|
file = Tempfile.new [ id, ".#{host_class.output_config[:filetype]}" ]
|
86
87
|
file.write output
|
87
88
|
Card::Auth.as_bot do
|
@@ -99,7 +100,7 @@ class Card
|
|
99
100
|
end
|
100
101
|
end
|
101
102
|
|
102
|
-
host_class.event "update_machine_output_#{host_class.name.gsub(':','_')}".to_sym, :after => :
|
103
|
+
host_class.event "update_machine_output_#{host_class.name.gsub(':','_')}".to_sym, :after => :store_subcards, :on => :save do
|
103
104
|
update_machine_output
|
104
105
|
end
|
105
106
|
end
|
@@ -108,10 +109,12 @@ class Card
|
|
108
109
|
def run_machine joint="\n"
|
109
110
|
before_engine
|
110
111
|
output = input_item_cards.map do |input|
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
112
|
+
unless input.kind_of? Card::Set::Type::Pointer
|
113
|
+
if input.respond_to? :machine_input
|
114
|
+
engine( input.machine_input )
|
115
|
+
else
|
116
|
+
engine( input.format._render_raw )
|
117
|
+
end
|
115
118
|
end
|
116
119
|
end.select(&:present?).join( joint )
|
117
120
|
after_engine output
|
@@ -125,6 +128,7 @@ class Card
|
|
125
128
|
def update_input_card
|
126
129
|
Card::Auth.as_bot do
|
127
130
|
machine_input_card.items = engine_input
|
131
|
+
#machine_input_card.save
|
128
132
|
end
|
129
133
|
end
|
130
134
|
|
@@ -134,7 +138,7 @@ class Card
|
|
134
138
|
|
135
139
|
def machine_output_url
|
136
140
|
ensure_machine_output
|
137
|
-
machine_output_card.attach.url
|
141
|
+
machine_output_card.attach.url #(:default, :timestamp => false) # to get rid of additional number in url
|
138
142
|
end
|
139
143
|
|
140
144
|
def machine_output_path
|
@@ -18,7 +18,7 @@ class Card
|
|
18
18
|
host_class.machine_input do
|
19
19
|
format._render_raw
|
20
20
|
end
|
21
|
-
host_class.event "after_machine_input_updated_#{host_class.name.gsub(':','_')}".to_sym, :after=>:
|
21
|
+
host_class.event "after_machine_input_updated_#{host_class.name.gsub(':','_')}".to_sym, :after=>:extend, :on => :save do
|
22
22
|
machines = Card.search( {:right_plus => [{:codename => "machine_input"}, {:link_to => name}]}.merge(host_class.machines_wql) )
|
23
23
|
machines.each do |item|
|
24
24
|
item.update_machine_output if item.kind_of? Machine
|
@@ -47,7 +47,7 @@ def attachment_format(ext)
|
|
47
47
|
return nil unless exts
|
48
48
|
return ext if exts.find {|mt| mt.extensions.member? ext }
|
49
49
|
return exts[0].extensions[0]
|
50
|
-
rescue
|
50
|
+
rescue => e
|
51
51
|
Rails.logger.info "attachment_format issue: #{e.message}"
|
52
52
|
nil
|
53
53
|
end
|
@@ -4,141 +4,139 @@ format do
|
|
4
4
|
view ||= :core
|
5
5
|
render view, args
|
6
6
|
end
|
7
|
-
end
|
8
7
|
|
9
|
-
# NAME VIEWS
|
8
|
+
# NAME VIEWS
|
10
9
|
|
11
|
-
view :name, :perms=>:none do |args| card.name end
|
12
|
-
view :codename, :perms=>:none do |args| card.codename.to_s end
|
13
|
-
view :key, :perms=>:none do |args| card.key end
|
14
|
-
view :id, :perms=>:none do |args| card.id end
|
15
|
-
view :type, :perms=>:none do |args| card.type_name end
|
16
|
-
view :linkname, :perms=>:none do |args| card.cardname.url_key end
|
17
|
-
view :url, :perms=>:none do |args| wagn_url _render_linkname end
|
18
|
-
|
19
|
-
view :link, :perms=>:none do |args|
|
20
|
-
|
21
|
-
end
|
10
|
+
view :name, :perms=>:none do |args| card.name end
|
11
|
+
view :codename, :perms=>:none do |args| card.codename.to_s end
|
12
|
+
view :key, :perms=>:none do |args| card.key end
|
13
|
+
view :id, :perms=>:none do |args| card.id end
|
14
|
+
view :type, :perms=>:none do |args| card.type_name end
|
15
|
+
view :linkname, :perms=>:none do |args| card.cardname.url_key end
|
16
|
+
view :url, :perms=>:none do |args| wagn_url _render_linkname end
|
17
|
+
|
18
|
+
view :link, :perms=>:none do |args|
|
19
|
+
card_link card.name, showname( args[:title] ), card.known?, args[:type]
|
20
|
+
end
|
22
21
|
|
23
22
|
|
24
|
-
# DATE VIEWS
|
23
|
+
# DATE VIEWS
|
25
24
|
|
26
|
-
view :created_at do |args| time_ago_in_words card.created_at end
|
27
|
-
view :updated_at do |args| time_ago_in_words card.updated_at end
|
25
|
+
view :created_at do |args| time_ago_in_words card.created_at end
|
26
|
+
view :updated_at do |args| time_ago_in_words card.updated_at end
|
28
27
|
|
29
28
|
|
30
|
-
# CONTENT VIEWS
|
29
|
+
# CONTENT VIEWS
|
31
30
|
|
32
|
-
view :raw do |args|
|
33
|
-
|
34
|
-
|
35
|
-
end
|
31
|
+
view :raw do |args|
|
32
|
+
scard = args[:structure] ? Card[ args[:structure] ] : card
|
33
|
+
scard ? scard.raw_content : _render_blank
|
34
|
+
end
|
36
35
|
|
37
|
-
view :core do |args|
|
38
|
-
|
39
|
-
end
|
36
|
+
view :core do |args|
|
37
|
+
process_content _render_raw(args)
|
38
|
+
end
|
40
39
|
|
41
|
-
view :content do |args|
|
42
|
-
|
43
|
-
end
|
40
|
+
view :content do |args|
|
41
|
+
_render_core args
|
42
|
+
end
|
44
43
|
|
45
|
-
view :open_content do |args|
|
46
|
-
|
47
|
-
end
|
44
|
+
view :open_content do |args|
|
45
|
+
_render_core args
|
46
|
+
end
|
48
47
|
|
49
|
-
view :closed_content do |args|
|
50
|
-
|
51
|
-
end
|
48
|
+
view :closed_content do |args|
|
49
|
+
Card::Content.truncatewords_with_closing_tags _render_core(args) #{ yield }
|
50
|
+
end
|
52
51
|
|
53
52
|
|
54
|
-
# note: content and open_content may look like they should be aliased to core, but it's important that they render
|
55
|
-
# core explicitly so that core view overrides work. the titled and labeled views below, however, are not intended
|
56
|
-
# for frequent override, so this shortcut is fine.
|
53
|
+
# note: content and open_content may look like they should be aliased to core, but it's important that they render
|
54
|
+
# core explicitly so that core view overrides work. the titled and labeled views below, however, are not intended
|
55
|
+
# for frequent override, so this shortcut is fine.
|
57
56
|
|
58
57
|
|
59
|
-
# NAME + CONTENT VIEWS
|
58
|
+
# NAME + CONTENT VIEWS
|
60
59
|
|
61
|
-
view :titled do |args|
|
62
|
-
|
63
|
-
end
|
64
|
-
view :open, :titled
|
60
|
+
view :titled do |args|
|
61
|
+
"#{ card.name }\n\n#{ _render_core args }"
|
62
|
+
end
|
63
|
+
view :open, :titled
|
65
64
|
|
66
|
-
view :labeled do |args|
|
67
|
-
|
68
|
-
end
|
69
|
-
view :closed, :labeled
|
65
|
+
view :labeled do |args|
|
66
|
+
"#{ card.name }: #{ _render_closed_content args }"
|
67
|
+
end
|
68
|
+
view :closed, :labeled
|
70
69
|
|
71
70
|
|
72
|
-
# SPECIAL VIEWS
|
71
|
+
# SPECIAL VIEWS
|
73
72
|
|
74
|
-
view :array do |args|
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
end
|
73
|
+
view :array do |args|
|
74
|
+
card.item_cards(:limit=>0).map do |item_card|
|
75
|
+
subformat(item_card)._render_core(args)
|
76
|
+
end.inspect
|
77
|
+
end
|
79
78
|
|
80
79
|
|
81
80
|
|
82
|
-
# ERROR VIEWS
|
81
|
+
# ERROR VIEWS
|
83
82
|
|
84
83
|
|
85
|
-
view :blank, :perms=>:none do |args| '' end
|
86
|
-
view :closed_missing, :perms=>:none do |args| '' end
|
87
|
-
view :missing, :perms=>:none do |args| '' end
|
84
|
+
view :blank, :perms=>:none do |args| '' end
|
85
|
+
view :closed_missing, :perms=>:none do |args| '' end
|
86
|
+
view :missing, :perms=>:none do |args| '' end
|
88
87
|
|
89
|
-
view :not_found, :perms=>:none, :error_code=>404 do |args|
|
90
|
-
|
91
|
-
end
|
88
|
+
view :not_found, :perms=>:none, :error_code=>404 do |args|
|
89
|
+
%{ Could not find #{card.name.present? ? %{"#{card.name}"} : 'the card requested'}. }
|
90
|
+
end
|
92
91
|
|
93
|
-
view :server_error, :perms=>:none, :error_code=>500 do |args|
|
94
|
-
|
95
|
-
|
96
|
-
end
|
92
|
+
view :server_error, :perms=>:none, :error_code=>500 do |args|
|
93
|
+
%{ Wagn Hitch! Server Error. Yuck, sorry about that.\n}+
|
94
|
+
%{ To tell us more and follow the fix, add a support ticket at http://wagn.org/new/Support_Ticket }
|
95
|
+
end
|
97
96
|
|
98
|
-
view :denial, :perms=>:none, :error_code=>403 do |args|
|
99
|
-
|
100
|
-
end
|
97
|
+
view :denial, :perms=>:none, :error_code=>403 do |args|
|
98
|
+
focal? ? 'Permission Denied' : ''
|
99
|
+
end
|
101
100
|
|
102
|
-
view :bad_address, :perms=>:none, :error_code=>404 do |args|
|
103
|
-
|
104
|
-
end
|
101
|
+
view :bad_address, :perms=>:none, :error_code=>404 do |args|
|
102
|
+
%{ 404: Bad Address }
|
103
|
+
end
|
105
104
|
|
106
|
-
view :too_deep, :perms=>:none do |args|
|
107
|
-
|
108
|
-
end
|
105
|
+
view :too_deep, :perms=>:none do |args|
|
106
|
+
%{ Man, you're too deep. (Too many levels of inclusions at a time) }
|
107
|
+
end
|
109
108
|
|
110
|
-
view :too_slow, :perms=>:none do |args|
|
111
|
-
|
112
|
-
end
|
109
|
+
view :too_slow, :perms=>:none do |args|
|
110
|
+
%{ Timed out! #{ showname } took too long to load. }
|
111
|
+
end
|
113
112
|
|
114
113
|
|
115
|
-
#none of the below belongs here!!
|
114
|
+
#none of the below belongs here!!
|
116
115
|
|
117
116
|
|
118
|
-
view :template_rule, :tags=>:unknown_ok do |args|
|
119
|
-
|
117
|
+
view :template_rule, :tags=>:unknown_ok do |args|
|
118
|
+
#FIXME - relativity should be handled in smartname
|
120
119
|
|
121
|
-
|
122
|
-
|
123
|
-
|
120
|
+
name = args[:inc_name] or return ''
|
121
|
+
regexp = /\b_(left|right|whole|self|user|main|\d+|L*R?)\b/
|
122
|
+
absolute = name !~ regexp && name !~ /^\+/
|
124
123
|
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
else
|
129
|
-
set_name = if absolute # find the most appropriate set to use as prototype for inclusion
|
130
|
-
"#{name}+#{Card[:self].name}"
|
124
|
+
tname = name.gsub regexp, ''
|
125
|
+
if tname !~ /^\+/ and !absolute
|
126
|
+
"{{#{args[:inc_syntax]}}}"
|
131
127
|
else
|
132
|
-
|
133
|
-
|
134
|
-
"#{tmpl_set_name.left_name}#{name}+#{Card[:type_plus_right].name}" # *type plus right
|
128
|
+
set_name = if absolute # find the most appropriate set to use as prototype for inclusion
|
129
|
+
"#{name}+#{Card[:self].name}"
|
135
130
|
else
|
136
|
-
|
131
|
+
tmpl_set_name = parent.card.cardname.trunk_name
|
132
|
+
if tmpl_set_class_name = tmpl_set_name.tag_name and Card[tmpl_set_class_name].codename == 'type'
|
133
|
+
"#{tmpl_set_name.left_name}#{name}+#{Card[:type_plus_right].name}" # *type plus right
|
134
|
+
else
|
135
|
+
"#{tname.gsub /^\+/,''}+#{Card[:right].name}" # *right
|
136
|
+
end
|
137
137
|
end
|
138
|
-
end
|
139
138
|
|
140
|
-
|
139
|
+
subformat( Card.fetch(set_name) ).render_template_link args
|
140
|
+
end
|
141
141
|
end
|
142
142
|
end
|
143
|
-
|
144
|
-
|
@@ -64,7 +64,7 @@ event :notify_followers, :after=>:extend do
|
|
64
64
|
Mailer.change_notice( watcher, self.left, 'updated', watched.to_s, [[name, action]], self ).send_if :deliver
|
65
65
|
end
|
66
66
|
end
|
67
|
-
rescue
|
67
|
+
rescue =>e #this error handling should apply to all extend callback exceptions
|
68
68
|
Airbrake.notify e if Airbrake.configuration.api_key
|
69
69
|
Rails.logger.info "\nController exception: #{e.message}"
|
70
70
|
Rails.logger.debug "BT: #{e.backtrace*"\n"}"
|
@@ -9,7 +9,7 @@ format :html do
|
|
9
9
|
else
|
10
10
|
args.merge! :view=>view if view
|
11
11
|
@main_opts = args
|
12
|
-
self.
|
12
|
+
self.render :layout
|
13
13
|
end
|
14
14
|
end
|
15
15
|
|
@@ -389,7 +389,8 @@ format :html do
|
|
389
389
|
rcard = Card.fetch rcardname, :new=>{}
|
390
390
|
|
391
391
|
nest_args = {
|
392
|
-
:view => ( rparams[:view] || :
|
392
|
+
:view => ( rparams[:view] || :open ),
|
393
|
+
:optional_toggle => :hide,
|
393
394
|
:optional_help => :show,
|
394
395
|
:optional_menu => :show
|
395
396
|
}
|
@@ -410,7 +411,8 @@ format :html do
|
|
410
411
|
|
411
412
|
if help_card = card.rule_card( *setting ) and help_card.ok? :read
|
412
413
|
with_inclusion_mode :normal do
|
413
|
-
|
414
|
+
process_content _render_raw( args.merge :structure=>help_card.name )
|
415
|
+
# render help card with current card's format so current card's context is used in help card inclusions
|
414
416
|
end
|
415
417
|
end
|
416
418
|
end
|
@@ -1,5 +1,12 @@
|
|
1
1
|
|
2
2
|
format :rss do
|
3
|
+
|
4
|
+
attr_accessor :xml
|
5
|
+
|
6
|
+
def initialize card, args
|
7
|
+
super
|
8
|
+
@xml = @parent.xml if @parent
|
9
|
+
end
|
3
10
|
|
4
11
|
def show view, args
|
5
12
|
@xml = Builder::XmlMarkup.new
|
@@ -19,7 +26,7 @@ format :rss do
|
|
19
26
|
render_feed_item_list
|
20
27
|
end
|
21
28
|
end
|
22
|
-
rescue
|
29
|
+
rescue =>e
|
23
30
|
@xml.error "\n\nERROR rendering RSS: #{e.inspect}\n\n #{e.backtrace}"
|
24
31
|
end
|
25
32
|
end
|
@@ -57,9 +64,9 @@ format :rss do
|
|
57
64
|
view :menu do |args| '' end
|
58
65
|
|
59
66
|
|
60
|
-
view :open, :titled
|
61
|
-
view :content, :core
|
62
|
-
view :open_content, :core
|
63
|
-
view :closed, :link
|
67
|
+
view :open, { :view=>:titled, :mod=>All::Base::Format }
|
68
|
+
view :content, { :view=>:core, :mod=>All::Base::Format }
|
69
|
+
view :open_content, { :view=>:core, :mod=>All::Base::Format }
|
70
|
+
view :closed, { :view=>:link, :mod=>All::Base::Format }
|
64
71
|
|
65
72
|
end
|