NIHVIVO-1332 Editing links for individual image
This commit is contained in:
parent
69e8180ae8
commit
91abe8e801
9 changed files with 75 additions and 43 deletions
|
@ -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.controller.freemarker.responsevalues.TemplateResponseValues;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao;
|
import edu.cornell.mannlib.vitro.webapp.dao.IndividualDao;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.ObjectPropertyDao;
|
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.EditConfiguration;
|
||||||
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.EditSubmission;
|
import edu.cornell.mannlib.vitro.webapp.edit.n3editing.EditSubmission;
|
||||||
import edu.cornell.mannlib.vitro.webapp.filestorage.model.FileInfo;
|
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 long serialVersionUID = 1L;
|
||||||
private static final Log log = LogFactory.getLog(IndividualController.class);
|
private static final Log log = LogFactory.getLog(IndividualController.class);
|
||||||
|
|
||||||
|
private static final Map<String, String> namespaces = new HashMap<String, String>() {{
|
||||||
|
put("vitro", VitroVocabulary.vitroURI);
|
||||||
|
put("vitroPublic", VitroVocabulary.VITRO_PUBLIC);
|
||||||
|
}};
|
||||||
|
|
||||||
private static final String TEMPLATE_INDIVIDUAL_DEFAULT = "individual.ftl";
|
private static final String TEMPLATE_INDIVIDUAL_DEFAULT = "individual.ftl";
|
||||||
private static final String TEMPLATE_HELP = "individual-help.ftl";
|
private static final String TEMPLATE_HELP = "individual-help.ftl";
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected ResponseValues processRequest(VitroRequest vreq) {
|
protected ResponseValues processRequest(VitroRequest vreq) {
|
||||||
try {
|
try {
|
||||||
|
@ -115,8 +122,8 @@ public class IndividualController extends FreemarkerHttpServlet {
|
||||||
Map<String, Object> body = new HashMap<String, Object>();
|
Map<String, Object> body = new HashMap<String, Object>();
|
||||||
|
|
||||||
body.put("title", individual.getName());
|
body.put("title", individual.getName());
|
||||||
|
|
||||||
body.put("relatedSubject", getRelatedSubject(vreq));
|
body.put("relatedSubject", getRelatedSubject(vreq));
|
||||||
|
body.put("namespaces", namespaces);
|
||||||
|
|
||||||
IndividualTemplateModel itm = getIndividualTemplateModel(vreq, individual);
|
IndividualTemplateModel itm = getIndividualTemplateModel(vreq, individual);
|
||||||
/* We need to expose non-getters in displaying the individual's property list,
|
/* 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.
|
* into the data model: no real data can be modified.
|
||||||
*/
|
*/
|
||||||
body.put("individual", getNonDefaultBeansWrapper(BeansWrapper.EXPOSE_SAFE).wrap(itm));
|
body.put("individual", getNonDefaultBeansWrapper(BeansWrapper.EXPOSE_SAFE).wrap(itm));
|
||||||
|
|
||||||
body.put("headContent", getRdfLinkTag(itm));
|
body.put("headContent", getRdfLinkTag(itm));
|
||||||
|
|
||||||
body.put("localName", new IndividualLocalNameMethod());
|
body.put("localName", new IndividualLocalNameMethod());
|
||||||
|
|
||||||
String template = getIndividualTemplate(individual);
|
String template = getIndividualTemplate(individual);
|
||||||
|
|
|
@ -36,6 +36,7 @@ public class UrlBuilder {
|
||||||
AUTHENTICATE("/authenticate"),
|
AUTHENTICATE("/authenticate"),
|
||||||
BROWSE("/browse"),
|
BROWSE("/browse"),
|
||||||
CONTACT("/contact"),
|
CONTACT("/contact"),
|
||||||
|
IMAGE_UPLOAD("/uploadImages"),
|
||||||
INDIVIDUAL("/individual"),
|
INDIVIDUAL("/individual"),
|
||||||
INDIVIDUAL_EDIT("/entityEdit"),
|
INDIVIDUAL_EDIT("/entityEdit"),
|
||||||
INDIVIDUAL_LIST("/individuallist"),
|
INDIVIDUAL_LIST("/individuallist"),
|
||||||
|
@ -280,6 +281,13 @@ public class UrlBuilder {
|
||||||
return profileUrl;
|
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) {
|
public static String urlEncode(String url) {
|
||||||
String encoding = "ISO-8859-1";
|
String encoding = "ISO-8859-1";
|
||||||
String encodedUrl = null;
|
String encodedUrl = null;
|
||||||
|
|
|
@ -45,10 +45,11 @@ public class GroupedPropertyList extends BaseTemplateModel {
|
||||||
private static final Log log = LogFactory.getLog(GroupedPropertyList.class);
|
private static final Log log = LogFactory.getLog(GroupedPropertyList.class);
|
||||||
private static final int MAX_GROUP_DISPLAY_RANK = 99;
|
private static final int MAX_GROUP_DISPLAY_RANK = 99;
|
||||||
|
|
||||||
|
@SuppressWarnings("serial")
|
||||||
private static final List<String> VITRO_PROPS_TO_ADD_TO_LIST = new ArrayList<String>() {{
|
private static final List<String> VITRO_PROPS_TO_ADD_TO_LIST = new ArrayList<String>() {{
|
||||||
add(VitroVocabulary.PRIMARY_LINK);
|
add(VitroVocabulary.PRIMARY_LINK);
|
||||||
add(VitroVocabulary.ADDITIONAL_LINK);
|
add(VitroVocabulary.ADDITIONAL_LINK);
|
||||||
//add(VitroVocabulary.IND_MAIN_IMAGE);
|
add(VitroVocabulary.IND_MAIN_IMAGE);
|
||||||
}};
|
}};
|
||||||
|
|
||||||
private Individual subject;
|
private Individual subject;
|
||||||
|
|
|
@ -66,12 +66,15 @@ public class IndividualTemplateModel extends BaseTemplateModel {
|
||||||
return isPerson() ? getUrl(Route.VISUALIZATION_AJAX.path(), "uri", getUri()) : null;
|
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() {
|
public String getImageUrl() {
|
||||||
String imageUrl = individual.getImageUrl();
|
String imageUrl = individual.getImageUrl();
|
||||||
return imageUrl == null ? null : getUrl(imageUrl);
|
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() {
|
public String getThumbUrl() {
|
||||||
String thumbUrl = individual.getThumbUrl();
|
String thumbUrl = individual.getThumbUrl();
|
||||||
return thumbUrl == null ? null : getUrl(thumbUrl);
|
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");
|
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<Link> getAdditionalLinks() {
|
|
||||||
return individual.getLinksList();
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<Link> getLinks() {
|
|
||||||
List<Link> additionalLinks = getAdditionalLinks();
|
|
||||||
List<Link> links = new ArrayList<Link>(additionalLinks.size()+1);
|
|
||||||
Link primaryLink = getPrimaryLink();
|
|
||||||
if (primaryLink != null) {
|
|
||||||
links.add(primaryLink);
|
|
||||||
}
|
|
||||||
links.addAll(additionalLinks);
|
|
||||||
return links;
|
|
||||||
}
|
|
||||||
|
|
||||||
public GroupedPropertyList getPropertyList() {
|
public GroupedPropertyList getPropertyList() {
|
||||||
if (propertyList == null) {
|
if (propertyList == null) {
|
||||||
propertyList = new GroupedPropertyList(individual, vreq, policyHelper);
|
propertyList = new GroupedPropertyList(individual, vreq, policyHelper);
|
||||||
|
|
|
@ -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;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder.ParamMap;
|
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.ObjectPropertyStatementDao;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
||||||
|
|
||||||
public class ObjectPropertyStatementTemplateModel extends PropertyStatementTemplateModel {
|
public class ObjectPropertyStatementTemplateModel extends PropertyStatementTemplateModel {
|
||||||
|
|
||||||
|
@ -82,6 +83,9 @@ public class ObjectPropertyStatementTemplateModel extends PropertyStatementTempl
|
||||||
public String getEditUrl() {
|
public String getEditUrl() {
|
||||||
String editUrl = "";
|
String editUrl = "";
|
||||||
if (isEditable()) {
|
if (isEditable()) {
|
||||||
|
if (propertyUri.equals(VitroVocabulary.IND_MAIN_IMAGE)) {
|
||||||
|
return UrlBuilder.getImageUploadUrl(subjectUri, "edit");
|
||||||
|
}
|
||||||
ParamMap params = new ParamMap(
|
ParamMap params = new ParamMap(
|
||||||
"subjectUri", subjectUri,
|
"subjectUri", subjectUri,
|
||||||
"predicateUri", propertyUri,
|
"predicateUri", propertyUri,
|
||||||
|
@ -90,6 +94,7 @@ public class ObjectPropertyStatementTemplateModel extends PropertyStatementTempl
|
||||||
params.put("deleteProhibited", "prohibited");
|
params.put("deleteProhibited", "prohibited");
|
||||||
}
|
}
|
||||||
editUrl = UrlBuilder.getUrl(EDIT_PATH, params);
|
editUrl = UrlBuilder.getUrl(EDIT_PATH, params);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return editUrl;
|
return editUrl;
|
||||||
|
@ -98,12 +103,16 @@ public class ObjectPropertyStatementTemplateModel extends PropertyStatementTempl
|
||||||
public String getDeleteUrl() {
|
public String getDeleteUrl() {
|
||||||
String deleteUrl = "";
|
String deleteUrl = "";
|
||||||
if (isDeletable()) {
|
if (isDeletable()) {
|
||||||
|
if (propertyUri.equals(VitroVocabulary.IND_MAIN_IMAGE)) {
|
||||||
|
return UrlBuilder.getImageUploadUrl(subjectUri, "delete");
|
||||||
|
}
|
||||||
ParamMap params = new ParamMap(
|
ParamMap params = new ParamMap(
|
||||||
"subjectUri", subjectUri,
|
"subjectUri", subjectUri,
|
||||||
"predicateUri", propertyUri,
|
"predicateUri", propertyUri,
|
||||||
"objectUri", objectUri,
|
"objectUri", objectUri,
|
||||||
"cmd", "delete");
|
"cmd", "delete");
|
||||||
deleteUrl = UrlBuilder.getUrl(EDIT_PATH, params);
|
deleteUrl = UrlBuilder.getUrl(EDIT_PATH, params);
|
||||||
|
|
||||||
}
|
}
|
||||||
return deleteUrl;
|
return deleteUrl;
|
||||||
}
|
}
|
||||||
|
|
|
@ -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;
|
||||||
import edu.cornell.mannlib.vitro.webapp.controller.freemarker.UrlBuilder.ParamMap;
|
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.ObjectPropertyDao;
|
||||||
|
import edu.cornell.mannlib.vitro.webapp.dao.VitroVocabulary;
|
||||||
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
import edu.cornell.mannlib.vitro.webapp.dao.WebappDaoFactory;
|
||||||
import freemarker.cache.TemplateLoader;
|
import freemarker.cache.TemplateLoader;
|
||||||
import freemarker.template.Configuration;
|
import freemarker.template.Configuration;
|
||||||
|
@ -353,10 +354,14 @@ public abstract class ObjectPropertyTemplateModel extends PropertyTemplateModel
|
||||||
public String getAddUrl() {
|
public String getAddUrl() {
|
||||||
String addUrl = "";
|
String addUrl = "";
|
||||||
if (addAccess) {
|
if (addAccess) {
|
||||||
|
if (propertyUri.equals(VitroVocabulary.IND_MAIN_IMAGE)) {
|
||||||
|
return UrlBuilder.getImageUploadUrl(subjectUri, "add");
|
||||||
|
}
|
||||||
ParamMap params = new ParamMap(
|
ParamMap params = new ParamMap(
|
||||||
"subjectUri", subjectUri,
|
"subjectUri", subjectUri,
|
||||||
"predicateUri", propertyUri);
|
"predicateUri", propertyUri);
|
||||||
addUrl = UrlBuilder.getUrl(EDIT_PATH, params);
|
addUrl = UrlBuilder.getUrl(EDIT_PATH, params);
|
||||||
|
|
||||||
}
|
}
|
||||||
return addUrl;
|
return addUrl;
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,12 +10,8 @@
|
||||||
|
|
||||||
<section id="individual-intro" class="vcard" role="region">
|
<section id="individual-intro" class="vcard" role="region">
|
||||||
<section id="share-contact" role="region">
|
<section id="share-contact" role="region">
|
||||||
<#-- Thumbnail -->
|
<#-- Image -->
|
||||||
<#if individual.thumbUrl??>
|
<@p.imageLinks individual propertyGroups editing />
|
||||||
<a href="${individual.imageUrl}"><img class="individual-photo2" src="${individual.thumbUrl}" title="click to view larger image" alt="${individual.name}" width="115" /></a>
|
|
||||||
<#--<#elseif individual.person>
|
|
||||||
<img class="individual-photo2" src="${urls.images}/placeholders/person.thumbnail.jpg" title = "no image" alt="placeholder image" width="115" />-->
|
|
||||||
</#if>
|
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
<section id="individual-info" role="region">
|
<section id="individual-info" role="region">
|
||||||
|
|
|
@ -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</#if>
|
||||||
|
</#assign>
|
||||||
|
|
||||||
|
<#assign propertyGroups = individual.propertyList>
|
|
@ -110,3 +110,21 @@ name will be used as the label. -->
|
||||||
</nav>
|
</nav>
|
||||||
</#if>
|
</#if>
|
||||||
</#macro>
|
</#macro>
|
||||||
|
|
||||||
|
<#-- 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>
|
||||||
|
<a href="${individual.imageUrl}"><img class="individual-photo2" src="${thumbUrl}" title="click to view larger image" alt="${individual.name}" width="115" /></a>
|
||||||
|
<@p.editingLinks mainImage.statements[0] showEditLinks />
|
||||||
|
<#else>
|
||||||
|
<@p.addLinkWithLabel mainImage showEditLinks "Photo" />
|
||||||
|
<#if placeholderImage?has_content>
|
||||||
|
<img class="individual-photo2" src="${dummyImage}" title = "no image" alt="placeholder image" width="115" />
|
||||||
|
</#if>
|
||||||
|
</#if>
|
||||||
|
|
||||||
|
</#macro>
|
Loading…
Add table
Add a link
Reference in a new issue