diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/IndividualController.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/IndividualController.java index 640bbb712..77ffc1a20 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/IndividualController.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/IndividualController.java @@ -47,6 +47,7 @@ import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.Res import edu.cornell.mannlib.vitro.webapp.controller.freemarker.responsevalues.TemplateResponseValues; import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao; import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyDao; +import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary; import edu.cornell.mannlib.vitro.webapp.edit.n3editing.EditConfiguration; import edu.cornell.mannlib.vitro.webapp.edit.n3editing.EditSubmission; import edu.cornell.mannlib.vitro.webapp.filestorage.model.FileInfo; @@ -73,9 +74,15 @@ public class IndividualController extends FreemarkerHttpServlet { private static final long serialVersionUID = 1L; private static final Log log = LogFactory.getLog(IndividualController.class); + private static final Map namespaces = new HashMap() {{ + put("vitro", VitroVocabulary.vitroURI); + put("vitroPublic", VitroVocabulary.VITRO_PUBLIC); + }}; + private static final String TEMPLATE_INDIVIDUAL_DEFAULT = "individual.ftl"; private static final String TEMPLATE_HELP = "individual-help.ftl"; + @Override protected ResponseValues processRequest(VitroRequest vreq) { try { @@ -114,9 +121,9 @@ public class IndividualController extends FreemarkerHttpServlet { Map body = new HashMap(); - body.put("title", individual.getName()); - + body.put("title", individual.getName()); body.put("relatedSubject", getRelatedSubject(vreq)); + body.put("namespaces", namespaces); IndividualTemplateModel itm = getIndividualTemplateModel(vreq, individual); /* We need to expose non-getters in displaying the individual's property list, @@ -125,9 +132,7 @@ public class IndividualController extends FreemarkerHttpServlet { * into the data model: no real data can be modified. */ body.put("individual", getNonDefaultBeansWrapper(BeansWrapper.EXPOSE_SAFE).wrap(itm)); - - body.put("headContent", getRdfLinkTag(itm)); - + body.put("headContent", getRdfLinkTag(itm)); body.put("localName", new IndividualLocalNameMethod()); String template = getIndividualTemplate(individual); diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/UrlBuilder.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/UrlBuilder.java index 882967087..85d600b36 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/UrlBuilder.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/controller/freemarker/UrlBuilder.java @@ -36,6 +36,7 @@ public class UrlBuilder { AUTHENTICATE("/authenticate"), BROWSE("/browse"), CONTACT("/contact"), + IMAGE_UPLOAD("/uploadImages"), INDIVIDUAL("/individual"), INDIVIDUAL_EDIT("/entityEdit"), INDIVIDUAL_LIST("/individuallist"), @@ -279,6 +280,13 @@ public class UrlBuilder { return profileUrl; } + + public static String getImageUploadUrl(String subjectUri, String action) { + ParamMap params = new ParamMap( + "entityUri", subjectUri, + "action", action); + return UrlBuilder.getUrl(Route.IMAGE_UPLOAD, params); + } public static String urlEncode(String url) { String encoding = "ISO-8859-1"; diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/individual/GroupedPropertyList.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/individual/GroupedPropertyList.java index e65748f30..6883648db 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/individual/GroupedPropertyList.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/individual/GroupedPropertyList.java @@ -45,10 +45,11 @@ public class GroupedPropertyList extends BaseTemplateModel { private static final Log log = LogFactory.getLog(GroupedPropertyList.class); private static final int MAX_GROUP_DISPLAY_RANK = 99; + @SuppressWarnings("serial") private static final List VITRO_PROPS_TO_ADD_TO_LIST = new ArrayList() {{ add(VitroVocabulary.PRIMARY_LINK); add(VitroVocabulary.ADDITIONAL_LINK); - //add(VitroVocabulary.IND_MAIN_IMAGE); + add(VitroVocabulary.IND_MAIN_IMAGE); }}; private Individual subject; diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/individual/IndividualTemplateModel.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/individual/IndividualTemplateModel.java index 5c10c5acb..5db09da2a 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/individual/IndividualTemplateModel.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/individual/IndividualTemplateModel.java @@ -66,12 +66,15 @@ public class IndividualTemplateModel extends BaseTemplateModel { return isPerson() ? getUrl(Route.VISUALIZATION_AJAX.path(), "uri", getUri()) : null; } - // ** Remove these when the new methods are written + // This remains as a convenience method for getting the image url. We could instead use a custom list + // view for mainImage which would provide this data in the query results. public String getImageUrl() { String imageUrl = individual.getImageUrl(); return imageUrl == null ? null : getUrl(imageUrl); } - + + // This remains as a convenience method for getting the thumbnail url. We could instead use a custom list + // view for mainImage which would provide this data in the query results. public String getThumbUrl() { String thumbUrl = individual.getThumbUrl(); return thumbUrl == null ? null : getUrl(thumbUrl); @@ -106,33 +109,6 @@ public class IndividualTemplateModel extends BaseTemplateModel { return individual.isVClass("http://xmlns.com/foaf/0.1/Organization"); } - public Link getPrimaryLink() { - Link primaryLink = null; - String anchor = individual.getAnchor(); - String url = individual.getUrl(); - if (anchor != null && url != null) { - primaryLink = new Link(); - primaryLink.setAnchor(individual.getAnchor()); - primaryLink.setUrl(individual.getUrl()); - } - return primaryLink; - } - - public List getAdditionalLinks() { - return individual.getLinksList(); - } - - public List getLinks() { - List additionalLinks = getAdditionalLinks(); - List links = new ArrayList(additionalLinks.size()+1); - Link primaryLink = getPrimaryLink(); - if (primaryLink != null) { - links.add(primaryLink); - } - links.addAll(additionalLinks); - return links; - } - public GroupedPropertyList getPropertyList() { if (propertyList == null) { propertyList = new GroupedPropertyList(individual, vreq, policyHelper); diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/individual/ObjectPropertyStatementTemplateModel.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/individual/ObjectPropertyStatementTemplateModel.java index 2d6d53f5d..4a17546e1 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/individual/ObjectPropertyStatementTemplateModel.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/individual/ObjectPropertyStatementTemplateModel.java @@ -16,6 +16,7 @@ import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder.ParamMap; import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyStatementDao; +import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary; public class ObjectPropertyStatementTemplateModel extends PropertyStatementTemplateModel { @@ -82,6 +83,9 @@ public class ObjectPropertyStatementTemplateModel extends PropertyStatementTempl public String getEditUrl() { String editUrl = ""; if (isEditable()) { + if (propertyUri.equals(VitroVocabulary.IND_MAIN_IMAGE)) { + return UrlBuilder.getImageUploadUrl(subjectUri, "edit"); + } ParamMap params = new ParamMap( "subjectUri", subjectUri, "predicateUri", propertyUri, @@ -90,6 +94,7 @@ public class ObjectPropertyStatementTemplateModel extends PropertyStatementTempl params.put("deleteProhibited", "prohibited"); } editUrl = UrlBuilder.getUrl(EDIT_PATH, params); + } return editUrl; @@ -98,12 +103,16 @@ public class ObjectPropertyStatementTemplateModel extends PropertyStatementTempl public String getDeleteUrl() { String deleteUrl = ""; if (isDeletable()) { + if (propertyUri.equals(VitroVocabulary.IND_MAIN_IMAGE)) { + return UrlBuilder.getImageUploadUrl(subjectUri, "delete"); + } ParamMap params = new ParamMap( "subjectUri", subjectUri, "predicateUri", propertyUri, "objectUri", objectUri, "cmd", "delete"); deleteUrl = UrlBuilder.getUrl(EDIT_PATH, params); + } return deleteUrl; } diff --git a/webapp/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/individual/ObjectPropertyTemplateModel.java b/webapp/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/individual/ObjectPropertyTemplateModel.java index 476fe8424..862cbdb3a 100644 --- a/webapp/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/individual/ObjectPropertyTemplateModel.java +++ b/webapp/src/edu/cornell/mannlib/vitro/webapp/web/templatemodels/individual/ObjectPropertyTemplateModel.java @@ -33,6 +33,7 @@ import edu.cornell.mannlib.vitro.webapp.controller.VitroRequest; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder; import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder.ParamMap; import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyDao; +import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary; import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory; import freemarker.cache.TemplateLoader; import freemarker.template.Configuration; @@ -353,10 +354,14 @@ public abstract class ObjectPropertyTemplateModel extends PropertyTemplateModel public String getAddUrl() { String addUrl = ""; if (addAccess) { + if (propertyUri.equals(VitroVocabulary.IND_MAIN_IMAGE)) { + return UrlBuilder.getImageUploadUrl(subjectUri, "add"); + } ParamMap params = new ParamMap( "subjectUri", subjectUri, - "predicateUri", propertyUri); - addUrl = UrlBuilder.getUrl(EDIT_PATH, params); + "predicateUri", propertyUri); + addUrl = UrlBuilder.getUrl(EDIT_PATH, params); + } return addUrl; } diff --git a/webapp/web/templates/freemarker/body/individual/individual.ftl b/webapp/web/templates/freemarker/body/individual/individual.ftl index 536da6d2b..ca993835e 100644 --- a/webapp/web/templates/freemarker/body/individual/individual.ftl +++ b/webapp/web/templates/freemarker/body/individual/individual.ftl @@ -10,12 +10,8 @@
- <#-- Thumbnail --> - <#if individual.thumbUrl??> - ${individual.name} - <#--<#elseif individual.person> - placeholder image--> - + <#-- Image --> + <@p.imageLinks individual propertyGroups editing />
diff --git a/webapp/web/templates/freemarker/body/partials/individual/individual-setup.ftl b/webapp/web/templates/freemarker/body/partials/individual/individual-setup.ftl new file mode 100644 index 000000000..661860e70 --- /dev/null +++ b/webapp/web/templates/freemarker/body/partials/individual/individual-setup.ftl @@ -0,0 +1,14 @@ +<#-- $This file is distributed under the terms of the license in /doc/license.txt$ --> + +<#-- Setup needed by all individual templates --> + +<#import "lib-list.ftl" as l> +<#import "lib-properties.ftl" as p> + +<#assign editing = individual.showEditingLinks> + +<#assign editingClass> + <#if editing>editing + + +<#assign propertyGroups = individual.propertyList> \ No newline at end of file diff --git a/webapp/web/templates/freemarker/body/partials/individual/lib-properties.ftl b/webapp/web/templates/freemarker/body/partials/individual/lib-properties.ftl index a36161432..46464b96d 100644 --- a/webapp/web/templates/freemarker/body/partials/individual/lib-properties.ftl +++ b/webapp/web/templates/freemarker/body/partials/individual/lib-properties.ftl @@ -110,3 +110,21 @@ name will be used as the label. --> + +<#-- Main image links --> +<#macro imageLinks individual propertyGroups showEditLinks placeholderImage=""> + <#assign mainImage = propertyGroups.getPropertyAndRemoveFromList("${namespaces.vitroPublic}mainImage")!> + <#assign thumbUrl = individual.thumbUrl!> + <#-- Don't assume that if the mainImage property is populated, there is a thumbnail image (though that is the general case). + If there's a mainImage statement but no thumbnail image, treat it as if there is no image. --> + <#if (mainImage.statements)?has_content && thumbUrl?has_content> + ${individual.name} + <@p.editingLinks mainImage.statements[0] showEditLinks /> + <#else> + <@p.addLinkWithLabel mainImage showEditLinks "Photo" /> + <#if placeholderImage?has_content> + placeholder image + + + + \ No newline at end of file