wagn 1.12.9 → 1.12.10

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +15 -0
  2. data/Gemfile +10 -22
  3. data/VERSION +1 -1
  4. data/app/assets/javascripts/wagn.js.coffee +3 -3
  5. data/app/controllers/account_controller.rb +23 -29
  6. data/app/controllers/admin_controller.rb +14 -20
  7. data/app/controllers/card_controller.rb +1 -39
  8. data/app/controllers/wagn_controller.rb +46 -3
  9. data/app/mailers/mailer.rb +11 -10
  10. data/config/environments/development.rb +3 -0
  11. data/{app/models → lib}/card.rb +0 -0
  12. data/lib/card/content.rb +2 -2
  13. data/lib/card/format.rb +26 -5
  14. data/{app/models → lib}/card/reference.rb +0 -0
  15. data/{app/models → lib}/card/revision.rb +0 -0
  16. data/lib/generators/wagn/templates/Gemfile +2 -0
  17. data/lib/tasks/wagn.rake +6 -7
  18. data/lib/wagn/all.rb +11 -2
  19. data/lib/wagn/application.rb +1 -0
  20. data/mods/core/formats/html_format.rb +74 -29
  21. data/mods/core/sets/all/content.rb +5 -1
  22. data/mods/core/sets/all/permissions.rb +11 -4
  23. data/mods/core/sets/all/trash.rb +6 -1
  24. data/mods/standard/chunks/include.rb +3 -5
  25. data/mods/standard/lib/stylesheets/functional.scss +2 -0
  26. data/mods/standard/lib/stylesheets/standard.scss +1 -1
  27. data/mods/standard/sets/all/account.rb +66 -53
  28. data/mods/standard/sets/all/admin.rb +16 -16
  29. data/mods/standard/sets/all/all_css.rb +2 -2
  30. data/mods/standard/sets/all/base.rb +8 -3
  31. data/mods/standard/sets/all/follow.rb +2 -2
  32. data/mods/standard/sets/all/history.rb +1 -1
  33. data/mods/standard/sets/all/json.rb +3 -2
  34. data/mods/standard/sets/all/kml.rb +3 -2
  35. data/mods/standard/sets/all/rich_html.rb +220 -169
  36. data/mods/standard/sets/all/rss.rb +2 -2
  37. data/mods/standard/sets/right/structure.rb +5 -4
  38. data/mods/standard/sets/self/head.rb +2 -2
  39. data/mods/standard/sets/type/account_request.rb +20 -27
  40. data/mods/standard/sets/type/cardtype.rb +15 -2
  41. data/mods/standard/sets/type/layout_type.rb +6 -4
  42. data/mods/standard/sets/type/search_type.rb +1 -1
  43. data/mods/standard/sets/type/set.rb +6 -3
  44. data/mods/standard/sets/type/user.rb +13 -10
  45. data/public/assets/{application-7f1664ac8e65db8af0bfa6539e23c7df.js → application-af2bc486eb3db1c02c4dcd0e23ca25fc.js} +1 -1
  46. data/public/assets/{application-7f1664ac8e65db8af0bfa6539e23c7df.js.gz → application-af2bc486eb3db1c02c4dcd0e23ca25fc.js.gz} +0 -0
  47. data/public/assets/application.js +1 -1
  48. data/public/assets/application.js.gz +0 -0
  49. data/public/assets/html5shiv-printshiv-ad36fc7219f4aeaa275f9a7fe2383413.js.gz +0 -0
  50. data/public/assets/html5shiv-printshiv.js.gz +0 -0
  51. data/public/assets/manifest.yml +2 -2
  52. data/public/assets/tinymce-22b5a139d9ff7df7643afae9ce205508.js.gz +0 -0
  53. data/public/assets/tinymce.js.gz +0 -0
  54. data/spec/lib/card/codename_spec.rb +1 -0
  55. data/spec/mods/core/sets/all/permissions_spec.rb +25 -0
  56. data/spec/mods/core/sets/all/trash_spec.rb +16 -0
  57. data/spec/mods/standard/chunks/include_spec.rb +5 -0
  58. data/spec/mods/standard/sets/all/json_spec.rb +6 -6
  59. data/spec/mods/standard/sets/all/rich_html_spec.rb +36 -0
  60. data/spec/mods/standard/sets/right/structure_spec.rb +8 -2
  61. data/wagn.gemspec +2 -2
  62. metadata +14 -38
