From 531cd203f387f8358a2e15da5f6171f5871ea688 Mon Sep 17 00:00:00 2001 From: James Moger Date: Wed, 20 Apr 2011 20:16:31 -0400 Subject: [PATCH] Support Markdown rendering. Use Wicket GoogleCharts from Maven. --- .classpath | 3 +- build.xml | 1 - .../codecommit/wicket/AbstractChartData.java | 46 -- .../com/codecommit/wicket/AreaFillType.java | 22 - .../com/codecommit/wicket/AxisAlignment.java | 23 - contrib/com/codecommit/wicket/Chart.java | 602 ------------------ contrib/com/codecommit/wicket/ChartAxis.java | 83 --- .../com/codecommit/wicket/ChartAxisType.java | 25 - .../codecommit/wicket/ChartDataEncoding.java | 82 --- contrib/com/codecommit/wicket/ChartGrid.java | 51 -- .../com/codecommit/wicket/ChartProvider.java | 176 ----- contrib/com/codecommit/wicket/ChartType.java | 34 - contrib/com/codecommit/wicket/FillArea.java | 54 -- contrib/com/codecommit/wicket/IChartAxis.java | 26 - contrib/com/codecommit/wicket/IChartData.java | 16 - contrib/com/codecommit/wicket/IChartFill.java | 10 - contrib/com/codecommit/wicket/IChartGrid.java | 18 - .../com/codecommit/wicket/IChartProvider.java | 47 -- contrib/com/codecommit/wicket/IFillArea.java | 21 - contrib/com/codecommit/wicket/ILineStyle.java | 16 - .../wicket/ILinearGradientFill.java | 18 - .../codecommit/wicket/ILinearStripesFill.java | 18 - .../com/codecommit/wicket/IRangeMarker.java | 20 - .../com/codecommit/wicket/IShapeMarker.java | 22 - contrib/com/codecommit/wicket/ISolidFill.java | 13 - contrib/com/codecommit/wicket/LineStyle.java | 48 -- .../codecommit/wicket/LinearGradientFill.java | 49 -- .../codecommit/wicket/LinearStripesFill.java | 49 -- contrib/com/codecommit/wicket/MarkerType.java | 33 - contrib/com/codecommit/wicket/Range.java | 32 - .../com/codecommit/wicket/RangeMarker.java | 55 -- contrib/com/codecommit/wicket/RangeType.java | 22 - .../com/codecommit/wicket/ShapeMarker.java | 69 -- contrib/com/codecommit/wicket/SolidFill.java | 25 - gitblit.properties | 5 +- src/com/gitblit/Build.java | 6 + src/com/gitblit/wicket/GitBlitWebApp.java | 4 + .../gitblit/wicket/GitBlitWebApp.properties | 3 +- src/com/gitblit/wicket/pages/BlobPage.java | 18 +- .../gitblit/wicket/pages/MarkdownPage.html | 28 + .../gitblit/wicket/pages/MarkdownPage.java | 60 ++ src/com/gitblit/wicket/pages/SummaryPage.java | 20 +- src/com/gitblit/wicket/resources/gitblit.css | 8 +- src/com/gitblit/wicket/resources/markdown.css | 54 ++ 44 files changed, 189 insertions(+), 1846 deletions(-) delete mode 100644 contrib/com/codecommit/wicket/AbstractChartData.java delete mode 100644 contrib/com/codecommit/wicket/AreaFillType.java delete mode 100644 contrib/com/codecommit/wicket/AxisAlignment.java delete mode 100644 contrib/com/codecommit/wicket/Chart.java delete mode 100644 contrib/com/codecommit/wicket/ChartAxis.java delete mode 100644 contrib/com/codecommit/wicket/ChartAxisType.java delete mode 100644 contrib/com/codecommit/wicket/ChartDataEncoding.java delete mode 100644 contrib/com/codecommit/wicket/ChartGrid.java delete mode 100644 contrib/com/codecommit/wicket/ChartProvider.java delete mode 100644 contrib/com/codecommit/wicket/ChartType.java delete mode 100644 contrib/com/codecommit/wicket/FillArea.java delete mode 100644 contrib/com/codecommit/wicket/IChartAxis.java delete mode 100644 contrib/com/codecommit/wicket/IChartData.java delete mode 100644 contrib/com/codecommit/wicket/IChartFill.java delete mode 100644 contrib/com/codecommit/wicket/IChartGrid.java delete mode 100644 contrib/com/codecommit/wicket/IChartProvider.java delete mode 100644 contrib/com/codecommit/wicket/IFillArea.java delete mode 100644 contrib/com/codecommit/wicket/ILineStyle.java delete mode 100644 contrib/com/codecommit/wicket/ILinearGradientFill.java delete mode 100644 contrib/com/codecommit/wicket/ILinearStripesFill.java delete mode 100644 contrib/com/codecommit/wicket/IRangeMarker.java delete mode 100644 contrib/com/codecommit/wicket/IShapeMarker.java delete mode 100644 contrib/com/codecommit/wicket/ISolidFill.java delete mode 100644 contrib/com/codecommit/wicket/LineStyle.java delete mode 100644 contrib/com/codecommit/wicket/LinearGradientFill.java delete mode 100644 contrib/com/codecommit/wicket/LinearStripesFill.java delete mode 100644 contrib/com/codecommit/wicket/MarkerType.java delete mode 100644 contrib/com/codecommit/wicket/Range.java delete mode 100644 contrib/com/codecommit/wicket/RangeMarker.java delete mode 100644 contrib/com/codecommit/wicket/RangeType.java delete mode 100644 contrib/com/codecommit/wicket/ShapeMarker.java delete mode 100644 contrib/com/codecommit/wicket/SolidFill.java create mode 100644 src/com/gitblit/wicket/pages/MarkdownPage.html create mode 100644 src/com/gitblit/wicket/pages/MarkdownPage.java create mode 100644 src/com/gitblit/wicket/resources/markdown.css diff --git a/.classpath b/.classpath index f4a6cb60..70505fff 100644 --- a/.classpath +++ b/.classpath @@ -1,7 +1,6 @@ - @@ -15,5 +14,7 @@ + + diff --git a/build.xml b/build.xml index 524a1789..08de19b2 100644 --- a/build.xml +++ b/build.xml @@ -32,7 +32,6 @@ - diff --git a/contrib/com/codecommit/wicket/AbstractChartData.java b/contrib/com/codecommit/wicket/AbstractChartData.java deleted file mode 100644 index 73c00925..00000000 --- a/contrib/com/codecommit/wicket/AbstractChartData.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Created on Dec 11, 2007 - */ -package com.codecommit.wicket; - -import java.io.Serializable; - -/** - * @author Daniel Spiewak - */ -public abstract class AbstractChartData implements IChartData, Serializable { - - private static final long serialVersionUID = 1L; - - private ChartDataEncoding encoding; - private double max; - - public AbstractChartData() { - this(62); - } - - public AbstractChartData(double max) { - this(ChartDataEncoding.SIMPLE, max); - } - - public AbstractChartData(ChartDataEncoding encoding, double max) { - this.encoding = encoding; - this.max = max; - } - - public ChartDataEncoding getEncoding() { - return encoding; - } - - public double getMax() { - return max; - } - - public void setEncoding(ChartDataEncoding encoding) { - this.encoding = encoding; - } - - public void setMax(double max) { - this.max = max; - } -} diff --git a/contrib/com/codecommit/wicket/AreaFillType.java b/contrib/com/codecommit/wicket/AreaFillType.java deleted file mode 100644 index 76ed1a18..00000000 --- a/contrib/com/codecommit/wicket/AreaFillType.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Created on Dec 11, 2007 - */ -package com.codecommit.wicket; - -/** - * @author Daniel Spiewak - */ -public enum AreaFillType { - BETWEEN("b"), - DOWN("B"); - - private final String rendering; - - private AreaFillType(String rendering) { - this.rendering = rendering; - } - - public String getRendering() { - return rendering; - } -} diff --git a/contrib/com/codecommit/wicket/AxisAlignment.java b/contrib/com/codecommit/wicket/AxisAlignment.java deleted file mode 100644 index 0f15ec0a..00000000 --- a/contrib/com/codecommit/wicket/AxisAlignment.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Created on Dec 11, 2007 - */ -package com.codecommit.wicket; - -/** - * @author Daniel Spiewak - */ -public enum AxisAlignment { - LEFT(-1), - CENTER(0), - RIGHT(1); - - private final int rendering; - - private AxisAlignment(int rendering) { - this.rendering = rendering; - } - - public int getRendering() { - return rendering; - } -} diff --git a/contrib/com/codecommit/wicket/Chart.java b/contrib/com/codecommit/wicket/Chart.java deleted file mode 100644 index 95461cf2..00000000 --- a/contrib/com/codecommit/wicket/Chart.java +++ /dev/null @@ -1,602 +0,0 @@ -/* - * Created on Dec 11, 2007 - */ -package com.codecommit.wicket; - -import java.awt.Color; -import java.awt.Dimension; -import java.lang.reflect.InvocationTargetException; -import java.util.concurrent.locks.ReadWriteLock; -import java.util.concurrent.locks.ReentrantReadWriteLock; - -import org.apache.wicket.markup.ComponentTag; -import org.apache.wicket.markup.html.WebComponent; - -/** - * @author Daniel Spiewak - */ -public class Chart extends WebComponent { - private static final long serialVersionUID = 1L; - - private IChartProvider provider; - - private StringBuilder url; - private final ReadWriteLock lock = new ReentrantReadWriteLock(); - - public Chart(String id, IChartProvider provider) { - super(id); - - this.provider = provider; - } - - @Override - public boolean getStatelessHint() { - return false; - } - - public void invalidate() { - lock.writeLock().lock(); - try { - url = null; - } finally { - lock.writeLock().unlock(); - } - } - - public CharSequence constructURL() { - lock.writeLock().lock(); - try { - if (url != null) { - return url; - } - - url = new StringBuilder("http://chart.apis.google.com/chart?"); - - addParameter(url, "chs", render(provider.getSize())); - addParameter(url, "chd", render(provider.getData())); - addParameter(url, "cht", render(provider.getType())); - addParameter(url, "chbh", render(provider.getBarWidth(), provider.getBarGroupSpacing())); - addParameter(url, "chtt", render(provider.getTitle())); - addParameter(url, "chdl", render(provider.getLegend())); - addParameter(url, "chco", render(provider.getColors())); - - IChartFill bgFill = provider.getBackgroundFill(); - IChartFill fgFill = provider.getChartFill(); - - StringBuilder fillParam = new StringBuilder(); - - if (bgFill != null) { - fillParam.append("bg,").append(render(bgFill)); - } - - if (fgFill != null) { - if (fillParam.length() > 0) { - fillParam.append('|'); - } - - fillParam.append("c,").append(render(fgFill)); - } - - if (fillParam.toString().trim().equals("")) { - fillParam = null; - } - - addParameter(url, "chf", fillParam); - - IChartAxis[] axes = provider.getAxes(); - addParameter(url, "chxt", renderTypes(axes)); - addParameter(url, "chxl", renderLabels(axes)); - addParameter(url, "chxp", renderPositions(axes)); - addParameter(url, "chxr", renderRanges(axes)); - addParameter(url, "chxs", renderStyles(axes)); - - addParameter(url, "chg", render(provider.getGrid())); - addParameter(url, "chm", render(provider.getShapeMarkers())); - addParameter(url, "chm", render(provider.getRangeMarkers())); - addParameter(url, "chls", render(provider.getLineStyles())); - addParameter(url, "chm", render(provider.getFillAreas())); - addParameter(url, "chl", render(provider.getPieLabels())); - - return url; - } finally { - lock.writeLock().unlock(); - } - } - - private void addParameter(StringBuilder url, CharSequence param, CharSequence value) { - if (value == null || value.length() == 0) { - return; - } - - if (url.charAt(url.length() - 1) != '?') { - url.append('&'); - } - - url.append(param).append('=').append(value); - } - - private CharSequence render(Dimension dim) { - if (dim == null) { - return null; - } - - return new StringBuilder().append(dim.width).append('x').append(dim.height); - } - - private CharSequence render(IChartData data) { - if (data == null) { - return null; - } - - ChartDataEncoding encoding = data.getEncoding(); - - StringBuilder back = new StringBuilder(); - back.append(render(encoding)).append(':'); - - for (double[] set : data.getData()) { - if (set == null || set.length == 0) { - back.append(encoding.convert(-1, data.getMax())); - } else { - for (double value : set) { - back.append(encoding.convert(value, data.getMax())).append(encoding.getValueSeparator()); - } - - if (back.substring(back.length() - encoding.getValueSeparator().length(), - back.length()).equals(encoding.getValueSeparator())) { - back.setLength(back.length() - encoding.getValueSeparator().length()); - } - } - - back.append(encoding.getSetSeparator()); - } - - if (back.substring(back.length() - encoding.getSetSeparator().length(), - back.length()).equals(encoding.getSetSeparator())) { - back.setLength(back.length() - encoding.getSetSeparator().length()); - } - - return back; - } - - private CharSequence render(Enum value) { - if (value == null) { - return null; - } - - try { - Object back = value.getClass().getMethod("getRendering").invoke(value); - - if (back != null) { - return back.toString(); - } - } catch (IllegalArgumentException e) { - } catch (SecurityException e) { - } catch (IllegalAccessException e) { - } catch (InvocationTargetException e) { - } catch (NoSuchMethodException e) { - } - - return null; - } - - private CharSequence render(int barWidth, int groupSpacing) { - if (barWidth == -1) { - return null; - } - - StringBuilder back = new StringBuilder(barWidth); - - if (groupSpacing >= 0) { - back.append(',').append(groupSpacing); - } - - return back; - } - - private CharSequence render(String[] values) { - if (values == null) { - return null; - } - - StringBuilder back = new StringBuilder(); - - for (String value : values) { - CharSequence toRender = render(value); - if (toRender == null) { - toRender = ""; - } - - back.append(toRender).append('|'); - } - - if (back.length() > 0) { - back.setLength(back.length() - 1); - } - - return back; - } - - private CharSequence render(String value) { - if (value == null) { - return value; - } - - StringBuilder back = new StringBuilder(); - - for (char c : value.toCharArray()) { - if (c == ' ') { - back.append('+'); - } else { - back.append(c); - } - } - - return back; - } - - private CharSequence render(Color[] values) { - if (values == null) { - return null; - } - - StringBuilder back = new StringBuilder(); - - for (Color value : values) { - CharSequence toRender = render(value); - if (toRender == null) { - continue; - } - char delimiter = ','; - switch(provider.getType()) { - case PIE: - case PIE_3D: - case BAR_VERTICAL_SET: - delimiter = '|'; - break; - } - back.append(toRender).append(delimiter); - } - - if (back.length() > 0) { - back.setLength(back.length() - 1); - } - - return back; - } - - private CharSequence render(Color value) { - if (value == null) { - return null; - } - - StringBuilder back = new StringBuilder(); - - { - String toPad = Integer.toHexString(value.getRed()); - - if (toPad.length() == 1) { - back.append(0); - } - back.append(toPad); - } - - { - String toPad = Integer.toHexString(value.getGreen()); - - if (toPad.length() == 1) { - back.append(0); - } - back.append(toPad); - } - - { - String toPad = Integer.toHexString(value.getBlue()); - - if (toPad.length() == 1) { - back.append(0); - } - back.append(toPad); - } - - { - String toPad = Integer.toHexString(value.getAlpha()); - - if (toPad.length() == 1) { - back.append(0); - } - back.append(toPad); - } - - return back; - } - - private CharSequence render(IChartFill fill) { - if (fill == null) { - return null; - } - - StringBuilder back = new StringBuilder(); - - if (fill instanceof ISolidFill) { - ISolidFill solidFill = (ISolidFill) fill; - - back.append("s,"); - back.append(render(solidFill.getColor())); - } else if (fill instanceof ILinearGradientFill) { - ILinearGradientFill gradientFill = (ILinearGradientFill) fill; - - back.append("lg,").append(gradientFill.getAngle()).append(','); - - Color[] colors = gradientFill.getColors(); - double[] offsets = gradientFill.getOffsets(); - for (int i = 0; i < colors.length; i++) { - back.append(render(colors[i])).append(',').append(offsets[i]).append(','); - } - - back.setLength(back.length() - 1); - } else if (fill instanceof ILinearStripesFill) { - ILinearStripesFill stripesFill = (ILinearStripesFill) fill; - - back.append("ls,").append(stripesFill.getAngle()).append(','); - - Color[] colors = stripesFill.getColors(); - double[] widths = stripesFill.getWidths(); - for (int i = 0; i < colors.length; i++) { - back.append(render(colors[i])).append(',').append(widths[i]).append(','); - } - - back.setLength(back.length() - 1); - } else { - return null; - } - - return back; - } - - private CharSequence renderTypes(IChartAxis[] axes) { - if (axes == null) { - return null; - } - - StringBuilder back = new StringBuilder(); - - for (IChartAxis axis : axes) { - back.append(render(axis.getType())).append(','); - } - - if (back.length() > 0) { - back.setLength(back.length() - 1); - } - - return back; - } - - private CharSequence renderLabels(IChartAxis[] axes) { - if (axes == null) { - return null; - } - - StringBuilder back = new StringBuilder(); - - for (int i = 0; i < axes.length; i++) { - if (axes[i] == null || axes[i].getLabels() == null) { - continue; - } - - back.append(i).append(":|"); - - for (String label : axes[i].getLabels()) { - if (label == null) { - back.append('|'); - continue; - } - - back.append(render(label)).append('|'); - } - - if (i == axes.length - 1) { - back.setLength(back.length() - 1); - } - } - - return back; - } - - private CharSequence renderPositions(IChartAxis[] axes) { - if (axes == null) { - return null; - } - - StringBuilder back = new StringBuilder(); - - for (int i = 0; i < axes.length; i++) { - if (axes[i] == null || axes[i].getPositions() == null) { - continue; - } - - back.append(i).append(','); - - for (double position : axes[i].getPositions()) { - back.append(position).append(','); - } - - back.setLength(back.length() - 1); - - back.append('|'); - } - - if (back.length() > 0) { - back.setLength(back.length() - 1); - } - - return back; - } - - private CharSequence renderRanges(IChartAxis[] axes) { - if (axes == null) { - return null; - } - - StringBuilder back = new StringBuilder(); - - for (int i = 0; i < axes.length; i++) { - if (axes[i] == null || axes[i].getRange() == null) { - continue; - } - - back.append(i).append(','); - - Range range = axes[i].getRange(); - back.append(range.getStart()).append(',').append(range.getEnd()).append('|'); - } - - if (back.length() > 0) { - back.setLength(back.length() - 1); - } - - return back; - } - - private CharSequence renderStyles(IChartAxis[] axes) { - if (axes == null) { - return null; - } - - StringBuilder back = new StringBuilder(); - - for (int i = 0; i < axes.length; i++) { - if (axes[i] == null || axes[i].getColor() == null - || axes[i].getFontSize() < 0 || axes[i].getAlignment() == null) { - continue; - } - - back.append(i).append(','); - back.append(render(axes[i].getColor())).append(','); - back.append(axes[i].getFontSize()).append(','); - back.append(render(axes[i].getAlignment())).append('|'); - } - - if (back.length() > 0) { - back.setLength(back.length() - 1); - } - - return back; - } - - private CharSequence render(IChartGrid grid) { - if (grid == null) { - return null; - } - - StringBuilder back = new StringBuilder(); - - back.append(grid.getXStepSize()).append(','); - back.append(grid.getYStepSize()); - - if (grid.getSegmentLength() >= 0) { - back.append(',').append(grid.getSegmentLength()); - back.append(',').append(grid.getBlankLength()); - } - - return back; - } - - private CharSequence render(IShapeMarker[] markers) { - if (markers == null) { - return null; - } - - StringBuilder back = new StringBuilder(); - - for (IShapeMarker marker : markers) { - back.append(render(marker.getType())).append(','); - back.append(render(marker.getColor())).append(','); - back.append(marker.getIndex()).append(','); - back.append(marker.getPoint()).append(','); - back.append(marker.getSize()).append('|'); - } - - if (back.length() > 0) { - back.setLength(back.length() - 1); - } - - return back; - } - - private CharSequence render(IRangeMarker[] markers) { - if (markers == null) { - return null; - } - - StringBuilder back = new StringBuilder(); - - for (IRangeMarker marker : markers) { - back.append(render(marker.getType())).append(','); - back.append(render(marker.getColor())).append(','); - back.append(0).append(','); - back.append(marker.getStart()).append(','); - back.append(marker.getEnd()).append('|'); - } - - if (back.length() > 0) { - back.setLength(back.length() - 1); - } - - return back; - } - - private CharSequence render(IFillArea[] areas) { - if (areas == null) { - return null; - } - - StringBuilder back = new StringBuilder(); - - for (IFillArea area : areas) { - back.append(render(area.getType())).append(','); - back.append(render(area.getColor())).append(','); - back.append(area.getStartIndex()).append(','); - back.append(area.getEndIndex()).append(','); - back.append(0).append('|'); - } - - if (back.length() > 0) { - back.setLength(back.length() - 1); - } - - return back; - } - - private CharSequence render(ILineStyle[] styles) { - if (styles == null) { - return null; - } - - StringBuilder back = new StringBuilder(); - - for (ILineStyle style : styles) { - if (style == null) { - back.append('|'); - continue; - } - - back.append(style.getThickness()).append(','); - back.append(style.getSegmentLength()).append(','); - back.append(style.getBlankLength()).append('|'); - } - - if (back.length() > 0) { - back.setLength(back.length() - 1); - } - - return back; - } - - @Override - protected void onComponentTag(ComponentTag tag) { - checkComponentTag(tag, "img"); - super.onComponentTag(tag); - - tag.put("src", constructURL()); - } -} \ No newline at end of file diff --git a/contrib/com/codecommit/wicket/ChartAxis.java b/contrib/com/codecommit/wicket/ChartAxis.java deleted file mode 100644 index 641007c7..00000000 --- a/contrib/com/codecommit/wicket/ChartAxis.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Created on Dec 11, 2007 - */ -package com.codecommit.wicket; - -import java.awt.Color; -import java.io.Serializable; - -/** - * @author Daniel Spiewak - */ -public class ChartAxis implements IChartAxis, Serializable { - - private static final long serialVersionUID = 1L; - - private AxisAlignment alignment; - private Color color; - private int fontSize = -1; - private String[] labels; - private double[] positions; - private Range range; - private ChartAxisType type; - - public ChartAxis(ChartAxisType type) { - this.type = type; - } - - public AxisAlignment getAlignment() { - return alignment; - } - - public Color getColor() { - return color; - } - - public int getFontSize() { - return fontSize; - } - - public String[] getLabels() { - return labels; - } - - public double[] getPositions() { - return positions; - } - - public Range getRange() { - return range; - } - - public ChartAxisType getType() { - return type; - } - - public void setAlignment(AxisAlignment alignment) { - this.alignment = alignment; - } - - public void setColor(Color color) { - this.color = color; - } - - public void setFontSize(int fontSize) { - this.fontSize = fontSize; - } - - public void setLabels(String[] labels) { - this.labels = labels; - } - - public void setPositions(double[] positions) { - this.positions = positions; - } - - public void setRange(Range range) { - this.range = range; - } - - public void setType(ChartAxisType type) { - this.type = type; - } -} diff --git a/contrib/com/codecommit/wicket/ChartAxisType.java b/contrib/com/codecommit/wicket/ChartAxisType.java deleted file mode 100644 index 82466548..00000000 --- a/contrib/com/codecommit/wicket/ChartAxisType.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Created on Dec 11, 2007 - */ -package com.codecommit.wicket; - -/** - * @author Daniel Spiewak - */ -public enum ChartAxisType { - BOTTOM("x"), - TOP("t"), - - LEFT("y"), - RIGHT("r"); - - private final String rendering; - - private ChartAxisType(String rendering) { - this.rendering = rendering; - } - - public String getRendering() { - return rendering; - } -} diff --git a/contrib/com/codecommit/wicket/ChartDataEncoding.java b/contrib/com/codecommit/wicket/ChartDataEncoding.java deleted file mode 100644 index 15677f49..00000000 --- a/contrib/com/codecommit/wicket/ChartDataEncoding.java +++ /dev/null @@ -1,82 +0,0 @@ -/* - * Created on Dec 11, 2007 - */ -package com.codecommit.wicket; - - -/** - * @author Daniel Spiewak - */ -public enum ChartDataEncoding { - SIMPLE("s", "", ",") { - CharSequence convert(double value, double max) { - if (value < 0) { - return "_"; - } - - value = Math.round((CHARS.length() - 1) * value / max); - - if (value > CHARS.length() - 1) { - throw new IllegalArgumentException(value + " is out of range for SIMPLE encoding"); - } - - return Character.toString(CHARS.charAt((int) value)); - } - }, - TEXT("t", ",", "|") { - CharSequence convert(double value, double max) { - if (value < 0) { - value = -1; - } - - if (value > 100) { - throw new IllegalArgumentException(value + " is out of range for TEXT encoding"); - } - - return Double.toString(value); - } - }, - EXTENDED("e", "", ",") { - CharSequence convert(double value, double max) { - if (value < 0) { - return "__"; - } - - value = Math.round(value); - - if (value > (EXT_CHARS.length() - 1) * (EXT_CHARS.length() - 1)) { - throw new IllegalArgumentException(value + " is out of range for EXTENDED encoding"); - } - - int rem = (int) (value % EXT_CHARS.length()); - int exp = (int) (value / EXT_CHARS.length()); - - return new StringBuilder().append(EXT_CHARS.charAt(exp)).append(EXT_CHARS.charAt(rem)); - } - }; - - private static final String CHARS = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"; - private static final String EXT_CHARS = CHARS + "-_."; - - private final String rendering, valueSeparator, setSeparator; - - private ChartDataEncoding(String rendering, String valueSeparator, String setSeparator) { - this.rendering = rendering; - this.valueSeparator = valueSeparator; - this.setSeparator = setSeparator; - } - - public String getRendering() { - return rendering; - } - - public String getValueSeparator() { - return valueSeparator; - } - - public String getSetSeparator() { - return setSeparator; - } - - abstract CharSequence convert(double value, double max); -} diff --git a/contrib/com/codecommit/wicket/ChartGrid.java b/contrib/com/codecommit/wicket/ChartGrid.java deleted file mode 100644 index 9fdee200..00000000 --- a/contrib/com/codecommit/wicket/ChartGrid.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Created on Dec 11, 2007 - */ -package com.codecommit.wicket; - -/** - * @author Daniel Spiewak - */ -public class ChartGrid implements IChartGrid { - private int blankLength = -1; - private int segmentLength = -1; - private int xStepSize = -1; - private int yStepSize = -1; - - public ChartGrid(int xStepSize, int yStepSize) { - this.xStepSize = xStepSize; - this.yStepSize = yStepSize; - } - - public int getBlankLength() { - return blankLength; - } - - public int getSegmentLength() { - return segmentLength; - } - - public double getXStepSize() { - return xStepSize; - } - - public double getYStepSize() { - return yStepSize; - } - - public void setBlankLength(int blankLength) { - this.blankLength = blankLength; - } - - public void setSegmentLength(int segmentLength) { - this.segmentLength = segmentLength; - } - - public void setXStepSize(int stepSize) { - xStepSize = stepSize; - } - - public void setYStepSize(int stepSize) { - yStepSize = stepSize; - } -} diff --git a/contrib/com/codecommit/wicket/ChartProvider.java b/contrib/com/codecommit/wicket/ChartProvider.java deleted file mode 100644 index 4e69bfc2..00000000 --- a/contrib/com/codecommit/wicket/ChartProvider.java +++ /dev/null @@ -1,176 +0,0 @@ -/* - * Created on Dec 11, 2007 - */ -package com.codecommit.wicket; - -import java.awt.Color; -import java.awt.Dimension; -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; - -/** - * @author Daniel Spiewak - */ -public class ChartProvider implements IChartProvider, Serializable { - private static final long serialVersionUID = 1L; - private List axes = new ArrayList(); - private IChartFill backgroundFill; - private int barGroupSpacing = -1; - private int barWidth = -1; - private IChartFill chartFill; - private Color[] colors; - private List fillAreas = new ArrayList(); - private IChartGrid grid; - private String[] legend; - private ILineStyle[] lineStyles; - private String[] pieLabels; - private List rangeMarkers = new ArrayList(); - private List shapeMarkers = new ArrayList(); - private Dimension size; - private String title; - private ChartType type; - private IChartData data; - - public ChartProvider(Dimension size, ChartType type, IChartData data) { - this.size = size; - this.type = type; - this.data = data; - } - - public IChartAxis[] getAxes() { - return axes.toArray(new IChartAxis[axes.size()]); - } - - public IChartFill getBackgroundFill() { - return backgroundFill; - } - - public int getBarGroupSpacing() { - return barGroupSpacing; - } - - public int getBarWidth() { - return barWidth; - } - - public IChartFill getChartFill() { - return chartFill; - } - - public Color[] getColors() { - return colors; - } - - public IFillArea[] getFillAreas() { - return fillAreas.toArray(new IFillArea[fillAreas.size()]); - } - - public IChartGrid getGrid() { - return grid; - } - - public String[] getLegend() { - return legend; - } - - public ILineStyle[] getLineStyles() { - return lineStyles; - } - - public String[] getPieLabels() { - return pieLabels; - } - - public IRangeMarker[] getRangeMarkers() { - return rangeMarkers.toArray(new IRangeMarker[rangeMarkers.size()]); - } - - public IShapeMarker[] getShapeMarkers() { - return shapeMarkers.toArray(new IShapeMarker[shapeMarkers.size()]); - } - - public Dimension getSize() { - return size; - } - - public String getTitle() { - return title; - } - - public ChartType getType() { - return type; - } - - public void addFillArea(IFillArea fillArea) { - fillAreas.add(fillArea); - } - - public void addAxis(IChartAxis axis) { - axes.add(axis); - } - - public void setBackgroundFill(IChartFill backgroundFill) { - this.backgroundFill = backgroundFill; - } - - public void setBarGroupSpacing(int barGroupSpacing) { - this.barGroupSpacing = barGroupSpacing; - } - - public void setBarWidth(int barWidth) { - this.barWidth = barWidth; - } - - public void setChartFill(IChartFill chartFill) { - this.chartFill = chartFill; - } - - public void setColors(Color[] colors) { - this.colors = colors; - } - - public void setGrid(IChartGrid grid) { - this.grid = grid; - } - - public void setLegend(String[] legend) { - this.legend = legend; - } - - public void setLineStyles(ILineStyle[] lineStyles) { - this.lineStyles = lineStyles; - } - - public void setPieLabels(String[] pieLabels) { - this.pieLabels = pieLabels; - } - - public void addRangeMarker(IRangeMarker rangeMarker) { - rangeMarkers.add(rangeMarker); - } - - public void addShapeMarker(IShapeMarker shapeMarker) { - shapeMarkers.add(shapeMarker); - } - - public void setSize(Dimension size) { - this.size = size; - } - - public void setTitle(String title) { - this.title = title; - } - - public void setType(ChartType type) { - this.type = type; - } - - public IChartData getData() { - return data; - } - - public void setData(IChartData data) { - this.data = data; - } -} diff --git a/contrib/com/codecommit/wicket/ChartType.java b/contrib/com/codecommit/wicket/ChartType.java deleted file mode 100644 index 3d25d422..00000000 --- a/contrib/com/codecommit/wicket/ChartType.java +++ /dev/null @@ -1,34 +0,0 @@ -/* - * Created on Dec 11, 2007 - */ -package com.codecommit.wicket; - -/** - * @author Daniel Spiewak - */ -public enum ChartType { - LINE("lc"), - LINE_XY("lxy"), - - BAR_HORIZONTAL_SET("bhs"), - BAR_VERTICAL_SET("bvs"), - BAR_HORIZONTAL_GROUP("bhg"), - BAR_VERTICAL_GROUP("bvg"), - - PIE("p"), - PIE_3D("p3"), - - VENN("v"), - - SCATTER("s"); - - private final String rendering; - - private ChartType(String rendering) { - this.rendering = rendering; - } - - public String getRendering() { - return rendering; - } -} diff --git a/contrib/com/codecommit/wicket/FillArea.java b/contrib/com/codecommit/wicket/FillArea.java deleted file mode 100644 index 2ab5ef38..00000000 --- a/contrib/com/codecommit/wicket/FillArea.java +++ /dev/null @@ -1,54 +0,0 @@ -/* - * Created on Dec 11, 2007 - */ -package com.codecommit.wicket; - -import java.awt.Color; - -/** - * @author Daniel Spiewak - */ -public class FillArea implements IFillArea { - private Color color; - private int endIndex = -1; - private int startIndex = -1; - private AreaFillType type = AreaFillType.BETWEEN; - - public FillArea(Color color, int startIndex, int endIndex) { - this.color = color; - this.startIndex = startIndex; - this.endIndex = endIndex; - } - - public Color getColor() { - return color; - } - - public int getEndIndex() { - return endIndex; - } - - public int getStartIndex() { - return startIndex; - } - - public AreaFillType getType() { - return type; - } - - public void setColor(Color color) { - this.color = color; - } - - public void setEndIndex(int endIndex) { - this.endIndex = endIndex; - } - - public void setStartIndex(int startIndex) { - this.startIndex = startIndex; - } - - public void setType(AreaFillType type) { - this.type = type; - } -} diff --git a/contrib/com/codecommit/wicket/IChartAxis.java b/contrib/com/codecommit/wicket/IChartAxis.java deleted file mode 100644 index c7c83dc0..00000000 --- a/contrib/com/codecommit/wicket/IChartAxis.java +++ /dev/null @@ -1,26 +0,0 @@ -/* - * Created on Dec 11, 2007 - */ -package com.codecommit.wicket; - -import java.awt.Color; - -/** - * @author Daniel Spiewak - */ -public interface IChartAxis { - - public ChartAxisType getType(); - - public String[] getLabels(); - - public double[] getPositions(); - - public Range getRange(); - - public Color getColor(); - - public int getFontSize(); - - public AxisAlignment getAlignment(); -} diff --git a/contrib/com/codecommit/wicket/IChartData.java b/contrib/com/codecommit/wicket/IChartData.java deleted file mode 100644 index c4f6ec7a..00000000 --- a/contrib/com/codecommit/wicket/IChartData.java +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Created on Dec 11, 2007 - */ -package com.codecommit.wicket; - -/** - * @author Daniel Spiewak - */ -public interface IChartData { - - public ChartDataEncoding getEncoding(); - - public double[][] getData(); - - public double getMax(); -} diff --git a/contrib/com/codecommit/wicket/IChartFill.java b/contrib/com/codecommit/wicket/IChartFill.java deleted file mode 100644 index 2ccb1d66..00000000 --- a/contrib/com/codecommit/wicket/IChartFill.java +++ /dev/null @@ -1,10 +0,0 @@ -/* - * Created on Dec 11, 2007 - */ -package com.codecommit.wicket; - -/** - * @author Daniel Spiewak - */ -public interface IChartFill { -} diff --git a/contrib/com/codecommit/wicket/IChartGrid.java b/contrib/com/codecommit/wicket/IChartGrid.java deleted file mode 100644 index 05f4c5f6..00000000 --- a/contrib/com/codecommit/wicket/IChartGrid.java +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Created on Dec 11, 2007 - */ -package com.codecommit.wicket; - -/** - * @author Daniel Spiewak - */ -public interface IChartGrid { - - public double getXStepSize(); - - public double getYStepSize(); - - public int getSegmentLength(); - - public int getBlankLength(); -} diff --git a/contrib/com/codecommit/wicket/IChartProvider.java b/contrib/com/codecommit/wicket/IChartProvider.java deleted file mode 100644 index 76e7fa62..00000000 --- a/contrib/com/codecommit/wicket/IChartProvider.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Created on Dec 11, 2007 - */ -package com.codecommit.wicket; - -import java.awt.Color; -import java.awt.Dimension; - -/** - * @author Daniel Spiewak - */ -public interface IChartProvider { - - public Dimension getSize(); - - public IChartData getData(); - - public ChartType getType(); - - public int getBarWidth(); - - public int getBarGroupSpacing(); - - public String getTitle(); - - public String[] getLegend(); - - public Color[] getColors(); - - public IChartFill getChartFill(); - - public IChartFill getBackgroundFill(); - - public String[] getPieLabels(); - - public IChartAxis[] getAxes(); - - public ILineStyle[] getLineStyles(); - - public IChartGrid getGrid(); - - public IShapeMarker[] getShapeMarkers(); - - public IRangeMarker[] getRangeMarkers(); - - public IFillArea[] getFillAreas(); -} diff --git a/contrib/com/codecommit/wicket/IFillArea.java b/contrib/com/codecommit/wicket/IFillArea.java deleted file mode 100644 index 3ba7f0a3..00000000 --- a/contrib/com/codecommit/wicket/IFillArea.java +++ /dev/null @@ -1,21 +0,0 @@ -/* - * Created on Dec 11, 2007 - */ -package com.codecommit.wicket; - -import java.awt.Color; - -/** - * @author Daniel Spiewak - */ -public interface IFillArea { - - public AreaFillType getType(); - - public Color getColor(); - - public int getStartIndex(); - - // unnecessary if BOTTOM - public int getEndIndex(); -} diff --git a/contrib/com/codecommit/wicket/ILineStyle.java b/contrib/com/codecommit/wicket/ILineStyle.java deleted file mode 100644 index 873debef..00000000 --- a/contrib/com/codecommit/wicket/ILineStyle.java +++ /dev/null @@ -1,16 +0,0 @@ -/* - * Created on Dec 11, 2007 - */ -package com.codecommit.wicket; - -/** - * @author Daniel Spiewak - */ -public interface ILineStyle { - - public int getThickness(); - - public int getSegmentLength(); - - public int getBlankLength(); -} diff --git a/contrib/com/codecommit/wicket/ILinearGradientFill.java b/contrib/com/codecommit/wicket/ILinearGradientFill.java deleted file mode 100644 index 8ed51de5..00000000 --- a/contrib/com/codecommit/wicket/ILinearGradientFill.java +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Created on Dec 11, 2007 - */ -package com.codecommit.wicket; - -import java.awt.Color; - -/** - * @author Daniel Spiewak - */ -public interface ILinearGradientFill extends IChartFill { - - public int getAngle(); - - public Color[] getColors(); - - public double[] getOffsets(); -} diff --git a/contrib/com/codecommit/wicket/ILinearStripesFill.java b/contrib/com/codecommit/wicket/ILinearStripesFill.java deleted file mode 100644 index 534896f9..00000000 --- a/contrib/com/codecommit/wicket/ILinearStripesFill.java +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Created on Dec 11, 2007 - */ -package com.codecommit.wicket; - -import java.awt.Color; - -/** - * @author Daniel Spiewak - */ -public interface ILinearStripesFill extends IChartFill { - - public int getAngle(); - - public Color[] getColors(); - - public double[] getWidths(); -} diff --git a/contrib/com/codecommit/wicket/IRangeMarker.java b/contrib/com/codecommit/wicket/IRangeMarker.java deleted file mode 100644 index 1cc30407..00000000 --- a/contrib/com/codecommit/wicket/IRangeMarker.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Created on Dec 11, 2007 - */ -package com.codecommit.wicket; - -import java.awt.Color; - -/** - * @author Daniel Spiewak - */ -public interface IRangeMarker { - - public RangeType getType(); - - public Color getColor(); - - public double getStart(); - - public double getEnd(); -} diff --git a/contrib/com/codecommit/wicket/IShapeMarker.java b/contrib/com/codecommit/wicket/IShapeMarker.java deleted file mode 100644 index 626eccb4..00000000 --- a/contrib/com/codecommit/wicket/IShapeMarker.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Created on Dec 11, 2007 - */ -package com.codecommit.wicket; - -import java.awt.Color; - -/** - * @author Daniel Spiewak - */ -public interface IShapeMarker { - - public MarkerType getType(); - - public Color getColor(); - - public int getIndex(); - - public double getPoint(); - - public int getSize(); -} diff --git a/contrib/com/codecommit/wicket/ISolidFill.java b/contrib/com/codecommit/wicket/ISolidFill.java deleted file mode 100644 index f97b064e..00000000 --- a/contrib/com/codecommit/wicket/ISolidFill.java +++ /dev/null @@ -1,13 +0,0 @@ -/* - * Created on Dec 11, 2007 - */ -package com.codecommit.wicket; - -import java.awt.Color; - -/** - * @author Daniel Spiewak - */ -public interface ISolidFill extends IChartFill { - public Color getColor(); -} diff --git a/contrib/com/codecommit/wicket/LineStyle.java b/contrib/com/codecommit/wicket/LineStyle.java deleted file mode 100644 index ef53c5b7..00000000 --- a/contrib/com/codecommit/wicket/LineStyle.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Created on Dec 11, 2007 - */ -package com.codecommit.wicket; - -import java.io.Serializable; - -/** - * @author Daniel Spiewak - */ -public class LineStyle implements ILineStyle, Serializable { - - private static final long serialVersionUID = 1L; - - private int blankLength = -1; - private int segmentLength = -1; - private int thickness = -1; - - public LineStyle(int thickness, int segmentLength, int blankLength) { - this.thickness = thickness; - this.segmentLength = segmentLength; - this.blankLength = blankLength; - } - - public int getBlankLength() { - return blankLength; - } - - public int getSegmentLength() { - return segmentLength; - } - - public int getThickness() { - return thickness; - } - - public void setBlankLength(int blankLength) { - this.blankLength = blankLength; - } - - public void setSegmentLength(int segmentLength) { - this.segmentLength = segmentLength; - } - - public void setThickness(int thickness) { - this.thickness = thickness; - } -} diff --git a/contrib/com/codecommit/wicket/LinearGradientFill.java b/contrib/com/codecommit/wicket/LinearGradientFill.java deleted file mode 100644 index 090a9a8a..00000000 --- a/contrib/com/codecommit/wicket/LinearGradientFill.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Created on Dec 11, 2007 - */ -package com.codecommit.wicket; - -import java.awt.Color; - -/** - * @author Daniel Spiewak - */ -public class LinearGradientFill implements ILinearGradientFill { - private int angle = -1; - private Color[] colors; - private double[] offsets; - - public LinearGradientFill(int angle, Color[] colors, double[] offsets) { - if (colors.length != offsets.length) { - throw new IllegalArgumentException("Must be same number of colors as offsets"); - } - - this.angle = angle; - this.colors = colors; - this.offsets = offsets; - } - - public int getAngle() { - return angle; - } - - public Color[] getColors() { - return colors; - } - - public double[] getOffsets() { - return offsets; - } - - public void setAngle(int angle) { - this.angle = angle; - } - - public void setColors(Color[] colors) { - this.colors = colors; - } - - public void setOffsets(double[] offsets) { - this.offsets = offsets; - } -} diff --git a/contrib/com/codecommit/wicket/LinearStripesFill.java b/contrib/com/codecommit/wicket/LinearStripesFill.java deleted file mode 100644 index 52b6f1e0..00000000 --- a/contrib/com/codecommit/wicket/LinearStripesFill.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Created on Dec 11, 2007 - */ -package com.codecommit.wicket; - -import java.awt.Color; - -/** - * @author Daniel Spiewak - */ -public class LinearStripesFill implements ILinearStripesFill { - private int angle = -1; - private Color[] colors; - private double[] widths; - - public LinearStripesFill(int angle, Color[] colors, double[] widths) { - if (colors.length != widths.length) { - throw new IllegalArgumentException("Must be same number of colors as widths"); - } - - this.angle = angle; - this.colors = colors; - this.widths = widths; - } - - public int getAngle() { - return angle; - } - - public Color[] getColors() { - return colors; - } - - public double[] getWidths() { - return widths; - } - - public void setAngle(int angle) { - this.angle = angle; - } - - public void setColors(Color[] colors) { - this.colors = colors; - } - - public void setWidths(double[] widths) { - this.widths = widths; - } -} diff --git a/contrib/com/codecommit/wicket/MarkerType.java b/contrib/com/codecommit/wicket/MarkerType.java deleted file mode 100644 index 2b227949..00000000 --- a/contrib/com/codecommit/wicket/MarkerType.java +++ /dev/null @@ -1,33 +0,0 @@ -/* - * Created on Dec 11, 2007 - */ -package com.codecommit.wicket; - -import java.io.Serializable; - -/** - * @author Daniel Spiewak - */ -public enum MarkerType implements Serializable { - ARROW("a"), - CROSS("c"), - DIAMOND("d"), - CIRCLE("o"), - SQUARE("s"), - - VERTICAL_TO_DATA("v"), - VERTICAL_TO_TOP("V"), - HORIZONTAL_ACROSS("h"), - - X("x"); - - private final String rendering; - - private MarkerType(String rendering) { - this.rendering = rendering; - } - - public String getRendering() { - return rendering; - } -} diff --git a/contrib/com/codecommit/wicket/Range.java b/contrib/com/codecommit/wicket/Range.java deleted file mode 100644 index d5b7eb62..00000000 --- a/contrib/com/codecommit/wicket/Range.java +++ /dev/null @@ -1,32 +0,0 @@ -/* - * Created on Dec 11, 2007 - */ -package com.codecommit.wicket; - -/** - * @author Daniel Spiewak - */ -public class Range { - private double start, end; - - public Range(double start, double end) { - this.start = start; - this.end = end; - } - - public double getStart() { - return start; - } - - public void setStart(double start) { - this.start = start; - } - - public double getEnd() { - return end; - } - - public void setEnd(double end) { - this.end = end; - } -} diff --git a/contrib/com/codecommit/wicket/RangeMarker.java b/contrib/com/codecommit/wicket/RangeMarker.java deleted file mode 100644 index a44c95ce..00000000 --- a/contrib/com/codecommit/wicket/RangeMarker.java +++ /dev/null @@ -1,55 +0,0 @@ -/* - * Created on Dec 11, 2007 - */ -package com.codecommit.wicket; - -import java.awt.Color; - -/** - * @author Daniel Spiewak - */ -public class RangeMarker implements IRangeMarker { - private Color color; - private double end = -1; - private double start = -1; - private RangeType type; - - public RangeMarker(RangeType type, Color color, double start, double end) { - this.type = type; - this.color = color; - this.start = start; - this.end = end; - } - - public Color getColor() { - return color; - } - - public double getEnd() { - return end; - } - - public double getStart() { - return start; - } - - public RangeType getType() { - return type; - } - - public void setColor(Color color) { - this.color = color; - } - - public void setEnd(double end) { - this.end = end; - } - - public void setStart(double start) { - this.start = start; - } - - public void setType(RangeType type) { - this.type = type; - } -} diff --git a/contrib/com/codecommit/wicket/RangeType.java b/contrib/com/codecommit/wicket/RangeType.java deleted file mode 100644 index 7a86d411..00000000 --- a/contrib/com/codecommit/wicket/RangeType.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Created on Dec 11, 2007 - */ -package com.codecommit.wicket; - -/** - * @author Daniel Spiewak - */ -public enum RangeType { - HORIZONTAL("r"), - VERTICAL("R"); - - private final String rendering; - - private RangeType(String rendering) { - this.rendering = rendering; - } - - public String getRendering() { - return rendering; - } -} diff --git a/contrib/com/codecommit/wicket/ShapeMarker.java b/contrib/com/codecommit/wicket/ShapeMarker.java deleted file mode 100644 index 3b42cfb2..00000000 --- a/contrib/com/codecommit/wicket/ShapeMarker.java +++ /dev/null @@ -1,69 +0,0 @@ -/* - * Created on Dec 11, 2007 - */ -package com.codecommit.wicket; - -import java.awt.Color; -import java.io.Serializable; - -/** - * @author Daniel Spiewak - */ -public class ShapeMarker implements IShapeMarker, Serializable { - - private static final long serialVersionUID = 1L; - - private Color color; - private int index = -1; - private double point = -1; - private int size = -1; - private MarkerType type; - - public ShapeMarker(MarkerType type, Color color, int index, double point, int size) { - this.type = type; - this.color = color; - this.index = index; - this.point = point; - this.size = size; - } - - public Color getColor() { - return color; - } - - public int getIndex() { - return index; - } - - public double getPoint() { - return point; - } - - public int getSize() { - return size; - } - - public MarkerType getType() { - return type; - } - - public void setColor(Color color) { - this.color = color; - } - - public void setIndex(int index) { - this.index = index; - } - - public void setPoint(double point) { - this.point = point; - } - - public void setSize(int size) { - this.size = size; - } - - public void setType(MarkerType type) { - this.type = type; - } -} diff --git a/contrib/com/codecommit/wicket/SolidFill.java b/contrib/com/codecommit/wicket/SolidFill.java deleted file mode 100644 index dac8734a..00000000 --- a/contrib/com/codecommit/wicket/SolidFill.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * Created on Dec 11, 2007 - */ -package com.codecommit.wicket; - -import java.awt.Color; - -/** - * @author Daniel Spiewak - */ -public class SolidFill implements ISolidFill { - private Color color; - - public SolidFill(Color color) { - this.color = color; - } - - public Color getColor() { - return color; - } - - public void setColor(Color color) { - this.color = color; - } -} diff --git a/gitblit.properties b/gitblit.properties index 27a9fff9..ae3866d2 100644 --- a/gitblit.properties +++ b/gitblit.properties @@ -48,7 +48,7 @@ web.allowAdministration = true # This is the message display above the repositories table. # This can point to a file with HTML content. -web.repositoriesMessage = Welcome to Git:Blit!
A quick and easy way to host your own Git repositories.
Built with JGit, Wicket, Jetty, SLF4J, Log4j, google-code-prettify, and JCommander. +web.repositoriesMessage = Welcome to Git:Blit!
A quick and easy way to host your own Git repositories.
Built with JGit, Wicket, WicketStuff googlecharts, MarkdownPapers, Jetty, SLF4J, Log4j, google-code-prettify, and JCommander. # Use the client timezone when formatting dates. # This uses AJAX to determine the browser's timezone and enables Wicket @@ -78,6 +78,9 @@ web.logPageCommitCount = 50 # Registered extensions for google-code-prettify web.prettyPrintExtensions = c cpp cs css htm html java js php pl prefs properties py rb sh sql xml vb +# Registered extensions for markdown transformation +web.markdownExtensions = md mkd markdown + # Image extensions web.imageExtensions = bmp jpg gif png diff --git a/src/com/gitblit/Build.java b/src/com/gitblit/Build.java index b12d44ed..604ee08f 100644 --- a/src/com/gitblit/Build.java +++ b/src/com/gitblit/Build.java @@ -36,6 +36,8 @@ public class Build { downloadFromMaven(MavenObject.WICKET); downloadFromMaven(MavenObject.WICKET_EXT); downloadFromMaven(MavenObject.WICKET_AUTH_ROLES); + downloadFromMaven(MavenObject.WICKET_GOOGLE_CHARTS); + downloadFromMaven(MavenObject.MARKDOWNPAPERS); } public static void compiletime() { @@ -192,8 +194,12 @@ public class Build { public static final MavenObject WICKET_AUTH_ROLES = new MavenObject("Apache Wicket Auth Roles", "org/apache/wicket", "wicket-auth-roles", "1.4.17", "86d20ff32f62d3026213ff11a78555da643bc676"); + public static final MavenObject WICKET_GOOGLE_CHARTS = new MavenObject("Apache Wicket Google Charts Add-On", "org/wicketstuff", "googlecharts", "1.4.17", "c567b98b0c5efe4147e77ef2d0d3c2d45c49dea5"); + public static final MavenObject JUNIT = new MavenObject("JUnit", "junit", "junit", "3.8.2", "07e4cde26b53a9a0e3fe5b00d1dbbc7cc1d46060"); + public static final MavenObject MARKDOWNPAPERS = new MavenObject("MarkdownPapers", "org/tautua/markdownpapers", "markdownpapers-core", "1.0.0", "feda63bd149f3315da210e397d45d02277038ad5"); + public final String name; public final String group; public final String artifact; diff --git a/src/com/gitblit/wicket/GitBlitWebApp.java b/src/com/gitblit/wicket/GitBlitWebApp.java index 106981e3..e3c41cd6 100644 --- a/src/com/gitblit/wicket/GitBlitWebApp.java +++ b/src/com/gitblit/wicket/GitBlitWebApp.java @@ -17,6 +17,7 @@ import com.gitblit.wicket.pages.CommitDiffPage; import com.gitblit.wicket.pages.CommitPage; import com.gitblit.wicket.pages.HistoryPage; import com.gitblit.wicket.pages.LogPage; +import com.gitblit.wicket.pages.MarkdownPage; import com.gitblit.wicket.pages.PatchPage; import com.gitblit.wicket.pages.RawPage; import com.gitblit.wicket.pages.RepositoriesPage; @@ -67,6 +68,9 @@ public class GitBlitWebApp extends WebApplication { mount(new MixedParamUrlCodingStrategy("/tickets", TicketsPage.class, new String[] { "r" })); mount(new MixedParamUrlCodingStrategy("/ticket", TicketPage.class, new String[] { "r", "h", "f" })); + // setup the markdown urls + mount(new MixedParamUrlCodingStrategy("/markdown", MarkdownPage.class, new String[] { "r", "h", "f" })); + // setup login/logout urls, if we are using authentication if (useAuthentication) { mount(new MixedParamUrlCodingStrategy("/login", LoginPage.class, new String[] {})); diff --git a/src/com/gitblit/wicket/GitBlitWebApp.properties b/src/com/gitblit/wicket/GitBlitWebApp.properties index f0638586..a2e51d11 100644 --- a/src/com/gitblit/wicket/GitBlitWebApp.properties +++ b/src/com/gitblit/wicket/GitBlitWebApp.properties @@ -55,4 +55,5 @@ gb.addition = addition gb.modification = modification gb.deletion = deletion gb.rename = rename -gb.stats = stats \ No newline at end of file +gb.stats = stats +gb.markdown = markdown \ No newline at end of file diff --git a/src/com/gitblit/wicket/pages/BlobPage.java b/src/com/gitblit/wicket/pages/BlobPage.java index e535199a..335d25a1 100644 --- a/src/com/gitblit/wicket/pages/BlobPage.java +++ b/src/com/gitblit/wicket/pages/BlobPage.java @@ -26,6 +26,20 @@ public class BlobPage extends RepositoryPage { final String blobPath = WicketUtils.getPath(params); + String extension = null; + if (blobPath.lastIndexOf('.') > -1) { + extension = blobPath.substring(blobPath.lastIndexOf('.') + 1).toLowerCase(); + } + + // see if we should redirect to the markdown page + for (String ext : GitBlit.self().settings().getStrings(Keys.web.markdownExtensions)) { + if (ext.equals(extension)) { + setResponsePage(MarkdownPage.class, params); + return; + } + } + + // standard blob view Repository r = getRepository(); RevCommit commit = JGitUtils.getCommit(r, objectId); @@ -38,10 +52,6 @@ public class BlobPage extends RepositoryPage { add(new LinkPanel("shortlog", "title", commit.getShortMessage(), CommitPage.class, newCommitParameter())); add(new PathBreadcrumbsPanel("breadcrumbs", repositoryName, blobPath, objectId)); - String extension = null; - if (blobPath.lastIndexOf('.') > -1) { - extension = blobPath.substring(blobPath.lastIndexOf('.') + 1); - } // Map the extensions to types Map map = new HashMap(); diff --git a/src/com/gitblit/wicket/pages/MarkdownPage.html b/src/com/gitblit/wicket/pages/MarkdownPage.html new file mode 100644 index 00000000..9b009348 --- /dev/null +++ b/src/com/gitblit/wicket/pages/MarkdownPage.html @@ -0,0 +1,28 @@ + + + + + + + + + + + + + +
[page links]
+ + + + + +
[markdown content]
+
+ + \ No newline at end of file diff --git a/src/com/gitblit/wicket/pages/MarkdownPage.java b/src/com/gitblit/wicket/pages/MarkdownPage.java new file mode 100644 index 00000000..83083abf --- /dev/null +++ b/src/com/gitblit/wicket/pages/MarkdownPage.java @@ -0,0 +1,60 @@ +package com.gitblit.wicket.pages; + +import java.io.StringReader; +import java.io.StringWriter; + +import org.apache.wicket.PageParameters; +import org.apache.wicket.markup.html.basic.Label; +import org.apache.wicket.markup.html.link.BookmarkablePageLink; +import org.eclipse.jgit.lib.Constants; +import org.eclipse.jgit.lib.Repository; +import org.eclipse.jgit.revwalk.RevCommit; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.tautua.markdownpapers.Markdown; +import org.tautua.markdownpapers.parser.ParseException; + +import com.gitblit.utils.JGitUtils; +import com.gitblit.wicket.RepositoryPage; +import com.gitblit.wicket.WicketUtils; + +public class MarkdownPage extends RepositoryPage { + + private final Logger logger = LoggerFactory.getLogger(MarkdownPage.class); + + public MarkdownPage(PageParameters params) { + super(params); + + final String markdownPath = WicketUtils.getPath(params); + + Repository r = getRepository(); + RevCommit commit = JGitUtils.getCommit(r, objectId); + + // markdown page links + add(new Label("blameLink", getString("gb.blame"))); + add(new BookmarkablePageLink("historyLink", HistoryPage.class, WicketUtils.newPathParameter(repositoryName, objectId, markdownPath))); + add(new BookmarkablePageLink("rawLink", RawPage.class, WicketUtils.newPathParameter(repositoryName, objectId, markdownPath))); + add(new BookmarkablePageLink("headLink", MarkdownPage.class, WicketUtils.newPathParameter(repositoryName, Constants.HEAD, markdownPath))); + + // Read raw markdown content and transform it to html + String htmlText = ""; + try { + String rawText = JGitUtils.getRawContentAsString(r, commit, markdownPath); + StringReader reader = new StringReader(rawText); + StringWriter writer = new StringWriter(); + Markdown md = new Markdown(); + md.transform(reader, writer); + htmlText = writer.toString(); + } catch (ParseException p) { + logger.error("Failed to parse markdown text from " + markdownPath, p); + } + + // Add the html to the page + add(new Label("markdownText", htmlText).setEscapeModelStrings(false)); + } + + @Override + protected String getPageName() { + return getString("gb.markdown"); + } +} diff --git a/src/com/gitblit/wicket/pages/SummaryPage.java b/src/com/gitblit/wicket/pages/SummaryPage.java index 53a684b5..b20dc643 100644 --- a/src/com/gitblit/wicket/pages/SummaryPage.java +++ b/src/com/gitblit/wicket/pages/SummaryPage.java @@ -10,16 +10,16 @@ import org.apache.wicket.markup.html.basic.Label; import org.apache.wicket.markup.html.image.ContextImage; import org.eclipse.jgit.lib.Repository; -import com.codecommit.wicket.AbstractChartData; -import com.codecommit.wicket.Chart; -import com.codecommit.wicket.ChartAxis; -import com.codecommit.wicket.ChartAxisType; -import com.codecommit.wicket.ChartProvider; -import com.codecommit.wicket.ChartType; -import com.codecommit.wicket.IChartData; -import com.codecommit.wicket.LineStyle; -import com.codecommit.wicket.MarkerType; -import com.codecommit.wicket.ShapeMarker; +import org.wicketstuff.googlecharts.AbstractChartData; +import org.wicketstuff.googlecharts.Chart; +import org.wicketstuff.googlecharts.ChartAxis; +import org.wicketstuff.googlecharts.ChartAxisType; +import org.wicketstuff.googlecharts.ChartProvider; +import org.wicketstuff.googlecharts.ChartType; +import org.wicketstuff.googlecharts.IChartData; +import org.wicketstuff.googlecharts.LineStyle; +import org.wicketstuff.googlecharts.MarkerType; +import org.wicketstuff.googlecharts.ShapeMarker; import com.gitblit.GitBlit; import com.gitblit.Keys; import com.gitblit.utils.JGitUtils; diff --git a/src/com/gitblit/wicket/resources/gitblit.css b/src/com/gitblit/wicket/resources/gitblit.css index d3d68b7a..3c5aca8b 100644 --- a/src/com/gitblit/wicket/resources/gitblit.css +++ b/src/com/gitblit/wicket/resources/gitblit.css @@ -4,7 +4,7 @@ html, body, table, dl, dt, dd, ol, ul, li, form, a, span, tr, th, td, div, em { font-family: verdana, sans-serif; font-size: 12px; - line-height: 15px; + line-height: 1.35em; margin: 0; padding: 0; border: 0; @@ -22,7 +22,7 @@ body { padding: 0px; } -pre, pre.prettyprint, pre.plainprint { +pre, code, pre.prettyprint, pre.plainprint { color: black; font-family: monospace; font-size:12px; @@ -75,6 +75,7 @@ div.header { background-color: #D2C3AF; padding: 3px; border: 1px solid #808080; + border-radius: 3px 3px 0 0; } div.header a { @@ -146,6 +147,7 @@ div.page_nav { color: #ddd; background-color: #000070; padding: 7px; + border-radius: 3px; } div.page_nav a { @@ -169,7 +171,7 @@ div.search { color:yellow; text-align:right; float:right; - padding:3px 4px 3px 3px; + padding:4px 4px 3px 3px; } .repositories_message { diff --git a/src/com/gitblit/wicket/resources/markdown.css b/src/com/gitblit/wicket/resources/markdown.css new file mode 100644 index 00000000..ce48cefb --- /dev/null +++ b/src/com/gitblit/wicket/resources/markdown.css @@ -0,0 +1,54 @@ +/* + * Git:Blit Markdown CSS definition. + */ + +div.markdown { +} + +div.markdown h1, +div.markdown h2, +div.markdown h3, +div.markdown h4, +div.markdown h5, +div.markdown h6 { + border: 0 none !important; +} + +div.markdown h1 { + margin-top: 1em; + margin-bottom: 0.5em; + padding-bottom: 0.5em; + border-bottom: 2px solid #000080 !important; +} + +div.markdown h2 { + margin-top: 1em; + margin-bottom: 0.5em; + padding-bottom: 0.5em; + border-bottom: 2px solid #000080 !important; +} + +div.markdown pre { + background-color: #f8f8f8; + border: 1px solid #2f6fab; + border-radius: 3px; + overflow: auto; + padding: 5px; +} + +div.markdown pre code { + background-color: inherit; + border: none; + padding: 0; +} + +div.markdown code { + background-color: #ffffe0; + border: 1px solid orange; + border-radius: 3px; + padding: 0 0.2em; +} + +div.markdown a { + text-decoration: underline; +} \ No newline at end of file -- 2.39.5