From aa45ded698f25e8d3bc8eef621d727186fe18dd2 Mon Sep 17 00:00:00 2001 From: Olivier Hallot Date: Fri, 23 Aug 2019 06:50:58 -0300 Subject: redmine#2555 replace Help online Google search This is the helpcontent2/ part of the patch. Add xapian-omega search to online Help. The patch replaces Google custom search with xapian-omega search. A new build key is introduced. --with-omindex=server : Localizes and adds the xapian result page template, adds the xapian form to each Help page. --with-omindex=noxap : do not localize the result template and do not add a form in the Help page. --with-omindex= will force Online Help build. Default is noxap NOTES: - xapian-omega databases are built in the server. - searches returns results only on localized Help pages, avoiding same resulis in many languages. TODO: - Tweak the xapian-omega result page CSS and markup. Change-Id: I3dc2b79c4111f61fd5fea01b1f8c95bfacab1e8f Reviewed-on: https://gerrit.libreoffice.org/79366 Tested-by: Jenkins Reviewed-by: Guilhem Moulin Tested-by: Guilhem Moulin --- AllLangPackage_html_lang.mk | 10 ++ CustomTarget_html.mk | 23 ++++- help3xsl/default.css | 16 ++- help3xsl/localized.xsl | 45 -------- help3xsl/online_transform.xsl | 41 +++----- help3xsl/xap_templ_query.xsl | 175 ++++++++++++++++++++++++++++++++ source/text/shared/help/browserhelp.xhp | 16 +++ 7 files changed, 249 insertions(+), 77 deletions(-) delete mode 100644 help3xsl/localized.xsl create mode 100644 help3xsl/xap_templ_query.xsl diff --git a/AllLangPackage_html_lang.mk b/AllLangPackage_html_lang.mk index d0b436f848..c3b25a09ce 100644 --- a/AllLangPackage_html_lang.mk +++ b/AllLangPackage_html_lang.mk @@ -19,4 +19,14 @@ $(eval $(call gb_AllLangPackage_add_files,helpcontent2_html_lang,$(LIBO_SHARE_HE ) \ )) +ifeq ($(HELP_OMINDEX_PAGE),TRUE) + +$(eval $(call gb_AllLangPackage_add_files,helpcontent2_html_lang,$(LIBO_SHARE_HELP_FOLDER)$(if $(HELP_ONLINE),/$(PRODUCTVERSION)),\ + $(foreach lang,$(gb_HELP_LANGS),\ + $(lang)/xap_tpl \ + ) \ +)) + +endif + # vim: set noet sw=4 ts=4: diff --git a/CustomTarget_html.mk b/CustomTarget_html.mk index de972bb73e..e43c17a48a 100644 --- a/CustomTarget_html.mk +++ b/CustomTarget_html.mk @@ -20,6 +20,7 @@ $(eval $(call gb_CustomTarget_register_targets,helpcontent2/help3xsl,\ $(foreach lang,$(gb_HELP_LANGS),\ $(lang)/bookmarks.js \ $(lang)/contents.js \ + $(if $(HELP_OMINDEX_PAGE),$(lang)/xap_tpl) \ $(lang)/html.text \ $(lang)/langnames.js \ $(foreach module,$(html_TREE_MODULES),$(module)/$(lang)/contents.part) \ @@ -53,6 +54,24 @@ $(call gb_CustomTarget_get_workdir,helpcontent2/help3xsl)/hid2file.js : \ ) > $@ \ ) +# Xapian localized templates +ifeq ($(HELP_OMINDEX_PAGE),TRUE) + +$(call gb_CustomTarget_get_workdir,helpcontent2/help3xsl)/%/xap_tpl : \ + $(SRCDIR)/helpcontent2/help3xsl/xap_templ_query.xsl \ + $(call gb_ExternalExecutable_get_dependencies,xsltproc) \ + $(SRCDIR)/helpcontent2/CustomTarget_html.mk + $(call gb_Output_announce,$(subst $(WORKDIR)/,,$@),$(true),XAT,1) + $(call gb_Helper_abbreviate_dirs,\ + $(call gb_ExternalExecutable_get_command,xsltproc) \ + --stringparam lang $* \ + -o $@ \ + $(SRCDIR)/helpcontent2/help3xsl/xap_templ_query.xsl \ + $(SRCDIR)/helpcontent2/source/text/shared/help/browserhelp.xhp \ + ) + +endif + # set of installed languages - has to be language independent $(call gb_CustomTarget_get_workdir,helpcontent2/help3xsl)/languages.js : \ $(SRCDIR)/helpcontent2/CustomTarget_html.mk @@ -62,6 +81,7 @@ $(call gb_CustomTarget_get_workdir,helpcontent2/help3xsl)/languages.js : \ printf ']);\n' \ ) > $@ + define html_gen_langnames_js_dep $(call gb_CustomTarget_get_workdir,helpcontent2/help3xsl)/$(1)/langnames.js : \ $(if $(filter en-US,$(1)),$(SRCDIR),$(call gb_HelpTranslatePartTarget_get_workdir,$(1)))/helpcontent2/source/text/shared/help/browserhelp.xhp @@ -152,6 +172,7 @@ $(call gb_CustomTarget_get_workdir,helpcontent2/help3xsl)/%/html.text : \ --stringparam root $(if $(filter WNT,$(OS)),$$(cygpath -m `pwd`),`pwd`)/ \ --stringparam productname "$(PRODUCTNAME)" \ --stringparam productversion "$(PRODUCTVERSION)" \ + --stringparam xapian $(if $(filter TRUE, $(HELP_OMINDEX_PAGE)),'yes','no') \ -o $(dir $@)$${xhp%.xhp}.html \ $(SRCDIR)/helpcontent2/help3xsl/online_transform.xsl \ $(if $(filter WNT,$(OS)),$$(cygpath -m `pwd`),`pwd`)/$$xhp \ @@ -160,7 +181,7 @@ $(call gb_CustomTarget_get_workdir,helpcontent2/help3xsl)/%/html.text : \ && rm "$$RESPONSEFILE" \ && touch $@ \ ) - + $(call gb_CustomTarget_get_workdir,helpcontent2/help3xsl)/%/bookmarks.js : $(call gb_Output_announce,$(subst $(WORKDIR)/,,$@),$(true),CAT,2) $(call gb_Helper_abbreviate_dirs,\ diff --git a/help3xsl/default.css b/help3xsl/default.css index 50a67b752a..f71cb68850 100644 --- a/help3xsl/default.css +++ b/help3xsl/default.css @@ -577,7 +577,7 @@ li.disabled a { #search-bar::placeholder { font-style: italic; } -.google-donation { +.xapian-donation { border-top: 2px solid #148603; background-color: #FCFCFC; box-shadow: 0 2px 8px 0 rgba(0,0,0,.05); @@ -607,9 +607,15 @@ li.disabled a { font-size:1.2rem; text-align: center; } -.google-search { +/*.xapian-omega-search { max-width: 300px; margin: 40px auto 0 auto; +}*/ +.xapian-omega-search { + margin: 0; + /*position: absolute;*/ + top: 19px; + left: 360px; } .modules { border-bottom: 2px solid #f3f3f3; @@ -803,7 +809,7 @@ li.disabled a { .rightside { grid-area: rightside; } - .google-donation { + .xapian-donation { grid-area: google; position: sticky; top: 0px; @@ -857,14 +863,14 @@ li.disabled a { /* Use @supports to sneak these rules past IE */ @supports (grid-area: auto) { @media screen and (min-width: 960px) { - .google-donation { + .xapian-donation { display: flex; justify-content: space-between; align-items: center; background-color: #18A303; border-top: none; } - .google-search { + .xapian-omega-search { margin: 0; } .donation { diff --git a/help3xsl/localized.xsl b/help3xsl/localized.xsl deleted file mode 100644 index c648049d56..0000000000 --- a/help3xsl/localized.xsl +++ /dev/null @@ -1,45 +0,0 @@ - - - - - - - - - - - var cx = '010161382024564278136:stzujqtpnve'; - var cx = '010161382024564278136:lcrnyzte-bs'; - var cx = '010161382024564278136:lcrnyzte-bs'; - var cx = '010161382024564278136:ruz0pcebqyi'; - var cx = '010161382024564278136:icywq-zn8hi'; - var cx = '010161382024564278136:5xb_5bltsto'; - var cx = '010161382024564278136:6ihy44_5qqu'; - var cx = '010161382024564278136:cdcn_oz4txg'; - var cx = '010161382024564278136:op1o8h6jnu8'; - var cx = '010161382024564278136:mimp7dbi-eq'; - var cx = '010161382024564278136:imtiawlmhnk'; - var cx = '010161382024564278136:xdxa9y906g0'; - var cx = '010161382024564278136:7wxg-zakzmu'; - var cx = '010161382024564278136:czaiuh5qxzu'; - var cx = '010161382024564278136:ndba33-gnzq'; - var cx = '010161382024564278136:1x2uk8j-rbw'; - var cx = '010161382024564278136:1x2uk8j-rbw'; - var cx = '010161382024564278136:syzgysikzms'; - var cx = '010161382024564278136:5varjpouixi'; - var cx = '010161382024564278136:gzcz3ueyhkw'; - var cx = '010161382024564278136:vkf9curztm8'; - var cx = '010161382024564278136:_goysgr6ptm'; - var cx = '010161382024564278136:stzujqtpnve'; - - - - diff --git a/help3xsl/online_transform.xsl b/help3xsl/online_transform.xsl index 2ca8deded7..f8d6dc2f91 100644 --- a/help3xsl/online_transform.xsl +++ b/help3xsl/online_transform.xsl @@ -21,7 +21,6 @@ - + + + + + + +$set{flag_spelling,$ne{$cgi{SPELL},0}} +$set{flag_spelling_correction,true} +$set{thousand,$.}$set{decimal,.} +$setmap{prefix,,$split{ S B F},title,S,author,A,topic,B} +${ +$def{PREV, +$if{$ne{$topdoc,0},, +} +} + +$def{NEXT, +$if{$ne{$last,$msize},, +} +} + +$def{P,} +$def{PAGE,$if{$gt{$1,9},$if{$gt{$1,99},$P{$1,$div{$1,100}}}$P{$1,$mod{$div{$1,10},10}}}$P{$1,$mod{$1,10}}} + +$def{S,$1} +$def{SPAGE,$if{$gt{$1,9},$if{$gt{$1,99},$S{$1,$div{$1,100}}}$S{$1,$mod{$div{$1,10},10}}}$S{$1,$mod{$1,10}}} +} + +$def{PREV,$if{$ne{$topdoc,0},}} + +$def{PAGE,} + +$def{SPAGE,} + + $def{NEXT,$if{$ne{$last,$msize},}} + + +$if{$query,Omega Search: $html{$query},Omega Search} + + + + + +
+
+ + + +
+]]>]]> + $map{$topterms,$html{$prettyterm{$_}} } +
+ +} +
+$if{$suggestion,]]>$html{$suggestion}
} + +$or{$html{$error}, +$if{$eq{$msize,0}, +$if{$query,]]>]]> +
+$if{$map{$queryterms,$set{U,$unstem{$_}}$set{F_$opt{U},$add{$opt{F_$opt{U}},$freq{$_}}}},$list{$unique{$map{$queryterms,$set{U,$unstem{$_}}$list{$html{$unique{$opt{U}}},,/,}: $nice{$opt{F_$opt{U}}}}},]]>]]> + +$hitlist{ +} +
+${$percentage%} +
+
+
+
+$if{$and{$field{modtime},$ne{$field{modtime},-1}}, + +
+} +$if{$field{language},Language: $html{$field{language}}
} +$if{$field{size},Size: $html{$filesize{$field{size}}}
} +
+ +
+
+
$html{$or{$field{caption},$field{title},$prettyurl{$field{url}},Untitled}}
+$snippet{$field{sample}}
+$html{$prettyurl{$field{url}}}
+ +]]>$list{$map{$terms,$html{$prettyterm{$_}}},$. , and }${for lynx:}

