Added notion of CMS_CONTENT as ancestor of CMS_NODE.
Moved CMS_CONTENT_TYPE to core library.
Added basic and limited taxonomy query /taxonomy/term/{termid} .
This commit is contained in:
@@ -103,7 +103,7 @@ feature -- Access node
|
||||
Result := taxonomy_storage.terms (a_vocab, a_limit, a_offset)
|
||||
end
|
||||
|
||||
term_by_id (a_tid: INTEGER): detachable CMS_TERM
|
||||
term_by_id (a_tid: INTEGER_64): detachable CMS_TERM
|
||||
do
|
||||
Result := taxonomy_storage.term_by_id (a_tid)
|
||||
end
|
||||
@@ -114,6 +114,14 @@ feature -- Access node
|
||||
Result := taxonomy_storage.term_by_text (a_term_text, a_vocabulary)
|
||||
end
|
||||
|
||||
entities_associated_with_term (a_term: CMS_TERM): detachable LIST [TUPLE [entity: READABLE_STRING_32; type: detachable READABLE_STRING_32]]
|
||||
-- Entities and related typename associated with `a_term'.
|
||||
require
|
||||
a_term_exists: a_term.has_id
|
||||
do
|
||||
Result := taxonomy_storage.entities_associated_with_term (a_term)
|
||||
end
|
||||
|
||||
feature -- Write
|
||||
|
||||
save_vocabulary (a_voc: CMS_VOCABULARY)
|
||||
|
||||
@@ -35,7 +35,7 @@ feature {NONE} -- Initialization
|
||||
version := "1.0"
|
||||
description := "Taxonomy solution"
|
||||
package := "core"
|
||||
-- add_dependency ({CMS_NODE_MODULE})
|
||||
-- put_dependency ({CMS_NODE_MODULE}, False)
|
||||
end
|
||||
|
||||
feature -- Access
|
||||
@@ -120,19 +120,9 @@ feature -- Access: router
|
||||
-- Configure router mapping for web interface.
|
||||
local
|
||||
l_taxonomy_handler: TAXONOMY_HANDLER
|
||||
l_uri_mapping: WSF_URI_MAPPING
|
||||
do
|
||||
create l_taxonomy_handler.make (a_api, a_taxonomy_api)
|
||||
-- Let the class BLOG_HANDLER handle the requests on "/taxonomys"
|
||||
create l_uri_mapping.make_trailing_slash_ignored ("/taxonomy", l_taxonomy_handler)
|
||||
a_router.map (l_uri_mapping, a_router.methods_get)
|
||||
|
||||
-- We can add a page number after /taxonomys/ to get older posts
|
||||
a_router.handle ("/taxonomy/{vocabulary}", l_taxonomy_handler, a_router.methods_get)
|
||||
|
||||
-- If a user id is given route with taxonomy user handler
|
||||
--| FIXME: maybe /user/{user}/taxonomys/ would be better.
|
||||
a_router.handle ("/taxonomy/{vocabulary}/{termid}", l_taxonomy_handler, a_router.methods_get)
|
||||
a_router.handle ("/taxonomy/term/{termid}", l_taxonomy_handler, a_router.methods_get)
|
||||
end
|
||||
|
||||
feature -- Hooks
|
||||
|
||||
@@ -1,9 +1,7 @@
|
||||
note
|
||||
description: "[
|
||||
Request handler related to
|
||||
/taxonomy
|
||||
/taxonomy/{vocabulary}
|
||||
/taxonomy/{vocabulary}/{term}
|
||||
/taxonomy/term/{termid}
|
||||
]"
|
||||
date: "$Date$"
|
||||
revision: "$revision$"
|
||||
@@ -69,13 +67,68 @@ feature -- HTTP Methods
|
||||
-- <Precursor>
|
||||
local
|
||||
l_page: CMS_RESPONSE
|
||||
tid: INTEGER_64
|
||||
l_typename: detachable READABLE_STRING_8
|
||||
l_entity: detachable READABLE_STRING_32
|
||||
s: STRING
|
||||
do
|
||||
-- Read page number from path parameter.
|
||||
if
|
||||
attached {WSF_STRING} req.path_parameter ("termid") as p_termid and then
|
||||
p_termid.is_integer
|
||||
then
|
||||
tid := p_termid.value.to_integer_64
|
||||
end
|
||||
|
||||
-- Responding with `main_content_html (l_page)'.
|
||||
create {GENERIC_VIEW_CMS_RESPONSE} l_page.make (req, res, api)
|
||||
l_page.set_main_content ("Not Yet Implemented -- In Progress")
|
||||
l_page.execute
|
||||
if tid > 0 then
|
||||
if attached taxonomy_api.term_by_id (tid) as t then
|
||||
-- Responding with `main_content_html (l_page)'.
|
||||
create {GENERIC_VIEW_CMS_RESPONSE} l_page.make (req, res, api)
|
||||
create s.make_empty
|
||||
l_page.set_page_title ("Entities associated with term %"" + l_page.html_encoded (t.text) + "%":")
|
||||
|
||||
if
|
||||
attached taxonomy_api.entities_associated_with_term (t) as l_entity_type_lst and then
|
||||
not l_entity_type_lst.is_empty
|
||||
then
|
||||
s.append ("<ul class=%"taxonomy-entities%">")
|
||||
across
|
||||
l_entity_type_lst as ic
|
||||
loop
|
||||
-- FIXME: for now basic implementation .. to be replaced by specific hook !
|
||||
if attached ic.item.entity as e and then e.is_valid_as_string_8 then
|
||||
l_entity := e.to_string_8
|
||||
if attached ic.item.type as l_type and then l_type.is_valid_as_string_8 then
|
||||
l_typename := l_type.to_string_8
|
||||
else
|
||||
l_typename := Void
|
||||
end
|
||||
if l_typename /= Void then
|
||||
s.append ("<li class=%""+ l_typename +"%">")
|
||||
if
|
||||
l_typename.is_case_insensitive_equal_general ("page")
|
||||
or l_typename.is_case_insensitive_equal_general ("blog")
|
||||
then
|
||||
s.append (l_page.link ({STRING_32} "" + l_typename + "/" + l_entity, "node/" + l_entity.to_string_8, Void))
|
||||
end
|
||||
s.append ("</li>%N")
|
||||
end
|
||||
end
|
||||
end
|
||||
s.append ("</ul>%N")
|
||||
else
|
||||
s.append ("No entity found.")
|
||||
end
|
||||
l_page.set_main_content (s)
|
||||
else
|
||||
-- Responding with `main_content_html (l_page)'.
|
||||
create {NOT_FOUND_ERROR_CMS_RESPONSE} l_page.make (req, res, api)
|
||||
end
|
||||
l_page.execute
|
||||
else
|
||||
-- Responding with `main_content_html (l_page)'.
|
||||
create {BAD_REQUEST_ERROR_CMS_RESPONSE} l_page.make (req, res, api)
|
||||
l_page.execute
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -80,6 +80,13 @@ feature -- Access
|
||||
deferred
|
||||
end
|
||||
|
||||
entities_associated_with_term (a_term: CMS_TERM): detachable LIST [TUPLE [entity: READABLE_STRING_32; type: detachable READABLE_STRING_32]]
|
||||
-- Entities and related typename associated with `a_term'.
|
||||
require
|
||||
a_term_exists: a_term.has_id
|
||||
deferred
|
||||
end
|
||||
|
||||
feature -- Store
|
||||
|
||||
save_vocabulary (a_voc: CMS_VOCABULARY)
|
||||
|
||||
@@ -78,6 +78,11 @@ feature -- Access
|
||||
do
|
||||
end
|
||||
|
||||
entities_associated_with_term (a_term: CMS_TERM): detachable LIST [TUPLE [entity: READABLE_STRING_32; type: detachable READABLE_STRING_32]]
|
||||
-- Entities and related typename associated with `a_term'.
|
||||
do
|
||||
end
|
||||
|
||||
feature -- Store
|
||||
|
||||
save_vocabulary (a_voc: CMS_VOCABULARY)
|
||||
|
||||
@@ -198,6 +198,38 @@ feature -- Access
|
||||
end
|
||||
end
|
||||
|
||||
entities_associated_with_term (a_term: CMS_TERM): detachable LIST [TUPLE [entity: READABLE_STRING_32; type: detachable READABLE_STRING_32]]
|
||||
-- Entities and related typename associated with `a_term'.
|
||||
local
|
||||
l_parameters: STRING_TABLE [detachable ANY]
|
||||
l_typename: detachable READABLE_STRING_32
|
||||
do
|
||||
error_handler.reset
|
||||
|
||||
create l_parameters.make (3)
|
||||
l_parameters.put (a_term.id, "tid")
|
||||
sql_query (sql_select_entity_and_type_by_term, l_parameters)
|
||||
|
||||
if not has_error then
|
||||
create {ARRAYED_LIST [TUPLE [entity: READABLE_STRING_32; type: detachable READABLE_STRING_32]]} Result.make (0)
|
||||
from
|
||||
sql_start
|
||||
until
|
||||
sql_after or has_error
|
||||
loop
|
||||
if attached sql_read_string_32 (1) as l_entity then
|
||||
l_typename := sql_read_string_32 (2)
|
||||
if l_typename /= Void and then l_typename.is_whitespace then
|
||||
l_typename := Void
|
||||
end
|
||||
Result.force ([l_entity, l_typename])
|
||||
end
|
||||
sql_forth
|
||||
end
|
||||
end
|
||||
sql_finalize
|
||||
end
|
||||
|
||||
feature -- Store
|
||||
|
||||
save_vocabulary (voc: CMS_VOCABULARY)
|
||||
@@ -477,6 +509,12 @@ feature {NONE} -- Queries
|
||||
SELECT tid FROM taxonomy_index WHERE type=:type AND entity=:entity;
|
||||
]"
|
||||
|
||||
sql_select_entity_and_type_by_term: STRING = "[
|
||||
SELECT entity, type FROM taxonomy_index WHERE tid=:tid AND entity > 0
|
||||
ORDER BY type ASC, entity ASC
|
||||
;
|
||||
]"
|
||||
|
||||
sql_select_vocabulary_terms_of_entity: STRING = "[
|
||||
SELECT taxonomy_index.tid
|
||||
FROM taxonomy_index INNER JOIN taxonomy_hierarchy ON taxonomy_index.tid=taxonomy_hierarchy.tid
|
||||
|
||||
@@ -16,6 +16,7 @@
|
||||
<library name="error" location="$ISE_LIBRARY\contrib\library\utility\general\error\error-safe.ecf"/>
|
||||
|
||||
<library name="http" location="$ISE_LIBRARY\contrib\library\network\protocol\http\http-safe.ecf"/>
|
||||
|
||||
<library name="wsf" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\wsf-safe.ecf"/>
|
||||
<library name="wsf_html" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf_html\wsf_html-safe.ecf"/>
|
||||
<library name="wsf_extension" location="$ISE_LIBRARY\contrib\library\web\framework\ewf\wsf\wsf_extension-safe.ecf" readonly="false"/>
|
||||
|
||||
Reference in New Issue
Block a user