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

Instance Method Details



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: error_message(exception)) { cardname }
end

#createableObject



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 error_message exception
  %{
    <h3>Error message (visible to admin only)</h3>
    <p><strong>#{CGI.escapeHTML exception.message}</strong></p>
    <div>#{exception.backtrace * "<br>\n"}</div>
  }
end

#error_modal_idObject



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_denialObject



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, loud_denial_message)]
  end
end

#loud_denial_messageObject



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 loud_denial_message
  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"]
     to_do_unauthorized_task
  end
end

#not_denied_task_read?Boolean

Returns:

  • (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_errorsObject



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_denialObject



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

Returns:

  • (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


146
147
148
149
150
151
152
153
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/error.rb', line 146

def  to_task
  return if Auth.signed_in?

  links = [, ].compact.join " #{t(:format_or)} "
  wrap_with(:div) do
    "#{[t(:format_please), links, to_task].join(' ')}."
  end
end


155
156
157
158
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/error.rb', line 155

def 
  link_to_card :signin, t(:account_sign_in)&.downcase,
               class: "signin-link", path: { view: :titled }
end


160
161
162
163
164
165
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/error.rb', line 160

def 
  return unless 

  link_to_card :signup, t(:account_sign_up)&.downcase,
               class: "signup-link", path: { action: :new }
end

#signup_ok?Boolean

Returns:

  • (Boolean)


167
168
169
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/error.rb', line 167

def 
  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 simple_error_message message
  h message
end

#standard_error_message(error) ⇒ Object



134
135
136
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/error.rb', line 134

def standard_error_message error
  "<p><strong>#{h error.attribute.to_s.upcase}:</strong> #{h error.message}</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),
      error_messages.join("<hr>")
    ]
  end
end

#to_do_unauthorized_taskObject



208
209
210
211
212
213
214
215
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/error.rb', line 208

def to_do_unauthorized_task
  if @denied_task
    t(:format_denied_task,
      denied_task: @denied_task)
  else
    t(:format_to_do_that)
  end
end

#unknown_iconObject



36
37
38
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/error.rb', line 36

def unknown_icon
  icon_tag :unknown
end


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_missingObject



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: conflictObject



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_errorObject



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: denialObject



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: errorsObject



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_unknownObject

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_foundObject



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, ("to create it")]
  end
end

#view: server_errorObject



9
# File 'platypus/tmp/set/gem-defaults/mod004-format/all/html/error.rb', line 9

view :server_error, template: :haml

#view: unknownObject



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