+ +
+ +${suppress next, prev, and page links if there's only one page} +$if{$ne{$lastpage,1}, +$set{a,$if{$opt{pagelink_height}, HEIGHT=$opt{pagelink_height}}$if{$opt{pagelink_width}, WIDTH=$opt{pagelink_width}}} + +${1-W ... X-(this)-Y ...} +$set{w,$min{3,$add{$thispage,-1}}} +$set{x,$max{$add{$opt{w},1},$add{$thispage,-3}}} +$set{y,$min{$lastpage,$add{$thispage,8}}} +$PREV +$map{$range{1,$opt{w}},$PAGE{$_}} +$if{$ne{$add{$opt{w},1},$opt{x}},...} +$map{$range{$opt{x},$add{$thispage,-1}},$PAGE{$_}} +$SPAGE{$thispage} +$map{$range{$add{$thispage,1},$opt{y}},$PAGE{$_}} +$if{$ne{$opt{y},$lastpage},...} +$NEXT +} +}} +

+$if{$ne{$topdoc,0},} +$if{$ne{$hitsperpage,10},} +$if{$cgi{COLLAPSE},} +$if{$queryterms,} + +$list{$relevants,} +$if{$cgi{THRESHOLD},} +${Preserve any B filters used - this needs modifying if you modify this template + to have B on radio buttons, SELECT, etc} +$map{$cgilist{B},} + +
+ + +$log{query.log}]]> +
+
diff --git a/source/text/shared/help/browserhelp.xhp b/source/text/shared/help/browserhelp.xhp index e4245d1432..1f3cba850a 100644 --- a/source/text/shared/help/browserhelp.xhp +++ b/source/text/shared/help/browserhelp.xhp @@ -95,5 +95,21 @@ Vietnamese Chinese (Simplified) Chinese (Traditional) + + Next + Previous + Modified: + Searching $nice{$dbsize} documents + All $nice{$msize} matches + Search took $time seconds + No documents match your query + Matching all words + Matching any words + of about $nice{$msize} matches + of exactly $nice{$msize} matches + Term frequencies: + matching: + Mark this document as relevant + Did you mean: -- cgit