Skip to content

Commit 2935cde

Browse files
committed
Merge pull request #3118 from IQSS/2469-widgets
2469 widgets
2 parents d0b80fb + a49554f commit 2935cde

62 files changed

Lines changed: 1920 additions & 1071 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ALTER TABLE dataverse ADD COLUMN citationRedirectURL character varying(255);

src/main/java/Bundle.properties

Lines changed: 68 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -80,12 +80,17 @@ header.user.selectTab.apiToken=API Token
8080

8181
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.
8282
body.skip=Skip to main content
83+
84+
# dataverse_footer.xhtml
85+
8386
footer.codeAvailable=Code available at
8487
footer.dataverseOnGitHub=Dataverse On GitHub
8588
footer.dataverseProjectOn=Dataverse Project on
8689
footer.Twitter=Twitter
87-
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>
90+
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>
8891
footer.copyright=Copyright &#169; 2016, The President &#38; Fellows of Harvard College
92+
footer.widget.datastored=Data is stored at {0}.
93+
footer.widget.login=Log in to
8994
footer.privacyPolicy=Privacy Policy
9095
footer.poweredby=Powered by
9196
footer.dataverseProject=The Dataverse Project
@@ -483,11 +488,28 @@ dataverse.theme.website.watermark=Your personal site, http://...
483488
dataverse.theme.website.invalidMsg=Invalid URL.
484489

485490
dataverse.widgets.title=Widgets
486-
dataverse.widgets.tip=Copy and paste this code into the HTML on your site.
491+
dataverse.widgets.notPublished.why.header=Why Use Widgets?
492+
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.
493+
dataverse.widgets.notPublished.why.reason2=Allows others to browse your dataverse and datasets without leaving your personal or project website.
494+
dataverse.widgets.notPublished.how.header=How To Use Widgets
495+
dataverse.widgets.notPublished.how.tip1=To use widgets, your dataverse and datasets need to be published.
496+
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.
497+
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>.
498+
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.
499+
dataverse.widgets.editAdvanced=Edit Advanced Options
500+
dataverse.widgets.editAdvanced.tip=<strong>Advanced Options</strong> &#150; Additional options for configuring your widget on your personal or project website.
501+
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.
487502
dataverse.widgets.searchBox.txt=Dataverse Search Box
488503
dataverse.widgets.searchBox.tip=Add a way for visitors on your website to be able to search Dataverse.
489504
dataverse.widgets.dataverseListing.txt=Dataverse Listing
490505
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.
506+
dataverse.widgets.advanced.popup.header=Widget Advanced Options
507+
dataverse.widgets.advanced.prompt=Forward persistent URL's in your dataset citation to your personal website.
508+
dataverse.widgets.advanced.url.label=Personal Website URL
509+
dataverse.widgets.advanced.url.watermark=http://www.example.com/page-name
510+
dataverse.widgets.advanced.invalid.message=Please enter a valid URL
511+
dataverse.widgets.advanced.success.message=Successfully updated your Personal Website URL
512+
dataverse.widgets.advanced.failure.message=The dataverse Personal Website URL has not been updated.
491513

492514
# permissions-manage.xhtml
493515

@@ -773,6 +795,7 @@ dataset.editBtn.itemLabel.upload=Files (Upload)
773795
dataset.editBtn.itemLabel.metadata=Metadata
774796
dataset.editBtn.itemLabel.terms=Terms
775797
dataset.editBtn.itemLabel.permissions=Permissions
798+
dataset.editBtn.itemLabel.widgets=Widgets
776799
dataset.editBtn.itemLabel.deleteDataset=Delete Dataset
777800
dataset.editBtn.itemLabel.deleteDraft=Delete Draft Version
778801
dataset.editBtn.itemLabel.deaccession=Deaccession Dataset
@@ -822,11 +845,11 @@ dataset.versionUI.deaccessioned=Deaccessioned
822845
dataset.cite.title.released=DRAFT VERSION will be replaced in the citation with V1 once the dataset has been published.
823846
dataset.cite.title.draft=DRAFT VERSION will be replaced in the citation with the selected version once the dataset has been published.
824847
dataset.cite.title.deassessioned=DEACCESSIONED VERSION has been added to the citation for this version since it is no longer available.
825-
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>.
826-
dataset.cite.downloadBtn=Download Citation
848+
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>.
849+
dataset.cite.downloadBtn=Cite Data
827850
dataset.cite.downloadBtn.xml=EndNote XML
828-
dataset.cite.downloadBtn.ris=RIS Format
829-
dataset.cite.downloadBtn.bib=BibTeX Format
851+
dataset.cite.downloadBtn.ris=RIS
852+
dataset.cite.downloadBtn.bib=BibTeX
830853
dataset.create.authenticatedUsersOnly=Only authenticated users can create datasets.
831854
dataset.deaccession.reason=Deaccession Reason
832855
dataset.beAccessedAt=The dataset can now be accessed at:
@@ -964,8 +987,8 @@ file.downloadBtn.format.citation=Data File Citation
964987
file.more.information.link=Link to more file information for
965988

