Added blog module as example, this is far from being a real blog module.

but this is an example about on to add a new content type, and support it.
Fixed new node form workflow.

The current state is not final, it requires many changes, but for now, it implements a node editing workflow.
This commit is contained in:
2015-04-15 22:32:38 +02:00
parent f2bb061488
commit a56338ad17
21 changed files with 1040 additions and 226 deletions

View File

@@ -147,25 +147,38 @@ feature -- Permissions system
feature -- Query: module
module (a_type: TYPE [CMS_MODULE]): detachable CMS_MODULE
module (a_type: TYPE [detachable CMS_MODULE]): detachable CMS_MODULE
-- Enabled module typed `a_type', if any.
--| usage: if attached module ({FOO_MODULE}) as mod then ...
local
t: STRING_8
l_type: TYPE [detachable CMS_MODULE]
do
t := a_type.name
if t.starts_with ("!") then
t.remove_head (1)
end
across
setup.modules as ic
until
Result /= Void
loop
Result := ic.item
if
not Result.is_enabled
or else Result.generating_type /~ a_type
then
if not Result.is_enabled then
Result := Void
else
l_type := Result.generating_type
if a_type ~ l_type then
-- Found
elseif t.same_string (l_type.name) then
-- Found
else
Result := Void
end
end
end
ensure
Result /= Void implies (Result.is_enabled and Result.generating_type ~ a_type)
Result /= Void implies (Result.is_enabled) -- and a_type.is_conforming_to (Result.generating_type))
end
module_api (a_type: TYPE [CMS_MODULE]): detachable CMS_MODULE_API

View File

@@ -1050,11 +1050,20 @@ feature {NONE} -- Execution
h := page.header
h.put_content_length (page.html.count)
h.put_current_date
h.put_header_object (header)
if attached redirection as l_location then
h.put_location (l_location)
-- FIXME: find out if this is safe or not.
if l_location.has_substring ("://") then
-- h.put_location (l_location)
response.redirect_now (l_location)
else
-- h.put_location (request.absolute_script_url (l_location))
response.redirect_now (request.absolute_script_url (l_location))
end
else
h.put_header_object (header)
response.send (page)
end
response.send (page)
on_terminated
end

View File

@@ -46,13 +46,22 @@ feature -- Status report
elseif a_user = Void then
Result := user_role_has_permission (anonymous_user_role, a_permission)
else
Result := user_role_has_permission (authenticated_user_role, a_permission)
if not Result then
Result := across user_roles (a_user) as ic some user_role_has_permission (ic.item, a_permission) end
if is_admin_user (a_user) then
Result := True
else
Result := user_role_has_permission (authenticated_user_role, a_permission)
if not Result then
Result := across user_roles (a_user) as ic some user_role_has_permission (ic.item, a_permission) end
end
end
end
end
is_admin_user (u: CMS_USER): BOOLEAN
do
Result := u.id = 1
end
user_roles (a_user: CMS_USER): LIST [CMS_USER_ROLE]
local
l_roles: detachable LIST [CMS_USER_ROLE]