Merge branch 'master' into es17.01
This commit is contained in:
@@ -260,7 +260,7 @@ feature -- Form
|
|||||||
l_node_path: READABLE_STRING_8
|
l_node_path: READABLE_STRING_8
|
||||||
l_path_alias, l_existing_path_alias, l_auto_path_alias: detachable READABLE_STRING_8
|
l_path_alias, l_existing_path_alias, l_auto_path_alias: detachable READABLE_STRING_8
|
||||||
do
|
do
|
||||||
fixme ("Refactor code per operation: Preview, Save/Publish/UnPublish")
|
-- Potential operations : Preview, Save/Publish/UnPublish")
|
||||||
l_preview := attached {WSF_STRING} fd.item ("op") as l_op and then l_op.same_string (preview_submit_label)
|
l_preview := attached {WSF_STRING} fd.item ("op") as l_op and then l_op.same_string (preview_submit_label)
|
||||||
if not l_preview then
|
if not l_preview then
|
||||||
l_op_save := True
|
l_op_save := True
|
||||||
|
|||||||
@@ -139,9 +139,7 @@ feature -- HTTP Methods
|
|||||||
elseif l_node = Void then
|
elseif l_node = Void then
|
||||||
send_not_found (req, res)
|
send_not_found (req, res)
|
||||||
else
|
else
|
||||||
if
|
if l_is_published then
|
||||||
l_rev > 0 and l_is_published
|
|
||||||
then
|
|
||||||
create view_response.make (req, res, api, node_api)
|
create view_response.make (req, res, api, node_api)
|
||||||
view_response.set_node (l_node)
|
view_response.set_node (l_node)
|
||||||
view_response.set_revision (l_rev)
|
view_response.set_revision (l_rev)
|
||||||
@@ -149,7 +147,9 @@ feature -- HTTP Methods
|
|||||||
elseif
|
elseif
|
||||||
attached api.user as l_user and then
|
attached api.user as l_user and then
|
||||||
( node_api.is_author_of_node (l_user, l_node)
|
( node_api.is_author_of_node (l_user, l_node)
|
||||||
or else api.user_has_permission (l_user, "view unpublished " + l_node.content_type)
|
or else (
|
||||||
|
api.user_has_permission (l_user, "view unpublished " + l_node.content_type)
|
||||||
|
)
|
||||||
)
|
)
|
||||||
then
|
then
|
||||||
create view_response.make (req, res, api, node_api)
|
create view_response.make (req, res, api, node_api)
|
||||||
|
|||||||
@@ -281,11 +281,12 @@ feature -- Filters
|
|||||||
l_module: CMS_MODULE
|
l_module: CMS_MODULE
|
||||||
l_api: like api
|
l_api: like api
|
||||||
do
|
do
|
||||||
api.logger.put_debug (generator + ".create_filter", Void)
|
l_api := api
|
||||||
|
l_api.logger.put_debug (generator + ".create_filter", Void)
|
||||||
l_filter := Void
|
l_filter := Void
|
||||||
|
|
||||||
-- Maintenance
|
-- Maintenance
|
||||||
create {WSF_MAINTENANCE_FILTER} f
|
create {CMS_MAINTENANCE_FILTER} f.make (Void, l_api)
|
||||||
f.set_next (l_filter)
|
f.set_next (l_filter)
|
||||||
l_filter := f
|
l_filter := f
|
||||||
|
|
||||||
@@ -295,7 +296,6 @@ feature -- Filters
|
|||||||
-- l_filter := f
|
-- l_filter := f
|
||||||
|
|
||||||
-- Include filters from modules
|
-- Include filters from modules
|
||||||
l_api := api
|
|
||||||
across
|
across
|
||||||
modules as ic
|
modules as ic
|
||||||
loop
|
loop
|
||||||
|
|||||||
109
src/service/filter/cms_maintenance_filter.e
Normal file
109
src/service/filter/cms_maintenance_filter.e
Normal file
@@ -0,0 +1,109 @@
|
|||||||
|
note
|
||||||
|
description: "Summary description for {CMS_MAINTENANCE_FILTER}."
|
||||||
|
author: ""
|
||||||
|
date: "$Date$"
|
||||||
|
revision: "$Revision$"
|
||||||
|
|
||||||
|
class
|
||||||
|
CMS_MAINTENANCE_FILTER
|
||||||
|
|
||||||
|
inherit
|
||||||
|
WSF_FILTER
|
||||||
|
|
||||||
|
create
|
||||||
|
make
|
||||||
|
|
||||||
|
feature {NONE} -- Initialization
|
||||||
|
|
||||||
|
make (a_name: detachable READABLE_STRING_GENERAL; a_api: CMS_API)
|
||||||
|
do
|
||||||
|
api := a_api
|
||||||
|
if a_name /= Void then
|
||||||
|
maintenance_fn := a_name
|
||||||
|
else
|
||||||
|
maintenance_fn := ".maintenance"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
feature -- Access
|
||||||
|
|
||||||
|
api: CMS_API
|
||||||
|
|
||||||
|
maintenance_fn: READABLE_STRING_GENERAL
|
||||||
|
|
||||||
|
feature -- Basic operations
|
||||||
|
|
||||||
|
execute (req: WSF_REQUEST; res: WSF_RESPONSE)
|
||||||
|
-- Execute the filter
|
||||||
|
local
|
||||||
|
l_line,s: STRING
|
||||||
|
h: HTTP_HEADER
|
||||||
|
f: PLAIN_TEXT_FILE
|
||||||
|
l_allow_user: STRING_8
|
||||||
|
l_allow_ip: STRING_8
|
||||||
|
do
|
||||||
|
create f.make_with_name (maintenance_fn)
|
||||||
|
if f.exists then
|
||||||
|
create s.make (64)
|
||||||
|
if f.is_access_readable then
|
||||||
|
f.open_read
|
||||||
|
from
|
||||||
|
until
|
||||||
|
f.exhausted
|
||||||
|
loop
|
||||||
|
f.read_line
|
||||||
|
l_line := f.last_string
|
||||||
|
if l_line.starts_with_general ("#") then
|
||||||
|
if l_line.starts_with_general ("#allow-user:") then
|
||||||
|
l_allow_user := l_line.substring (l_line.index_of (':', 1) + 1, l_line.count)
|
||||||
|
l_allow_user.adjust
|
||||||
|
if l_allow_user.is_empty then
|
||||||
|
l_allow_user := Void
|
||||||
|
end
|
||||||
|
elseif l_line.starts_with_general ("#allow-ip:") then
|
||||||
|
l_allow_ip := l_line.substring (l_line.index_of (':', 1) + 1, l_line.count)
|
||||||
|
l_allow_ip.adjust
|
||||||
|
if l_allow_ip.is_empty then
|
||||||
|
l_allow_ip := Void
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
s.append (l_line)
|
||||||
|
s.append_character ('%N')
|
||||||
|
end
|
||||||
|
end
|
||||||
|
f.close
|
||||||
|
end
|
||||||
|
if s.is_empty then
|
||||||
|
s.append ("In maintenance, please come back later ...")
|
||||||
|
end
|
||||||
|
if
|
||||||
|
l_allow_user /= Void and then
|
||||||
|
attached api.user as u and then
|
||||||
|
u.name.same_string_general (l_allow_user)
|
||||||
|
then
|
||||||
|
-- User allowed!
|
||||||
|
execute_next (req, res)
|
||||||
|
elseif
|
||||||
|
l_allow_ip /= Void and then
|
||||||
|
req.remote_addr.same_string (l_allow_ip)
|
||||||
|
then
|
||||||
|
-- IP allowed!
|
||||||
|
execute_next (req, res)
|
||||||
|
else
|
||||||
|
create h.make_with_count (1)
|
||||||
|
h.put_content_length (s.count)
|
||||||
|
h.put_content_type_text_plain
|
||||||
|
res.set_status_code ({HTTP_STATUS_CODE}.service_unavailable)
|
||||||
|
res.put_header_lines (h)
|
||||||
|
res.put_string (s)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
execute_next (req, res)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
note
|
||||||
|
copyright: "2011-2017, Jocelyn Fiat, Javier Velilla, Eiffel Software and others"
|
||||||
|
license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)"
|
||||||
|
end
|
||||||
Reference in New Issue
Block a user