Update of /cvsroot/webmacro/wiki/src/org/tcdi/opensource/wiki
In directory sc8-pr-cvs1:/tmp/cvs-serv5523/src/org/tcdi/opensource/wiki
Modified Files:
Wiki.java WikiPage.java WikiUtil.java
Log Message:
- adding a "Diff to previous" feature that uses a java version of GNU 'diff' from http://www.bmsi.com/java/#diff
I need to contact this person to ensure it's actually okay to use here. It think it will be b/c Wiki is GPL'd too
Index: Wiki.java
===================================================================
RCS file: /cvsroot/webmacro/wiki/src/org/tcdi/opensource/wiki/Wiki.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -C2 -d -r1.9 -r1.10
*** Wiki.java 2 Jul 2003 03:01:52 -0000 1.9
--- Wiki.java 2 Jul 2003 06:55:13 -0000 1.10
***************
*** 133,145 ****
public void savePage(WikiPage page, String title) {
! WikiPage oldVersion = (WikiPage) _pageStore.get(title);
boolean isnew = false;
! if (oldVersion != null) {
// backup old version of this page
! oldVersion.setTitle(oldVersion.getTitle() + "." + oldVersion.getVersion());
! _pageStore.put(oldVersion.getTitle() + "." + oldVersion.getVersion(), page);
} else {
// this is a brand new page
isnew = true;
}
--- 133,146 ----
public void savePage(WikiPage page, String title) {
! WikiPage currentVersion = (WikiPage) _pageStore.get (title);
boolean isnew = false;
! if (currentVersion != null) {
// backup old version of this page
! _pageStore.put (currentVersion.getTitle() + "." + currentVersion.getVersion(), currentVersion);
! page.setVersion (currentVersion.getVersion()+1);
} else {
// this is a brand new page
isnew = true;
+ page.setVersion(0);
}
Index: WikiPage.java
===================================================================
RCS file: /cvsroot/webmacro/wiki/src/org/tcdi/opensource/wiki/WikiPage.java,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -C2 -d -r1.1.1.1 -r1.2
*** WikiPage.java 30 Sep 2001 08:28:27 -0000 1.1.1.1
--- WikiPage.java 2 Jul 2003 06:55:13 -0000 1.2
***************
*** 196,199 ****
--- 196,210 ----
public long getVersion() { return _version; }
+ /** increment the version number of this page. You'll probably want to re-save it
+ * to the page store after this
+ */
+ public void incrementVersion () {
+ _version++;
+ }
+
+ public void setVersion (long version) {
+ _version = version;
+ }
+
/**
* @return Author of this page.
Index: WikiUtil.java
===================================================================
RCS file: /cvsroot/webmacro/wiki/src/org/tcdi/opensource/wiki/WikiUtil.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** WikiUtil.java 2 Jul 2003 03:01:52 -0000 1.4
--- WikiUtil.java 2 Jul 2003 06:55:13 -0000 1.5
***************
*** 208,210 ****
--- 208,232 ----
return l;
}
+
+ /**
+ * take a delimited string and convert to a String[]
+ * @param in the delimited string
+ * @param delim the delimiter
+ * @return a String[]
+ */
+ public static final String[] delimitedToArray(String in, String delim) {
+ if (in == null || delim == null)
+ return new String[0];
+ StringTokenizer st = new StringTokenizer(in, delim);
+ String[] rc = new String[st.countTokens()];
+ if (rc.length == 0)
+ return new String[]{in};
+
+ int x = 0;
+ while (st.hasMoreTokens()) {
+ rc[x++] = st.nextToken();
+ }
+
+ return rc;
+ }
}
|