966989
file.requestAccess=Request Access
967-
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.
968-
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.
990+
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.
991+
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.
969992
file.accessRequested=Access Requested
970993

971994
file.ingestInproGress=Ingest in progress...
@@ -1113,6 +1136,31 @@ file.results.btn.sort.option.oldest=Oldest
11131136
file.results.btn.sort.option.size=Size
11141137
file.results.btn.sort.option.type=Type
11151138

1139+
# dataset-widgets.xhtml
1140+
dataset.widgets.title=Dataset Widgets
1141+
dataset.widgets.notPublished.why.header=Why Use Widgets?
1142+
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.
1143+
dataset.widgets.notPublished.why.reason2=Allows others to browse your dataverse and datasets without leaving your personal or project website.
1144+
dataset.widgets.notPublished.how.header=How To Use Widgets
1145+
dataset.widgets.notPublished.how.tip1=To use widgets, your dataverse and datasets need to be published.
1146+
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.
1147+
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>.
1148+
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.
1149+
dataset.widgets.editAdvanced=Edit Advanced Options
1150+
dataset.widgets.editAdvanced.tip=<strong>Advanced Options</strong> &#150; Additional options for configuring your widget on your personal or project website.
1151+
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.
1152+
dataset.widgets.citation.txt=Dataset Citation
1153+
dataset.widgets.citation.tip=Add a citation for your dataset to your personal or project website.
1154+
dataset.widgets.datasetFull.txt=Dataset
1155+
dataset.widgets.datasetFull.tip=Add a way for visitors on your website to be able to view your datasets, download files, etc.
1156+
dataset.widgets.advanced.popup.header=Widget Advanced Options
1157+
dataset.widgets.advanced.prompt=Forward persistent URL's in your dataset citation to your personal website.
1158+
dataset.widgets.advanced.url.label=Personal Website URL
1159+
dataset.widgets.advanced.url.watermark=http://www.example.com/page-name
1160+
dataset.widgets.advanced.invalid.message=Please enter a valid URL
1161+
dataset.widgets.advanced.success.message=Successfully updated your Personal Website URL
1162+
dataset.widgets.advanced.failure.message=The dataverse Personal Website URL has not been updated.
1163+
11161164
# file.xhtml
11171165
file.title.label=Title
11181166
file.citation.label=Citation
@@ -1137,8 +1185,18 @@ error.500.message=<strong>Internal Server Error</strong> - An unexpected error w
11371185

11381186
# 404.xhtml
11391187
error.404.page.title=404 Not Found
1140-
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.
1188+
error.404.message=<strong>Page Not Found</strong> - The page you are looking for was not found.
11411189

