diff --git a/src/org/opensolaris/opengrok/history/History.java b/src/org/opensolaris/opengrok/history/History.java index c14a2f38b7b..b3f0d39e47f 100644 --- a/src/org/opensolaris/opengrok/history/History.java +++ b/src/org/opensolaris/opengrok/history/History.java @@ -71,6 +71,20 @@ public List getHistoryEntries() { return entries; } + /** + * Get the list of log entries, most recent first. + * With parameters + * @param limit max number of entries + * @param offset starting position + * + * @return The list of entries in this history + */ + public List getHistoryEntries(int limit, int offset) { + offset = offset < 0 ? 0 : offset; + limit = offset + limit > entries.size() ? limit = entries.size() - offset : limit; + return entries.subList(offset, offset + limit); + } + /** * Check if at least one history entry has a file list. * diff --git a/src/org/opensolaris/opengrok/web/PageConfig.java b/src/org/opensolaris/opengrok/web/PageConfig.java index a10da14f852..00ff5dfe520 100644 --- a/src/org/opensolaris/opengrok/web/PageConfig.java +++ b/src/org/opensolaris/opengrok/web/PageConfig.java @@ -18,7 +18,7 @@ */ /* - * Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2016, Oracle and/or its affiliates. All rights reserved. * Portions copyright (c) 2011 Jens Elkner. */ package org.opensolaris.opengrok.web; @@ -416,7 +416,7 @@ public int getIntParam(String name, int defaultValue) { } return ret; } - + /** * Get the start index for a search result to return by looking up * the {@code start} request parameter. diff --git a/web/default/style.css b/web/default/style.css index 16865177fc0..ad792e3753b 100644 --- a/web/default/style.css +++ b/web/default/style.css @@ -745,7 +745,7 @@ a.scope { /* scope */ color: dodgerblue; font-weight: bold; pa #results { } -#results p { /* pagetitle and slider */ +#results p, #revisions p { /* pagetitle and slider */ padding: 0.1em; } @@ -795,14 +795,14 @@ a.scope { /* scope */ color: dodgerblue; font-weight: bold; pa padding-left: 1ex; } -#results .sel { /* slider item for the shown search result page */ +#results .sel, #revisions .sel { /* slider item for the shown search result page */ background-color: #a3b8cb; border: 1px #333366 solid; padding: .5em; margin: 1px; } -#results .more { /* slider item for the n-th search result page */ +#results .more, #revisions .more { /* slider item for the n-th search result page */ border: 1px #bba solid; padding: .3em; margin: 1px; diff --git a/web/history.jsp b/web/history.jsp index 9759229f92c..b8ee0a33d88 100644 --- a/web/history.jsp +++ b/web/history.jsp @@ -18,7 +18,7 @@ information: Portions Copyright [yyyy] [name of copyright owner] CDDL HEADER END -Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. +Copyright (c) 2005, 2016, Oracle and/or its affiliates. All rights reserved. Portions Copyright 2011 Jens Elkner. @@ -87,10 +87,73 @@ document.domReady.push(function() {domReadyHistory();}); } +<% +// We have a lots of results to show: create a slider for +String slider = ""; +int thispage; // number of items to display on the current page +int start = cfg.getSearchStart(); +int max = cfg.getSearchMaxItems(); +int totalHits = hist.getHistoryEntries().size(); +if (max < totalHits) { + StringBuilder buf = new StringBuilder(4096); + thispage = (start + max) < totalHits ? max : totalHits - start; + int labelStart = 1; + int sstart = start - max * (start / max % 10 + 1) ; + if (sstart < 0) { + sstart = 0; + labelStart = 1; + } else { + labelStart = sstart / max + 1; + } + int label = labelStart; + int labelEnd = label + 11; + for (int i = sstart; i < totalHits && label <= labelEnd; i+= max) { + if (i <= start && start < i + max) { + buf.append("").append(label).append(""); + } else { + buf.append(""); + if (label == labelStart && label != 1) { + buf.append("<<"); + } else if (label == labelEnd && i < totalHits) { + buf.append(">>"); + } else { + buf.append(label); + } + buf.append(""); + } + label++; + } + slider = buf.toString(); +} else { + // set the max index to max or last + thispage = totalHits - start; +} + +int revision2 = cfg.getIntParam("r2", -1) < 0 ? 0 : cfg.getIntParam("r2", -1); +int revision1 = cfg.getIntParam("r1", -1) < revision2 ? revision2 + 1 : cfg.getIntParam("r1", -1); +revision2 = revision2 >= hist.getHistoryEntries().size() ? hist.getHistoryEntries().size() - 1 : revision2; + + +%> +
+ + uriEncodedName %>"><%= path %> + (Results <%= start + 1 %> - <%= thispage + start + %> of <%= totalHits %>) +

