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.
Files changed (91) hide show
  1. checksums.yaml +4 -4
  2. data/VERSION +1 -1
  3. data/app/controllers/card_controller.rb +3 -3
  4. data/db/migrate_cards/20140307231621_user_data_to_cards.rb +5 -1
  5. data/lib/card.rb +5 -7
  6. data/lib/card/chunk.rb +1 -0
  7. data/lib/card/codename.rb +48 -31
  8. data/lib/card/env.rb +0 -1
  9. data/lib/card/exceptions.rb +3 -3
  10. data/lib/card/format.rb +89 -166
  11. data/lib/card/generators/set/USAGE +1 -1
  12. data/lib/card/loader.rb +1 -1
  13. data/lib/card/set.rb +196 -112
  14. data/lib/card/set_pattern.rb +37 -71
  15. data/lib/wagn/cache.rb +8 -7
  16. data/lib/wagn/commands.rb +1 -1
  17. data/lib/wagn/config/environments/development.rb +1 -1
  18. data/lib/wagn/config/initializers/paperclip.rb +1 -0
  19. data/lib/wagn/generators/wagn/templates/Gemfile +59 -55
  20. data/lib/wagn/location.rb +2 -2
  21. data/mods/core/formats/html_format.rb +2 -6
  22. data/mods/core/formats/text_format.rb +1 -1
  23. data/mods/core/set_patterns/01_all.rb +0 -5
  24. data/mods/core/set_patterns/02_all_plus.rb +1 -3
  25. data/mods/core/set_patterns/07_type_plus_right.rb +0 -1
  26. data/mods/core/sets/all/active_card.rb +1 -1
  27. data/mods/core/sets/all/name.rb +3 -2
  28. data/mods/core/sets/all/pattern.rb +9 -23
  29. data/mods/core/sets/all/phases.rb +27 -13
  30. data/mods/core/sets/all/rules.rb +3 -3
  31. data/mods/core/sets/all/templating.rb +5 -2
  32. data/mods/core/sets/all/tracked_attributes.rb +2 -1
  33. data/mods/core/sets/right/structure.rb +13 -0
  34. data/mods/{standard → core}/sets/type/plain_text.rb +0 -0
  35. data/mods/standard/formats/email_html_format.rb +1 -1
  36. data/mods/standard/lib/card/machine.rb +16 -12
  37. data/mods/standard/lib/card/machine_input.rb +1 -1
  38. data/mods/standard/sets/all/attach.rb +1 -1
  39. data/mods/standard/sets/all/base.rb +92 -94
  40. data/mods/standard/sets/all/follow.rb +1 -1
  41. data/mods/standard/sets/all/rich_html.rb +5 -3
  42. data/mods/standard/sets/all/rss.rb +12 -5
  43. data/mods/standard/sets/right/account.rb +1 -1
  44. data/mods/standard/sets/right/add_help.rb +3 -1
  45. data/mods/standard/sets/right/comment.rb +92 -3
  46. data/mods/standard/sets/right/create.rb +2 -87
  47. data/mods/standard/sets/right/default.rb +3 -2
  48. data/mods/standard/sets/right/delete.rb +2 -5
  49. data/mods/standard/sets/right/help.rb +3 -1
  50. data/mods/standard/sets/right/machine_output.rb +9 -7
  51. data/mods/standard/sets/right/read.rb +2 -5
  52. data/mods/standard/sets/right/style.rb +3 -2
  53. data/mods/standard/sets/right/update.rb +2 -5
  54. data/mods/standard/sets/rstar/rules.rb +0 -2
  55. data/mods/standard/sets/self/head.rb +2 -3
  56. data/mods/standard/sets/self/navbox.rb +0 -7
  57. data/mods/standard/sets/self/recent.rb +2 -2
  58. data/mods/standard/sets/self/search.rb +10 -3
  59. data/mods/standard/sets/self/signin.rb +3 -3
  60. data/mods/standard/sets/type/cardtype.rb +2 -2
  61. data/mods/standard/sets/type/coffee_script.rb +4 -4
  62. data/mods/standard/sets/type/css.rb +12 -4
  63. data/mods/standard/sets/type/image.rb +19 -19
  64. data/mods/standard/sets/type/java_script.rb +1 -1
  65. data/mods/standard/sets/type/layout_type.rb +3 -2
  66. data/mods/standard/sets/type/pointer.rb +3 -2
  67. data/mods/standard/sets/type/scss.rb +6 -34
  68. data/mods/standard/sets/type/search_type.rb +22 -16
  69. data/mods/standard/sets/type/set.rb +2 -2
  70. data/mods/standard/sets/type/setting.rb +2 -2
  71. data/mods/standard/sets/type/skin.rb +4 -18
  72. data/spec/controllers/card_controller_spec.rb +2 -2
  73. data/spec/lib/card/flexmail_spec.rb +1 -0
  74. data/spec/lib/card/format_spec.rb +9 -9
  75. data/spec/lib/card/loader_spec.rb +1 -2
  76. data/spec/lib/card/name_spec.rb +7 -1
  77. data/spec/lib/card/set_pattern_spec.rb +5 -5
  78. data/spec/mods/core/sets/all/pattern_spec.rb +0 -9
  79. data/spec/mods/core/sets/all/phases_spec.rb +2 -1
  80. data/spec/mods/standard/lib/machine_input_spec.rb +20 -4
  81. data/spec/mods/standard/lib/machine_spec.rb +64 -14
  82. data/spec/mods/standard/sets/right/machine_output_spec.rb +2 -17
  83. data/spec/mods/standard/sets/right/script_spec.rb +9 -5
  84. data/spec/mods/standard/sets/right/style_spec.rb +11 -5
  85. data/spec/mods/standard/sets/type/coffeescript_spec.rb +5 -7
  86. data/spec/mods/standard/sets/type/css_spec.rb +3 -4
  87. data/spec/mods/standard/sets/type/javascript_spec.rb +3 -5
  88. data/spec/mods/standard/sets/type/scss_spec.rb +4 -7
  89. data/spec/mods/standard/sets/type/skin_spec.rb +29 -8
  90. metadata +5 -4
  91. data/mods/standard/sets/right/structure.rb +0 -12