@@ -1,28 +1,28 @@
1
1
  view :setup, :tags=>:unknown_ok do |args|
2
2
  account = User.new( ( params[:card] && params[:card][:account_args] ) || {} )
3
- frame_args = {
3
+ args.merge!( {
4
4
  :title=>'Welcome, Wagneer!',
5
- :show_help=>true,
5
+ :optional_help=>:show,
6
6
  :optional_menu=>:never,
7
- :help_text=>'To get started, set up an account.'
8
- }
7
+ :help_text=>'To get started, set up an account.',
8
+ :buttons => submit_tag( 'Create' ),
9
+ :hidden => {
10
+ :success => "REDIRECT: #{ Card.path_setting '/' }",
11
+ 'card[type_id]' => Card.default_accounted_type_id
12
+ }
13
+ } )
9
14
 
10
- wrap_frame :setup, frame_args do
11
- form_for :card do |f|
12
- @form = f
13
- %{
14
- #{ _render_name_editor :help=>'usually first and last name' }
15
- #{ hidden_field_tag 'card[type_id]', Card.default_accounted_type_id }
16
- #{ _render_account_detail :account=>account, :setup=>true }
17
- <fieldset><div class="button-area">#{ submit_tag 'Create' }</div></fieldset>
18
- #{ render_error }
19
- }
20
- end
15
+ frame_and_form 'admin/setup', args, :recaptcha=>:off do
16
+ %{
17
+ #{ _render_name_fieldset :help=>'usually first and last name' }
18
+ #{ _render_account_detail :account=>account, :setup=>true }
19
+ #{ _optional_render :button_fieldset, args}
20
+ }
21
21
  end
22
22
  end
23
23
 
24
24
  view :show_cache do |args|
25
- wrap_frame :show_cache, args do
25
+ frame args do
26
26
  key = card.key
27
27
  cache_card = Card.fetch(key)
28
28
  db_card = Card.find_by_key(key)
@@ -6,9 +6,9 @@ format :css do
6
6
  { :view => :content }
7
7
  end
8
8
 
9
- view :show do |args|
9
+ def show args
10
10
  view = args[:view] || :content
11
- render view
11
+ render view, args
12
12
  end
13
13
 
14
14
  view :content do |args|
@@ -1,10 +1,12 @@
1
1
  # -*- encoding : utf-8 -*-
2
2
 
3
- view :show, :perms=>:none do |args|
4
- render( ( args[:view] || :core ), args )
3
+ format do
4
+ def show args
5
+ view = args[:view] || :core
6
+ render view, args
7
+ end
5
8
  end
6
9
 
7
-
8
10
  # NAME VIEWS
9
11
 
10
12
  view :name, :perms=>:none do |args| card.name end
@@ -108,6 +110,7 @@ view :too_slow, :perms=>:none do |args|
108
110
  end
109
111
 
110
112
 
113
+ #none of the below belongs here!!
111
114
 
112
115
 
113
116
  view :template_rule, :tags=>:unknown_ok do |args|
@@ -135,3 +138,5 @@ view :template_rule, :tags=>:unknown_ok do |args|
135
138
  subformat( Card.fetch(set_name) ).render_template_link args
136
139
  end
137
140
  end
141
+
142
+
@@ -3,7 +3,7 @@ format :html do
3
3
  watch_perms = lambda { |r| Account.logged_in? && !r.card.new_card? }
4
4
  view :watch, :tags=>[:unknown_ok, :no_wrap_comments], :denial=>:blank, :perms=>watch_perms do |args|
5
5
 
6
- wrap :watch, args do
6
+ wrap args do
7
7
  if card.watching_type?
8
8
  watching_type_cards
9
9
  else
@@ -38,7 +38,7 @@ end
38
38
 
39
39
  event :notify_followers, :after=>:extend do
40
40
  begin
41
- return false if Card.record_timestamps==false || ENV['WAGN_MIGRATION']
41
+ return false if Card.record_timestamps==false or Wagn.config.send_emails==false
42
42
  # userstamps and timestamps are turned off in cases like updating read_rules that are automated and
43
43
  # generally not of enough interest to warrant notification
44
44
 
@@ -5,7 +5,7 @@ format :html do
5
5
  view :history do |args|
6
6
  load_revisions
7
7
  if @revision
