Skip to content

Commit

Permalink
Merge pull request IQSS#3118 from IQSS/2469-widgets
Browse files Browse the repository at this point in the history
2469 widgets
  • Loading branch information
scolapasta committed May 27, 2016
2 parents d0b80fb + a49554f commit 2935cde
Show file tree
Hide file tree
Showing 62 changed files with 1,920 additions and 1,071 deletions.
1 change: 1 addition & 0 deletions scripts/database/upgrades/upgrade_v4.3.1_to_v4.4.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE dataverse ADD COLUMN citationRedirectURL character varying(255);
78 changes: 68 additions & 10 deletions src/main/java/Bundle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -80,12 +80,17 @@ header.user.selectTab.apiToken=API Token

head.meta.description=The Dataverse Project is an open source software application to share, cite and archive data. Dataverse provides a robust infrastructure for data stewards to host and archive data, while offering researchers an easy way to share and get credit for their data.
body.skip=Skip to main content

# dataverse_footer.xhtml

footer.codeAvailable=Code available at
footer.dataverseOnGitHub=Dataverse On GitHub
footer.dataverseProjectOn=Dataverse Project on
footer.Twitter=Twitter
footer.dataScienceIQSS=<a href="http://datascience.iq.harvard.edu/" title="Data Science at The Institute for Quantitative Social Science" target="_blank">Data Science</a> at <a href="http://www.iq.harvard.edu/" title="The Institute for Quantitative Social Science" target="_blank">The Institute for Quantitative Social Science</a>
footer.dataScienceIQSS=Developed at the <a href="http://www.iq.harvard.edu/" title="Institute for Quantitative Social Science" target="_blank">Institute for Quantitative Social Science</a>
footer.copyright=Copyright &#169; 2016, The President &#38; Fellows of Harvard College
footer.widget.datastored=Data is stored at {0}.
footer.widget.login=Log in to
footer.privacyPolicy=Privacy Policy
footer.poweredby=Powered by
footer.dataverseProject=The Dataverse Project
Expand Down Expand Up @@ -483,11 +488,28 @@ dataverse.theme.website.watermark=Your personal site, http://...
dataverse.theme.website.invalidMsg=Invalid URL.

dataverse.widgets.title=Widgets
dataverse.widgets.tip=Copy and paste this code into the HTML on your site.
dataverse.widgets.notPublished.why.header=Why Use Widgets?
dataverse.widgets.notPublished.why.reason1=Increases the web visibility of your data by allowing you to embed your dataverse and datasets into your personal or project website.
dataverse.widgets.notPublished.why.reason2=Allows others to browse your dataverse and datasets without leaving your personal or project website.
dataverse.widgets.notPublished.how.header=How To Use Widgets
dataverse.widgets.notPublished.how.tip1=To use widgets, your dataverse and datasets need to be published.
dataverse.widgets.notPublished.how.tip2=After publishing, code will be available on this page for you to copy and add to your personal or project website.
dataverse.widgets.notPublished.how.tip3=Do you have an OpenScholar website? If so, learn more about adding the Dataverse widgets to your website <a href="{0}/{1}/user/dataverse-management.html#adding-widgets-to-an-openscholar-website" title="Adding Widgets to an OpenScholar Website - Dataverse User Guide" target="_blank">here</a>.
dataverse.widgets.notPublished.getStarted=To get started, publish your dataverse. To learn more about Widgets, visit the <a href="{0}/{1}/user/dataverse-management.html#theme-widgets" title="Theme + Widgets - Dataverse User Guide" target="_blank">Theme + Widgets</a> section of the User Guide.
dataverse.widgets.editAdvanced=Edit Advanced Options
dataverse.widgets.editAdvanced.tip=<strong>Advanced Options</strong> &#150; Additional options for configuring your widget on your personal or project website.
dataverse.widgets.tip=Copy and paste this code into the HTML on your site. To learn more about Widgets, visit the <a href="{0}/{1}/user/dataverse-management.html#theme-widgets" title="Theme + Widgets - Dataverse User Guide" target="_blank">Theme + Widgets</a> section of the User Guide.
dataverse.widgets.searchBox.txt=Dataverse Search Box
dataverse.widgets.searchBox.tip=Add a way for visitors on your website to be able to search Dataverse.
dataverse.widgets.dataverseListing.txt=Dataverse Listing
dataverse.widgets.dataverseListing.tip=Add a way for visitors on your website to be able to view your dataverses and datasets, sort, or page through them.
dataverse.widgets.advanced.popup.header=Widget Advanced Options
dataverse.widgets.advanced.prompt=Forward persistent URL's in your dataset citation to your personal website.
dataverse.widgets.advanced.url.label=Personal Website URL
dataverse.widgets.advanced.url.watermark=http://www.example.com/page-name
dataverse.widgets.advanced.invalid.message=Please enter a valid URL
dataverse.widgets.advanced.success.message=Successfully updated your Personal Website URL
dataverse.widgets.advanced.failure.message=The dataverse Personal Website URL has not been updated.

