提交 a2b9eaee 编写于 作者: K kohsuke

implemented #152.


git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@1132 71c3de6d-444a-0410-be80-ed276b4c234a
上级 4de81f1e
...@@ -170,6 +170,12 @@ public class Functions { ...@@ -170,6 +170,12 @@ public class Functions {
return null; return null;
} }
public static String getCookie(HttpServletRequest req,String name, String defaultValue) {
Cookie c = getCookie(req, name);
if(c==null || c.getValue()==null) return defaultValue;
return c.getValue();
}
/** /**
* Creates a sub map by using the given range (both ends inclusive). * Creates a sub map by using the given range (both ends inclusive).
*/ */
......
...@@ -30,6 +30,7 @@ import javax.servlet.ServletContext; ...@@ -30,6 +30,7 @@ import javax.servlet.ServletContext;
import javax.servlet.ServletException; import javax.servlet.ServletException;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession; import javax.servlet.http.HttpSession;
import javax.servlet.http.Cookie;
import java.io.File; import java.io.File;
import java.io.FileFilter; import java.io.FileFilter;
import java.io.FileInputStream; import java.io.FileInputStream;
...@@ -1045,6 +1046,14 @@ public final class Hudson extends JobCollection implements Node { ...@@ -1045,6 +1046,14 @@ public final class Hudson extends JobCollection implements Node {
req.getView(this,"_script.jelly").forward(req,rsp); req.getView(this,"_script.jelly").forward(req,rsp);
} }
/**
* Changes the icon size by changing the cookie
*/
public void doIconSize( StaplerRequest req, StaplerResponse rsp ) throws IOException {
rsp.addCookie(new Cookie("iconSize",req.getQueryString()));
rsp.sendRedirect2(".");
}
public void doFingerprintCleanup( StaplerRequest req, StaplerResponse rsp ) throws IOException { public void doFingerprintCleanup( StaplerRequest req, StaplerResponse rsp ) throws IOException {
FingerprintCleanupThread.invoke(); FingerprintCleanupThread.invoke();
rsp.setStatus(HttpServletResponse.SC_OK); rsp.setStatus(HttpServletResponse.SC_OK);
......
...@@ -3,6 +3,14 @@ ...@@ -3,6 +3,14 @@
<%@ attribute name="showViewTabs" required="true" type="java.lang.Boolean" %> <%@ attribute name="showViewTabs" required="true" type="java.lang.Boolean" %>
--> -->
<j:jelly xmlns:j="jelly:core" xmlns:x="jelly:xml" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form"> <j:jelly xmlns:j="jelly:core" xmlns:x="jelly:xml" xmlns:st="jelly:stapler" xmlns:d="jelly:define" xmlns:l="/lib/layout" xmlns:t="/lib/hudson" xmlns:f="/lib/form">
<j:set var="iconSize" value="${h.getCookie(request,'iconSize','32x32')}" />
<!--
balls look smaller than their actual size,
so we try not to make the secondary icons look bigger than the icon.
we want the user's eyes to go to balls, not the clock.
-->
<j:set var="subIconSize" value="${h.ifThenElse(iconSize=='32x32','24x24',iconSize)}"/>
<div class="dashboard"> <div class="dashboard">
<j:if test="${!empty(jobs)}"> <j:if test="${!empty(jobs)}">
<!-- view tab bar --> <!-- view tab bar -->
...@@ -38,7 +46,7 @@ ...@@ -38,7 +46,7 @@
<j:set var="lfBuild" value="${job.lastFailedBuild}" /> <j:set var="lfBuild" value="${job.lastFailedBuild}" />
<tr> <tr>
<td data="${job.iconColor}"> <td data="${job.iconColor}">
<img width="32" height="32" src="${rootURL}/images/32x32/${job.buildStatusUrl}" /> <img src="${rootURL}/images/${iconSize}/${job.buildStatusUrl}" />
</td> </td>
<td> <td>
<a href="${rootURL}/${job.url}"> <a href="${rootURL}/${job.url}">
...@@ -86,14 +94,39 @@ ...@@ -86,14 +94,39 @@
<l:isAdmin> <l:isAdmin>
<td> <td>
<j:if test="${job.buildable}"> <j:if test="${job.buildable}">
<a href="${rootURL}/${job.url}build"><img src="${rootURL}/images/24x24/clock.gif" title="Schedule a build" border="0" /></a> <a href="${rootURL}/${job.url}build">
<img src="${rootURL}/images/${subIconSize}/clock.gif" title="Schedule a build" border="0" /></a>
</j:if> </j:if>
</td> </td>
</l:isAdmin> </l:isAdmin>
</tr> </tr>
</j:forEach> </j:forEach>
</x:element> </x:element>
<table style="width:100%">
<tr>
<d:taglib uri="local">
<d:tag name="iconSizeLink">
<st:nbsp/>
<j:choose>
<j:when test="${sz==iconSize}">
${title}
</j:when>
<j:otherwise>
<a href="${rootURL}/iconSize?${sz}">${title}</a>
</j:otherwise>
</j:choose>
</d:tag>
</d:taglib>
<td xmlns:local="local">Icon:
<local:iconSizeLink title="S" sz="16x16" />
<local:iconSizeLink title="M" sz="24x24" />
<local:iconSizeLink title="L" sz="32x32" />
</td><td>
<t:rssBar /> <t:rssBar />
</td>
</tr>
</table>
</j:if> </j:if>
</div> </div>
</j:jelly> </j:jelly>
\ No newline at end of file
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册