From bb3e2abf55a26433fa101c191b552b29510758c3 Mon Sep 17 00:00:00 2001 From: jvelilla Date: Wed, 8 Feb 2017 10:31:40 -0300 Subject: [PATCH] Updated google search module to keep the search input using an alter value. Updated feature description. --- examples/demo/site/themes/bootstrap/page.tpl | 2 +- .../src/google_custom_search_module.e | 37 +++++++++++++++++-- 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/examples/demo/site/themes/bootstrap/page.tpl b/examples/demo/site/themes/bootstrap/page.tpl index 3205841..4e584b8 100644 --- a/examples/demo/site/themes/bootstrap/page.tpl +++ b/examples/demo/site/themes/bootstrap/page.tpl @@ -42,7 +42,7 @@
- +
diff --git a/modules/google_search/src/google_custom_search_module.e b/modules/google_search/src/google_custom_search_module.e index 6001ce5..562a52d 100644 --- a/modules/google_search/src/google_custom_search_module.e +++ b/modules/google_search/src/google_custom_search_module.e @@ -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) + -- + 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