summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJames Moger <james.moger@gitblit.com>2013-06-10 18:42:14 -0400
committerJames Moger <james.moger@gitblit.com>2013-06-10 18:42:14 -0400
commit1a8eb19b3cd55646adde33d922e8bc10f0090050 (patch)
tree919f543834ddf933b69e25074bc84e0610c187e3
parent90fe56fc71e7a7f43ed34831dddb13b94ad3d1cb (diff)
downloadgitblit-1a8eb19b3cd55646adde33d922e8bc10f0090050.tar.gz
gitblit-1a8eb19b3cd55646adde33d922e8bc10f0090050.zip
Make days back filter a setting
-rw-r--r--releases.moxie3
-rw-r--r--src/main/distrib/data/gitblit.properties12
-rw-r--r--src/main/java/com/gitblit/GitBlit.java13
-rw-r--r--src/main/java/com/gitblit/IStoredSettings.java35
-rw-r--r--src/main/java/com/gitblit/wicket/pages/ActivityPage.java2
-rw-r--r--src/main/java/com/gitblit/wicket/pages/RootPage.java12
6 files changed, 69 insertions, 8 deletions
diff --git a/releases.moxie b/releases.moxie
index 2b72bd22..0a73d5bb 100644
--- a/releases.moxie
+++ b/releases.moxie
@@ -35,6 +35,8 @@ r17: {
- Improve Gerrit change ref decoration in the refs panel (issue 206)
- Disable Gson's pretty printing which has a huge performance gain
- Properly set application/json content-type on api calls
+ - Make days back filter choices a setting
+ - Changed default days back filter setting to 7 days
- Improved page title
- Updated Polish translation
- Updated Japanese translation
@@ -105,6 +107,7 @@ r17: {
- { name: 'mail.smtps', defaultValue: false }
- { name: 'realm.salesforce.backingUserService', defaultValue: 'users.conf' }
- { name: 'realm.salesforce.orgId', defaultValue: 0 }
+ - { name: 'web.activityDurationChoices', defaultValue: '7 14 28 60 90 180' }
- { name: 'web.allowAppCloneLinks', defaultValue: true }
- { name: 'web.forceDefaultLocale', defaultValue: ' ' }
- { name: 'web.overviewPushCount', defaultValue: 5 }
diff --git a/src/main/distrib/data/gitblit.properties b/src/main/distrib/data/gitblit.properties
index 82e77f35..a6dc3158 100644
--- a/src/main/distrib/data/gitblit.properties
+++ b/src/main/distrib/data/gitblit.properties
@@ -814,11 +814,17 @@ web.showSearchTypeSelection = false
# SINCE 0.5.0
web.generateActivityGraph = true
-# The number of days to show on the activity page.
-# Value must exceed 0 else default of 14 is used
+# The default number of days to show on the activity page.
+# Value must exceed 0 else default of 7 is used
#
# SINCE 0.8.0
-web.activityDuration = 14
+web.activityDuration = 7
+
+# Choices for days of activity to display.
+#
+# SPACE-DELIMITED
+# SINCE 1.3.0
+web.activityDurationChoices = 7 14 28 60 90 180
# The number of commits to display on the summary page
# Value must exceed 0 else default of 20 is used
diff --git a/src/main/java/com/gitblit/GitBlit.java b/src/main/java/com/gitblit/GitBlit.java
index 71f33b4a..ceb40c13 100644
--- a/src/main/java/com/gitblit/GitBlit.java
+++ b/src/main/java/com/gitblit/GitBlit.java
@@ -312,6 +312,19 @@ public class GitBlit implements ServletContextListener {
public static int getInteger(String key, int defaultValue) {
return self().settings.getInteger(key, defaultValue);
}
+
+ /**
+ * Returns the integer list for the specified key. If the key does not
+ * exist or the value for the key can not be interpreted as an integer, an
+ * empty list is returned.
+ *
+ * @see IStoredSettings.getIntegers(String key)
+ * @param key
+ * @return key value or defaultValue
+ */
+ public static List<Integer> getIntegers(String key) {
+ return self().settings.getIntegers(key);
+ }
/**
* Returns the value in bytes for the specified key. If the key does not
diff --git a/src/main/java/com/gitblit/IStoredSettings.java b/src/main/java/com/gitblit/IStoredSettings.java
index f0b1e632..acb9fc60 100644
--- a/src/main/java/com/gitblit/IStoredSettings.java
+++ b/src/main/java/com/gitblit/IStoredSettings.java
@@ -261,6 +261,41 @@ public abstract class IStoredSettings {
}
/**
+ * Returns a list of space-separated integers from the specified key.
+ *
+ * @param name
+ * @return list of strings
+ */
+ public List<Integer> getIntegers(String name) {
+ return getIntegers(name, " ");
+ }
+
+ /**
+ * Returns a list of integers from the specified key using the specified
+ * string separator.
+ *
+ * @param name
+ * @param separator
+ * @return list of integers
+ */
+ public List<Integer> getIntegers(String name, String separator) {
+ List<Integer> ints = new ArrayList<Integer>();
+ Properties props = getSettings();
+ if (props.containsKey(name)) {
+ String value = props.getProperty(name);
+ List<String> strings = StringUtils.getStringsFromValue(value, separator);
+ for (String str : strings) {
+ try {
+ int i = Integer.parseInt(str);
+ ints.add(i);
+ } catch (NumberFormatException e) {
+ }
+ }
+ }
+ return ints;
+ }
+
+ /**
* Returns a map of strings from the specified key.
*
* @param name
diff --git a/src/main/java/com/gitblit/wicket/pages/ActivityPage.java b/src/main/java/com/gitblit/wicket/pages/ActivityPage.java
index 8e841c79..61838ba2 100644
--- a/src/main/java/com/gitblit/wicket/pages/ActivityPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/ActivityPage.java
@@ -109,7 +109,7 @@ public class ActivityPage extends RootPage {
ActivityPage.class);
PageParameters currentParameters = getPageParameters();
- int daysBack = GitBlit.getInteger(Keys.web.activityDuration, 14);
+ int daysBack = GitBlit.getInteger(Keys.web.activityDuration, 7);
if (currentParameters != null && !currentParameters.containsKey("db")) {
currentParameters.put("db", daysBack);
}
diff --git a/src/main/java/com/gitblit/wicket/pages/RootPage.java b/src/main/java/com/gitblit/wicket/pages/RootPage.java
index bbe20f5b..a279163c 100644
--- a/src/main/java/com/gitblit/wicket/pages/RootPage.java
+++ b/src/main/java/com/gitblit/wicket/pages/RootPage.java
@@ -27,6 +27,7 @@ import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
+import java.util.TreeSet;
import java.util.concurrent.atomic.AtomicInteger;
import java.util.regex.Pattern;
@@ -178,7 +179,7 @@ public abstract class RootPage extends BasePage {
// remove days back parameter if it is the default value
if (params.containsKey("db")
- && params.getInt("db") == GitBlit.getInteger(Keys.web.activityDuration, 14)) {
+ && params.getInt("db") == GitBlit.getInteger(Keys.web.activityDuration, 7)) {
params.remove("db");
}
return params;
@@ -295,12 +296,15 @@ public abstract class RootPage extends BasePage {
protected List<DropDownMenuItem> getTimeFilterItems(PageParameters params) {
// days back choices - additive parameters
- int daysBack = GitBlit.getInteger(Keys.web.activityDuration, 14);
+ int daysBack = GitBlit.getInteger(Keys.web.activityDuration, 7);
if (daysBack < 1) {
- daysBack = 14;
+ daysBack = 7;
}
List<DropDownMenuItem> items = new ArrayList<DropDownMenuItem>();
- Set<Integer> choicesSet = new HashSet<Integer>(Arrays.asList(daysBack, 14, 28, 60, 90, 180));
+ Set<Integer> choicesSet = new TreeSet<Integer>(GitBlit.getIntegers(Keys.web.activityDurationChoices));
+ if (choicesSet.isEmpty()) {
+ choicesSet.addAll(Arrays.asList(7, 14, 28, 60, 90, 180));
+ }
List<Integer> choices = new ArrayList<Integer>(choicesSet);
Collections.sort(choices);
String lastDaysPattern = getString("gb.lastNDays");