8
- wrap_frame :history, args.merge(:content=>true, :subheader=>_render_revision_subheader ) do
8
+ frame args.merge(:content=>true, :subheader=>_render_revision_subheader ) do
9
9
  _render_diff
10
10
  end
11
11
  end
@@ -21,8 +21,9 @@ format :json do
21
21
  params[:max_depth] || 1
22
22
  end
23
23
 
24
- view :show do |args|
25
- raw = render( ( args[:view] || :atom ), args )
24
+ def show args
25
+ view = args[:view] || :atom
26
+ raw = render view, args
26
27
  case
27
28
  when String === raw ; raw
28
29
  when params[:pretty] ; JSON.pretty_generate raw
@@ -3,8 +3,9 @@ require_dependency 'active_support/builder' unless defined?(Builder)
3
3
 
4
4
  format :kml do
5
5
 
6
- view :show do |args|
7
- render( args[:view] || :search)
6
+ def show args
7
+ view = args[:view] || :search
8
+ render view, args
8
9
  end
9
10
 
10
11
  # FIXME: integrate this with common XML features when it is added
@@ -1,11 +1,8 @@
1
1
  # -*- encoding : utf-8 -*-
2
- def clean_html?
3
- true
4
- end
5
2
 
6
3
  format :html do
7
-
8
- view :show do |args|
4
+
5
+ def show args
9
6
  @main_view = args[:view] || args[:home_view]
10
7
 
11
8
  if ajax_call?
@@ -22,33 +19,33 @@ format :html do
22
19
  end
23
20
 
24
21
  view :content do |args|
25
- wrap :content, args.merge(:slot_class=>'card-content') do
26
- menu = optional_render :menu, args, :hide
27
- %{#{ menu }#{ _render_core args }}
22
+ wrap args.merge(:slot_class=>'card-content') do
23
+ [
24
+ _optional_render( :menu, args, :hide ),
25
+ _render_core( args )
26
+ ]
28
27
  end
29
28
  end
30
29
 
31
30
  view :titled, :tags=>:comment do |args|
32
- wrap :titled, args do
33
- %{
34
- #{ _render_header args.merge( :optional_menu=>:hide ) }
35
- #{ wrap_body( :content=>true ) { _render_core args } }
36
- #{ optional_render :comment_box, args }
37
- }
31
+ wrap args do
32
+ [
33
+ _render_header( args.merge :optional_menu=>:hide ),
34
+ wrap_body( :content=>true ) { _render_core args },
35
+ optional_render( :comment_box, args )
36
+ ]
38
37
  end
39
38
  end
40
-
39
+
41
40
  view :labeled do |args|
42
- wrap :labeled, args do
43
- %{
44
- #{ _optional_render :menu, args }
45
- <label>#{ _render_title args }</label>
46
- #{
47
- wrap_body :body_class=>'closed-content', :content=>true do
48
- _render_closed_content args
49
- end
50
- }
51
- }
41
+ wrap args do
42
+ [
43
+ _optional_render( :menu, args ),
44
+ "<label>#{ _render_title args }</label>",
45
+ wrap_body( :body_class=>'closed-content', :content=>true ) do
46
+ _render_closed_content args
47
+ end
48
+ ]
52
49
  end
53
50
  end
54
51
 
@@ -58,17 +55,17 @@ format :html do
58
55
  add_name_context
59
56
  title
60
57
  end
61
-
58
+
62
59
  view :title_link do |args|
63
60
  link_to_page (args[:title_ready] || showname(args[:title]) ), card.name
64
61
  end
65
62
 
66
63
  view :open, :tags=>:comment do |args|
67
- wrap_frame :open, args.merge(:content=>true, :optional_toggle=>:show) do
68
- %{
69
- #{ _render_open_content args }
70
- #{ optional_render :comment_box, args }
71
- }
64
+ frame args.merge(:content=>true, :optional_toggle=>:show) do
65
+ [
66
+ _render_open_content( args ),
67
+ optional_render( :comment_box, args )
68
+ ]
72
69
  end
73
70
  end
74
71
 
@@ -86,7 +83,7 @@ format :html do
86
83
  %{
87
84
  <h1 class="card-header">
88
85
  #{ _optional_render :toggle, args, :hide }
89
- #{ _render_title args }
86
+ #{ _optional_render :title, args }
90
87
  #{ _optional_render :menu, args }
91
88
  </h1>
92
89
  }