<%= slider %>

+ + <% if (!cfg.isDir()) { %> - <% + <% } %> @@ -122,9 +192,9 @@ document.domReady.push(function() {domReadyHistory();}); - <% + <% int count=0; - for (HistoryEntry entry : hist.getHistoryEntries()) { + for (HistoryEntry entry : hist.getHistoryEntries(max, start)) { String rev = entry.getRevision(); if (rev == null || rev.length() == 0) { rev = ""; @@ -157,20 +227,32 @@ document.domReady.push(function() {domReadyHistory();}); title="link to revision line">#<%= rev %> - <% + <% } else { striked = true; %> diff --git a/web/offwhite/style.css b/web/offwhite/style.css index 07d401601ac..b18177fb5e3 100644 --- a/web/offwhite/style.css +++ b/web/offwhite/style.css @@ -746,7 +746,7 @@ a.scope { /* scope */ color: dodgerblue; font-weight: bold; pa #results { } -#results p { /* pagetitle and slider */ +#results p, #revisions p { /* pagetitle and slider */ padding: 0.5em; } @@ -782,14 +782,14 @@ a.scope { /* scope */ color: dodgerblue; font-weight: bold; pa font-weight: bold; } -#results .sel { /* slider item for the shown search result page */ +#results .sel, #revisions .sel { /* slider item for the shown search result page */ background-color: #d6d6c0; border: 1px #998 solid; padding: .5em; margin: 1px; } -#results .more { /* slider item for the n-th search result page */ +#results .more, #revisions .more { /* slider item for the n-th search result page */ border: 1px #bba solid; padding: .3em; margin: 1px; diff --git a/web/polished/style.css b/web/polished/style.css index 767fcad65fa..4a797ba70f1 100644 --- a/web/polished/style.css +++ b/web/polished/style.css @@ -805,7 +805,7 @@ a.scope { /* scope */ color: dodgerblue; font-weight: bold; pa padding: 1ex 0; } -#results p { /* pagetitle and slider */ +#results p, #revisions p { /* pagetitle and slider */ padding: 0.5em; } @@ -851,14 +851,14 @@ a.scope { /* scope */ color: dodgerblue; font-weight: bold; pa font-weight: bold; } -#results .sel { /* slider item for the shown search result page */ +#results .sel, #revisions .sel { /* slider item for the shown search result page */ background-color: #a3b8cb; border: 1px solid #333366; padding: .5em; margin: 1px; } -#results .more { /* slider item for the n-th search result page */ +#results .more, #revisions .more { /* slider item for the n-th search result page */ border: 1px #ccc solid; padding: .3em; margin: 1px;
History log of <%= path %>
Revision <% @@ -104,7 +167,14 @@ document.domReady.push(function() {domReadyHistory();}); %> + <% if (hist.getHistoryEntries().size() > revision1 && revision1 >= 0) { %> + + <% } %> + <% if (hist.getHistoryEntries().size() > revision2 && revision2 >= 0) { %> + + <% } %> + Date
- disabled="disabled"<% - } else if (count == 1) { - %> checked="checked"<% - } - %> name="r1" value="<%= path %>@<%= rev%>"/> - checked="checked"<% - } - %> value="<%= path %>@<%= rev %>"/><% + String url; + if (count + start > revision1 || (count + start > revision2 && count + start <= revision1 - 1)) { + // revision1 enabled + url = context + Prefix.HIST_L + uriEncodedName + "?n=" + max + "&start=" + start +"&r1="+(start + count) +"&r2="+revision2; + %><% + } else if (count + start == revision1 ) { + // revision1 selected + %><% + } else if( count + start <= revision2 ) { + // revision1 disabled + %><% + } + + if( count + start < revision2 || (count + start > revision2 && count + start <= revision1 - 1) ) { + // revision2 enabled + url = context + Prefix.HIST_L + uriEncodedName + "?n=" + max + "&start=" + start +"&r1="+revision1 +"&r2="+(start + count); + %><% + } else if( count + start == revision2 ) { + // revision2 selected + %><% + } else if (count + start >= revision1 ) { + // revision2 disabled + %><% + } + %>