James Moger
2013-06-10 1a8eb19b3cd55646adde33d922e8bc10f0090050
Make days back filter a setting
6 files modified
77 ■■■■ changed files
releases.moxie 3 ●●●●● patch | view | raw | blame | history
src/main/distrib/data/gitblit.properties 12 ●●●● patch | view | raw | blame | history
src/main/java/com/gitblit/GitBlit.java 13 ●●●●● patch | view | raw | blame | history
src/main/java/com/gitblit/IStoredSettings.java 35 ●●●●● patch | view | raw | blame | history
src/main/java/com/gitblit/wicket/pages/ActivityPage.java 2 ●●● patch | view | raw | blame | history
src/main/java/com/gitblit/wicket/pages/RootPage.java 12 ●●●●● patch | view | raw | blame | history
releases.moxie
@@ -35,6 +35,8 @@
     - 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 @@
    - { 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 }
src/main/distrib/data/gitblit.properties
@@ -814,11 +814,17 @@
# 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
src/main/java/com/gitblit/GitBlit.java
@@ -312,6 +312,19 @@
    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
src/main/java/com/gitblit/IStoredSettings.java
@@ -261,6 +261,41 @@
    }
    
    /**
     * 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
src/main/java/com/gitblit/wicket/pages/ActivityPage.java
@@ -109,7 +109,7 @@
                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);
        }
src/main/java/com/gitblit/wicket/pages/RootPage.java
@@ -27,6 +27,7 @@
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 @@
                // 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 @@
    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");