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