# permissions-manage.xhtml

Expand Down Expand Up @@ -773,6 +795,7 @@ dataset.editBtn.itemLabel.upload=Files (Upload)
dataset.editBtn.itemLabel.metadata=Metadata
dataset.editBtn.itemLabel.terms=Terms
dataset.editBtn.itemLabel.permissions=Permissions
dataset.editBtn.itemLabel.widgets=Widgets
dataset.editBtn.itemLabel.deleteDataset=Delete Dataset
dataset.editBtn.itemLabel.deleteDraft=Delete Draft Version
dataset.editBtn.itemLabel.deaccession=Deaccession Dataset
Expand Down Expand Up @@ -822,11 +845,11 @@ dataset.versionUI.deaccessioned=Deaccessioned
dataset.cite.title.released=DRAFT VERSION will be replaced in the citation with V1 once the dataset has been published.
dataset.cite.title.draft=DRAFT VERSION will be replaced in the citation with the selected version once the dataset has been published.
dataset.cite.title.deassessioned=DEACCESSIONED VERSION has been added to the citation for this version since it is no longer available.
dataset.cite.standards.tip=If you use these data, please add this citation to your scholarly resources. Learn about <a href="http://best-practices.dataverse.org/data-citation/" title="Get Recognition: Data Citation - Dataverse Best Practices" target="_blank">Data Citation Standards</a>.
dataset.cite.downloadBtn=Download Citation
dataset.cite.standards.tip=Learn about <a href="http://best-practices.dataverse.org/data-citation/" title="Get Recognition: Data Citation - Dataverse Best Practices" target="_blank">Data Citation Standards</a>.
dataset.cite.downloadBtn=Cite Data
dataset.cite.downloadBtn.xml=EndNote XML
dataset.cite.downloadBtn.ris=RIS Format
dataset.cite.downloadBtn.bib=BibTeX Format
dataset.cite.downloadBtn.ris=RIS
dataset.cite.downloadBtn.bib=BibTeX
dataset.create.authenticatedUsersOnly=Only authenticated users can create datasets.
dataset.deaccession.reason=Deaccession Reason
dataset.beAccessedAt=The dataset can now be accessed at:
Expand Down Expand Up @@ -964,8 +987,8 @@ file.downloadBtn.format.citation=Data File Citation
file.more.information.link=Link to more file information for

file.requestAccess=Request Access
file.requestAccess.dialog.msg=You need to <a href="/loginpage.xhtml{0}" title="Log into your Dataverse Account">Log In</a> to request access to this file.
file.requestAccess.dialog.msg.signup=You need to <a href="/dataverseuser.xhtml{0}&amp;editMode=CREATE" title="Sign Up for a Dataverse Account">Sign Up</a> or <a href="/loginpage.xhtml{0}" title="Log into your Dataverse Account">Log In</a> to request access to this file.
file.requestAccess.dialog.msg=You need to <a href="/loginpage.xhtml{0}" target="{1}" title="Log into your Dataverse Account">Log In</a> to request access to this file.
file.requestAccess.dialog.msg.signup=You need to <a href="/dataverseuser.xhtml{0}&amp;editMode=CREATE" target="{1}" title="Sign Up for a Dataverse Account">Sign Up</a> or <a href="/loginpage.xhtml{0}" target="{1}" title="Log into your Dataverse Account">Log In</a> to request access to this file.
file.accessRequested=Access Requested

