Procházet zdrojové kódy

add searchpath UI extension

Baris Ayaz před 5 roky
rodič
revize
4140862328

+ 1 - 0
src/main/resources/fess_label_de.properties

@@ -320,6 +320,7 @@ labels.profile.placeholder_confirm_new_password=Neues Passwort (bestätigen)
 labels.top.search=Suche
 labels.index_title=Fess
 labels.index_form_search_btn=Suche
+labels.index_form_searchpath_btn=Pfad
 labels.index_osdd_title=Suche
 labels.index_form_option_btn=Optionen
 labels.index_help=Hilfe

+ 1 - 0
src/main/resources/fess_label_en.properties

@@ -364,6 +364,7 @@ labels.profile.placeholder_confirm_new_password=Confirm New Password
 labels.top.search=Search
 labels.index_title=Fess
 labels.index_form_search_btn=Search
+labels.index_form_searchpath_btn=Path
 labels.index_osdd_title=Search
 labels.index_form_option_btn=Options
 labels.index_help=Help

+ 26 - 0
src/main/webapp/WEB-INF/view/header.jsp

@@ -21,6 +21,14 @@
 								class="btn btn-primary">
 								<em class="fa fa-search"></em>
 							</button>
+							<button type="button" class="btn btn-light"
+								data-toggle="control-search-path" data-target="#searchPath"
+								id="searchPathButton">
+								<i class="far fa-folder"></i> 
+								<span class="sr-only">
+									<la:message key="labels.index_form_searchpath_btn" />
+								</span>
+							</button>
 							<button type="button" class="btn btn-light"
 								data-toggle="control-options" data-target="#searchOptions"
 								id="searchOptionsButton">
@@ -94,4 +102,22 @@
 			</div>
 		</div>
 	</div>
+
+	<div id="searchPath" class="control-search-path">
+		<div class="container">
+				<div class="input-group mb-3">
+						<div class="input-group-prepend">
+								<span class="input-group-text" id="basic-addon1"><i class="far fa-folder"></i></span>
+						</div>
+						<input type="text" class="form-control" placeholder="" aria-label="" aria-describedby="search path"
+								id="searchPathField" name="searchPath" value="${f:h(fe:join(searchPath))}">
+						<div class="input-group-append">
+								<button class="btn btn-outline-secondary" type="button" id="searchPathFieldClear">
+										<i class="fa fa-times-circle"></i>
+								</button>
+						</div>
+				</div>
+		</div>
+</div>
+
 </la:form>

+ 22 - 0
src/main/webapp/WEB-INF/view/index.jsp

@@ -118,6 +118,22 @@
 									autocomplete="off" />
 							</div>
 						</div>
+						<div id="searchPath" class="control-search-path mx-auto col-10 col-sm-8 col-md-8 col-lg-6" style="margin-top:10px;">
+							<div class="container">
+								<div class="input-group mb-3">
+									<div class="input-group-prepend">
+										<span class="input-group-text" id="basic-addon1"><i class="far fa-folder"></i></span>
+									</div>
+									<input type="text" class="form-control" placeholder="" aria-label="" aria-describedby="search path"
+										id="searchPathField" name="searchPath" value="${f:h(fe:join(searchPath))}">
+									<div class="input-group-append">
+										<button class="btn btn-outline-secondary" type="button" id="searchPathFieldClear">
+											<i class="fa fa-times-circle"></i>
+										</button>
+									</div>
+								</div>
+							</div>
+						</div>
 						<c:if test="${!empty popularWords}">
 							<div class="clearfix">
 								<p class="text-truncate">
@@ -141,6 +157,11 @@
 								<em class="fa fa-search"></em>
 								<la:message key="labels.index_form_search_btn" />
 							</button>
+							<button type="button" class="btn btn-outline-secondary"
+								data-toggle="control-search-path" data-target="#searchPath" id="searchPathButton">
+								<i class="far fa-folder"></i>
+								<la:message key="labels.index_form_searchpath_btn" />
+							</button>
 							<button type="button" class="btn btn-outline-secondary"
 								data-toggle="control-options" data-target="#searchOptions"
 								id="searchOptionsButton">
@@ -160,5 +181,6 @@
 	<script type="text/javascript" src="${fe:url('/js/bootstrap.min.js')}"></script>
 	<script type="text/javascript" src="${fe:url('/js/suggestor.js')}"></script>
 	<script type="text/javascript" src="${fe:url('/js/index.js')}"></script>
+	<script type="text/javascript" src="${fe:url('/js/searchpath.js')}"></script>
 </body>
 </html>

+ 1 - 0
src/main/webapp/WEB-INF/view/search.jsp

@@ -153,5 +153,6 @@
 	<script type="text/javascript" src="${fe:url('/js/bootstrap.min.js')}"></script>
 	<script type="text/javascript" src="${fe:url('/js/suggestor.js')}"></script>
 	<script type="text/javascript" src="${fe:url('/js/search.js')}"></script>
+	<script type="text/javascript" src="${fe:url('/js/searchpath.js')}"></script>
 </body>
 </html>

+ 4 - 0
src/main/webapp/css/style.css

@@ -160,3 +160,7 @@ legend{
 		white-space: nowrap;
 	}
 }
+
+/* searchPath extension */
+#searchPath {display: none;}
+#searchPath.active {display: block;}

+ 52 - 0
src/main/webapp/js/searchpath.js

@@ -0,0 +1,52 @@
+// Search Path extension
+$("[data-toggle='control-search-path']").click(function (e) {
+  e.preventDefault();
+  var target = $(this).attr("data-target") || $(this).attr("href");
+  if (target) {
+    $(target).toggleClass("active");
+  }
+});
+
+$('#searchPathFieldClear').click(function (e) {
+  $('#searchPathField').val('');
+});
+
+
+$(function () {
+  var query = (location.search.split('q' + '=')[1] || '').split('&')[0];
+  var searchPathTerms = [];
+
+  if (query.indexOf("inurl") > 0) {
+    var inurlEncodedMatches = query.match(/inurl%3A%22(.*?)%22/g) || [""];
+    inurlEncodedMatches.forEach(function (item, idx) {
+      var inurl = decodeURIComponent(item)
+      // console.log("In URL: " + inurl);
+
+      var searchPathTerm = (inurl.match("\\inurl:\"(.*?)\\\"") || [""])[1];
+      // console.log("Search Path Term: " + searchPathTerm);
+
+      //Replace inurl in query
+      $('#query').val($('#query').val().replace('inurl:\"' + searchPathTerm + '\"', '').trim())
+      searchPathTerms.push(searchPathTerm);
+    });
+
+    //Activate search path field
+    $('#searchPath').toggleClass("active", true);
+    $('#searchPathField').val(searchPathTerms.join(" "));
+  }
+});
+
+$('#searchForm').submit(function () {
+  var searchPath = $('#searchPathField').val();
+  if (searchPath != "") {
+    $('#query').css('color', 'white');
+    $('#contentQuery').css('color', 'white');
+    $('#searchPathField').css('color', 'white');
+
+    var searchPathTerms = searchPath.split(" ");
+    searchPathTerms.forEach(function (item, idx) {
+      $('#query').val($('#query').val() + " inurl:\"" + item + "\"");
+      $('#contentQuery').val($('#contentQuery').val() + " inurl:\"" + item + "\"");
+    })
+  }
+});