card 1.96.1 → 1.96.2

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/config/locales/de.yml +18 -23
  4. data/config/locales/en.yml +16 -21
  5. data/config/locales/es.yml +16 -21
  6. data/lib/card.rb +1 -3
  7. data/lib/card/codename.rb +2 -1
  8. data/lib/card/error.rb +73 -57
  9. data/lib/card/format.rb +2 -2
  10. data/lib/card/format/error.rb +17 -18
  11. data/lib/card/format/nesting/mode.rb +1 -1
  12. data/lib/card/format/permission.rb +8 -10
  13. data/lib/card/format/render.rb +1 -2
  14. data/lib/card/model/save_helper.rb +20 -12
  15. data/lib/card/query.rb +1 -1
  16. data/lib/card/query/card_query.rb +2 -2
  17. data/lib/card/query/card_query/found_by.rb +43 -0
  18. data/lib/card/query/card_query/match_attributes.rb +72 -0
  19. data/lib/card/query/card_query/relational_attributes.rb +19 -0
  20. data/lib/card/view.rb +0 -1
  21. data/lib/card/view/cache_action.rb +1 -10
  22. data/mod/account/set/right/token.rb +1 -3
  23. data/mod/account/set/self/account_links.rb +9 -12
  24. data/mod/basic_formats/set/all/json.rb +19 -54
  25. data/mod/basic_formats/spec/set/all/json_spec.rb +13 -3
  26. data/mod/basic_formats/spec/shared_context/json_shared_context.rb +3 -8
  27. data/mod/basic_types/set/type/json.rb +13 -1
  28. data/mod/bootstrap/set/abstract/bootswatch_theme/html_views.rb +0 -1
  29. data/mod/bootstrap/set/all/bootstrap/helper.rb +7 -0
  30. data/mod/bootstrap/set/self/script_bootstrap.rb +1 -2
  31. data/mod/core/set/all/content.rb +4 -6
  32. data/mod/core/set/all/export.rb +39 -15
  33. data/mod/core/set/all/fetch.rb +9 -0
  34. data/mod/core/set/all/permissions.rb +0 -4
  35. data/mod/core/set/all/phases.rb +1 -1
  36. data/mod/core/set/all/subcards.rb +1 -0
  37. data/mod/core/set/all/trash.rb +6 -2
  38. data/mod/core/set/all/type.rb +1 -1
  39. data/mod/core/set/all/utils.rb +13 -1
  40. data/mod/core/spec/set/all/fetch_spec.rb +17 -4
  41. data/mod/history/set/all/history.rb +34 -57
  42. data/mod/history/set/all/{act_view.rb → history/act_listing.rb} +0 -13
  43. data/mod/history/set/all/history/actions.rb +119 -0
  44. data/mod/history/set/all/history/acts.rb +12 -0
  45. data/mod/history/set/all/history/events.rb +94 -0
  46. data/mod/history/set/all/history/last.rb +97 -0
  47. data/mod/history/set/all/history/revision.rb +54 -0
  48. data/mod/history/set/all/history/selected.rb +64 -0
  49. data/mod/history/set/all/history/views.rb +34 -0
  50. data/mod/history/spec/set/all/history/views_spec.rb +29 -0
  51. data/mod/item/spec/set/all/bar_spec.rb +2 -2
  52. data/mod/machines/file/all_script_machine_output/file.js +66 -30621
  53. data/mod/machines/file/all_style_machine_output/file.css +2 -2
  54. data/mod/machines/file/script_html5shiv_printshiv_machine_output/file.js +1 -1
  55. data/mod/machines/lib/javascript/decko.js.coffee +1 -1
  56. data/mod/pointer/lib/javascript/script_pointer_config.js.coffee +1 -1
  57. data/mod/pointer/set/abstract/01_paging.rb +1 -0
  58. data/mod/pointer/set/abstract/02_pointer/html_views.rb +2 -2
  59. data/mod/pointer/set/abstract/02_pointer/html_views/checkbox_input.haml +2 -2
  60. data/mod/pointer/set/abstract/02_pointer/html_views/filter/filter_items.haml +1 -1
  61. data/mod/pointer/set/abstract/02_pointer/html_views/radio_input.haml +4 -4
  62. data/mod/pointer/set/abstract/02_pointer/options_api.rb +25 -1
  63. data/mod/pointer/set/abstract/02_pointer/other_views.rb +4 -0
  64. data/mod/pointer/spec/set/abstract/pointer/options_api_spec.rb +35 -0
  65. data/mod/search/set/abstract/search.rb +4 -114
  66. data/mod/search/set/abstract/search/views.rb +156 -0
  67. data/mod/search/set/abstract/wql_search.rb +10 -0
  68. data/mod/search/set/self/search.rb +3 -10
  69. data/mod/search/set/type/search_type.rb +5 -1
  70. data/mod/search/template/abstract/03_filter/filter_form.haml +1 -1
  71. data/mod/standard/set/all/error.rb +24 -192
  72. data/mod/standard/set/all/rich_html/content.rb +1 -1
  73. data/mod/standard/set/all/rich_html/error.rb +177 -0
  74. data/mod/standard/{template/all → set/all/rich_html}/error/not_found.haml +0 -0
  75. data/mod/standard/{template/all → set/all/rich_html}/error/server_error.haml +0 -0
  76. data/mod/standard/set/all/rich_html/form.rb +9 -9
  77. data/mod/standard/set/all/rich_html/menu.rb +14 -5
  78. data/mod/standard/spec/content/chunk/include_spec.rb +1 -2
  79. data/mod/standard/spec/set/type/search_type_spec.rb +1 -1
  80. data/mod/utility/set/abstract/bs_badge/bs_badge.haml +1 -1
  81. data/mod/utility/set/abstract/media.rb +3 -1
  82. metadata +20 -16
  83. data/lib/card/query/card_query/attribute_helper.rb +0 -74
  84. data/lib/card/query/card_query/special_attributes.rb +0 -49
  85. data/mod/history/set/all/action_view.rb +0 -52
  86. data/mod/history/set/all/actions.rb +0 -185
  87. data/mod/history/set/all/acts.rb +0 -16
  88. data/mod/history/set/all/content_history.rb +0 -180
  89. data/mod/history/spec/set/all/act_view_spec.rb +0 -16
  90. data/mod/history/spec/set/all/action_view_spec.rb +0 -10
  91. data/mod/history/spec/set/all/history_spec.rb +0 -11