file.ingestInproGress=Ingest in progress...
Expand Down Expand Up @@ -1113,6 +1136,31 @@ file.results.btn.sort.option.oldest=Oldest
file.results.btn.sort.option.size=Size
file.results.btn.sort.option.type=Type

# dataset-widgets.xhtml
dataset.widgets.title=Dataset Widgets
dataset.widgets.notPublished.why.header=Why Use Widgets?
dataset.widgets.notPublished.why.reason1=Increases the web visibility of your data by allowing you to embed your dataverse and datasets into your personal or project website.
dataset.widgets.notPublished.why.reason2=Allows others to browse your dataverse and datasets without leaving your personal or project website.
dataset.widgets.notPublished.how.header=How To Use Widgets
dataset.widgets.notPublished.how.tip1=To use widgets, your dataverse and datasets need to be published.
dataset.widgets.notPublished.how.tip2=After publishing, code will be available on this page for you to copy and add to your personal or project website.
dataset.widgets.notPublished.how.tip3=Do you have an OpenScholar website? If so, learn more about adding the Dataverse widgets to your website <a href="{0}/{1}/user/dataverse-management.html#adding-widgets-to-an-openscholar-website" title="Adding Widgets to an OpenScholar Website - Dataverse User Guide" target="_blank">here</a>.
dataset.widgets.notPublished.getStarted=To get started, publish your dataset. To learn more about Widgets, visit the <a href="{0}/{1}/user/dataset-management.html#widgets" title="Widgets - Dataverse User Guide" target="_blank">Widgets</a> section of the User Guide.
dataset.widgets.editAdvanced=Edit Advanced Options
dataset.widgets.editAdvanced.tip=<strong>Advanced Options</strong> &#150; Additional options for configuring your widget on your personal or project website.
dataset.widgets.tip=Copy and paste this code into the HTML on your site. To learn more about Widgets, visit the <a href="{0}/{1}/user/dataset-management.html#widgets" title="Widgets - Dataverse User Guide" target="_blank">Widgets</a> section of the User Guide.
dataset.widgets.citation.txt=Dataset Citation
dataset.widgets.citation.tip=Add a citation for your dataset to your personal or project website.
dataset.widgets.datasetFull.txt=Dataset
dataset.widgets.datasetFull.tip=Add a way for visitors on your website to be able to view your datasets, download files, etc.
dataset.widgets.advanced.popup.header=Widget Advanced Options
dataset.widgets.advanced.prompt=Forward persistent URL's in your dataset citation to your personal website.
dataset.widgets.advanced.url.label=Personal Website URL
dataset.widgets.advanced.url.watermark=http://www.example.com/page-name
dataset.widgets.advanced.invalid.message=Please enter a valid URL
dataset.widgets.advanced.success.message=Successfully updated your Personal Website URL
dataset.widgets.advanced.failure.message=The dataverse Personal Website URL has not been updated.

# file.xhtml
file.title.label=Title
file.citation.label=Citation
Expand All @@ -1137,8 +1185,18 @@ error.500.message=<strong>Internal Server Error</strong> - An unexpected error w

# 404.xhtml
error.404.page.title=404 Not Found
error.404.message=<strong>Page Not Found</strong> - The page you are looking for was not found. To contact support, please press the Support link above.
error.404.message=<strong>Page Not Found</strong> - The page you are looking for was not found.

# 403.xhtml
error.403.page.title=403 Not Authorized
error.403.message=<strong>Not Authorized</strong> - You are not authorized to view this page. To contact support, please press the Support link above.
error.403.message=<strong>Not Authorized</strong> - You are not authorized to view this page.

# general error - support message
error.support.message= If you believe this is an error, please contact {0} for assistance.

# citation-frame.xhtml
citationFrame.banner.message=If the site below does not load, the archived data can be found in the {0} {1}. {2}
citationFrame.banner.message.here=here
citationFrame.banner.closeIcon=Close this message, go to dataset
citationFrame.banner.countdownMessage= This message will close in
citationFrame.banner.countdownMessage.seconds=seconds
86 changes: 86 additions & 0 deletions src/main/java/edu/harvard/iq/dataverse/BibtexCitation.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package edu.harvard.iq.dataverse;