@@ -0,0 +1,13 @@
1
+
2
+ format :html do
3
+ view :core do |args|
4
+ with_inclusion_mode :template do
5
+ super args
6
+ end
7
+ end
8
+
9
+ view :closed_content do |args|
10
+ "#{_render_type} : #{_render_raw}"
11
+ end
12
+
13
+ end
File without changes
@@ -1,7 +1,7 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
 
3
3
  class Card::EmailHtmlFormat < Card::HtmlFormat
4
- @@aliases[:email] = :email_html
4
+ @@aliases['email'] = 'email_html'
5
5
 
6
6
  def internal_url relative_path
7
7
  wagn_url relative_path
@@ -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 = [] # avoid loops
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.include? item
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
- already_extended << item
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 => :store, :on => :save do
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
- if input.respond_to? :machine_input
112
- engine( input.machine_input )
113
- else
114
- engine( input.format._render_raw )
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=>:store_subcards, :on => :save do
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 Exception => e
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
- card_link card.name, showname( args[:title] ), card.known?, args[:type]
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
- scard = args[:structure] ? Card[ args[:structure] ] : card
34
- scard ? scard.raw_content : _render_blank
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
- process_content _render_raw(args)
39
- end
36
+ view :core do |args|
37
+ process_content _render_raw(args)
38
+ end
40
39
 
41
- view :content do |args|
42
- _render_core args
43
- end
40
+ view :content do |args|
41
+ _render_core args
42
+ end
44
43
 
45
- view :open_content do |args|
46
- _render_core args
47
- end
44
+ view :open_content do |args|
45
+ _render_core args
46
+ end
48
47
 
49
- view :closed_content do |args|
50
- Card::Content.truncatewords_with_closing_tags _render_core(args) #{ yield }
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
- "#{ card.name }\n\n#{ _render_core args }"
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
- "#{ card.name }: #{ _render_closed_content args }"
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
- card.item_cards(:limit=>0).map do |item_card|
76
- subformat(item_card)._render_core(args)
77
- end.inspect
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
- %{ Could not find #{card.name.present? ? %{"#{card.name}"} : 'the card requested'}. }
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
- %{ Wagn Hitch! Server Error. Yuck, sorry about that.\n}+
95
- %{ To tell us more and follow the fix, add a support ticket at http://wagn.org/new/Support_Ticket }
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
- focal? ? 'Permission Denied' : ''
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
- %{ 404: Bad Address }
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
- %{ Man, you're too deep. (Too many levels of inclusions at a time) }
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
- %{ Timed out! #{ showname } took too long to load. }
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
- #FIXME - relativity should be handled in smartname
117
+ view :template_rule, :tags=>:unknown_ok do |args|
118
+ #FIXME - relativity should be handled in smartname
120
119
 
121
- name = args[:inc_name]
122
- regexp = /\b_(left|right|whole|self|user|main|\d+|L*R?)\b/
123
- absolute = name !~ regexp && name !~ /^\+/
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
- tname = name.gsub regexp, ''
126
- if tname !~ /^\+/ and !absolute
127
- "{{#{args[:inc_syntax]}}}"
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
- tmpl_set_name = parent.card.cardname.trunk_name
133
- if tmpl_set_class_name = tmpl_set_name.tag_name and Card[tmpl_set_class_name].codename == 'type'
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
- "#{tname.gsub /^\+/,''}+#{Card[:right].name}" # *right
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
- subformat( Card.fetch(set_name) ).render_template_link args
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 Exception=>e #this error handling should apply to all extend callback exceptions
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.render_layout
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] || :titled ),
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
- _final_core args.merge( :structure=>help_card.name )
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 Exception=>e
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
@@ -23,7 +23,7 @@ format :html do
23
23
 
24
24
  view :edit do |args|
25
25
  args[:structure] = true
26
- _final_edit args
26
+ super args
27
27
  end
28
28
  end
29
29
 
@@ -1 +1,3 @@
1
- view :core, :right=>:structure
1
+ format :html do
2
+ include Structure::HtmlFormat
3
+ end