@@ -59,6 +59,12 @@ def empty_query_error!
59
59
  "Error in card '#{name}':can't run search with empty content"
60
60
  end
61
61
 
62
+ def item_type
63
+ type = wql_hash[:type]
64
+ return if type.is_a?(Array) || type.is_a?(Hash)
65
+ type
66
+ end
67
+
62
68
  format do
63
69
  def default_limit
64
70
  card_content_limit || super
@@ -70,6 +76,10 @@ format do
70
76
  nil
71
77
  end
72
78
 
79
+ def implicit_item_view
80
+ super query_with_params.statement[:item]
81
+ end
82
+
73
83
  def query_with_params
74
84
  @query_with_params ||= card.fetch_query search_params
75
85
  end
@@ -1,5 +1,3 @@
1
- include_set Abstract::SearchParams
2
-
3
1
  def query_args args={}
4
2
  return super unless keyword_contains_wql? args
5
3
  args.merge parse_keyword_wql(args)
@@ -48,7 +46,7 @@ end
48
46
 
49
47
  format :json do
50
48
  view :complete, cache: :never do
51
- term = complete_term
49
+ term = term_param
52
50
  exact = Card.fetch term, new: {}
53
51
 
54
52
  {
@@ -75,7 +73,7 @@ format :json do
75
73
  end
76
74
 
77
75
  def goto_items term, exact
78
- goto_names = Card.search goto_wql(term), "goto items for term: #{term}"
76
+ goto_names = complete_or_match_search
79
77
  goto_names.unshift exact.name if add_exact_to_goto_names? exact, goto_names
80
78
  goto_names.map do |name|
81
79
  [name, name.to_name.url_key, highlight(name, term)]
@@ -86,16 +84,11 @@ format :json do
86
84
  exact.known? && !goto_names.find { |n| n.to_name.key == exact.key }
87
85
  end
88
86
 
89
- def complete_term
87
+ def term_param
90
88
  term = query_params[:keyword]
91
89
  if (term =~ /^\+/) && (main = params["main"])
92
90
  term = main + term
93
91
  end
94
92
  term
95
93
  end
96
-
97
- # hacky. here for override
98
- def goto_wql term
99
- { complete: term, limit: 8, sort: "name", return: "name" }
100
- end
101
94
  end
@@ -1,5 +1,5 @@
1
- include_set Abstract::WqlSearch
2
1
  include_set Type::Json
2
+ include_set Abstract::WqlSearch
3
3
 
4
4
  format do
5
5
  view :core, cache: :never do
@@ -48,6 +48,10 @@ format :rss do
48
48
  end
49
49
 
50
50
  format :html do
51
+ view :core do
52
+ _render search_result_view
53
+ end
54
+
51
55
  view :closed do
52
56
  voo.hide :closed_content
53
57
  super()
@@ -1,5 +1,5 @@
1
1
 
2
- .card.w-100
2
+ .card.w-100.nodblclick
3
3
  .card-body
4
4
  ._filter-widget
5
5
  ._filter-input-field-prototypes.d-none
@@ -9,222 +9,54 @@ format do
9
9
  ""
10
10
  end
11
11
 
12
- view :unsupported_view, perms: :none, tags: :unknown_ok, error_code: 404 do
13
- tr(:unsupported_view, view: voo.unsupported_view, cardname: error_cardname)
14
- end
15
-
16
12
  view :missing, perms: :none do
17
13
  ""
18
14
  end
19
15
 
20
- view :not_found, perms: :none, error_code: 404 do
21
- error_name = card.name.present? ? safe_name : tr(:not_found_no_name)
22
- tr(:not_found_named, cardname: error_name)
23
- end
24
-
25
- view :server_error, perms: :none, error_code: 500 do
16
+ view :server_error, perms: :none do
26
17
  tr(:server_error)
27
18
  end
28
19
 
29
- view :denial, perms: :none, error_code: 403 do
20
+ view :denial, perms: :none do
30
21
  focal? ? tr(:denial) : ""
31
22
  end
32
23
 
33
- view :bad_address, perms: :none, error_code: 404 do
34
- tr(:bad_address)
24
+ view :not_found, perms: :none do
25
+ error_name = card.name.present? ? safe_name : tr(:not_found_no_name)
26
+ tr(:not_found_named, cardname: error_name)
35
27
  end
36
28
 
37
- view :too_deep, perms: :none, closed: true do
38
- tr(:too_deep)
29
+ view :bad_address, perms: :none do
30
+ root.error_status = 404
31
+ tr(:bad_address)
39
32
  end
40
33
 
41
- view :too_slow, perms: :none, closed: true, error_code: 408 do
42
- tr(:too_slow, showname: title_in_context)
34
+ def unsupported_view_error_message view
35
+ tr(:unsupported_view, view: view, cardname: card.name)
43
36
  end
44
37
  end
45
38
 
46
- format :html do
47
- def view_for_unknown view
48
- case
49
- when focal? && ok?(:create) then :new
50
- when commentable?(view) then view
51
- else super
52
- end
53
- end
54
-
55
- def commentable? view
56
- return false unless self.class.tagged(view, :comment) &&
57
- show_view?(:comment_box, :hide)
58
- ok? :comment
59
- end
60
-
61
- def nested_error exception, view
62
- debug_error exception if Auth.always_ok?
63
- details = Auth.always_ok? ? backtrace_link(exception) : error_cardname
64
- wrap_with :span, class: "render-error alert alert-danger" do
65
- [tr(:error_rendering), details, "(#{view} view)"].join "\n"
66
- end
67
- end
68
-
69
- def backtrace_link exception
70
- class_up "alert", "render-error-message errors-view admin-error-message"
71
- warning = alert("warning", true) do
72
- %{
73
- <h3>Error message (visible to admin only)</h3>
74
- <p><strong>#{CGI.escapeHTML exception.message}</strong></p>
75
- <div>#{exception.backtrace * "<br>\n"}</div>
76
- }
77
- end
78
- link = link_to_card error_cardname, nil, class: "render-error-link"
79
- link + warning
80
- end
81
-
82
- view :unsupported_view, perms: :none, tags: :unknown_ok do
83
- %(
84
- <strong>
85
- view <em>#{voo.unsupported_view}</em>
86
- not supported for <em>#{error_cardname}</em>
87
- </strong>
88
- )
89
- end
90
-
91
- view :message, perms: :none, tags: :unknown_ok do
92
- frame { params[:message] }
93
- end
94
-
95
- view :missing do
96
- return "" unless card.ok? :create # should this be moved into ok_view?
97
- path_opts = voo.type ? { card: { type: voo.type } } : {}
98
- link_text = "Add #{_render_title}"
99
- klass = "slotter missing-#{@denied_view || voo.home_view}"
100
- wrap { link_to_view :new, link_text, path: path_opts, class: klass }
101
- end
102
-
103
- view :closed_missing, perms: :none do
104
- wrap_with :span, h(title_in_context), class: "faint"
105
- end
106
-
107
- view :conflict, error_code: 409, cache: :never do
108
- actor_link = link_to_card card.last_action.act.actor.name
109
- class_up "card-slot", "error-view"
110
- wrap do # ENGLISH below
111
- alert "warning" do
112
- %(
113
- <strong>Conflict!</strong>
114
- <span class="new-current-revision-id">#{card.last_action_id}</span>
115
- <div>#{actor_link} has also been making changes.</div>
116
- <div>Please examine below, resolve above, and re-submit.</div>
117
- #{render_act}
118
- )
119
- end
120
- end
121
- end
122
-
123
- view :errors, perms: :none do
124
- return if card.errors.empty?
125
- voo.title = card.name.blank? ? "Problems" : tr(:problems_name, cardname: card.name)
126
- voo.hide! :menu
127
- class_up "d0-card-frame", "card card-warning card-inverse"
128
- class_up "alert", "card-error-msg"
129
- frame { standard_errors }
39
+ format :json do
40
+ view :errors do
41
+ format_error error_list
130
42
  end
131
43
 
132
- def standard_errors
133
- card.errors.map do |attrib, msg|
134
- alert "warning", true do
135
- attrib == :abort ? h(msg) : standard_error_message(attrib, msg)
136
- end
137
- end
138
- end
139
-
140
- def standard_error_message attribute, message
141
- "<strong>#{h attribute.to_s.upcase}:</strong> #{h message}"
142
- end
143
-
144
- view :not_found do # ug. bad name.
145
- voo.hide! :menu
146
- voo.title = "Not Found"
147
- frame do
148
- [not_found_errors, sign_in_or_up_links("to create it")]
149
- end
150
- end
151
-
152
- def not_found_errors
153
- if card.errors.any?
154
- standard_errors
155
- else
156
- haml :not_found
157
- end
158
- end
159
-
160
- def sign_in_or_up_links to_task
161
- return if Auth.signed_in?
162
- links = [signin_link, signup_link].compact.join " #{tr :or} "
163
- wrap_with(:div) do
164
- [tr(:please), links, to_task].join(" ") + "."
165
- end
166
- end
167
-
168
- def signin_link
169
- link_to_card :signin, tr(:sign_in_c)
170
- end
171
-
172
- def signup_link
173
- return unless signup_ok?
174
- link_to tr(:sign_up_c), path: { action: :new, mark: :signup }
175
- end
176
-
177
- def signup_ok?
178
- Card.new(type_id: Card::SignupID).ok? :create
179
- end
180
-
181
- view :denial do
182
- focal? ? loud_denial : quiet_denial
183
- end
184
-
185
- def quiet_denial
186
- wrap_with :span, class: "denied" do
187
- "<!-- Sorry, you don't have permission (#{@denied_task}) -->"
188
- end
189
- end
44
+ view :server_error, :errors
45
+ view :denial, :errors
46
+ view :not_found, :errors
190
47
 
191
- def loud_denial
192
- frame do
193
- [wrap_with(:h1, tr(:sorry)),
194
- wrap_with(:div, loud_denial_message)]
195
- end
196
- end
197
-
198
- def loud_denial_message
199
- to_task = @denied_task ? tr(:denied_task, denied_task: @denied_task) : tr(:to_do_that)
200
-
201
- case
202
- when not_denied_task_read?
203
- tr(:read_only)
204
- when Auth.signed_in?
205
- tr(:need_permission_task, task: to_task)
206
- else
207
- Env.save_interrupted_action request.env["REQUEST_URI"]
208
- sign_in_or_up_links to_do_unauthorized_task
209
- end
210
- end
211
-
212
- def not_denied_task_read?
213
- @denied_task != :read && Card.config.read_only
48
+ view :bad_address do
49
+ format_error super()
214
50
  end
215
51
 
216
- def to_do_unauthorized_task
217
- @denied_task ? tr(:denied_task, denied_task: @denied_task) : tr(:to_do_that)
52
+ def format_error error
53
+ { error_status: error_status,
54
+ errors: error }
218
55
  end
219
56
 
220
- def denial_message_with_links to_task
221
- linx = [link_to_card(:signin, "sign in")]
222
- if Card.new(type_id: Card::SignupID).ok?(:create)
223
- [tr(:or), link_to(tr(:sign_up), path: { action: "new", mark: :signup })]
57
+ def error_list
58
+ card.errors.each_with_object([]) do |(field, message), list|
59
+ list << { field: field, message: message }
224
60
  end
225
- Env.save_interrupted_action request.env["REQUEST_URI"]
226
- "#{tr(:please)} #{linx.join ' '} #{to_task}"
227
61
  end
228
-
229
- view :server_error, template: :haml
230
62
  end
@@ -147,7 +147,7 @@ format :html do
147
147
  def rule_based_help
148
148
  return "" unless (rule_card = card.help_rule_card)
149
149
  with_nest_mode :normal do
150
- process_content _render_raw(structure: rule_card.name), chunk_list: :references
150
+ process_content rule_card.content, chunk_list: :references
151
151
  # render help card with current card's format
152
152
  # so current card's context is used in help card nests
153
153
  end
@@ -0,0 +1,177 @@
1
+ format :html do
2
+ view :server_error, template: :haml
3
+
4
+ view :message, perms: :none, tags: :unknown_ok do
5
+ frame { params[:message] }
6
+ end
7
+
8
+ view :missing do
9
+ return "" unless card.ok? :create # should this be moved into ok_view?
10
+ path_opts = voo.type ? { card: { type: voo.type } } : {}
11
+ link_text = "Add #{_render_title}"
12
+ klass = "slotter missing-#{@denied_view || voo.home_view}"
13
+ wrap { link_to_view :new, link_text, path: path_opts, class: klass }
14
+ end
15
+
16
+ view :closed_missing, perms: :none do
17
+ wrap_with :span, h(title_in_context), class: "faint"
18
+ end
19
+
20
+ view :conflict, cache: :never do
21
+ actor_link = link_to_card card.last_action.act.actor.name
22
+ class_up "card-slot", "error-view"
23
+ wrap do # ENGLISH below
24
+ alert "warning" do
25
+ %(
26
+ <strong>Conflict!</strong>
27
+ <span class="new-current-revision-id">#{card.last_action_id}</span>
28
+ <div>#{actor_link} has also been making changes.</div>
29
+ <div>Please examine below, resolve above, and re-submit.</div>
30
+ #{render_act}
31
+ )
32
+ end
33
+ end
34
+ end
35
+
36
+ view :errors, perms: :none do
37
+ return if card.errors.empty?
38
+ voo.title = card.name.blank? ? "Problems" : tr(:problems_name, cardname: card.name)
39
+ voo.hide! :menu
40
+ class_up "d0-card-frame", "card card-warning card-inverse"
41
+ class_up "alert", "card-error-msg"
42
+ frame { standard_errors }
43
+ end
44
+
45
+ view :not_found do
46
+ voo.hide! :menu
47
+ voo.title = "Not Found"
48
+ frame do
49
+ [not_found_errors, sign_in_or_up_links("to create it")]
50
+ end
51
+ end
52
+
53
+ view :denial do
54
+ focal? ? loud_denial : quiet_denial
55
+ end
56
+
57
+ def view_for_unknown view
58
+ case
59
+ when focal? && ok?(:create) then :new
60
+ when commentable?(view) then view
61
+ else super
62
+ end
63
+ end
64
+
65
+ def commentable? view
66
+ return false unless self.class.tagged(view, :comment) &&
67
+ show_view?(:comment_box, :hide)
68
+ ok? :comment
69
+ end
70
+
71
+ def show_all_errors?
72
+ # make configurable by env
73
+ Auth.always_ok? || Rails.env.development?
74
+ end
75
+
76
+ def error_cardname exception
77
+ cardname = super
78
+ show_all_errors? ? backtrace_link(cardname, exception) : cardname
79
+ end
80
+
81
+ def rendering_error exception, view
82
+ wrap_with(:span, class: "render-error alert alert-danger") { super }
83
+ end
84
+
85
+ def error_modal_id
86
+ @error_modal_id ||= unique_id
87
+ end
88
+
89
+ def error_message exception
90
+ %{
91
+ <h3>Error message (visible to admin only)</h3>
92
+ <p><strong>#{CGI.escapeHTML exception.message}</strong></p>
93
+ <div>#{exception.backtrace * "<br>\n"}</div>
94
+ }
95
+ end
96
+
97
+ def backtrace_link cardname, exception
98
+ # TODO: make this a modal link after new modal handling is merged in
99
+ wrap_with(:span, title: error_message(exception)) { cardname }
100
+ end
101
+
102
+ def standard_errors
103
+ card.errors.map do |attrib, msg|
104
+ alert "warning", true do
105
+ attrib == :abort ? h(msg) : standard_error_message(attrib, msg)
106
+ end
107
+ end
108
+ end
109
+
110
+ def standard_error_message attribute, message
111
+ "<strong>#{h attribute.to_s.upcase}:</strong> #{h message}"
112
+ end
113
+
114
+ def not_found_errors
115
+ if card.errors.any?
116
+ standard_errors
117
+ else
118
+ haml :not_found
119
+ end
120
+ end
121
+
122
+ def sign_in_or_up_links to_task
123
+ return if Auth.signed_in?
124
+ links = [signin_link, signup_link].compact.join " #{tr :or} "
125
+ wrap_with(:div) do
126
+ [tr(:please), links, to_task].join(" ") + "."
127
+ end
128
+ end
129
+
130
+ def signin_link
131
+ link_to_card :signin, tr(:sign_in)
132
+ end
133
+
134
+ def signup_link
135
+ return unless signup_ok?
136
+ link_to tr(:sign_up), path: { action: :new, mark: :signup }
137
+ end
138
+
139
+ def signup_ok?
140
+ Card.new(type_id: Card::SignupID).ok? :create
141
+ end
142
+
143
+ def quiet_denial
144
+ wrap_with :span, class: "denied" do
145
+ "<!-- Sorry, you don't have permission (#{@denied_task}) -->"
146
+ end
147
+ end
148
+
149
+ def loud_denial
150
+ frame do
151
+ [wrap_with(:h1, tr(:sorry)),
152
+ wrap_with(:div, loud_denial_message)]
153
+ end
154
+ end
155
+
156
+ def loud_denial_message
157
+ to_task = @denied_task ? tr(:denied_task, denied_task: @denied_task) : tr(:to_do_that)
158
+
159
+ case
160
+ when not_denied_task_read?
161
+ tr(:read_only)
162
+ when Auth.signed_in?
163
+ tr(:need_permission_task, task: to_task)
164
+ else
165
+ Env.save_interrupted_action request.env["REQUEST_URI"]
166
+ sign_in_or_up_links to_do_unauthorized_task
167
+ end
168
+ end
169
+
170
+ def not_denied_task_read?
171
+ @denied_task != :read && Card.config.read_only
172
+ end
173
+
174
+ def to_do_unauthorized_task
175
+ @denied_task ? tr(:denied_task, denied_task: @denied_task) : tr(:to_do_that)
176
+ end
177
+ end