import java.net.URL;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
import org.apache.commons.lang.StringEscapeUtils;
import org.apache.commons.lang.StringUtils;

/**
*
* @author gdurand
*/
public class BibtexCitation {

private List<String> authors = new ArrayList();
private String title;
private String year;
private GlobalId persistentId;
private String publisher;

public BibtexCitation(DatasetVersion dsv) {
//authors
dsv.getDatasetAuthors().stream().forEach((author) -> {
authors.add(author.getName().getDisplayValue());
});

// year
year = dsv.getVersionYear();

// title
title = dsv.getTitle();

// The Global Identifier:
persistentId = new GlobalId(dsv.getDataset());

// publisher
publisher = dsv.getRootDataverseNameforCitation();
}

public List<String> getAuthors() {
return authors;
}

public String getTitle() {
return title;
}

public String getYear() {
return year;
}

public GlobalId getPersistentId() {
return persistentId;
}

public String getPublisher() {
return publisher;
}


@Override
public String toString() {
StringBuilder citation = new StringBuilder("@data{");
citation.append(persistentId.getIdentifier() + "_" + year + "," + "\r\n");
citation.append("author = {").append(String.join("; ", authors)).append("},\r\n");
citation.append("publisher = {").append(publisher).append("},\r\n");
citation.append("title = {").append(title).append("},\r\n");
citation.append("year = {").append(year).append("},\r\n");
citation.append("doi = {").append(persistentId.getAuthority()).append("/").append(persistentId.getIdentifier()).append("},\r\n");
citation.append("url = {").append(persistentId.toURL().toString()).append("}\r\n");
citation.append("}");

return citation.toString();
}

}

93 changes: 93 additions & 0 deletions src/main/java/edu/harvard/iq/dataverse/CitationServlet.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package edu.harvard.iq.dataverse;

import edu.harvard.iq.dataverse.util.StringUtil;
import java.io.IOException;
import java.io.PrintWriter;
import javax.ejb.EJB;
import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

/**
*
* @author gdurand
*/
public class CitationServlet extends HttpServlet {

@EJB
DatasetServiceBean datasetService;

/**
* Processes requests for both HTTP <code>GET</code> and <code>POST</code>
* methods.
*
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {

String persistentId = request.getParameter("persistentId");
if (persistentId != null) {
Dataset ds = datasetService.findByGlobalId(persistentId);
if (ds != null) {
if (StringUtil.isEmpty(ds.getOwner().getCitationRedirectURL())) {
response.sendRedirect("dataset.xhtml?persistentId=" + persistentId);
return;
} else {
response.sendRedirect("citation-frame.xhtml?persistentId=" + persistentId);
return;
}
}
}
response.sendError(HttpServletResponse.SC_NOT_FOUND);
}

// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
/**
* Handles the HTTP <code>GET</code> method.
*
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
@Override
protected void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}

/**
* Handles the HTTP <code>POST</code> method.
*
* @param request servlet request
* @param response servlet response
* @throws ServletException if a servlet-specific error occurs
* @throws IOException if an I/O error occurs
*/
@Override
protected void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
processRequest(request, response);
}

/**
* Returns a short description of the servlet.
*
* @return a String containing servlet description
*/
@Override
public String getServletInfo() {
return "Servlet for redirecting requests from persistent identifier references.";
}// </editor-fold>

}
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public String createIdentifier(String identifier, HashMap<String, String> metada
metadataTemplate.setDescription(dataset.getLatestVersion().getDescription());
metadataTemplate.setContacts(dataset.getLatestVersion().getDatasetContacts());
metadataTemplate.setProducers(dataset.getLatestVersion().getDatasetProducers());
metadataTemplate.setTitle(metadata.get("datacite.title"));
metadataTemplate.setTitle(dataset.getLatestVersion().getTitle());
metadataTemplate.setPublisher(metadata.get("datacite.publisher"));
metadataTemplate.setPublisherYear(metadata.get("datacite.publicationyear"));

Expand Down
Loading

0 comments on commit 2935cde

Please sign in to comment.