11421190
# 403.xhtml
11431191
error.403.page.title=403 Not Authorized
1144-
error.403.message=<strong>Not Authorized</strong> - You are not authorized to view this page. To contact support, please press the Support link above.
1192+
error.403.message=<strong>Not Authorized</strong> - You are not authorized to view this page.
1193+
1194+
# general error - support message
1195+
error.support.message= If you believe this is an error, please contact {0} for assistance.
1196+
1197+
# citation-frame.xhtml
1198+
citationFrame.banner.message=If the site below does not load, the archived data can be found in the {0} {1}. {2}
1199+
citationFrame.banner.message.here=here
1200+
citationFrame.banner.closeIcon=Close this message, go to dataset
1201+
citationFrame.banner.countdownMessage= This message will close in
1202+
citationFrame.banner.countdownMessage.seconds=seconds
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
/*
2+
* To change this license header, choose License Headers in Project Properties.
3+
* To change this template file, choose Tools | Templates
4+
* and open the template in the editor.
5+
*/
6+
package edu.harvard.iq.dataverse;
7+
8+
import java.net.URL;
9+
import java.text.ParseException;
10+
import java.text.SimpleDateFormat;
11+
import java.util.ArrayList;
12+
import java.util.Date;
13+
import java.util.List;
14+
import java.util.stream.Collectors;
15+
import org.apache.commons.lang.StringEscapeUtils;
16+
import org.apache.commons.lang.StringUtils;
17+
18+
/**
19+
*
20+
* @author gdurand
21+
*/
22+
public class BibtexCitation {
23+
24+
private List<String> authors = new ArrayList();
25+
private String title;
26+
private String year;
27+
private GlobalId persistentId;
28+
private String publisher;
29+
30+
public BibtexCitation(DatasetVersion dsv) {
31+
//authors
32+
dsv.getDatasetAuthors().stream().forEach((author) -> {
33+
authors.add(author.getName().getDisplayValue());
34+
});
35+
36+
// year
37+
year = dsv.getVersionYear();
38+
39+
// title
40+
title = dsv.getTitle();
41+
42+
// The Global Identifier:
43+
persistentId = new GlobalId(dsv.getDataset());
44+
45+
// publisher
46+
publisher = dsv.getRootDataverseNameforCitation();
47+
}
48+
49+
public List<String> getAuthors() {
50+
return authors;
51+
}
52+
53+
public String getTitle() {
54+
return title;
55+
}
56+
57+
public String getYear() {
58+
return year;
59+
}
60+
61+
public GlobalId getPersistentId() {
62+
return persistentId;
63+
}
64+
65+
public String getPublisher() {
66+
return publisher;
67+
}
68+
69+
70+
@Override
71+
public String toString() {
72+
StringBuilder citation = new StringBuilder("@data{");
73+
citation.append(persistentId.getIdentifier() + "_" + year + "," + "\r\n");
74+
citation.append("author = {").append(String.join("; ", authors)).append("},\r\n");
75+
citation.append("publisher = {").append(publisher).append("},\r\n");
76+
citation.append("title = {").append(title).append("},\r\n");
77+
citation.append("year = {").append(year).append("},\r\n");
78+
citation.append("doi = {").append(persistentId.getAuthority()).append("/").append(persistentId.getIdentifier()).append("},\r\n");
79+
citation.append("url = {").append(persistentId.toURL().toString()).append("}\r\n");
80+
citation.append("}");
81+
82+
return citation.toString();
83+
}
84+
85+
}
86+
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
/*
2+
* To change this license header, choose License Headers in Project Properties.
3+
* To change this template file, choose Tools | Templates
4+
* and open the template in the editor.
5+
*/
6+
package edu.harvard.iq.dataverse;
7+
8+
import edu.harvard.iq.dataverse.util.StringUtil;
9+
import java.io.IOException;
10+
import java.io.PrintWriter;
11+
import javax.ejb.EJB;
12+
import javax.servlet.ServletException;
13+
import javax.servlet.http.HttpServlet;
14+
import javax.servlet.http.HttpServletRequest;
15+
import javax.servlet.http.HttpServletResponse;
16+
17+
/**
18+
*
19+
* @author gdurand
20+
*/
21+
public class CitationServlet extends HttpServlet {
22+
23+
@EJB
24+
DatasetServiceBean datasetService;
25+
26+
/**
27+
* Processes requests for both HTTP <code>GET</code> and <code>POST</code>
28+
* methods.
29+
*
30+
* @param request servlet request
31+
* @param response servlet response
32+
* @throws ServletException if a servlet-specific error occurs
33+
* @throws IOException if an I/O error occurs
34+
*/
35+
protected void processRequest(HttpServletRequest request, HttpServletResponse response)
36+
throws ServletException, IOException {
37+
38+
String persistentId = request.getParameter("persistentId");
39+
if (persistentId != null) {
40+
Dataset ds = datasetService.findByGlobalId(persistentId);
41+
if (ds != null) {
42+
if (StringUtil.isEmpty(ds.getOwner().getCitationRedirectURL())) {
43+
response.sendRedirect("dataset.xhtml?persistentId=" + persistentId);
44+
return;
45+
} else {
46+
response.sendRedirect("citation-frame.xhtml?persistentId=" + persistentId);
47+
return;
48+
}
49+
}
50+
}
51+
response.sendError(HttpServletResponse.SC_NOT_FOUND);
52+
}
53+
54+
// <editor-fold defaultstate="collapsed" desc="HttpServlet methods. Click on the + sign on the left to edit the code.">
55+
/**
56+
* Handles the HTTP <code>GET</code> method.
57+
*
58+
* @param request servlet request
59+
* @param response servlet response
60+
* @throws ServletException if a servlet-specific error occurs
61+
* @throws IOException if an I/O error occurs
62+
*/
63+
@Override
64+
protected void doGet(HttpServletRequest request, HttpServletResponse response)
65+
throws ServletException, IOException {
66+
processRequest(request, response);
67+
}
68+
69+
/**
70+
* Handles the HTTP <code>POST</code> method.
71+
*
72+
* @param request servlet request
73+
* @param response servlet response
74+
* @throws ServletException if a servlet-specific error occurs
75+
* @throws IOException if an I/O error occurs
76+
*/
77+
@Override
78+
protected void doPost(HttpServletRequest request, HttpServletResponse response)
79+
throws ServletException, IOException {
80+
processRequest(request, response);
81+
}
82+
83+
/**
84+
* Returns a short description of the servlet.
85+
*
86+
* @return a String containing servlet description
87+
*/
88+
@Override
89+
public String getServletInfo() {
90+
return "Servlet for redirecting requests from persistent identifier references.";
91+
}// </editor-fold>
92+
93+
}

src/main/java/edu/harvard/iq/dataverse/DOIDataCiteRegisterService.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public String createIdentifier(String identifier, HashMap<String, String> metada
4949
metadataTemplate.setDescription(dataset.getLatestVersion().getDescription());
5050
metadataTemplate.setContacts(dataset.getLatestVersion().getDatasetContacts());
5151
metadataTemplate.setProducers(dataset.getLatestVersion().getDatasetProducers());
52-
metadataTemplate.setTitle(metadata.get("datacite.title"));
52+
metadataTemplate.setTitle(dataset.getLatestVersion().getTitle());
5353
metadataTemplate.setPublisher(metadata.get("datacite.publisher"));
5454
metadataTemplate.setPublisherYear(metadata.get("datacite.publicationyear"));
5555

0 commit comments

Comments
 (0)