Skip to content

Instantly share code, notes, and snippets.

@peterdietz
Created February 24, 2011 15:32
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save peterdietz/842301 to your computer and use it in GitHub Desktop.
Save peterdietz/842301 to your computer and use it in GitHub Desktop.
DSpace adding a java page to /about
diff --git a/dspace-xmlui/dspace-xmlui-api/src/main/java/org/dspace/app/xmlui/aspect/artifactbrowser/AboutPage.java b/dspace-xmlui/dspace-xmlui-api/src/main/java/org/dspace/app/xmlui/aspect/artifactbrowser/AboutPage.java
new file mode 100644
index 0000000..8a23488
--- /dev/null
+++ b/dspace-xmlui/dspace-xmlui-api/src/main/java/org/dspace/app/xmlui/aspect/artifactbrowser/AboutPage.java
@@ -0,0 +1,78 @@
+/*
+ * AboutPage.java
+ *
+ * Version: $Revision$
+ *
+ * Date: $Date$
+ *
+ * Copyright (c) 2002, Hewlett-Packard Company and Massachusetts
+ * Institute of Technology. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are
+ * met:
+ *
+ * - Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ *
+ * - Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * - Neither the name of the Hewlett-Packard Company nor the name of the
+ * Massachusetts Institute of Technology nor the names of their
+ * contributors may be used to endorse or promote products derived from
+ * this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * HOLDERS OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
+ * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
+ * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR
+ * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
+ * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
+ * DAMAGE.
+ */
+package org.dspace.app.xmlui.aspect.artifactbrowser;
+
+import org.apache.log4j.Logger;
+import org.dspace.app.xmlui.cocoon.AbstractDSpaceTransformer;
+import org.dspace.app.xmlui.wing.WingException;
+import org.dspace.app.xmlui.wing.element.Body;
+import org.dspace.app.xmlui.wing.element.Division;
+import org.dspace.app.xmlui.wing.element.PageMeta;
+
+import org.xml.sax.SAXException;
+
+/**
+ * Display about us page.
+ *
+ * @author Peter Dietz
+ */
+public class AboutPage extends AbstractDSpaceTransformer
+{
+ private static Logger log = Logger.getLogger(AboutPage.class);
+
+ /**
+ * Add a page title and trail links.
+ */
+ public void addPageMeta(PageMeta pageMeta) throws WingException
+ {
+ // Set the page title
+ pageMeta.addMetadata("title").addContent("About Us");
+ }
+
+ /**
+ * Add some basic stuff
+ */
+ public void addBody(Body body) throws WingException, SAXException
+ {
+ Division division = body.addDivision("about-page", "primary");
+ division.setHead("About Us - Institutional Repository");
+ division.addPara("We are an institutional repository that specializes in storing your digital artifacts.");
+ }
+}
\ No newline at end of file
diff --git a/dspace-xmlui/dspace-xmlui-api/src/main/resources/aspects/ArtifactBrowser/sitemap.xmap b/dspace-xmlui/dspace-xmlui-api/src/main/resources/aspects/ArtifactBrowser/sitemap.xmap
index 8dacc9e..290bc0a 100644
--- a/dspace-xmlui/dspace-xmlui-api/src/main/resources/aspects/ArtifactBrowser/sitemap.xmap
+++ b/dspace-xmlui/dspace-xmlui-api/src/main/resources/aspects/ArtifactBrowser/sitemap.xmap
@@ -64,6 +64,7 @@ and searching the repository.
<map:transformer name="Contact" src="org.dspace.app.xmlui.aspect.artifactbrowser.Contact"/>
<map:transformer name="RestrictedItem" src="org.dspace.app.xmlui.aspect.artifactbrowser.RestrictedItem"/>
<map:transformer name="FrontPageSearch" src="org.dspace.app.xmlui.aspect.artifactbrowser.FrontPageSearch"/>
+ <map:transformer name="AboutPage" src="org.dspace.app.xmlui.aspect.artifactbrowser.AboutPage" />
<map:transformer name="Statistics" src="org.dspace.app.xmlui.aspect.artifactbrowser.StatisticsViewer"/>
<map:transformer name="Dashboard" src="org.dspace.app.xmlui.aspect.artifactbrowser.DashboardViewer"/>
@@ -152,6 +153,10 @@ and searching the repository.
<map:transform type="AdvancedSearch"/>
<map:serialize type="xml"/>
</map:match>
+ <map:match pattern="about">
+ <map:transform type="AboutPage"/>
+ <map:serialize type="xml" />
+ </map:match>
<!-- Browse (by anything) -->
@helix84
Copy link

helix84 commented Jun 15, 2012

If you're trying this in DSpace 1.8 and you're wondering why it's not working, it's because the artifactbrowser aspect has been deprecated. Just move it to another aspect, like browseArtifacts and it should work (s/artifactbrowser/browseArtifacts/), move AboutPage.java to dspace-xmlui/dspace-xmlui-api/src/main/java/org/dspace/app/xmlui/aspect/browseArtifacts/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment