Wiki source code of Interactive Link Visualizer
Last modified by RPG Research Xwiki Documents Administrator on 2023/09/27 22:38
Hide last authors
| author | version | line-number | content |
|---|---|---|---|
| |
1.1 | 1 | {{velocity output="false"}} |
| 2 | #set ($discard = $xwiki.ssx.use('XWiki.InteractiveLinkVisualizer.Code.MainVisualisation')) | ||
| 3 | #set ($discard = $xwiki.jsx.use('XWiki.InteractiveLinkVisualizer.Code.MainVisualisation')) | ||
| 4 | {{/velocity}} | ||
| 5 | |||
| 6 | {{include reference="Main.SolrSearchConfig" /}} | ||
| 7 | |||
| 8 | {{include reference="Main.SolrSearchMacros" /}} | ||
| 9 | |||
| 10 | {{velocity output="false"}} | ||
| 11 | #set ($discard = $solrConfig.facetFields.remove('type')) | ||
| 12 | #set ($discard = $solrConfig.filterQuery.add('type:DOCUMENT')) | ||
| 13 | #set ($discard = $solrConfig.put('facetEnabled', false)) | ||
| 14 | ## To return visualisation as search results | ||
| 15 | #macro (displaySearchResults) | ||
| 16 | {{html}} | ||
| 17 | <div id="top-bar"> | ||
| 18 | <div id="search"> | ||
| 19 | <i class="fa fa-search"></i> | ||
| 20 | <input | ||
| 21 | type="search" | ||
| 22 | id="search-input" | ||
| 23 | list="suggestions" | ||
| 24 | placeholder="$services.localization.render('intlv.topbar.search.placeholder')" | ||
| 25 | title="$services.localization.render('intlv.topbar.search.title')"> | ||
| 26 | </input> | ||
| 27 | <datalist id="suggestions"></datalist> | ||
| 28 | </div> | ||
| 29 | <div title="$services.localization.render('intlv.topbar.graphinfo.hint')" id="graph-info"> | ||
| 30 | <span id="node-count"></span> | ||
| 31 | <span id="edge-count"></span> | ||
| 32 | </div> | ||
| 33 | </div> | ||
| 34 | <div id="sigma-container" data-results="$escapetool.xml($jsontool.serialize($searchResponse.results))"> | ||
| 35 | <div class="buttonwrapper" id="graph-buttons"> | ||
| 36 | <button class="icon-button" title="$services.localization.render('intlv.sigmacontainer.buttons.title.zoomin') | ||
| 37 | " id="zoom-in">$services.icon.renderHTML('search-plus')</button> | ||
| 38 | <button class="icon-button" title="$services.localization.render('intlv.sigmacontainer.buttons.title.zoomout') | ||
| 39 | " id="zoom-out">$services.icon.renderHTML('search-minus')</button> | ||
| 40 | <button class="icon-button" title="$services.localization.render('intlv.sigmacontainer.buttons.title.iterations') | ||
| 41 | " id="iteration-button">$services.icon.renderHTML('refresh')</button> | ||
| 42 | <button class="icon-button" title="$services.localization.render('intlv.sigmacontainer.buttons.title.zoomdefault') | ||
| 43 | " id="zoom-reset">$services.icon.renderHTML('world')</button> | ||
| 44 | <button class="icon-button" title="$services.localization.render('intlv.sigmacontainer.buttons.title.fullscreen') | ||
| 45 | " id="view-fullscreen">$services.icon.renderHTML('arrows')</button> | ||
| 46 | <button class="icon-button hidden" title="$services.localization.render('intlv.sigmacontainer.buttons.title.killgraph')" id="kill-graph-button">$services.icon.renderHTML('delete')</button> | ||
| 47 | </div> | ||
| 48 | </div> | ||
| 49 | {{/html}} | ||
| 50 | #end | ||
| 51 | |||
| 52 | ## To get only the relevant field list (ridiculous performance improvement) | ||
| 53 | #macro(setHighlightQuery $query) | ||
| 54 | #set ($discard = $query.bindValue('fl', 'title_, reference, links, wiki, name, spaces')) | ||
| 55 | #end | ||
| 56 | ## For number of results input & rows override | ||
| 57 | |||
| 58 | #macro (displaySearchForm) | ||
| 59 | ## Override default no. of rows | ||
| 60 | #set ($rows = $numbertool.toNumber($request.rows).intValue()) | ||
| 61 | #if ("$!rows" == '') | ||
| 62 | #set ($rows = 1000) | ||
| 63 | #end | ||
| 64 | ## | ||
| 65 | #set($void = $services.progress.startStep('#displaySearchForm')) | ||
| 66 | {{html clean="false"}} | ||
| 67 | <form class="search-form row" action="$doc.getURL()" role="search"> | ||
| 68 | <div class="hidden"> | ||
| 69 | <input type="hidden" name="sort" value="$!escapetool.xml($sort)"/> | ||
| 70 | <input type="hidden" name="sortOrder" value="$!escapetool.xml($sortOrder)"/> | ||
| 71 | <input type="hidden" name="highlight" value="$highlightEnabled"/> | ||
| 72 | <input type="hidden" name="facet" value="$facetEnabled"/> | ||
| 73 | ## The parameter used to determine if the request has been redirected with default search filters. | ||
| 74 | <input type="hidden" name="r" value="$!escapetool.xml($request.r)"/> | ||
| 75 | #if ("$!request.debug" != '') | ||
| 76 | <input type="hidden" name="debug" value="$escapetool.xml($request.debug)"/> | ||
| 77 | #end | ||
| 78 | ## Preserve the current facet values when submitting a new search query. | ||
| 79 | #foreach ($entry in $request.parameterMap.entrySet()) | ||
| 80 | #if ($entry.key.startsWith('f_') || $entry.key.startsWith('l_')) | ||
| 81 | #foreach ($value in $entry.value) | ||
| 82 | <input type="hidden" name="$escapetool.xml($entry.key)" value="$escapetool.xml($value)"/> | ||
| 83 | #end | ||
| 84 | #end | ||
| 85 | #end | ||
| 86 | </div> | ||
| 87 | <div class="col-xs-12 col-sm-6"> | ||
| 88 | <div class="input-group"> | ||
| 89 | <input type="search" name="text" class="form-control withTip useTitleAsTip" | ||
| 90 | title="$services.localization.render('search.page.bar.query.title')" value="$escapetool.xml($text)"/> | ||
| 91 | <span class="input-group-btn"> | ||
| 92 | <button type="submit" class="btn btn-primary"> | ||
| 93 | $services.icon.renderHTML('search') | ||
| 94 | <span class="sr-only">$services.localization.render('search.page.bar.submit')</span> | ||
| 95 | </button> | ||
| 96 | </span> | ||
| 97 | </div> | ||
| 98 | <div> | ||
| 99 | <label for="rows" style="margin-right: 2%;">$services.localization.render('intlv.sigmacontainer.form.label.documentfilter') | ||
| 100 | </label> | ||
| 101 | <input id="rows" type="number" name="rows" title="$services.localization.render('intlv.sigmacontainer.form.title.documentfilter')" | ||
| 102 | placeholder="1000" value="$!escapetool.xml($request.rows)"/> | ||
| 103 | <span> | ||
| 104 | <button type="submit" id="refresh-button" class="btn btn-primary"> | ||
| 105 | $services.icon.renderHTML('refresh') | ||
| 106 | </button> | ||
| 107 | </span> | ||
| 108 | </div> | ||
| 109 | </div> | ||
| 110 | </form> | ||
| 111 | |||
| 112 | {{/html}} | ||
| 113 | #if ($text == '') | ||
| 114 | #set ($text = "*") | ||
| 115 | #end | ||
| 116 | #end | ||
| 117 | |||
| 118 | ## To disable Highlighting Search Option | ||
| 119 | #macro (displaySearchResultsSort) | ||
| 120 | #set ($defaultSortOrder = $solrConfig.sortFields.get($type)) | ||
| 121 | #if (!$defaultSortOrder) | ||
| 122 | #set ($defaultSortOrder = {'score': 'desc'}) | ||
| 123 | #end | ||
| 124 | #set ($sortOrderSymbol = { | ||
| 125 | 'asc': $services.icon.render('caret-up'), | ||
| 126 | 'desc': $services.icon.render('caret-down') | ||
| 127 | }) | ||
| 128 | (% class="search-options" %) | ||
| 129 | * {{translation key="solr.options"/}} | ||
| 130 | #if($facetEnabled)#extendQueryString($url {'facet': [false]})#else#extendQueryString($url {'facet': [true]})#end | ||
| 131 | * [[{{translation key="solr.options.facet"/}}>>path:${url}||class="options-item#if($facetEnabled) active#end" title="$services.localization.render('solr.options.facet.title')"]] | ||
| 132 | |||
| 133 | (% class="search-results-sort" %) | ||
| 134 | * {{translation key="solr.sortBy"/}} | ||
| 135 | #foreach ($entry in $defaultSortOrder.entrySet()) | ||
| 136 | #set ($class = 'sort-item') | ||
| 137 | #set ($sortOrderIndicator = $NULL) | ||
| 138 | #set ($targetSortOrder = $entry.value) | ||
| 139 | #if ($sort == $entry.key) | ||
| 140 | #set ($class = "$class active") | ||
| 141 | #set ($sortOrderHint = $services.localization.render("solr.sortOrder.$sortOrder")) | ||
| 142 | #set ($sortOrderIndicator = "(% class=""sort-item-order"" title=""$sortOrderHint"" %)$sortOrderSymbol.get($sortOrder)(%%)") | ||
| 143 | #set ($targetSortOrder = "#if ($sortOrder == 'asc')desc#{else}asc#end") | ||
| 144 | #end | ||
| 145 | #extendQueryString($url {'sort': [$entry.key], 'sortOrder': [$targetSortOrder]}) | ||
| 146 | * [[{{translation key="solr.sortBy.$entry.key"/}}$!sortOrderIndicator>>path:${url}||class="$class"]] | ||
| 147 | #end | ||
| 148 | #end | ||
| 149 | {{/velocity}} | ||
| 150 | |||
| 151 | {{velocity}} | ||
| 152 | #handleSolrSearchRequest | ||
| 153 | {{/velocity}} |