@@ -97,7 +94,7 @@ format :html do
97
94
  disc_card = unless card.new_card? or card.junction? && card.cardname.tag_name.key == disc_tagname.key
98
95
  Card.fetch "#{card.name}+#{disc_tagname}", :skip_virtual=>true, :skip_modules=>true, :new=>{}
99
96
  end
100
-
97
+
101
98
  @menu_vars = {
102
99
  :self => card.name,
103
100
  :type => card.type_name,
@@ -118,7 +115,7 @@ format :html do
118
115
  )
119
116
  })
120
117
  end
121
-
118
+
122
119
  json = html_escape_except_quotes JSON( @menu_vars )
123
120
  %{<span class="card-menu-link" data-menu-vars='#{json}'>#{_render_menu_link}</span>}
124
121
  end
@@ -130,72 +127,168 @@ format :html do
130
127
 
131
128
  view :type do |args|
132
129
  klasses = ['cardtype']
133
- klasses << 'default-type' if card.type_id==Card.default_type_id ? " default-type" : ''
130
+ klass = args[:type_class] and klasses << klass
134
131
  link_to_page card.type_name, nil, :class=>klasses
135
132
  end
136
133
 
137
134
  view :closed do |args|
138
- wrap_frame :closed, args.merge(:content=>true, :body_class=>'closed-content', :toggle_mode=>:close, :optional_toggle=>:show ) do
135
+ frame args.merge(:content=>true, :body_class=>'closed-content', :toggle_mode=>:close, :optional_toggle=>:show ) do
139
136
  _optional_render :closed_content, args
140
137
  end
141
138
  end
142
139
 
143
140
 
141
+ ###---( TOP_LEVEL (used by menu) NEW / EDIT VIEWS )
142
+
144
143
  view :new, :perms=>:create, :tags=>:unknown_ok do |args|
145
- name_ready = !card.cardname.blank? && !Card.exists?( card.cardname )
146
- prompt_for_name = !name_ready && !card.rule_card( :autoname )
144
+ frame_and_form :create, args, 'main-success'=>'REDIRECT' do |form|
145
+ [
146
+ _optional_render( :name_fieldset, args ),
147
+ _optional_render( :type_fieldset, args ),
148
+ _optional_render( :content_fieldsets, args ),
149
+ _optional_render( :button_fieldset, args )
150
+ ]
151
+ end
152
+ end
153
+
154
+
155
+ def default_new_args args
156
+ hidden = args[:hidden] ||= {}
157
+ hidden[:success] ||= card.rule(:thanks) || '_self'
158
+ hidden[:card ] ||={}
159
+
160
+ args[:optional_help] = :show
161
+
162
+ # name field / title
163
+ if !params[:name_prompt] and !card.cardname.blank?
164
+ # name is ready and will show up in title
165
+ hidden[:card][:name] ||= card.name
166
+ else
167
+ # name is not ready; need generic title
168
+ args[:title] ||= "New #{ card.type_name unless card.type_id == Card.default_type_id }" #fixme - overrides nest args
169
+ unless card.rule_card :autoname
170
+ # prompt for name
171
+ hidden[:name_prompt] = true unless hidden.has_key? :name_prompt
172
+ args[:optional_name_fieldset] ||= :show
173
+ end
174
+ end
175
+ args[:optional_name_fieldset] ||= :hide
147
176
 
148
- hidden = args[:hidden] || { :success=> card.rule(:thanks) || '_self' }
149
- if name_ready
150
- hidden['card[name]'] = card.name
177
+
178
+ # type field
179
+ if ( !params[:type] and !args[:type] and
180
+ ( main? || card.simple? || card.is_template? ) and
181
+ Card.new( :type_id=>card.type_id ).ok? :create #otherwise current type won't be on menu
182
+ )
183
+ args[:optional_type_fieldset] = :show
151
184
  else
152
- args[:title] ||= "New #{ card.type_name unless card.type_id == Card.default_type_id }"
185
+ hidden[:card][:type_id] ||= card.type_id
186
+ args[:optional_type_fieldset] = :hide
153
187
  end
154
188
 
155
- prompt_for_type = (
156
- !params[:type] and !args[:type] and
157
- ( main? || card.simple? || card.is_template? ) and
158
- Card.new( :type_id=>card.type_id ).ok? :create #otherwise current type won't be on menu
159
- )
160
189
 
161
190
  cancel = if main?
162
191
  { :class=>'redirecter', :href=>Card.path_setting('/*previous') }
163
- else
192
+ else
164
193
  { :class=>'slotter', :href=>path( :view=>:missing ) }
165
194
  end
166
195
 
167
- wrap_frame :new, args.merge(:show_help=>true) do
168
- card_form :create, 'card-form', 'main-success'=>'REDIRECT' do |form|
169
- @form = form
170
- %{
171
- #{ hidden_tags hidden.merge( args[:hidden] || {} ) }
172
- #{ _render_name_editor if prompt_for_name }
173
- #{ prompt_for_type ? _render_type_menu : form.hidden_field( :type_id ) }
174
- <div class="card-editor editor">
175
- #{ edit_slot args.merge( :label => prompt_for_name || prompt_for_type ) }
176
- </div>
177
- <fieldset>
178
- <div class="button-area">
179
- #{ submit_tag 'Submit', :class=>'create-submit-button', :disable_with=>'Submitting' }
180
- #{ button_tag 'Cancel', :type=>'button', :class=>"create-cancel-button #{cancel[:class]}", :href=>cancel[:href] }
181
- </div>
182
- </fieldset>
183
- }
184
- end
196
+ args[:buttons] ||= %{
197
+ #{ submit_tag 'Submit', :class=>'create-submit-button', :disable_with=>'Submitting' }
198
+ #{ button_tag 'Cancel', :type=>'button', :class=>"create-cancel-button #{cancel[:class]}", :href=>cancel[:href] }
199
+ }
200
+
201
+ end
202
+
203
+
204
+ view :edit, :perms=>:update, :tags=>:unknown_ok do |args|
205
+ frame_and_form :update, args do |form|
206
+ [
207
+ _optional_render( :content_fieldsets, args ),
208
+ _optional_render( :button_fieldset, args )
209
+ ]
185
210
  end
186
211
  end
187
212
 
213
+ def default_edit_args args
214
+ args[:optional_help] = :show
215
+
216
+ args[:buttons] = %{
217
+ #{ submit_tag 'Submit', :class=>'submit-button' }
218
+ #{ button_tag 'Cancel', :class=>'cancel-button slotter', :href=>path, :type=>'button' }
219
+ }
220
+ end
221
+
222
+ view :edit_name, :perms=>:update do |args|
223
+ frame_and_form( { :action=>:update, :id=>card.id }, args, 'main-success'=>'REDIRECT' ) do
224
+ [
225
+ _render_name_fieldset( args ),
226
+ _optional_render( :confirm_rename, args ),
227
+ _optional_render( :button_fieldset, args )
228
+ ]
229
+ end
230
+ end
231
+
232
+ view :confirm_rename do |args|
233
+ referers = args[:referers]
234
+ dependents = card.dependents
235
+ wrap args do
236
+ %{
237
+ <h1>Are you sure you want to rename <em>#{card.name}</em>?</h1>
238
+ #{ %{ <h2>This change will...</h2> } if referers.any? || dependents.any? }
239
+ <ul>
240
+ #{ %{<li>automatically alter #{ dependents.size } related name(s). } if dependents.any? }
241
+ #{ %{<li>affect at least #{referers.size} reference(s) to "#{card.name}".} if referers.any? }
242
+ </ul>
243
+ #{ %{<p>You may choose to <em>update or ignore</em> the references.</p>} if referers.any? }
244
+ }
245
+ end
246
+ end
188
247
 
189
- view :editor do |args|
190
- form.text_area :content, :rows=>3, :class=>'tinymce-textarea card-content', :id=>unique_id
248
+ def default_edit_name_args args
249
+ referers = args[:referers] = card.extended_referencers
250
+ args[:hidden] ||= {}
251
+ args[:hidden].reverse_merge!(
252
+ :success => '_self',
253
+ :old_name => card.name,
254
+ :referers => referers.size,
255
+ :card => { :update_referencers => false }
256
+ )
257
+ args[:buttons] = %{
258
+ #{ submit_tag 'Rename and Update', :class=>'renamer-updater' }
259
+ #{ submit_tag 'Rename', :class=>'renamer' }
260
+ #{ button_tag 'Cancel', :class=>'slotter', :type=>'button', :href=>path(:view=>:edit, :id=>card.id)}
261
+ }
262
+
191
263
  end
192
264
 
265
+
266
+ view :edit_type, :perms=>:update do |args|
267
+ frame_and_form :update, args do
268
+ #'main-success'=>'REDIRECT: _self', # adding this back in would make main cards redirect on cardtype changes
269
+ [
270
+ _render_type_fieldset( args ),
271
+ optional_render( :button_fieldset, args )
272
+ ]
273
+ end
274
+ end
275
+
276
+ def default_edit_type_args args
277
+ args[:variety] = :edit #YUCK!
278
+ args[:hidden] ||= { :view=>:edit }
279
+ args[:buttons] = %{
280
+ #{ submit_tag 'Submit', :disable_with=>'Submitting' }
281
+ #{ button_tag 'Cancel', :href=>path(:view=>:edit), :type=>'button', :class=>'slotter' }
282
+ }
283
+ end
284
+
285
+
193
286
  view :missing do |args|
194
287
  return '' unless card.ok? :create #this should be moved into ok_view
195
288
  new_args = { :view=>:new, 'card[name]'=>card.name }
196
289
  new_args['card[type]'] = args[:type] if args[:type]
197
290
 
198
- wrap :missing, args do
291
+ wrap args do
199
292
  link_to raw("Add #{ fancy_title args[:title] }"), path(new_args),
200
293
  :class=>"slotter missing-#{ args[:denied_view] || args[:home_view]}", :remote=>true
201
294
  end
@@ -205,101 +298,55 @@ format :html do
205
298
  %{<span class="faint"> #{ showname } </span>}
206
299
  end
207
300
 
208
- ###---( EDIT VIEWS )
209
- view :edit, :perms=>:update, :tags=>:unknown_ok do |args|
210
- wrap_frame :edit, args.merge(:show_help=>true) do
211
- card_form :update, 'card-form autosave' do |f|
212
- @form= f
213
- %{
214
- #{ hidden_tags(( args[:hidden] || {} )) }
215
- <div class="card-editor">
216
- #{ edit_slot args }
217
- </div>
218
- <fieldset>
219
- <div class="button-area">
220
- #{ submit_tag 'Submit', :class=>'submit-button' }
221
- #{ button_tag 'Cancel', :class=>'cancel-button slotter', :href=>path, :type=>'button' }
222
- </div>
223
- </fieldset>
224
- }
225
- end
226
- end
227
- end
228
301
 
229
- view :name_editor do |args|
230
- fieldset 'name', raw( name_field form ), :editor=>'name', :help=>args[:help]
231
- end
232
302
 
233
- view :edit_name, :perms=>:update do |args|
234
- card.update_referencers = false
235
- referers = card.extended_referencers
236
- dependents = card.dependents
237
303
 
238
- wrap_frame :edit_name, args do
239
- card_form( path(:action=>:update, :id=>card.id), 'card-name-form card-editor', 'main-success'=>'REDIRECT' ) do |f|
240
- @form = f
241
- %{
242
- #{ _render_name_editor}
243
- #{ f.hidden_field :update_referencers, :class=>'update_referencers' }
244
- #{ hidden_field_tag :success, '_self' }
245
- #{ hidden_field_tag :old_name, card.name }
246
- #{ hidden_field_tag :referers, referers.size }
247
- <div class="confirm-rename hidden">
248
- <h1>Are you sure you want to rename <em>#{card.name}</em>?</h1>
249
- #{ %{ <h2>This change will...</h2> } if referers.any? || dependents.any? }
250
- <ul>
251
- #{ %{<li>automatically alter #{ dependents.size } related name(s). } if dependents.any? }
252
- #{ %{<li>affect at least #{referers.size} reference(s) to "#{card.name}".} if referers.any? }
253
- </ul>
254
- #{ %{<p>You may choose to <em>ignore or update</em> the references.</p>} if referers.any? }
255
- </div>
256
- <fieldset>
257
- <div class="button-area">
258
- #{ submit_tag 'Rename and Update', :class=>'renamer-updater hidden' }
259
- #{ submit_tag 'Rename', :class=>'renamer' }
260
- #{ button_tag 'Cancel', :class=>'edit-name-cancel-button slotter', :type=>'button', :href=>path(:view=>:edit, :id=>card.id)}
261
- </div>
262
- </fieldset>
263
- }
264
- end
265
- end
304
+ # FIELDSET VIEWS
305
+
306
+ view :name_fieldset do |args|
307
+ fieldset 'name', raw( name_field form ), :editor=>'name', :help=>args[:help]
266
308
  end
267
309
 
268
- view :type_menu do |args|
269
- field = if args[:variety] == :edit
310
+ view :type_fieldset do |args|
311
+ field = if args[:variety] == :edit #FIXME dislike this api -ef
270
312
  type_field :class=>'type-field edit-type-field'
271
313
  else
272
314
  type_field :class=>"type-field live-type-field", :href=>path(:view=>:new), 'data-remote'=>true
273
315
  end
274
316
  fieldset 'type', field, :editor => 'type', :attribs => { :class=>'type-fieldset'}
275
317
  end
276
-
277
- view :edit_type, :perms=>:update do |args|
278
- wrap_frame :edit_type, args do
279
- card_form( :update, 'card-edit-type-form card-editor' ) do |f|
280
- #'main-success'=>'REDIRECT: _self', # adding this back in would make main cards redirect on cardtype changes
281
- %{
282
- #{ hidden_field_tag :view, :edit }
283
- #{if card.type_id == Card::CardtypeID and !Card.search(:type_id=>card.id).empty? #ENGLISH
284
- %{<div>Sorry, you can't make this card anything other than a Cardtype so long as there are <strong>#{ card.name }</strong> cards.</div>}
285
- else
286
- _render_type_menu :variety=>:edit #FIXME dislike this api -ef
287
- end}
288
- <fieldset>
289
- <div class="button-area">
290
- #{ submit_tag 'Submit', :disable_with=>'Submitting' }
291
- #{ button_tag 'Cancel', :href=>path(:view=>:edit), :type=>'button', :class=>'edit-type-cancel-button slotter' }
292
- </div>
293
- </fieldset>
294
- }
295
- end
296
- end
318
+
319
+
320
+ view :button_fieldset do |args|
321
+ %{
322
+ <fieldset>
323
+ <div class="button-area">
324
+ #{ args[:buttons] }
325
+ </div>
326
+ </fieldset>
327
+ }
328
+ end
329
+
330
+ view :content_fieldsets do |args|
331
+ %{
332
+ <div class="card-editor editor">
333
+ #{ edit_slot args }
334
+ </div>
335
+ }
336
+ end
337
+
338
+ # FIELD VIEWS
339
+
340
+ view :editor do |args|
341
+ form.text_area :content, :rows=>3, :class=>'tinymce-textarea card-content', :id=>unique_id
297
342
  end
298
343
 
299
- view :edit_in_form, :perms=>:update, :tags=>:unknown_ok do |args|
344
+
345
+
346
+ view :edit_in_form, :perms=>:update, :tags=>:unknown_ok do |args| #fixme. why is this a view??
300
347
  eform = form_for_multi
301
348
  content = content_field eform, args.merge( :nested=>true )
302
- opts = { :editor=>'content', :help=>true, :attribs =>
349
+ opts = { :editor=>'content', :help=>true, :attribs =>
303
350
  { :class=> "card-editor RIGHT-#{ card.cardname.tag_name.safe_key }" }
304
351
  }
305
352
  if card.new_card?
@@ -314,10 +361,10 @@ format :html do
314
361
  view :options, :tags=>:unknown_ok do |args|
315
362
  current_set = Card.fetch( params[:current_set] || card.related_sets[0][0] )
316
363
 
317
- wrap_frame :options, args do
364
+ frame args do
318
365
  %{
319
366
  #{ subformat( current_set ).render_content }
320
- #{
367
+ #{
321
368
  if card.accountable? && !card.account
322
369
  %{
323
370
  <div class="new-account-link">
@@ -330,18 +377,23 @@ format :html do
330
377
  }
331
378
  end
332
379
  end
333
-
334
-
380
+
381
+
335
382
  view :related do |args|
336
383
  if rparams = params[:related]
337
384
  rcardname = rparams[:name].to_name.to_absolute_name( card.cardname)
338
385
  rcard = Card.fetch rcardname, :new=>{}
339
- rview = rparams[:view] || :titled
340
- show = 'menu,help'
341
- show += ',comment_box' if rparams[:name] == '+discussion' #fixme. yuck!
342
386
 
343
- wrap_frame :related, args do
344
- process_inclusion rcard, :view=>rview, :show=>show
387
+ nest_args = {
388
+ :view => ( rparams[:view] || :titled ),
389
+ :optional_help => :show,
390
+ :optional_menu => :show
391
+ }
392
+
393
+ nest_args[:optional_comment_box] = :show if rparams[:name] == '+discussion' #fixme. yuck!
394
+
395
+ frame args do
396
+ process_inclusion rcard, nest_args
345
397
  end
346
398
  end
347
399
  end
@@ -352,7 +404,7 @@ format :html do
352
404
  else
353
405
  setting = card.new_card? ? :add_help : :help
354
406
  setting = [ :add_help, { :fallback => :help } ] if setting == :add_help
355
-
407
+
356
408
  if help_card = card.rule_card( *setting ) and help_card.ok? :read
357
409
  with_inclusion_mode :normal do
358
410
  _final_core args.merge( :structure=>help_card.name )
@@ -364,7 +416,7 @@ format :html do
364
416
 
365
417
  view :conflict, :error_code=>409 do |args|
366
418
  load_revisions
367
- wrap :errors do |args|
419
+ wrap args.merge( :slot_class=>'error-view' ) do
368
420
  %{<strong>Conflict!</strong><span class="new-current-revision-id">#{@revision.id}</span>
369
421
  <div>#{ link_to_page @revision.creator.name } has also been making changes.</div>
370
422
  <div>Please examine below, resolve above, and re-submit.</div>
@@ -373,7 +425,7 @@ format :html do
373
425
  end
374
426
 
375
427
  view :change do |args|
376
- wrap :change, args do
428
+ wrap args do
377
429
  %{
378
430
  #{ link_to_page card.name, nil, :class=>'change-card' }
379
431
  #{ _optional_render :menu, args, :hide }
@@ -387,7 +439,7 @@ format :html do
387
439
  when rev.created_at.to_s; link_to('edited', path(:view=>:history), :class=>'last-edited', :rel=>'nofollow')
388
440
  else; 'updated'
389
441
  end} #{
390
-
442
+
391
443
  time_ago_in_words card.updated_at } ago by #{ #ENGLISH
392
444
  link_to_page card.updater.name, nil, :class=>'last-editor'}
393
445
  </span>}
@@ -400,7 +452,7 @@ format :html do
400
452
  view :errors, :perms=>:none do |args|
401
453
  #Rails.logger.debug "errors #{args.inspect}, #{card.inspect}, #{caller[0..3]*", "}"
402
454
  if card.errors.any?
403
- wrap :errors, args do
455
+ wrap args do
404
456
  %{ <h2>Problems #{%{ with <em>#{card.name}</em>} unless card.name.blank?}</h2> } +
405
457
  card.errors.map { |attrib, msg| "<div>#{attrib.to_s.upcase}: #{msg}</div>" } * ''
406
458
  end
@@ -414,8 +466,7 @@ format :html do
414
466
  #{link_to 'Sign Up', :controller=>'account', :action=>'signup'} to create it.
415
467
  </div>}
416
468
  end
417
-
418
- wrap_frame :notfound, args.merge(:title=>'Not Found', :optional_menu=>:never) do
469
+ frame args.merge(:title=>'Not Found', :optional_menu=>:never) do
419
470
  %{
420
471
  <h2>Could not find #{card.name.present? ? "<em>#{card.name}</em>" : 'that'}.</h2>
421
472
  #{sign_in_or_up_links}
@@ -429,11 +480,11 @@ format :html do
429
480
  else
430
481
  'to do that.'
431
482
  end
432
-
483
+
433
484
  if !focal?
434
485
  %{<span class="denied"><!-- Sorry, you don't have permission #{to_task} --></span>}
435
486
  else
436
- wrap_frame :denial, args do #ENGLISH below
487
+ frame args do #ENGLISH below
437
488
  message = case
438
489
  when task != :read && Wagn.config.read_only
439
490
  "We are currently in read-only mode. Please try again later."
@@ -441,11 +492,11 @@ format :html do
441
492
  "You need permission #{to_task}"
442
493
  else
443
494
  or_signup = if Card.new(:type_id=>Card::AccountRequestID).ok? :create
444
- "or #{ link_to 'sign up', wagn_url('account/signup') }"
495
+ "or #{ link_to 'sign up', wagn_url('new/:account_request') }"
445
496
  end
446
497
  "You have to #{ link_to 'sign in', wagn_url('account/signin') } #{or_signup} #{to_task}"
447
498
  end
448
-
499
+
449
500
  %{<h1>Sorry!</h1>\n<div>#{ message }</div>}
450
501
  end
451
502
  end