提交 e0063c29 编写于 作者: K kohsuke

added the search GUI.


git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@4062 71c3de6d-444a-0410-be80-ed276b4c234a
上级 682938f7
......@@ -14,6 +14,7 @@ import hudson.model.Project;
import hudson.model.Run;
import hudson.model.TopLevelItem;
import hudson.model.View;
import hudson.search.SearchableModelObject;
import org.apache.commons.jexl.parser.ASTSizeFunction;
import org.kohsuke.stapler.Ancestor;
import org.kohsuke.stapler.Stapler;
......@@ -355,6 +356,19 @@ public class Functions {
return null;
}
/**
* Finds the inner-most {@link SearchableModelObject} in scope.
*/
public static String getSearchURL() {
List list = Stapler.getCurrentRequest().getAncestors();
for( int i=list.size()-1; i>=0; i-- ) {
Ancestor anc = (Ancestor) list.get(i);
if(anc.getObject() instanceof SearchableModelObject)
return anc.getUrl()+"/search";
}
return null;
}
public static String appendSpaceIfNotNull(String n) {
if(n==null) return null;
else return n+' ';
......@@ -583,4 +597,7 @@ public class Functions {
}
return buf.toString();
}
// the switch to enable search feature
public static boolean searchFeature = System.getProperty("search")!=null;
}
......@@ -52,15 +52,15 @@
<tr><td style="font-weight:bold; font-size: 2em;">
<a href="${rootURL}/"><img src="${rootURL}/images/title.png" alt="title" /></a>
</td><td style="vertical-align: middle; text-align: right; padding-right: 1em;">
<!--form action="search">
<div id="searchform">
<img width="24" height="24" src="${rootURL}/images/24x24/find.gif"/>
<b>Search:</b>
<input name="search" size="12" value=""/>
<input type="submit" value="Go"/> <st:nbsp/>
</div>
</form-->
<j:if test="${h.searchFeature}">
<form action="${h.searchURL}">
<div id="searchform">
<input name="q" size="12" value="" id="search-box"/>
</div>
</form>
</j:if>
<j:if test="${app.useSecurity}">
<st:nbsp/>
<j:choose>
<j:when test="${request.userPrincipal!=null}">
<a style="color:white" href="${rootURL}/logout"><b>logout</b></a>
......
......@@ -36,6 +36,10 @@ table.center-align td {
text-decoration: none;
}
#search-box {
background: white url(../images/16x16/search.gif) no-repeat 2px center;
padding-left: 20px;
}
#left-top-nav {
text-align: left;
border-left: 10px solid #fff;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册