Merge branch 'master' into es_17_01
This commit is contained in:
@@ -42,7 +42,7 @@
|
||||
<div class="col-md-2 col-md-offset-9">
|
||||
<form action="{$site_url/}gcse" class="search-form" id="gcse_search_form">
|
||||
<div class="form-group has-feedback">
|
||||
<input type="search" class="form-control" name="q" id="gcse_search" placeholder="search">
|
||||
<input type="search" class="form-control" name="q" id="gcse_search" placeholder="search" value="{$google_search/}" >
|
||||
<span class="glyphicon glyphicon-search form-control-feedback"></span>
|
||||
</div>
|
||||
</form>
|
||||
|
||||
@@ -158,7 +158,7 @@ feature -- HTML Output
|
||||
lnk: CMS_LOCAL_LINK
|
||||
do
|
||||
-- Output the title. If more than one page, also output the current page number
|
||||
append_page_title_html_to (a_output)
|
||||
append_page_title_html_to (page, a_output)
|
||||
|
||||
-- Get the posts from the current page (given by page number and entries per page)
|
||||
-- Start list of posts
|
||||
@@ -174,7 +174,7 @@ feature -- HTML Output
|
||||
append_creation_date_html_to (n, a_output)
|
||||
|
||||
-- Output the author of the post
|
||||
append_author_html_to (n, a_output)
|
||||
append_author_html_to (n, page, a_output)
|
||||
|
||||
-- Output the title of the post as a link (to the detail page)
|
||||
append_title_html_to (n, page, a_output)
|
||||
@@ -192,7 +192,7 @@ feature -- HTML Output
|
||||
append_pagination_html_to (a_output)
|
||||
end
|
||||
|
||||
append_page_title_html_to (a_output: STRING)
|
||||
append_page_title_html_to (a_page: CMS_RESPONSE; a_output: STRING)
|
||||
-- Append the title of the page as a html string to `a_output'.
|
||||
-- It shows the current page number.
|
||||
do
|
||||
@@ -215,12 +215,12 @@ feature -- HTML Output
|
||||
end
|
||||
end
|
||||
|
||||
append_author_html_to (n: CMS_NODE; a_output: STRING)
|
||||
append_author_html_to (n: CMS_NODE; a_page: CMS_RESPONSE; a_output: STRING)
|
||||
-- Append to `a_output', the author of node `n' as html link to author's posts.
|
||||
do
|
||||
if attached n.author as l_author then
|
||||
a_output.append ("by ")
|
||||
a_output.append ("<a class=%"blog_user_link%" href=%"/blog/" + l_author.id.out + "%">" + html_encoded (l_author.name) + "</a>")
|
||||
a_output.append ("<a class=%"blog_user_link%" href=%"/blog/" + l_author.id.out + "%">" + html_encoded (a_page.user_profile_name (l_author)) + "</a>")
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -114,12 +114,12 @@ feature -- Query
|
||||
|
||||
feature -- HTML Output
|
||||
|
||||
append_page_title_html_to (a_output: STRING)
|
||||
append_page_title_html_to (a_page: CMS_RESPONSE; a_output: STRING)
|
||||
-- Returns the title of the page as a html string. It shows the current page number and the name of the current user
|
||||
do
|
||||
a_output.append ("<h2>Posts from ")
|
||||
if attached user as l_user then
|
||||
a_output.append (html_encoded (l_user.name))
|
||||
a_output.append (html_encoded (a_page.user_profile_name (l_user)))
|
||||
else
|
||||
a_output.append ("unknown user")
|
||||
end
|
||||
|
||||
@@ -11,9 +11,14 @@ class
|
||||
inherit
|
||||
|
||||
CMS_MODULE
|
||||
redefine
|
||||
setup_hooks
|
||||
end
|
||||
|
||||
CMS_HOOK_BLOCK_HELPER
|
||||
|
||||
CMS_HOOK_VALUE_TABLE_ALTER
|
||||
|
||||
SHARED_EXECUTION_ENVIRONMENT
|
||||
export
|
||||
{NONE} all
|
||||
@@ -50,12 +55,36 @@ feature -- Router
|
||||
do
|
||||
create m.make_trailing_slash_ignored ("/gcse", create {WSF_URI_AGENT_HANDLER}.make (agent handle_search (a_api, ?, ?)))
|
||||
a_router.map (m, a_router.methods_head_get)
|
||||
end
|
||||
end
|
||||
|
||||
feature -- Recaptcha
|
||||
feature -- Hooks configuration
|
||||
|
||||
setup_hooks (a_hooks: CMS_HOOK_CORE_MANAGER)
|
||||
-- Module hooks configuration.
|
||||
do
|
||||
a_hooks.subscribe_to_value_table_alter_hook (Current)
|
||||
end
|
||||
|
||||
value_table_alter (a_value: CMS_VALUE_TABLE; a_response: CMS_RESPONSE)
|
||||
-- <Precursor>
|
||||
local
|
||||
l_url: STRING
|
||||
l_url_name: READABLE_STRING_GENERAL
|
||||
do
|
||||
if
|
||||
attached {WSF_STRING} a_response.request.query_parameter ("q") as l_query and then
|
||||
not l_query.value.is_empty
|
||||
then
|
||||
a_value.force (l_query.value, "google_search")
|
||||
else
|
||||
a_value.force (Void, "google_search")
|
||||
end
|
||||
end
|
||||
|
||||
feature -- GCSE Keys
|
||||
|
||||
gcse_secret_key (api: CMS_API): detachable READABLE_STRING_8
|
||||
-- Get recaptcha security key.
|
||||
-- Get google custom search security key.
|
||||
local
|
||||
utf: UTF_CONVERTER
|
||||
do
|
||||
@@ -70,7 +99,7 @@ feature -- Recaptcha
|
||||
end
|
||||
|
||||
gcse_cx_key (api: CMS_API): detachable READABLE_STRING_8
|
||||
-- Get recaptcha security key.
|
||||
-- Get google custom search cx key.
|
||||
local
|
||||
utf: UTF_CONVERTER
|
||||
do
|
||||
|
||||
@@ -335,7 +335,7 @@ feature {NONE} -- Trash:Restore
|
||||
b.append ("</a>")
|
||||
if attached n.author as l_author then
|
||||
b.append (" by ")
|
||||
b.append (r.link (l_author.name, "user/" + l_author.id.out, Void))
|
||||
b.append (r.link (r.user_profile_name (l_author), "user/" + l_author.id.out, Void))
|
||||
end
|
||||
if node_api.has_permission_for_action_on_node ("edit revisions", l_node, api.user) then
|
||||
b.append (" (<a href=%"")
|
||||
|
||||
@@ -123,7 +123,7 @@ feature -- HTTP Methods
|
||||
s.append (" | ")
|
||||
end
|
||||
if attached l_response.user as u and then l_response.has_permission ("view own trash") then
|
||||
s.append (l_response.link ("Your-trash", "trash?user=" + l_response.url_encoded (u.name), Void))
|
||||
s.append (l_response.link ("Your-trash", "trash?user=" + u.id.out, Void))
|
||||
s.append (" | ")
|
||||
end
|
||||
|
||||
|
||||
@@ -51,7 +51,11 @@ feature -- HTTP Methods
|
||||
create {GENERIC_VIEW_CMS_RESPONSE} l_page.make (req, res, api)
|
||||
if attached {WSF_STRING} req.query_parameter ("user") as p_username then
|
||||
l_username := p_username.value
|
||||
l_trash_owner := api.user_api.user_by_name (l_username)
|
||||
if l_username.is_integer_64 then
|
||||
l_trash_owner := api.user_api.user_by_id (l_username.to_integer_64)
|
||||
else
|
||||
l_trash_owner := api.user_api.user_by_name (l_username)
|
||||
end
|
||||
end
|
||||
if
|
||||
(l_trash_owner /= Void and then l_page.has_permissions (<<"view any trash", "view own trash">>))
|
||||
@@ -59,7 +63,7 @@ feature -- HTTP Methods
|
||||
then
|
||||
-- NOTE: for development purposes we have the following hardcode output.
|
||||
if l_trash_owner /= Void then
|
||||
create s.make_from_string ("<p>Trash for user " + l_page.html_encoded (l_trash_owner.name) + "</p>")
|
||||
create s.make_from_string ("<p>Trash for user " + l_page.html_encoded (l_page.user_profile_name (l_trash_owner)) + "</p>")
|
||||
else
|
||||
create s.make_from_string ("<p>Trash</p>")
|
||||
end
|
||||
|
||||
@@ -346,7 +346,7 @@ feature -- Handler
|
||||
l_content.append ("</td>")
|
||||
l_content.append ("<td class=%"user%">")
|
||||
if attached ch.author as u then
|
||||
l_content.append (r.link (u.name, "user/" + u.id.out, Void))
|
||||
l_content.append (r.link (r.user_profile_name (u), "user/" + u.id.out, Void))
|
||||
elseif attached ch.author_name as un then
|
||||
l_content.append (r.html_encoded (un))
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user