-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
126 additions
and
109 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
class Releaf::Core::ErrorsController < ::Releaf::BaseController | ||
class Releaf::Core::ErrorsController < Releaf::BaseController | ||
def page_not_found | ||
error_response('page_not_found', 404) | ||
respond_with(nil, responder: action_responder(:page_not_found)) | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,6 @@ def setup | |
@features = { | ||
edit: true, | ||
index: true, | ||
edit_ajax_reload: true | ||
} | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
module Releaf::Responders | ||
|
||
def respond_with(resource = nil, options = {}, &block) | ||
options[:responder] = active_responder unless options.has_key? :responder | ||
super | ||
end | ||
|
||
def action_responders | ||
{ | ||
create: Releaf::Responders::AfterSaveResponder, | ||
update: Releaf::Responders::AfterSaveResponder, | ||
confirm_destroy: Releaf::Responders::ConfirmDestroyResponder, | ||
destroy: Releaf::Responders::DestroyResponder, | ||
access_denied: Releaf::Responders::AccessDeniedResponder, | ||
feature_disabled: Releaf::Responders::FeatureDisabledResponder, | ||
page_not_found: Releaf::Responders::PageNotFoundResponder, | ||
} | ||
end | ||
|
||
# Returns generic view name for given action | ||
# @return String | ||
def action_responder(_action_name) | ||
action_responders[_action_name.to_sym] | ||
end | ||
|
||
# Returns generic view name for current action | ||
# @return String | ||
def active_responder | ||
action_responder(action_name) | ||
end | ||
end |
9 changes: 9 additions & 0 deletions
9
releaf-core/app/lib/releaf/responders/access_denied_responder.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module Releaf::Responders | ||
class AccessDeniedResponder < ActionController::Responder | ||
include Releaf::Responders::ErrorResponder | ||
|
||
def status_code | ||
403 | ||
end | ||
end | ||
end |
13 changes: 13 additions & 0 deletions
13
releaf-core/app/lib/releaf/responders/confirm_destroy_responder.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
module Releaf::Responders | ||
class ConfirmDestroyResponder < ActionController::Responder | ||
delegate :render_notification, to: :controller | ||
|
||
def to_html | ||
if options[:destroyable] | ||
super | ||
else | ||
render 'refused_destroy' | ||
end | ||
end | ||
end | ||
end |
10 changes: 10 additions & 0 deletions
10
releaf-core/app/lib/releaf/responders/destroy_responder.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
module Releaf::Responders | ||
class DestroyResponder < ActionController::Responder | ||
delegate :render_notification, to: :controller | ||
|
||
def to_html | ||
render_notification(@resource.destroyed?, failure_message_key: 'cant destroy, because relations exists') | ||
super | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module Releaf::Responders::ErrorResponder | ||
def template | ||
self.class.name.split("::").last.gsub(/Responder$/, "").underscore | ||
end | ||
|
||
def to_html | ||
render "releaf/error_pages/#{template}", status: status_code | ||
end | ||
end |
9 changes: 9 additions & 0 deletions
9
releaf-core/app/lib/releaf/responders/feature_disabled_responder.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module Releaf::Responders | ||
class FeatureDisabledResponder < ActionController::Responder | ||
include Releaf::Responders::ErrorResponder | ||
|
||
def status_code | ||
403 | ||
end | ||
end | ||
end |
9 changes: 9 additions & 0 deletions
9
releaf-core/app/lib/releaf/responders/page_not_found_responder.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
module Releaf::Responders | ||
class PageNotFoundResponder < ActionController::Responder | ||
include Releaf::Responders::ErrorResponder | ||
|
||
def status_code | ||
404 | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.