From a51d0d3c68006681a60047114beb1aa2c1446b94 Mon Sep 17 00:00:00 2001 From: Jocelyn Fiat Date: Thu, 13 Nov 2014 10:50:22 +0100 Subject: [PATCH 1/3] Added copyright, various description notes. Added CMS_EXTERNAL_LINK, and improve various link interfaces. Structured the model library with sub folder: user, link and content. --- README.md | 1 + cms/layout/license.lic | 3 + cms/layout/src/application_layout.e | 21 ++- .../configuration/database_configuration.e | 3 + .../src/configuration/json_configuration.e | 3 + .../src/configuration/logger_configuration.e | 7 +- cms/layout/src/error/basic_error_handler.e | 3 + cms/layout/src/error/shared_error.e | 3 + cms/layout/src/logger/logging_facility.e | 3 + cms/layout/src/logger/shared_logger.e | 3 + cms/license.lic | 3 + cms/model/license.lic | 3 + cms/model/src/cms_content_type.e | 10 -- cms/model/src/cms_link_composite.e | 27 ---- cms/model/src/cms_user_profile.e | 48 ------- cms/model/src/cms_user_role.e | 90 ------------- cms/model/src/content/cms_content_type.e | 15 +++ cms/model/src/{ => content}/cms_node.e | 39 ++++-- cms/model/src/link/cms_external_link.e | 53 ++++++++ cms/model/src/{ => link}/cms_link.e | 26 +++- cms/model/src/link/cms_link_composite.e | 52 ++++++++ cms/model/src/{ => link}/cms_local_link.e | 69 +++++++--- cms/model/src/{ => link}/cms_menu.e | 45 +++++-- cms/model/src/{ => user}/cms_user.e | 100 +++++++++------ cms/model/src/user/cms_user_profile.e | 56 ++++++++ cms/model/src/user/cms_user_role.e | 120 ++++++++++++++++++ 26 files changed, 534 insertions(+), 272 deletions(-) create mode 100644 README.md create mode 100644 cms/layout/license.lic create mode 100644 cms/license.lic create mode 100644 cms/model/license.lic delete mode 100644 cms/model/src/cms_content_type.e delete mode 100644 cms/model/src/cms_link_composite.e delete mode 100644 cms/model/src/cms_user_profile.e delete mode 100644 cms/model/src/cms_user_role.e create mode 100644 cms/model/src/content/cms_content_type.e rename cms/model/src/{ => content}/cms_node.e (84%) create mode 100644 cms/model/src/link/cms_external_link.e rename cms/model/src/{ => link}/cms_link.e (62%) create mode 100644 cms/model/src/link/cms_link_composite.e rename cms/model/src/{ => link}/cms_local_link.e (67%) rename cms/model/src/{ => link}/cms_menu.e (50%) rename cms/model/src/{ => user}/cms_user.e (63%) create mode 100644 cms/model/src/user/cms_user_profile.e create mode 100644 cms/model/src/user/cms_user_role.e diff --git a/README.md b/README.md new file mode 100644 index 0000000..118e4b5 --- /dev/null +++ b/README.md @@ -0,0 +1 @@ +ROC: The REST On CMS solution diff --git a/cms/layout/license.lic b/cms/layout/license.lic new file mode 100644 index 0000000..1f97942 --- /dev/null +++ b/cms/layout/license.lic @@ -0,0 +1,3 @@ +${NOTE_KEYWORD} + copyright: "2011-${YEAR}, Javier Velilla, Jocelyn Fiat, Eiffel Software and others" + license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" diff --git a/cms/layout/src/application_layout.e b/cms/layout/src/application_layout.e index a76e3d3..aded89d 100644 --- a/cms/layout/src/application_layout.e +++ b/cms/layout/src/application_layout.e @@ -1,7 +1,18 @@ note - description: "[API Layout, to provide paths(config, application, log, documentation, www, html cj)]" - date: "$Date: 2014-08-20 15:21:15 -0300 (mi., 20 ago. 2014) $" - revision: "$Revision: 95678 $" + description: "[ + Application layout + Related to file system locations such as + - configuration locations + - application + - log + - documentation + - www + - assets + - templates (html, Collection+JSON, ...) + - ... + ]" + date: "$Date$" + revision: "$Revision$" class APPLICATION_LAYOUT @@ -31,6 +42,7 @@ feature {NONE} -- Initialization feature -- Access path: PATH + -- Root location. feature -- Access: internal @@ -150,4 +162,7 @@ feature {NONE} -- Implementation internal_template_path: detachable like template_path -- Directory for templates (HTML, etc). +;note + copyright: "2011-2014, Javier Velilla, Jocelyn Fiat, Eiffel Software and others" + license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" end diff --git a/cms/layout/src/configuration/database_configuration.e b/cms/layout/src/configuration/database_configuration.e index c24629b..e4441f3 100644 --- a/cms/layout/src/configuration/database_configuration.e +++ b/cms/layout/src/configuration/database_configuration.e @@ -36,4 +36,7 @@ feature -- Access Result := "Driver={"+driver+"};" + database_string; end +note + copyright: "2011-2014, Javier Velilla, Jocelyn Fiat, Eiffel Software and others" + license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" end diff --git a/cms/layout/src/configuration/json_configuration.e b/cms/layout/src/configuration/json_configuration.e index 087e233..e8f0453 100644 --- a/cms/layout/src/configuration/json_configuration.e +++ b/cms/layout/src/configuration/json_configuration.e @@ -97,4 +97,7 @@ feature {NONE} -- JSON create Result.make_parser (a_string) end +note + copyright: "2011-2014, Javier Velilla, Jocelyn Fiat, Eiffel Software and others" + license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" end diff --git a/cms/layout/src/configuration/logger_configuration.e b/cms/layout/src/configuration/logger_configuration.e index 25650a6..7a16ee4 100644 --- a/cms/layout/src/configuration/logger_configuration.e +++ b/cms/layout/src/configuration/logger_configuration.e @@ -1,5 +1,5 @@ note - description: "Object that represent Logger configuration settings" + description: "Object that represents Logger configuration settings" date: "$Date: 2014-08-20 15:21:15 -0300 (mi., 20 ago. 2014) $" revision: "$Revision: 95678 $" @@ -42,7 +42,7 @@ feature -- Access -- When non-zero, the value specifies the maximum number of backup files. level: INTEGER - -- Logger level. + -- Logger level. feature -- Element Change @@ -77,4 +77,7 @@ feature -- Element Change level := 0 end end +note + copyright: "2011-2014, Javier Velilla, Jocelyn Fiat, Eiffel Software and others" + license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" end diff --git a/cms/layout/src/error/basic_error_handler.e b/cms/layout/src/error/basic_error_handler.e index 3c29d2c..f010565 100644 --- a/cms/layout/src/error/basic_error_handler.e +++ b/cms/layout/src/error/basic_error_handler.e @@ -48,4 +48,7 @@ feature -- Change Element error_location_set: error_location = a_location end +note + copyright: "2011-2014, Javier Velilla, Jocelyn Fiat, Eiffel Software and others" + license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" end diff --git a/cms/layout/src/error/shared_error.e b/cms/layout/src/error/shared_error.e index 82c87b6..943cd5c 100644 --- a/cms/layout/src/error/shared_error.e +++ b/cms/layout/src/error/shared_error.e @@ -102,4 +102,7 @@ feature -- Element Settings last_error__reset: last_error = Void successful: successful end +note + copyright: "2011-2014, Javier Velilla, Jocelyn Fiat, Eiffel Software and others" + license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" end diff --git a/cms/layout/src/logger/logging_facility.e b/cms/layout/src/logger/logging_facility.e index e2cbb94..7807e15 100644 --- a/cms/layout/src/logger/logging_facility.e +++ b/cms/layout/src/logger/logging_facility.e @@ -134,4 +134,7 @@ feature -- Output l_retry := True retry end +note + copyright: "2011-2014, Javier Velilla, Jocelyn Fiat, Eiffel Software and others" + license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" end diff --git a/cms/layout/src/logger/shared_logger.e b/cms/layout/src/logger/shared_logger.e index f8160a8..9f6996f 100644 --- a/cms/layout/src/logger/shared_logger.e +++ b/cms/layout/src/logger/shared_logger.e @@ -106,4 +106,7 @@ feature {NONE} -- JSON create Result.make_parser (a_string) end +note + copyright: "2011-2014, Javier Velilla, Jocelyn Fiat, Eiffel Software and others" + license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" end diff --git a/cms/license.lic b/cms/license.lic new file mode 100644 index 0000000..3e50931 --- /dev/null +++ b/cms/license.lic @@ -0,0 +1,3 @@ +${NOTE_KEYWORD} + copyright: "2011-${YEAR}, Jocelyn Fiat, Javier Velilla, Eiffel Software and others" + license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" diff --git a/cms/model/license.lic b/cms/model/license.lic new file mode 100644 index 0000000..1f97942 --- /dev/null +++ b/cms/model/license.lic @@ -0,0 +1,3 @@ +${NOTE_KEYWORD} + copyright: "2011-${YEAR}, Javier Velilla, Jocelyn Fiat, Eiffel Software and others" + license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" diff --git a/cms/model/src/cms_content_type.e b/cms/model/src/cms_content_type.e deleted file mode 100644 index fc6cec2..0000000 --- a/cms/model/src/cms_content_type.e +++ /dev/null @@ -1,10 +0,0 @@ -note - description: "Summary description for {CMS_CONTENT_TYPE}." - author: "" - date: "$Date$" - revision: "$Revision$" - -class - CMS_CONTENT_TYPE - -end diff --git a/cms/model/src/cms_link_composite.e b/cms/model/src/cms_link_composite.e deleted file mode 100644 index 3a9c7da..0000000 --- a/cms/model/src/cms_link_composite.e +++ /dev/null @@ -1,27 +0,0 @@ -note - description: "Summary description for {CMS_LINK_COMPOSITE}." - author: "" - date: "$Date$" - revision: "$Revision$" - -deferred class - CMS_LINK_COMPOSITE - -inherit - ITERABLE [CMS_LINK] - -feature -- Access - - items: detachable LIST [CMS_LINK] - deferred - end - - extend (lnk: CMS_LINK) - deferred - end - - remove (lnk: CMS_LINK) - deferred - end - -end diff --git a/cms/model/src/cms_user_profile.e b/cms/model/src/cms_user_profile.e deleted file mode 100644 index 878ce38..0000000 --- a/cms/model/src/cms_user_profile.e +++ /dev/null @@ -1,48 +0,0 @@ -note - description: "Summary description for {CMS_USER_PROFILE}." - date: "$Date$" - revision: "$Revision$" - -class - CMS_USER_PROFILE - -inherit - TABLE_ITERABLE [READABLE_STRING_8, READABLE_STRING_8] - -create - make - -feature {NONE} -- Initialization - - make - do - create items.make (0) - end - -feature -- Access - - item (k: READABLE_STRING_8): detachable READABLE_STRING_8 - do - Result := items.item (k.as_string_8) - end - -feature -- Change - - force (v: READABLE_STRING_8; k: READABLE_STRING_8) - do - items.force (v, k.as_string_8) - end - -feature -- Access - - new_cursor: TABLE_ITERATION_CURSOR [READABLE_STRING_8, READABLE_STRING_8] - -- Fresh cursor associated with current structure - do - Result := items.new_cursor - end - -feature {NONE} -- Implementation - - items: HASH_TABLE [READABLE_STRING_8, STRING_8] - -end diff --git a/cms/model/src/cms_user_role.e b/cms/model/src/cms_user_role.e deleted file mode 100644 index 48f18ca..0000000 --- a/cms/model/src/cms_user_role.e +++ /dev/null @@ -1,90 +0,0 @@ -note - description: "Summary description for {CMS_USER_ROLE}." - date: "$Date$" - revision: "$Revision$" - -class - CMS_USER_ROLE - -inherit - ANY - redefine - is_equal - end - -create - make, - make_with_id - -feature {NONE} -- Initialization - - make_with_id (a_id: like id; a_name: like name) - do - id := a_id - make (a_name) - end - - make (a_name: like name) - do - name := a_name - create {ARRAYED_LIST [READABLE_STRING_8]} permissions.make (0) - end - -feature -- Status report - - has_id: BOOLEAN - do - Result := id > 0 - end - - has_permission (p: READABLE_STRING_8): BOOLEAN - do - Result := across permissions as c some c.item.is_case_insensitive_equal (p) end - end - -feature -- Access - - id: INTEGER - - name: READABLE_STRING_8 - - permissions: LIST [READABLE_STRING_8] - -feature -- Comparison - - same_user_role (r: CMS_USER_ROLE): BOOLEAN - do - Result := r.id = id - end - - is_equal (other: like Current): BOOLEAN - -- Is `other' attached to an object considered - -- equal to current object? - do - Result := id = other.id - end - -feature -- Change - - set_id (a_id: like id) - -- Set `id' with `a_id'. - do - id := a_id - ensure - set_id: id = a_id - end - - set_name (a_name: like name) - -- Set `name' with `a_name'. - do - name := a_name - ensure - name_set: name = a_name - end - - add_permission (n: READABLE_STRING_8) - do - permissions.force (n) - end - -end diff --git a/cms/model/src/content/cms_content_type.e b/cms/model/src/content/cms_content_type.e new file mode 100644 index 0000000..2b58002 --- /dev/null +++ b/cms/model/src/content/cms_content_type.e @@ -0,0 +1,15 @@ +note + description: "[ + Interface defining a CMS content type. + ]" + status: "draft" + date: "$Date$" + revision: "$Revision$" + +class + CMS_CONTENT_TYPE + +note + copyright: "2011-2014, Javier Velilla, Jocelyn Fiat, Eiffel Software and others" + license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" +end diff --git a/cms/model/src/cms_node.e b/cms/model/src/content/cms_node.e similarity index 84% rename from cms/model/src/cms_node.e rename to cms/model/src/content/cms_node.e index 07ee57b..13010bd 100644 --- a/cms/model/src/cms_node.e +++ b/cms/model/src/content/cms_node.e @@ -1,5 +1,8 @@ note - description: "Summary description for {NODE}." + description: "[ + CMS abstraction for CMS content entity, named "node". + ]" + status: "draft" date: "$Date$" revision: "$Revision$" @@ -14,7 +17,9 @@ create make feature{NONE} -- Initialization - make (a_content: READABLE_STRING_32; a_summary:READABLE_STRING_32; a_title: READABLE_STRING_32) + + make (a_content: READABLE_STRING_32; a_summary: READABLE_STRING_32; a_title: READABLE_STRING_32) + -- Create current node with `a_content', `a_summary' and `a_title'. local l_time: DATE_TIME do @@ -25,12 +30,14 @@ feature{NONE} -- Initialization set_creation_date (l_time) set_modification_date (l_time) set_publication_date (l_time) + debug ("refactor_fixme") - fixme ("Remove harcode format") + fixme ("Remove default harcoded format") end set_format ("HTML") + debug ("refactor_fixme") - fixme ("Remove harcode content type") + fixme ("Remove default harcoded content type") end set_content_type ("Page") ensure @@ -41,6 +48,9 @@ feature{NONE} -- Initialization feature -- Access + id: INTEGER_64 assign set_id + -- Unique id. + content: READABLE_STRING_32 -- Content of the node. @@ -62,10 +72,7 @@ feature -- Access publication_date_output: READABLE_STRING_32 -- Formatted output. - id: INTEGER_64 assign set_id - -- Unique id. - - format: READABLE_STRING_32 + format: READABLE_STRING_32 -- Format associated with `body'. -- For example: text, mediawiki, html, etc @@ -73,19 +80,20 @@ feature -- Access -- Associated content type name. -- Page, Article, Blog, News, etc. + author: detachable CMS_USER + -- Author of current node. + + collaborators: detachable LIST[CMS_USER] + -- Users contributed to current Node. + feature -- status report has_id: BOOLEAN + -- Has unique identifier? do Result := id > 0 end - author: detachable CMS_USER - -- Node's author. - - collaborators: detachable LIST[CMS_USER] - -- Node's collaborators. - feature -- Element change set_content (a_content: like content) @@ -182,4 +190,7 @@ feature -- Element change lst.force (a_user) end +note + copyright: "2011-2014, Javier Velilla, Jocelyn Fiat, Eiffel Software and others" + license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" end diff --git a/cms/model/src/link/cms_external_link.e b/cms/model/src/link/cms_external_link.e new file mode 100644 index 0000000..c9ffd25 --- /dev/null +++ b/cms/model/src/link/cms_external_link.e @@ -0,0 +1,53 @@ +note + description: "[ + Abstraction to represent a link outside current CMS system. + For instance, a web url. + ]" + date: "$Date$" + revision: "$Revision: 95883 $" + +class + CMS_EXTERNAL_LINK + +inherit + CMS_LINK + +create + make + +feature {NONE} -- Initialization + + make (a_title: like title; a_location: like location) + -- Create current external link with optional title `a_title' and location `a_location'. + do + title := a_title + location := a_location + end + +feature -- Status report + + is_active: BOOLEAN = False + -- + + is_expanded: BOOLEAN = False + -- + + is_collapsed: BOOLEAN = False + -- + + is_expandable: BOOLEAN = False + -- + + has_children: BOOLEAN = False + -- + +feature -- Access + + children: detachable LIST [CMS_LINK] + -- + +invariant +note + copyright: "2011-2014, Javier Velilla, Jocelyn Fiat, Eiffel Software and others" + license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" +end diff --git a/cms/model/src/cms_link.e b/cms/model/src/link/cms_link.e similarity index 62% rename from cms/model/src/cms_link.e rename to cms/model/src/link/cms_link.e index 70aca33..a16b86c 100644 --- a/cms/model/src/cms_link.e +++ b/cms/model/src/link/cms_link.e @@ -1,6 +1,7 @@ note - description: "Summary description for {CMS_MENU}." - author: "" + description: "[ + Abstraction to represent a URI link in the CMS system. + ]" date: "$Date$" revision: "$Revision$" @@ -17,14 +18,16 @@ inherit feature -- Access title: READABLE_STRING_32 - -- link's title. + -- Associated title. location: READABLE_STRING_8 - -- link's location. + -- Associated url location. feature -- status report is_active: BOOLEAN + -- Is current link active? + -- i.e: related to requested url. deferred end @@ -44,16 +47,20 @@ feature -- status report -- Is expandable? deferred end - + has_children: BOOLEAN + -- Has sub link? deferred end feature -- Query parent: detachable CMS_LINK + -- Optional parent link. children: detachable LIST [CMS_LINK] + -- Optional children links. + -- Useful to have a non flat menu. deferred end @@ -71,10 +78,15 @@ feature -- Access feature -- Status report - debug_output: STRING + debug_output: STRING_32 -- String that should be displayed in debugger to represent `Current'. do - Result := title.as_string_8 + " -> " + location + create Result.make_from_string (title) + Result.append_string_general (" -> ") + Result.append_string_general (location) end +note + copyright: "2011-2014, Javier Velilla, Jocelyn Fiat, Eiffel Software and others" + license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" end diff --git a/cms/model/src/link/cms_link_composite.e b/cms/model/src/link/cms_link_composite.e new file mode 100644 index 0000000..c4cdc2c --- /dev/null +++ b/cms/model/src/link/cms_link_composite.e @@ -0,0 +1,52 @@ +note + description: "[ + Abstraction to represent a links container in the CMS system. + ]" + date: "$Date$" + revision: "$Revision$" + +deferred class + CMS_LINK_COMPOSITE + +inherit + ITERABLE [CMS_LINK] + +feature -- Access + + items: detachable LIST [CMS_LINK] + -- Children links. + deferred + end + +feature -- Element change + + extend (lnk: CMS_LINK) + -- Add `lnk' as a sub link. + deferred + end + + remove (lnk: CMS_LINK) + -- Remove link `lnk' from Current container. + deferred + end + +feature -- status report + + is_empty: BOOLEAN + -- Is container empty? + do + Result := not attached items as l_items or else l_items.is_empty + end + + count: INTEGER + -- Number of immediate sub links. + do + if attached items as l_items then + Result := l_items.count + end + end + +note + copyright: "2011-2014, Javier Velilla, Jocelyn Fiat, Eiffel Software and others" + license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" +end diff --git a/cms/model/src/cms_local_link.e b/cms/model/src/link/cms_local_link.e similarity index 67% rename from cms/model/src/cms_local_link.e rename to cms/model/src/link/cms_local_link.e index a8757d6..f33c93b 100644 --- a/cms/model/src/cms_local_link.e +++ b/cms/model/src/link/cms_local_link.e @@ -1,5 +1,7 @@ note - description: "Summary description for {CMS_LOCAL_MENU}." + description: "[ + Abstraction to represent a link to a CMS resource. + ]" date: "$Date$" revision: "$Revision$" @@ -22,6 +24,7 @@ create feature {NONE} -- Initialization make (a_title: detachable like title; a_location: like location) + -- Create current local link with optional title `a_title' and location `a_location'. do if a_title /= Void then title := a_title @@ -31,44 +34,47 @@ feature {NONE} -- Initialization location := a_location end +feature -- Access + + permission_arguments: detachable ITERABLE [READABLE_STRING_8] + -- Permissions required by current link resource. + + children: detachable LIST [CMS_LINK] + -- + feature -- Status report is_active: BOOLEAN + -- is_expanded: BOOLEAN + -- do Result := is_expandable and then internal_is_expanded end is_collapsed: BOOLEAN - -- Is expanded, but visually collapsed? + -- do Result := is_expandable and then internal_is_collapsed end is_expandable: BOOLEAN + -- do Result := internal_is_expandable or internal_is_expanded or has_children end has_children: BOOLEAN + -- do Result := attached children as l_children and then not l_children.is_empty end - permission_arguments: detachable ITERABLE [READABLE_STRING_8] - - children: detachable LIST [CMS_LINK] - - internal_is_expandable: BOOLEAN - - internal_is_expanded: BOOLEAN - - internal_is_collapsed: BOOLEAN - feature -- Element change add_link (lnk: CMS_LINK) + -- local lst: like children do @@ -81,6 +87,7 @@ feature -- Element change end remove_link (lnk: CMS_LINK) + -- local lst: like children do @@ -94,8 +101,19 @@ feature -- Element change end set_children (lst: like children) + -- Set `children' to `lst'. do children := lst + ensure + children_set: children = lst + end + + set_permission_arguments (args: like permission_arguments) + -- Set `permission_arguments' to `args'. + do + permission_arguments := args + ensure + permission_arguments_set: permission_arguments = args end feature -- Status change @@ -104,33 +122,52 @@ feature -- Status change -- Set `is_active' to `b'. do is_active := b + ensure + is_active: is_active = b end set_expanded (b: like is_expanded) + -- Set `is_expanded' to `b'. do if b then set_expandable (True) set_collapsed (False) end internal_is_expanded := b + ensure + is_expanded: is_expanded = b end set_collapsed (b: like is_collapsed) + -- Set `is_collapsed' to `b'. do if b then set_expanded (False) end internal_is_collapsed := b + ensure + is_collapsed: is_collapsed= b end set_expandable (b: like is_expandable) + -- Set `is_expandable' to `b'. do internal_is_expandable := b + ensure + is_expandable: is_expandable = b end - set_permission_arguments (args: like permission_arguments) - do - permission_arguments := args - end +feature {NONE} -- Implementation + internal_is_expandable: BOOLEAN + + internal_is_expanded: BOOLEAN + + internal_is_collapsed: BOOLEAN + +invariant + +note + copyright: "2011-2014, Javier Velilla, Jocelyn Fiat, Eiffel Software and others" + license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" end diff --git a/cms/model/src/cms_menu.e b/cms/model/src/link/cms_menu.e similarity index 50% rename from cms/model/src/cms_menu.e rename to cms/model/src/link/cms_menu.e index 6cb332f..fd38a5a 100644 --- a/cms/model/src/cms_menu.e +++ b/cms/model/src/link/cms_menu.e @@ -1,5 +1,8 @@ note - description: "Summary description for {CMS_MENU}." + description: "[ + Abstraction to represent a MENU in the CMS system. + It has items as sub menu/link. + ]" date: "$Date$" revision: "$Revision$" @@ -8,6 +11,9 @@ class inherit CMS_LINK_COMPOSITE + redefine + is_empty + end create make, @@ -15,45 +21,53 @@ create feature {NONE} -- Initialization - make (a_name: like name; n: INTEGER) + make (a_name: like name; a_capacity: INTEGER) + -- Create menu with name `a_name' and a capacity of `a_capacity'. do name := a_name - create items.make (n) + create items.make (a_capacity) end - make_with_title (a_name: like name; a_title: READABLE_STRING_32; n: INTEGER) + make_with_title (a_name: like name; a_title: READABLE_STRING_32; a_capacity: INTEGER) + -- Create menu with name `a_name' and a capacity of `a_capacity', and title `a_title' do - make (a_name, n) + make (a_name, a_capacity) set_title (a_title) end feature -- Access name: READABLE_STRING_8 + -- Identifier for Current menu. title: detachable READABLE_STRING_32 + -- Optional title. items: ARRAYED_LIST [CMS_LINK] + -- + +feature -- Status report + + is_empty: BOOLEAN + -- + do + Result := items.is_empty + end + +feature -- Element change extend (lnk: CMS_LINK) + -- do items.extend (lnk) end remove (lnk: CMS_LINK) + -- do items.prune_all (lnk) end -feature -- status report - - is_empty: BOOLEAN - do - Result := items.is_empty - end - -feature -- Element change - set_title (t: like title) do title := t @@ -69,4 +83,7 @@ feature -- Access invariant +note + copyright: "2011-2014, Javier Velilla, Jocelyn Fiat, Eiffel Software and others" + license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" end diff --git a/cms/model/src/cms_user.e b/cms/model/src/user/cms_user.e similarity index 63% rename from cms/model/src/cms_user.e rename to cms/model/src/user/cms_user.e index 5bd836e..b50de8a 100644 --- a/cms/model/src/cms_user.e +++ b/cms/model/src/user/cms_user.e @@ -1,5 +1,7 @@ note - description: "Summary description for {USER}." + description: "[ + Interface representing a USER in the CMS system. + ]" date: "$Date$" revision: "$Revision$" @@ -27,31 +29,33 @@ feature {NONE} -- Initialization feature -- Access id: INTEGER_64 - -- Unique id. + -- Unique id. name: READABLE_STRING_32 - -- User name. + -- User name. password: detachable READABLE_STRING_32 - -- User password. + -- User password. email: detachable READABLE_STRING_32 - -- User email. + -- User email. profile: detachable CMS_USER_PROFILE - -- User profile. + -- User profile. creation_date: DATE_TIME - -- Creation date. + -- Creation date. last_login_date: detachable DATE_TIME - -- User last login. + -- User last login. + +feature -- Access: data data: detachable STRING_TABLE [detachable ANY] - -- Additional user's data. + -- Additional data. data_item (k: READABLE_STRING_GENERAL): detachable ANY - -- Additional item data. + -- Additional item data associated with key `k'. do if attached data as l_data then Result := l_data.item (k) @@ -70,14 +74,21 @@ feature -- Status report Result := attached email as e and then not e.is_empty end - debug_output: STRING + debug_output: STRING_32 do - Result := name + create Result.make_from_string (name) + if has_id then + Result.append_character (' ') + Result.append_character ('<') + Result.append_integer_64 (id) + Result.append_character ('>') + end end - same_as (u: detachable CMS_USER): BOOLEAN + same_as (other: detachable CMS_USER): BOOLEAN + -- Is Current same as `other'? do - Result := u /= Void and then id = u.id + Result := other /= Void and then id = other.id end feature -- Change element @@ -98,20 +109,20 @@ feature -- Change element name_set: name = n end - set_password (p: like password) - -- Set `password' with `p'. + set_password (a_password: like password) + -- Set `password' with `a_password'. do - password := p + password := a_password ensure - password_set: password = p + password_set: password = a_password end - set_email (m: like email) - -- Set `email' with `m'. + set_email (a_email: like email) + -- Set `email' with `a_email'. do - email := m + email := a_email ensure - email_set: email = m + email_set: email = a_email end set_profile (prof: like profile) @@ -122,25 +133,6 @@ feature -- Change element profile_set: profile = prof end - set_data_item (k: READABLE_STRING_GENERAL; d: like data_item) - local - l_data: like data - do - l_data := data - if l_data = Void then - create l_data.make (1) - data := l_data - end - l_data.force (d, k) - end - - remove_data_item (k: READABLE_STRING_GENERAL) - do - if attached data as l_data then - l_data.remove (k) - end - end - set_profile_item (k: READABLE_STRING_8; v: READABLE_STRING_8) local prof: like profile @@ -163,4 +155,30 @@ feature -- Change element set_last_login_date (create {DATE_TIME}.make_now_utc) end +feature -- Change element: data + + set_data_item (k: READABLE_STRING_GENERAL; d: like data_item) + -- Associate data item `d' with key `k'. + local + l_data: like data + do + l_data := data + if l_data = Void then + create l_data.make (1) + data := l_data + end + l_data.force (d, k) + end + + remove_data_item (k: READABLE_STRING_GENERAL) + -- Remove data item associated with key `k'. + do + if attached data as l_data then + l_data.remove (k) + end + end + +note + copyright: "2011-2014, Javier Velilla, Jocelyn Fiat, Eiffel Software and others" + license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" end diff --git a/cms/model/src/user/cms_user_profile.e b/cms/model/src/user/cms_user_profile.e new file mode 100644 index 0000000..1f0a407 --- /dev/null +++ b/cms/model/src/user/cms_user_profile.e @@ -0,0 +1,56 @@ +note + description: "[ + User profile used to extend information associated with a {CMS_USER}. + ]" + date: "$Date$" + revision: "$Revision$" + +class + CMS_USER_PROFILE + +inherit + TABLE_ITERABLE [READABLE_STRING_8, READABLE_STRING_GENERAL] + +create + make + +feature {NONE} -- Initialization + + make + -- Create Current profile. + do + create items.make (0) + end + +feature -- Access + + item (k: READABLE_STRING_GENERAL): detachable READABLE_STRING_8 + -- Profile item associated with key `k'. + do + Result := items.item (k) + end + +feature -- Change + + force (v: READABLE_STRING_8; k: READABLE_STRING_GENERAL) + -- Associated value `v' with key `k'. + do + items.force (v, k) + end + +feature -- Access + + new_cursor: TABLE_ITERATION_CURSOR [READABLE_STRING_8, READABLE_STRING_GENERAL] + -- Fresh cursor associated with current structure + do + Result := items.new_cursor + end + +feature {NONE} -- Implementation + + items: STRING_TABLE [READABLE_STRING_8] + +;note + copyright: "2011-2014, Javier Velilla, Jocelyn Fiat, Eiffel Software and others" + license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" +end diff --git a/cms/model/src/user/cms_user_role.e b/cms/model/src/user/cms_user_role.e new file mode 100644 index 0000000..0b7b663 --- /dev/null +++ b/cms/model/src/user/cms_user_role.e @@ -0,0 +1,120 @@ +note + description: "[ + The user roles are used for the CMS permission system. + A role has a list of permissions, that describes what users of current role + are authorized to operation. + ]" + date: "$Date$" + revision: "$Revision$" + +class + CMS_USER_ROLE + +inherit + ANY + redefine + is_equal + end + +create + make, + make_with_id + +feature {NONE} -- Initialization + + make_with_id (a_id: like id; a_name: like name) + do + id := a_id + make (a_name) + end + + make (a_name: like name) + do + name := a_name + create {ARRAYED_LIST [READABLE_STRING_8]} permissions.make (0) + end + +feature -- Status report + + has_id: BOOLEAN + -- Has a unique identifier? + do + Result := id > 0 + end + + has_permission (p: READABLE_STRING_8): BOOLEAN + -- Has permission `p'? + do + Result := across permissions as c some c.item.is_case_insensitive_equal (p) end + end + +feature -- Access + + id: INTEGER + -- Unique id associated with Current role. + + name: READABLE_STRING_8 + -- Name of Current role. + + permissions: LIST [READABLE_STRING_8] + -- List of permissions. + +feature -- Comparison + + same_user_role (other: CMS_USER_ROLE): BOOLEAN + -- Is Current role same as role `other' ? + do + Result := other.id = id + end + + is_equal (other: like Current): BOOLEAN + -- Is `other' attached to an object considered + -- equal to current object? + do + Result := id = other.id + end + +feature -- Change + + set_id (a_id: like id) + -- Set `id' with `a_id'. + do + id := a_id + ensure + set_id: id = a_id + end + + set_name (a_name: like name) + -- Set `name' with `a_name'. + do + name := a_name + ensure + name_set: name = a_name + end + +feature -- Permission change + + add_permission (a_permission_name: READABLE_STRING_8) + -- Add permission `a_permission_name' to Current role. + require + is_not_blank: not a_permission_name.is_whitespace + do + permissions.force (a_permission_name) + ensure + has_permission: has_permission (a_permission_name) + end + + remove_permission (a_permission_name: READABLE_STRING_8) + -- Remove permission `a_permission_name' from Current role. + require + is_not_blank: not a_permission_name.is_whitespace + do + permissions.prune_all (a_permission_name) + ensure + not_has_permission: not has_permission (a_permission_name) + end + +note + copyright: "2011-2014, Javier Velilla, Jocelyn Fiat, Eiffel Software and others" + license: "Eiffel Forum License v2 (see http://www.eiffel.com/licensing/forum.txt)" +end From 9cd53c7c7880ae48c484b78f3ce063776deb020a Mon Sep 17 00:00:00 2001 From: Jocelyn Fiat Date: Thu, 13 Nov 2014 10:53:57 +0100 Subject: [PATCH 2/3] updated readme. --- README.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 118e4b5..a1123e9 100644 --- a/README.md +++ b/README.md @@ -1 +1,4 @@ -ROC: The REST On CMS solution +ROC: The "REST On CMS" solution + +Simple content management system built with Eiffel, and the Eiffel Web Framework, with REST API in mind. + From 71734a6dd7751fe289c261e380209e24870c70e8 Mon Sep 17 00:00:00 2001 From: Jocelyn Fiat Date: Thu, 13 Nov 2014 11:15:35 +0100 Subject: [PATCH 3/3] Renamed model-safe.ecf as cms_model-safe.ecf since it is very specific to the cms. Fixed compilation issue due to recent use of STRING_TABLE. --- cms/cms-safe.ecf | 2 +- cms/model/{model-safe.ecf => cms_model-safe.ecf} | 6 +++--- .../implementation/mysql/persistence_mysql-safe.ecf | 2 +- .../implementation/mysql/src/provider/user_data_provider.e | 4 ++-- cms/persistence/implementation/mysql/tests/tests.ecf | 2 +- .../implementation/sqlite/persistence_sqlite-safe.ecf | 1 + examples/roc_api/modules/demo/cms_demo_module-safe.ecf | 2 +- 7 files changed, 10 insertions(+), 9 deletions(-) rename cms/model/{model-safe.ecf => cms_model-safe.ecf} (81%) diff --git a/cms/cms-safe.ecf b/cms/cms-safe.ecf index 2c2d41f..56aac47 100644 --- a/cms/cms-safe.ecf +++ b/cms/cms-safe.ecf @@ -10,7 +10,7 @@ - + diff --git a/cms/model/model-safe.ecf b/cms/model/cms_model-safe.ecf similarity index 81% rename from cms/model/model-safe.ecf rename to cms/model/cms_model-safe.ecf index cc50b08..18d774b 100644 --- a/cms/model/model-safe.ecf +++ b/cms/model/cms_model-safe.ecf @@ -1,6 +1,6 @@ - - + + - + diff --git a/cms/persistence/implementation/sqlite/persistence_sqlite-safe.ecf b/cms/persistence/implementation/sqlite/persistence_sqlite-safe.ecf index 90af783..9e6d263 100644 --- a/cms/persistence/implementation/sqlite/persistence_sqlite-safe.ecf +++ b/cms/persistence/implementation/sqlite/persistence_sqlite-safe.ecf @@ -11,6 +11,7 @@ + diff --git a/examples/roc_api/modules/demo/cms_demo_module-safe.ecf b/examples/roc_api/modules/demo/cms_demo_module-safe.ecf index e1b0524..bb9ae6d 100644 --- a/examples/roc_api/modules/demo/cms_demo_module-safe.ecf +++ b/examples/roc_api/modules/demo/cms_demo_module-safe.ecf @@ -12,7 +12,7 @@ - +