Module: Card::Set::All::Html::Error::HtmlFormat
- Extended by:
- Card::Set::AbstractFormat
- Defined in:
- platypus/tmp/set/gem-defaults/mod004-format/all/html/error.rb
Instance Method Summary collapse
-
#backtrace_link(cardname, exception) ⇒ Object
-
#createable ⇒ Object
-
#error_cardname(exception) ⇒ Object
-
#error_message(exception) ⇒ Object
-
#error_modal_id ⇒ Object
-
#loud_denial ⇒ Object
-
#loud_denial_message ⇒ Object
-
#not_denied_task_read? ⇒ Boolean
-
#not_found_errors ⇒ Object
-
#quiet_denial ⇒ Object
-
#rendering_error(exception, view) ⇒ Object
-
#show_all_errors? ⇒ Boolean
-
#sign_in_or_up_links(to_task) ⇒ Object
-
#signin_link ⇒ Object
-
#signup_link ⇒ Object
-
#signup_ok? ⇒ Boolean
-
#simple_error_message(message) ⇒ Object
-
#standard_error_message(error) ⇒ Object
-
#standard_errors(heading = nil) ⇒ Object
-
#to_do_unauthorized_task ⇒ Object
-
#unknown_icon ⇒ Object
-
#unknown_link(text) ⇒ Object
-
#view: compact_missing ⇒ Object
-
#view: conflict ⇒ Object
-
#view: debug_server_error ⇒ Object
-
#view: denial ⇒ Object
-
#view: errors ⇒ Object
-
#view: mini_unknown ⇒ Object
icon only, no wrap.
-
#view: not_found ⇒ Object
-
#view: server_error ⇒ Object
-
#view: unknown ⇒ Object
-
#view_for_unknown(setting_view) ⇒ Object
Instance Method Details
#backtrace_link(cardname, exception) ⇒ Object
116 117 118 119 |
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/error.rb', line 116 def backtrace_link cardname, exception # TODO: make this a modal link after new modal handling is merged in wrap_with(:span, title: (exception)) { cardname } end |
#createable ⇒ Object
26 27 28 |
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/error.rb', line 26 def createable card.ok?(:create) ? yield : "" end |
#error_cardname(exception) ⇒ Object
95 96 97 98 |
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/error.rb', line 95 def error_cardname exception cardname = super show_all_errors? ? backtrace_link(cardname, exception) : cardname end |
#error_message(exception) ⇒ Object
108 109 110 111 112 113 114 |
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/error.rb', line 108 def exception %{ <h3>Error message (visible to admin only)</h3> <p><strong>#{CGI.escapeHTML exception.}</strong></p> <div>#{exception.backtrace * "<br>\n"}</div> } end |
#error_modal_id ⇒ Object
104 105 106 |
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/error.rb', line 104 def error_modal_id @error_modal_id ||= unique_id end |
#loud_denial ⇒ Object
177 178 179 180 181 182 183 |
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/error.rb', line 177 def loud_denial voo.hide :menu frame do [wrap_with(:h1, t(:format_sorry)), wrap_with(:div, )] end end |
#loud_denial_message ⇒ Object
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 |
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/error.rb', line 185 def to_task = if @denied_task t(:format_denied_task, denied_task: @denied_task) else t(:format_to_do_that) end case when not_denied_task_read? t(:format_read_only) when Auth.signed_in? t(:format_need_permission_task, task: to_task) else Env.save_interrupted_action request.env["REQUEST_URI"] sign_in_or_up_links end end |
#not_denied_task_read? ⇒ Boolean
204 205 206 |
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/error.rb', line 204 def not_denied_task_read? @denied_task != :read && Card.config.read_only end |
#not_found_errors ⇒ Object
138 139 140 141 142 143 144 |
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/error.rb', line 138 def not_found_errors if card.errors.any? standard_errors else haml :not_found end end |
#quiet_denial ⇒ Object
171 172 173 174 175 |
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/error.rb', line 171 def quiet_denial wrap_with :span, class: "denied" do "<!-- Sorry, you don't have permission (#{@denied_task}) -->" end end |
#rendering_error(exception, view) ⇒ Object
100 101 102 |
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/error.rb', line 100 def rendering_error exception, view wrap_with(:span, class: "render-error alert alert-danger") { super } end |
#show_all_errors? ⇒ Boolean
90 91 92 93 |
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/error.rb', line 90 def show_all_errors? # make configurable by env Auth.always_ok? || Rails.env.development? end |
#sign_in_or_up_links(to_task) ⇒ Object
146 147 148 149 150 151 152 153 |
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/error.rb', line 146 def sign_in_or_up_links to_task return if Auth.signed_in? links = [signin_link, signup_link].compact.join " #{t(:format_or)} " wrap_with(:div) do "#{[t(:format_please), links, to_task].join(' ')}." end end |
#signin_link ⇒ Object
155 156 157 158 |
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/error.rb', line 155 def signin_link link_to_card :signin, t(:account_sign_in)&.downcase, class: "signin-link", path: { view: :titled } end |
#signup_link ⇒ Object
160 161 162 163 164 165 |
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/error.rb', line 160 def signup_link return unless signup_ok? link_to_card :signup, t(:account_sign_up)&.downcase, class: "signup-link", path: { action: :new } end |
#signup_ok? ⇒ Boolean
167 168 169 |
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/error.rb', line 167 def signup_ok? Card.new(type_id: Card::SignupID).ok? :create end |
#simple_error_message(message) ⇒ Object
130 131 132 |
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/error.rb', line 130 def h end |
#standard_error_message(error) ⇒ Object
134 135 136 |
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/error.rb', line 134 def error "<p><strong>#{h error.attribute.to_s.upcase}:</strong> #{h error.}</p>" end |
#standard_errors(heading = nil) ⇒ Object
121 122 123 124 125 126 127 128 |
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/error.rb', line 121 def standard_errors heading=nil alert "warning", true do [ (wrap_with(:h4, heading, class: "alert-heading error") if heading), .join("<hr>") ] end end |
#to_do_unauthorized_task ⇒ Object
208 209 210 211 212 213 214 215 |
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/error.rb', line 208 def if @denied_task t(:format_denied_task, denied_task: @denied_task) else t(:format_to_do_that) end end |
#unknown_icon ⇒ Object
36 37 38 |
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/error.rb', line 36 def unknown_icon icon_tag :unknown end |
#unknown_link(text) ⇒ Object
30 31 32 33 34 |
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/error.rb', line 30 def unknown_link text link_to_view :new_in_modal, text, path: (voo.type ? { card: { type: voo.type } } : {}), class: classy("unknown-link") end |
#view: compact_missing ⇒ Object
40 41 42 |
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/error.rb', line 40 view :compact_missing, perms: :none do wrap_with :span, h(title_in_context), class: "text-muted" end |
#view: conflict ⇒ Object
44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/error.rb', line 44 view :conflict, cache: :never do actor_link = link_to_card card.last_action.act.actor.name class_up "card-slot", "error-view" wrap do # LOCALIZE alert "warning" do %( <strong>Conflict!</strong> <span class="new-current-revision-id">#{card.last_action_id}</span> <div>#{actor_link} has also been making changes.</div> <div>Please examine below, resolve above, and re-submit.</div> #{render_act} ) end end end |
#view: debug_server_error ⇒ Object
11 12 13 14 15 |
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/error.rb', line 11 view :debug_server_error, wrap: { modal: { size: :full } } do error_page = BetterErrors::ErrorPage.new Card::Error.current, "PATH_INFO" => request.env["REQUEST_URI"] haml :debug_server_error, {}, error_page end |
#view: denial ⇒ Object
82 83 84 |
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/error.rb', line 82 view :denial do focal? ? loud_denial : quiet_denial end |
#view: errors ⇒ Object
60 61 62 63 64 65 66 67 68 69 70 71 72 |
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/error.rb', line 60 view :errors, perms: :none do return if card.errors.empty? voo.title = if card.name.blank? "Problems" else t(:format_problems_name, cardname: card.name) end voo.hide! :menu class_up "alert", "card-error-msg" standard_errors voo.title end |
#view: mini_unknown ⇒ Object
icon only, no wrap
22 23 24 |
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/error.rb', line 22 view :mini_unknown, unknown: true, cache: :never do createable { unknown_link unknown_icon } end |
#view: not_found ⇒ Object
74 75 76 77 78 79 80 |
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/error.rb', line 74 view :not_found, cache: :never do voo.hide! :menu voo.title = "Not Found" frame do [not_found_errors, sign_in_or_up_links("to create it")] end end |
#view: server_error ⇒ Object
9 |
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/error.rb', line 9 view :server_error, template: :haml |
#view: unknown ⇒ Object
17 18 19 |
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/error.rb', line 17 view :unknown do createable { wrap { unknown_link "#{unknown_icon} #{render_title}" } } end |
#view_for_unknown(setting_view) ⇒ Object
86 87 88 |
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/error.rb', line 86 def view_for_unknown setting_view main? && voo.root? && ok?(:create) ? :new : super end |