wagn 1.14.4 → 1.14.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/app/controllers/card_controller.rb +4 -3
- data/db/bootstrap/card_actions.yml +597 -583
- data/db/bootstrap/card_acts.yml +2 -2
- data/db/bootstrap/card_changes.yml +297 -248
- data/db/bootstrap/card_references.yml +3111 -1284
- data/db/bootstrap/cards.yml +1067 -1022
- data/db/migrate_core_cards/20141208132416_partial_reference_type.rb +7 -0
- data/db/migrate_core_cards/20141208162106_add_ace_script.rb +12 -0
- data/db/migrate_core_cards/20141230204340_uri_codename.rb +13 -0
- data/db/version_core_cards.txt +1 -1
- data/features/history.feature +2 -1
- data/features/layouts.feature +4 -0
- data/features/navbox.feature +1 -0
- data/features/step_definitions/wagn_steps.rb +6 -1
- data/features/support/env.rb +1 -1
- data/lib/card/env.rb +1 -1
- data/lib/card/format.rb +35 -48
- data/lib/card/loader.rb +9 -9
- data/lib/card/mailer.rb +0 -2
- data/lib/card/query.rb +8 -8
- data/lib/card/query/{card_spec.rb → card_clause.rb} +42 -42
- data/lib/card/query/{spec.rb → clause.rb} +3 -3
- data/lib/card/query/ref_clause.rb +47 -0
- data/lib/card/query/value_clause.rb +65 -0
- data/lib/card/reference.rb +11 -20
- data/lib/card/set.rb +6 -6
- data/lib/card/set_pattern.rb +5 -1
- data/lib/wagn/commands.rb +28 -14
- data/lib/wagn/config/environments/test.rb +3 -0
- data/lib/wagn/generators/wagn/templates/Gemfile +6 -0
- data/lib/wagn/generators/wagn/templates/Rakefile +1 -0
- data/lib/wagn/generators/wagn/templates/config/application.rb +1 -0
- data/lib/wagn/generators/wagn/templates/spec/javascripts/support/deck_jasmine.yml +56 -0
- data/lib/wagn/generators/wagn/templates/spec/javascripts/support/wagn_jasmine.yml +69 -0
- data/lib/wagn/generators/wagn/wagn_generator.rb +19 -2
- data/lib/wagn/migration.rb +10 -0
- data/lib/wagn/spec_helper.rb +2 -0
- data/lib/wagn/tasks/wagn.rake +9 -16
- data/mod/01_core/chunk/link.rb +2 -2
- data/mod/01_core/chunk/uri.rb +4 -4
- data/mod/01_core/format/html_format.rb +43 -280
- data/mod/01_core/set/all/active_card.rb +2 -0
- data/mod/01_core/set/all/collection.rb +19 -1
- data/mod/01_core/set/all/fetch.rb +5 -0
- data/mod/01_core/set/all/initialize.rb +1 -1
- data/mod/01_core/set/all/references.rb +25 -8
- data/mod/01_core/set/all/templating.rb +1 -1
- data/mod/01_core/set/all/tracked_attributes.rb +1 -1
- data/mod/01_core/set/all/type.rb +1 -1
- data/mod/01_core/set/all/utils.rb +1 -0
- data/mod/01_core/set_pattern/07_type_plus_right.rb +2 -1
- data/mod/01_core/spec/format/html_format_spec.rb +0 -2
- data/mod/01_core/spec/set/all/initialize_spec.rb +4 -4
- data/mod/01_core/spec/set/all/notify_spec.rb +9 -9
- data/mod/02_basic_types/set/type/pointer.rb +19 -8
- data/mod/03_machines/lib/javascript/ace.js +18204 -0
- data/mod/03_machines/lib/javascript/jquery-ui.js +13109 -11440
- data/mod/03_machines/lib/javascript/jquery.autosize.js +52 -33
- data/mod/03_machines/lib/javascript/jquery.fileupload.js +10 -8
- data/mod/03_machines/lib/javascript/jquery.iframe-transport.js +44 -16
- data/mod/03_machines/lib/javascript/jquery.js +4 -9473
- data/mod/03_machines/lib/javascript/jquery_ujs.js +156 -116
- data/mod/03_machines/lib/javascript/jquerymobile.js +14890 -8236
- data/mod/03_machines/lib/javascript/theme-textmate.js +130 -0
- data/mod/03_machines/lib/javascript/wagn_mod.js.coffee +50 -10
- data/mod/03_machines/set/self/script_ace.rb +8 -0
- data/mod/03_machines/set/type/coffee_script.rb +1 -1
- data/mod/03_machines/set/type/css.rb +0 -2
- data/mod/03_machines/set/type/java_script.rb +1 -1
- data/mod/03_machines/spec/lib/{machine_spec.rb → shared_machine_examples.rb} +0 -0
- data/mod/03_machines/spec/lib/{machine_input_spec.rb → shared_machine_input_examples.rb} +0 -0
- data/mod/03_machines/spec/set/type/scss_spec.rb +2 -2
- data/mod/04_settings/set/right/comment.rb +2 -2
- data/mod/04_settings/set/type/setting.rb +2 -2
- data/mod/04_settings/spec/set/right/structure_spec.rb +2 -2
- data/mod/04_settings/spec/set/right/style_spec.rb +1 -1
- data/mod/05_email/set/type/email_template.rb +3 -2
- data/mod/05_standard/set/all/all_css.rb +1 -1
- data/mod/05_standard/set/all/all_js.rb +1 -1
- data/mod/05_standard/set/all/attach.rb +8 -7
- data/mod/05_standard/set/all/base.rb +6 -34
- data/mod/05_standard/set/all/editing.rb +145 -0
- data/mod/05_standard/set/all/error.rb +203 -0
- data/mod/05_standard/set/all/follow.rb +2 -2
- data/mod/05_standard/set/all/form.rb +211 -0
- data/mod/05_standard/set/all/header.rb +60 -0
- data/mod/05_standard/set/all/history.rb +3 -3
- data/mod/05_standard/set/all/links.rb +101 -0
- data/mod/05_standard/set/all/rich_html.rb +14 -392
- data/mod/05_standard/set/all/wrapper.rb +74 -0
- data/mod/05_standard/set/right/account.rb +1 -2
- data/mod/05_standard/set/rstar/rules.rb +5 -5
- data/mod/05_standard/set/self/account_links.rb +8 -4
- data/mod/05_standard/set/self/head.rb +3 -3
- data/mod/05_standard/set/self/signin.rb +5 -3
- data/mod/05_standard/set/type/search_type.rb +25 -25
- data/mod/05_standard/set/type/set.rb +2 -2
- data/mod/05_standard/set/type/signup.rb +0 -2
- data/mod/05_standard/set/type/uri.rb +11 -0
- data/mod/05_standard/spec/set/all/rich_html_spec.rb +6 -6
- data/mod/05_standard/spec/set/all/rss_spec.rb +1 -1
- data/mod/05_standard/spec/set/type/signup_spec.rb +0 -1
- data/mod/05_standard/spec/set/type/uri_spec.rb +41 -0
- data/public/assets/ace/mode-coffee.js +1 -0
- data/public/assets/ace/mode-css.js +1 -0
- data/public/assets/ace/mode-html.js +1 -0
- data/public/assets/ace/mode-javascript.js +1 -0
- data/public/assets/ace/mode-json.js +1 -0
- data/public/assets/ace/mode-scss.js +922 -0
- data/public/assets/ace/theme-github.js +98 -0
- data/public/assets/ace/theme-textmate.js +1 -0
- data/public/assets/ace/worker-coffee.js +1 -0
- data/public/assets/ace/worker-css.js +1 -0
- data/public/assets/ace/worker-html.js +1 -0
- data/public/assets/ace/worker-javascript.js +1 -0
- data/public/assets/ace/worker-json.js +1 -0
- data/spec/controllers/card_controller_spec.rb +0 -1
- data/spec/controllers/location_spec.rb +0 -2
- data/spec/javascripts/helpers/jasmine-jquery.js +812 -0
- data/spec/javascripts/support/jasmine.yml +8 -6
- data/spec/javascripts/support/jasmine_config.rb +1 -1
- data/spec/javascripts/support/jasmine_runner.rb +1 -1
- data/spec/javascripts/wagn_spec.coffee +2 -0
- data/spec/lib/card/content_spec.rb +28 -6
- data/spec/lib/card/format_spec.rb +62 -15
- data/spec/lib/card/reference_spec.rb +3 -3
- data/spec/spec_helper.rb +2 -2
- data/test/fixtures/card_actions.yml +1260 -1239
- data/test/fixtures/card_acts.yml +347 -341
- data/test/fixtures/card_changes.yml +2345 -2276
- data/test/fixtures/card_references.yml +4098 -1606
- data/test/fixtures/cards.yml +1950 -1887
- metadata +39 -13
- data/lib/card/query/ref_spec.rb +0 -37
- data/lib/card/query/value_spec.rb +0 -65
- data/lib/wagn/location.rb +0 -93
- data/spec/javascripts/helpers/jasmine-config.js +0 -2
- data/spec/javascripts/helpers/jasmine-jquery-1.3.1.js +0 -295
@@ -0,0 +1,60 @@
|
|
1
|
+
format :html do
|
2
|
+
|
3
|
+
view :toggle do |args|
|
4
|
+
verb, adjective, direction = ( args[:toggle_mode] == :close ? %w{ open open e } : %w{ close closed s } )
|
5
|
+
|
6
|
+
view_link '', adjective, :title => "#{verb} #{card.name}",
|
7
|
+
:class => "#{verb}-icon ui-icon ui-icon-circle-triangle-#{direction} toggler slotter nodblclick"
|
8
|
+
end
|
9
|
+
|
10
|
+
|
11
|
+
view :header do |args|
|
12
|
+
%{
|
13
|
+
<h1 class="card-header">
|
14
|
+
#{ _optional_render :toggle, args, :hide }
|
15
|
+
#{ _optional_render :title, args }
|
16
|
+
#{ _optional_render :menu, args }
|
17
|
+
</h1>
|
18
|
+
}
|
19
|
+
end
|
20
|
+
|
21
|
+
view :menu, :tags=>:unknown_ok do |args|
|
22
|
+
return _render_template_closer if args[:menu_hack] == :template_closer
|
23
|
+
disc_tagname = Card.fetch(:discussion, :skip_modules=>true).cardname
|
24
|
+
disc_card = unless card.new_card? or card.junction? && card.cardname.tag_name.key == disc_tagname.key
|
25
|
+
Card.fetch "#{card.name}+#{disc_tagname}", :skip_virtual=>true, :skip_modules=>true, :new=>{}
|
26
|
+
end
|
27
|
+
|
28
|
+
@menu_vars = {
|
29
|
+
:self => card.name,
|
30
|
+
:linkname => card.cardname.url_key,
|
31
|
+
:type => card.type_name,
|
32
|
+
:structure => card.structure && card.template.ok?(:update) && card.template.name,
|
33
|
+
:discuss => disc_card && disc_card.ok?( disc_card.new_card? ? :comment : :read ),
|
34
|
+
:piecenames => card.junction? && card.cardname.piece_names[0..-2].map { |n| { :item=>n.to_s } },
|
35
|
+
:related_sets => card.related_sets.map { |name,label| { :text=>label, :path_opts=>{ :current_set => name } } }
|
36
|
+
}
|
37
|
+
if card.real?
|
38
|
+
@menu_vars.merge!({
|
39
|
+
:edit => card.ok?(:update),
|
40
|
+
:account => card.account && card.ok?(:update),
|
41
|
+
:watch => Auth.signed_in? && render_watch,
|
42
|
+
:creator => card.creator.name,
|
43
|
+
:updater => card.updater.name,
|
44
|
+
:delete => card.ok?(:delete) && link_to( 'delete', :action=>:delete,
|
45
|
+
:class => 'slotter standard-delete', :remote => true, :'data-confirm' => "Are you sure you want to delete #{card.name}?"
|
46
|
+
)
|
47
|
+
})
|
48
|
+
end
|
49
|
+
|
50
|
+
json = html_escape_except_quotes JSON( @menu_vars )
|
51
|
+
%{<span class="card-menu-link" data-menu-vars='#{json}'>#{_render_menu_link}</span>}
|
52
|
+
end
|
53
|
+
|
54
|
+
view :menu_link do |args|
|
55
|
+
'<a class="ui-icon ui-icon-gear"></a>'
|
56
|
+
end
|
57
|
+
|
58
|
+
|
59
|
+
|
60
|
+
end
|
@@ -162,7 +162,7 @@ format :html do
|
|
162
162
|
= "##{rev_nr}"
|
163
163
|
.title
|
164
164
|
.actor
|
165
|
-
= link_to act.actor.name, wagn_url( act.actor )
|
165
|
+
= link_to act.actor.name, wagn_url( act.actor.cardname.url_key )
|
166
166
|
.time.timeago
|
167
167
|
= time_ago_in_words(act.acted_at)
|
168
168
|
ago
|
@@ -284,13 +284,13 @@ format :html do
|
|
284
284
|
else
|
285
285
|
toggled_view = :act_expanded
|
286
286
|
end
|
287
|
-
link_to '',
|
287
|
+
link_to '', args.merge(:view=>toggled_view),
|
288
288
|
:class=>"slotter revision-#{args[:act_id]} #{ args[:act_view]==:expanded ? "arrow-down" : "arrow-right"}",
|
289
289
|
:remote=>true
|
290
290
|
end
|
291
291
|
|
292
292
|
def show_or_hide_changes_link hide_diff, args
|
293
|
-
"| " +
|
293
|
+
"| " + view_link( (hide_diff ? "Show" : "Hide") + " changes", :act_expanded,
|
294
294
|
:path_opts=>args.merge(:hide_diff=>!hide_diff),
|
295
295
|
:class=>'slotter', :remote=>true )
|
296
296
|
end
|
@@ -0,0 +1,101 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
format do
|
4
|
+
|
5
|
+
# link is called by web_link, card_link, and view_link
|
6
|
+
# (and is overridden in other formats)
|
7
|
+
def link_to text, href, opts={}
|
8
|
+
if text and href != text
|
9
|
+
"#{text}[#{href}]"
|
10
|
+
else
|
11
|
+
href
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
# link to a specific url or path
|
16
|
+
def web_link href, opts={}
|
17
|
+
text = opts.delete(:text) || href
|
18
|
+
new_class = case href
|
19
|
+
when /^https?:/ ; 'external-link'
|
20
|
+
when /^mailto:/ ; 'email-link'
|
21
|
+
when /^([a-zA-Z][\-+\.a-zA-Z\d]*):/ ; $1 + '-link'
|
22
|
+
when /^\//
|
23
|
+
href = internal_url href[1..-1] ; 'internal-link'
|
24
|
+
else
|
25
|
+
return card_link href, options
|
26
|
+
end
|
27
|
+
add_class opts, new_class
|
28
|
+
link_to text, href, opts
|
29
|
+
end
|
30
|
+
|
31
|
+
# link to a specific card
|
32
|
+
def card_link name, opts={}
|
33
|
+
text = (opts.delete(:text) || name).to_name.to_show @context_names
|
34
|
+
|
35
|
+
path_opts = opts.delete( :path_opts ) || {}
|
36
|
+
path_opts[:name ] = name
|
37
|
+
path_opts[:known] = opts[:known].nil? ? Card.known?(name) : opts.delete(:known)
|
38
|
+
add_class opts, ( path_opts[:known] ? 'known-card' : 'wanted-card' )
|
39
|
+
link_to text, path_opts, opts
|
40
|
+
end
|
41
|
+
|
42
|
+
|
43
|
+
# link to a specific view (defaults to current card)
|
44
|
+
# this is generally used for ajax calls
|
45
|
+
def view_link text, view, opts={}
|
46
|
+
path_opts = opts.delete( :path_opts ) || {}
|
47
|
+
path_opts[:view] = view unless view == :home
|
48
|
+
opts[:remote] = true
|
49
|
+
opts[:rel] = 'nofollow'
|
50
|
+
|
51
|
+
link_to text, path_opts, opts
|
52
|
+
end
|
53
|
+
|
54
|
+
def path opts={}
|
55
|
+
name = opts.delete(:name) || card.name
|
56
|
+
base = opts[:action] ? "card/#{ opts.delete :action }/" : ''
|
57
|
+
|
58
|
+
opts[:no_id] = true if [:new, :create].member? opts[:action]
|
59
|
+
#generalize. dislike hardcoding views/actions here
|
60
|
+
|
61
|
+
linkname = name.to_name.url_key
|
62
|
+
unless name.empty? || opts.delete(:no_id)
|
63
|
+
base += ( opts[:id] ? "~#{ opts.delete :id }" : linkname )
|
64
|
+
end
|
65
|
+
|
66
|
+
opts[:card] = {}
|
67
|
+
opts[:card][:name] = name if opts.delete(:known)==false && name.present? && name.to_s != linkname
|
68
|
+
|
69
|
+
if type = opts.delete(:type) and Card.known?( type )
|
70
|
+
opts[:card][:type] = type
|
71
|
+
end
|
72
|
+
opts.delete(:card) if opts[:card].empty?
|
73
|
+
|
74
|
+
query = opts.empty? ? '' : "?#{opts.to_param}"
|
75
|
+
internal_url( base + query )
|
76
|
+
end
|
77
|
+
|
78
|
+
def internal_url relative_path
|
79
|
+
wagn_path relative_path
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
83
|
+
|
84
|
+
format :html do
|
85
|
+
|
86
|
+
|
87
|
+
def link_to text, href, opts={}
|
88
|
+
if Hash===href
|
89
|
+
href = path href
|
90
|
+
end
|
91
|
+
|
92
|
+
[:remote, :method].each do |key|
|
93
|
+
if val = opts.delete(key)
|
94
|
+
opts["data-#{key}"] = val
|
95
|
+
end
|
96
|
+
end
|
97
|
+
|
98
|
+
content_tag :a, raw(text), opts.merge(:href=>href)
|
99
|
+
end
|
100
|
+
|
101
|
+
end
|
@@ -56,7 +56,7 @@ format :html do
|
|
56
56
|
end
|
57
57
|
|
58
58
|
view :title_link do |args|
|
59
|
-
|
59
|
+
card_link card.cardname, :text=>( args[:title_ready] || showname(args[:title]) )
|
60
60
|
end
|
61
61
|
|
62
62
|
view :open, :tags=>:comment do |args|
|
@@ -69,25 +69,7 @@ format :html do
|
|
69
69
|
end
|
70
70
|
end
|
71
71
|
|
72
|
-
|
73
|
-
verb, adjective, direction = ( args[:toggle_mode] == :close ? %w{ open open e } : %w{ close closed s } )
|
74
|
-
|
75
|
-
link_to '', path( :view=>adjective ),
|
76
|
-
:remote => true,
|
77
|
-
:title => "#{verb} #{card.name}",
|
78
|
-
:class => "#{verb}-icon ui-icon ui-icon-circle-triangle-#{direction} toggler slotter nodblclick"
|
79
|
-
end
|
80
|
-
|
81
|
-
|
82
|
-
view :header do |args|
|
83
|
-
%{
|
84
|
-
<h1 class="card-header">
|
85
|
-
#{ _optional_render :toggle, args, :hide }
|
86
|
-
#{ _optional_render :title, args }
|
87
|
-
#{ _optional_render :menu, args }
|
88
|
-
</h1>
|
89
|
-
}
|
90
|
-
end
|
72
|
+
|
91
73
|
|
92
74
|
=begin
|
93
75
|
view :anchor, :perms=>:none, :tags=>:unknown_ok do |args|
|
@@ -95,47 +77,10 @@ format :html do
|
|
95
77
|
end
|
96
78
|
=end
|
97
79
|
|
98
|
-
view :menu, :tags=>:unknown_ok do |args|
|
99
|
-
return _render_template_closer if args[:menu_hack] == :template_closer
|
100
|
-
disc_tagname = Card.fetch(:discussion, :skip_modules=>true).cardname
|
101
|
-
disc_card = unless card.new_card? or card.junction? && card.cardname.tag_name.key == disc_tagname.key
|
102
|
-
Card.fetch "#{card.name}+#{disc_tagname}", :skip_virtual=>true, :skip_modules=>true, :new=>{}
|
103
|
-
end
|
104
|
-
|
105
|
-
@menu_vars = {
|
106
|
-
:self => card.name,
|
107
|
-
:linkname => card.cardname.url_key,
|
108
|
-
:type => card.type_name,
|
109
|
-
:structure => card.structure && card.template.ok?(:update) && card.template.name,
|
110
|
-
:discuss => disc_card && disc_card.ok?( disc_card.new_card? ? :comment : :read ),
|
111
|
-
:piecenames => card.junction? && card.cardname.piece_names[0..-2].map { |n| { :item=>n.to_s } },
|
112
|
-
:related_sets => card.related_sets.map { |name,label| { :text=>label, :path_opts=>{ :current_set => name } } }
|
113
|
-
}
|
114
|
-
if card.real?
|
115
|
-
@menu_vars.merge!({
|
116
|
-
:edit => card.ok?(:update),
|
117
|
-
:account => card.account && card.ok?(:update),
|
118
|
-
:watch => Auth.signed_in? && render_watch,
|
119
|
-
:creator => card.creator.name,
|
120
|
-
:updater => card.updater.name,
|
121
|
-
:delete => card.ok?(:delete) && link_to( 'delete', path(:action=>:delete),
|
122
|
-
:class => 'slotter standard-delete', :remote => true, :'data-confirm' => "Are you sure you want to delete #{card.name}?"
|
123
|
-
)
|
124
|
-
})
|
125
|
-
end
|
126
|
-
|
127
|
-
json = html_escape_except_quotes JSON( @menu_vars )
|
128
|
-
%{<span class="card-menu-link" data-menu-vars='#{json}'>#{_render_menu_link}</span>}
|
129
|
-
end
|
130
|
-
|
131
|
-
view :menu_link do |args|
|
132
|
-
'<a class="ui-icon ui-icon-gear"></a>'
|
133
|
-
end
|
134
|
-
|
135
80
|
view :type do |args|
|
136
81
|
klasses = ['cardtype']
|
137
82
|
klass = args[:type_class] and klasses << klass
|
138
|
-
|
83
|
+
card_link card.type_card.name, :class=>klasses
|
139
84
|
end
|
140
85
|
|
141
86
|
view :closed do |args|
|
@@ -145,227 +90,17 @@ format :html do
|
|
145
90
|
end
|
146
91
|
|
147
92
|
|
148
|
-
|
149
|
-
|
150
|
-
view :new, :perms=>:create, :tags=>:unknown_ok do |args|
|
151
|
-
frame_and_form :create, args, 'main-success'=>'REDIRECT' do
|
152
|
-
[
|
153
|
-
_optional_render( :name_fieldset, args ),
|
154
|
-
_optional_render( :type_fieldset, args ),
|
155
|
-
_optional_render( :content_fieldsets, args ),
|
156
|
-
_optional_render( :button_fieldset, args )
|
157
|
-
]
|
158
|
-
end
|
159
|
-
end
|
160
|
-
|
161
|
-
|
162
|
-
def default_new_args args
|
163
|
-
hidden = args[:hidden] ||= {}
|
164
|
-
hidden[:success] ||= card.rule(:thanks) || '_self'
|
165
|
-
hidden[:card ] ||={}
|
166
|
-
|
167
|
-
args[:optional_help] ||= :show
|
168
|
-
|
169
|
-
# name field / title
|
170
|
-
if !params[:name_prompt] and !card.cardname.blank?
|
171
|
-
# name is ready and will show up in title
|
172
|
-
hidden[:card][:name] ||= card.name
|
173
|
-
else
|
174
|
-
# name is not ready; need generic title
|
175
|
-
args[:title] ||= "New #{ card.type_name unless card.type_id == Card.default_type_id }" #fixme - overrides nest args
|
176
|
-
unless card.rule_card :autoname
|
177
|
-
# prompt for name
|
178
|
-
hidden[:name_prompt] = true unless hidden.has_key? :name_prompt
|
179
|
-
args[:optional_name_fieldset] ||= :show
|
180
|
-
end
|
181
|
-
end
|
182
|
-
args[:optional_name_fieldset] ||= :hide
|
183
|
-
|
184
|
-
|
185
|
-
# type field
|
186
|
-
if ( !params[:type] and !args[:type] and
|
187
|
-
( main? || card.simple? || card.is_template? ) and
|
188
|
-
Card.new( :type_id=>card.type_id ).ok? :create #otherwise current type won't be on menu
|
189
|
-
)
|
190
|
-
args[:optional_type_fieldset] = :show
|
191
|
-
else
|
192
|
-
hidden[:card][:type_id] ||= card.type_id
|
193
|
-
args[:optional_type_fieldset] = :hide
|
194
|
-
end
|
195
|
-
|
196
|
-
|
197
|
-
cancel = if main?
|
198
|
-
{ :class=>'redirecter', :href=>Card.path_setting('/*previous') }
|
199
|
-
else
|
200
|
-
{ :class=>'slotter', :href=>path( :view=>:missing ) }
|
201
|
-
end
|
202
|
-
|
203
|
-
args[:buttons] ||= %{
|
204
|
-
#{ button_tag 'Submit', :class=>'create-submit-button', :disable_with=>'Submitting' }
|
205
|
-
#{ button_tag 'Cancel', :type=>'button', :class=>"create-cancel-button #{cancel[:class]}", :href=>cancel[:href] }
|
206
|
-
}
|
207
|
-
|
208
|
-
end
|
209
|
-
|
210
|
-
|
211
|
-
view :edit, :perms=>:update, :tags=>:unknown_ok do |args|
|
212
|
-
frame_and_form :update, args do
|
213
|
-
[
|
214
|
-
_optional_render( :content_fieldsets, args ),
|
215
|
-
_optional_render( :button_fieldset, args )
|
216
|
-
]
|
217
|
-
end
|
218
|
-
end
|
219
|
-
|
220
|
-
def default_edit_args args
|
221
|
-
args[:optional_help] = :show
|
222
|
-
|
223
|
-
args[:buttons] = %{
|
224
|
-
#{ button_tag 'Submit', :class=>'submit-button', :disable_with=>'Submitting' }
|
225
|
-
#{ button_tag 'Cancel', :class=>'cancel-button slotter', :href=>path, :type=>'button' }
|
226
|
-
}
|
227
|
-
end
|
228
|
-
|
229
|
-
view :edit_name, :perms=>:update do |args|
|
230
|
-
frame_and_form( { :action=>:update, :id=>card.id }, args, 'main-success'=>'REDIRECT' ) do
|
231
|
-
[
|
232
|
-
_render_name_fieldset( args ),
|
233
|
-
_optional_render( :confirm_rename, args ),
|
234
|
-
_optional_render( :button_fieldset, args )
|
235
|
-
]
|
236
|
-
end
|
237
|
-
end
|
238
|
-
|
239
|
-
view :confirm_rename do |args|
|
240
|
-
referers = args[:referers]
|
241
|
-
dependents = card.dependents
|
93
|
+
view :change do |args|
|
94
|
+
args[:optional_title_link] = :show
|
242
95
|
wrap args do
|
243
|
-
%{
|
244
|
-
<h1>Are you sure you want to rename <em>#{card.name}</em>?</h1>
|
245
|
-
#{ %{ <h2>This change will...</h2> } if referers.any? || dependents.any? }
|
246
|
-
<ul>
|
247
|
-
#{ %{<li>automatically alter #{ dependents.size } related name(s). } if dependents.any? }
|
248
|
-
#{ %{<li>affect at least #{referers.size} reference(s) to "#{card.name}".} if referers.any? }
|
249
|
-
</ul>
|
250
|
-
#{ %{<p>You may choose to <em>update or ignore</em> the references.</p>} if referers.any? }
|
251
|
-
}
|
252
|
-
end
|
253
|
-
end
|
254
|
-
|
255
|
-
def default_edit_name_args args
|
256
|
-
referers = args[:referers] = card.extended_referencers
|
257
|
-
args[:hidden] ||= {}
|
258
|
-
args[:hidden].reverse_merge!(
|
259
|
-
:success => '_self',
|
260
|
-
:old_name => card.name,
|
261
|
-
:referers => referers.size,
|
262
|
-
:card => { :update_referencers => false }
|
263
|
-
)
|
264
|
-
args[:buttons] = %{
|
265
|
-
#{ button_tag 'Rename and Update', :disable_with=>'Renaming', :class=>'renamer-updater' }
|
266
|
-
#{ button_tag 'Rename', :disable_with=>'Renaming', :class=>'renamer' }
|
267
|
-
#{ button_tag 'Cancel', :class=>'slotter', :type=>'button', :href=>path(:view=>:edit, :id=>card.id)}
|
268
|
-
}
|
269
|
-
|
270
|
-
end
|
271
|
-
|
272
|
-
|
273
|
-
view :edit_type, :perms=>:update do |args|
|
274
|
-
frame_and_form :update, args do
|
275
|
-
#'main-success'=>'REDIRECT: _self', # adding this back in would make main cards redirect on cardtype changes
|
276
96
|
[
|
277
|
-
|
278
|
-
|
97
|
+
_optional_render( :title, args ),
|
98
|
+
_optional_render( :menu, args, :hide ),
|
99
|
+
_optional_render( :last_action, args )
|
279
100
|
]
|
280
101
|
end
|
281
102
|
end
|
282
103
|
|
283
|
-
def default_edit_type_args args
|
284
|
-
args[:variety] = :edit #YUCK!
|
285
|
-
args[:hidden] ||= { :view=>:edit }
|
286
|
-
args[:buttons] = %{
|
287
|
-
#{ button_tag 'Submit', :disable_with=>'Submitting' }
|
288
|
-
#{ button_tag 'Cancel', :href=>path(:view=>:edit), :type=>'button', :class=>'slotter' }
|
289
|
-
}
|
290
|
-
end
|
291
|
-
|
292
|
-
|
293
|
-
view :missing do |args|
|
294
|
-
return '' unless card.ok? :create # should this be moved into ok_view?
|
295
|
-
new_args = { :view=>:new, 'card[name]'=>card.name }
|
296
|
-
new_args['card[type]'] = args[:type] if args[:type]
|
297
|
-
|
298
|
-
wrap args do
|
299
|
-
link_to raw("Add #{ fancy_title args[:title] }"), path(new_args),
|
300
|
-
:class=>"slotter missing-#{ args[:denied_view] || args[:home_view]}", :remote=>true
|
301
|
-
end
|
302
|
-
end
|
303
|
-
|
304
|
-
view :closed_missing, :perms=>:none do |args|
|
305
|
-
%{<span class="faint"> #{ showname } </span>}
|
306
|
-
end
|
307
|
-
|
308
|
-
|
309
|
-
|
310
|
-
|
311
|
-
# FIELDSET VIEWS
|
312
|
-
|
313
|
-
view :name_fieldset do |args|
|
314
|
-
fieldset 'name', raw( name_field form ), :editor=>'name', :help=>args[:help]
|
315
|
-
end
|
316
|
-
|
317
|
-
view :type_fieldset do |args|
|
318
|
-
field = if args[:variety] == :edit #FIXME dislike this api -ef
|
319
|
-
type_field :class=>'type-field edit-type-field'
|
320
|
-
else
|
321
|
-
type_field :class=>"type-field live-type-field", :href=>path(:view=>:new), 'data-remote'=>true
|
322
|
-
end
|
323
|
-
fieldset 'type', field, :editor => 'type', :attribs => { :class=>'type-fieldset'}
|
324
|
-
end
|
325
|
-
|
326
|
-
|
327
|
-
view :button_fieldset do |args|
|
328
|
-
%{
|
329
|
-
<fieldset>
|
330
|
-
<div class="button-area">
|
331
|
-
#{ args[:buttons] }
|
332
|
-
</div>
|
333
|
-
</fieldset>
|
334
|
-
}
|
335
|
-
end
|
336
|
-
|
337
|
-
view :content_fieldsets do |args|
|
338
|
-
raw %{
|
339
|
-
<div class="card-editor editor">
|
340
|
-
#{ edit_slot args }
|
341
|
-
</div>
|
342
|
-
}
|
343
|
-
end
|
344
|
-
|
345
|
-
# FIELD VIEWS
|
346
|
-
|
347
|
-
view :editor do |args|
|
348
|
-
form.text_area :content, :rows=>3, :class=>'tinymce-textarea card-content', :id=>unique_id
|
349
|
-
end
|
350
|
-
|
351
|
-
|
352
|
-
view :edit_in_form, :perms=>:update, :tags=>:unknown_ok do |args|
|
353
|
-
eform = form_for_multi
|
354
|
-
content = content_field eform, args.merge( :nested=>true )
|
355
|
-
opts = { :editor=>'content', :help=>true, :attribs =>
|
356
|
-
{ :class=> "card-editor RIGHT-#{ card.cardname.tag_name.safe_key }" }
|
357
|
-
}
|
358
|
-
if card.new_card?
|
359
|
-
content += raw( "\n #{ eform.hidden_field :type_id }" )
|
360
|
-
else
|
361
|
-
opts[:attribs].merge! :card_id=>card.id, :card_name=>(h card.name)
|
362
|
-
end
|
363
|
-
|
364
|
-
fieldset fancy_title( args[:title] ), content, opts
|
365
|
-
end
|
366
|
-
|
367
|
-
|
368
|
-
|
369
104
|
view :options, :tags=>:unknown_ok do |args|
|
370
105
|
current_set = Card.fetch( params[:current_set] || card.related_sets[0][0] )
|
371
106
|
|
@@ -394,7 +129,7 @@ format :html do
|
|
394
129
|
end
|
395
130
|
end
|
396
131
|
end
|
397
|
-
|
132
|
+
|
398
133
|
view :help, :tags=>:unknown_ok do |args|
|
399
134
|
text = if args[:help_text]
|
400
135
|
args[:help_text]
|
@@ -410,56 +145,6 @@ format :html do
|
|
410
145
|
%{<div class="instruction">#{raw text}</div>} if text
|
411
146
|
end
|
412
147
|
|
413
|
-
view :message, :perms=>:none, :tags=>:unknown_ok do |args|
|
414
|
-
frame args do
|
415
|
-
params[:message]
|
416
|
-
end
|
417
|
-
end
|
418
|
-
|
419
|
-
view :conflict, :error_code=>409 do |args|
|
420
|
-
# FIXME: hack to get the conflicted update as a proper act for the diff view
|
421
|
-
card.current_act.save
|
422
|
-
action = card.actions.last # the unsaved action with the new changes
|
423
|
-
action.card_act_id = card.current_act.id
|
424
|
-
action.draft = true
|
425
|
-
action.save
|
426
|
-
card.store_changes # deletes action if there are no changes
|
427
|
-
|
428
|
-
# as a consequence card.current_act.actions can be empty when both users made exactly the same changes
|
429
|
-
# but an act is always supposed to have at least one action, so we have to delete the act to avoid bad things
|
430
|
-
card.current_act.reload
|
431
|
-
if card.current_act.actions.empty?
|
432
|
-
card.current_act.delete
|
433
|
-
card.current_act = nil
|
434
|
-
end
|
435
|
-
|
436
|
-
wrap args.merge( :slot_class=>'error-view' ) do #ENGLISH below
|
437
|
-
%{<strong>Conflict!</strong><span class="new-current-revision-id">#{card.last_action_id}</span>
|
438
|
-
<div>#{ link_to_page card.last_action.act.actor.name } has also been making changes.</div>
|
439
|
-
<div>Please examine below, resolve above, and re-submit.</div>
|
440
|
-
#{ wrap do |args|
|
441
|
-
if card.current_act
|
442
|
-
_render_act_expanded :act=>card.current_act, :current_rev_nr => 0
|
443
|
-
else
|
444
|
-
"No difference between your changes and #{card.last_action.act.actor.name}'s version."
|
445
|
-
end
|
446
|
-
end
|
447
|
-
}
|
448
|
-
}
|
449
|
-
end
|
450
|
-
end
|
451
|
-
|
452
|
-
view :change do |args|
|
453
|
-
args[:optional_title_link] = :show
|
454
|
-
wrap args do
|
455
|
-
[
|
456
|
-
_optional_render( :title, args ),
|
457
|
-
_optional_render( :menu, args, :hide ),
|
458
|
-
_optional_render( :last_action, args )
|
459
|
-
]
|
460
|
-
end
|
461
|
-
end
|
462
|
-
|
463
148
|
|
464
149
|
view :last_action do |args|
|
465
150
|
action_type = case ( action = card.last_act.action_on(card.id) and action.action_type )
|
@@ -477,77 +162,14 @@ format :html do
|
|
477
162
|
</span>
|
478
163
|
}
|
479
164
|
end
|
480
|
-
|
481
|
-
view :errors, :perms=>:none do |args|
|
482
|
-
if card.errors.any?
|
483
|
-
title = %{ Problems #{%{ with #{card.name} } unless card.name.blank?} }
|
484
|
-
frame args.merge( :title=>title ) do
|
485
|
-
card.errors.map do |attrib, msg|
|
486
|
-
msg = "#{attrib.to_s.upcase}: #{msg}" unless attrib == :abort
|
487
|
-
%{ <div class="card-error-msg">#{msg}</div> }
|
488
|
-
end
|
489
|
-
end
|
490
|
-
end
|
491
|
-
end
|
492
|
-
|
493
|
-
view :not_found do |args| #ug. bad name.
|
494
|
-
sign_in_or_up_links = if !Auth.signed_in?
|
495
|
-
%{<div>
|
496
|
-
#{link_to "Sign in", wagn_path(':signin') } or
|
497
|
-
#{link_to 'Sign up', wagn_path('account/signup') } to create it.
|
498
|
-
</div>}
|
499
|
-
end
|
500
|
-
frame args.merge(:title=>'Not Found', :optional_menu=>:never) do
|
501
|
-
%{
|
502
|
-
<h2>Could not find #{card.name.present? ? "<em>#{card.name}</em>" : 'that'}.</h2>
|
503
|
-
#{sign_in_or_up_links}
|
504
|
-
}
|
505
|
-
end
|
506
|
-
end
|
507
|
-
|
508
|
-
view :denial do |args|
|
509
|
-
to_task = if task = args[:denied_task]
|
510
|
-
%{to #{task} this.}
|
511
|
-
else
|
512
|
-
'to do that.'
|
513
|
-
end
|
514
|
-
|
515
|
-
if !focal?
|
516
|
-
%{<span class="denied"><!-- Sorry, you don't have permission #{to_task} --></span>}
|
517
|
-
else
|
518
|
-
frame args do #ENGLISH below
|
519
|
-
message = case
|
520
|
-
when task != :read && Wagn.config.read_only
|
521
|
-
"We are currently in read-only mode. Please try again later."
|
522
|
-
when Auth.signed_in?
|
523
|
-
"You need permission #{to_task}"
|
524
|
-
else
|
525
|
-
or_signup = if Card.new(:type_id=>Card::SignupID).ok? :create
|
526
|
-
"or #{ link_to 'sign up', wagn_url('account/signup') }"
|
527
|
-
end
|
528
|
-
save_interrupted_action(request.env['REQUEST_URI'])
|
529
|
-
"You have to #{ link_to 'sign in', wagn_url(':signin') } #{or_signup} #{to_task}"
|
530
|
-
end
|
531
|
-
|
532
|
-
%{<h1>Sorry!</h1>\n<div>#{ message }</div>}
|
533
|
-
end
|
534
|
-
end
|
535
|
-
end
|
165
|
+
|
536
166
|
|
167
|
+
|
168
|
+
private
|
537
169
|
|
538
|
-
|
539
|
-
%{
|
540
|
-
<body>
|
541
|
-
<div class="dialog">
|
542
|
-
<h1>Wagn Hitch :(</h1>
|
543
|
-
<p>Server Error. Yuck, sorry about that.</p>
|
544
|
-
<p><a href="http://www.wagn.org/new/Support_Ticket">Add a support ticket</a>
|
545
|
-
to tell us more and follow the fix.</p>
|
546
|
-
</div>
|
547
|
-
</body>
|
548
|
-
}
|
170
|
+
def fancy_title title=nil
|
171
|
+
raw %{<span class="card-title">#{ showname(title).to_name.parts.join %{<span class="joint">+</span>} }</span>}
|
549
172
|
end
|
550
|
-
|
551
173
|
end
|
552
174
|
|
553
175
|
|