Skip to content

Commit

Permalink
Merge branch 'develop' into 1551-shib-redirect #1551
Browse files Browse the repository at this point in the history
  • Loading branch information
pdurbin committed Jun 20, 2017
2 parents f7e1b71 + 6c7e016 commit ec23367
Show file tree
Hide file tree
Showing 19 changed files with 598 additions and 90 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<style>
/* NOTE: You can use the custom CSS configuration to move this CSS your own stylesheet. */

/* Overwrite default footer styles to make room at the bottom of the browser page for our custom footer... */
html, body {
height: 100%;
}
#content.container {
min-height: calc(100% - 210px);
margin-bottom: -142px;
}
#content.container:after {
content: "";
display: block;
}
#footer {
color: #a9a9a9; margin-top:0px; padding-bottom:0px; bottom:-150px; position: relative;
}

/* Place custom footer just above default footer at the bottom of the page... */
#custom-footer, #content.container:after {
height: 142px;
}
#custom-footer {
background: #414141; color: #a9a9a9; min-height: 100px; padding: 1.25em 0 100px 0;
}
#custom-footer a {
color: #fff;
}
</style>
<div id="custom-footer">
<div class="container">
<p>SAMPLE FOOTER TEXT</p>
<p class="small">
<a href="https://dataverse.org" title="SAMPLE LINK" target="_blank">SAMPLE LINK</a>
</p>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
<style>
/* NOTE: You can use the custom CSS configuration to move this CSS your own stylesheet... */

/* Overwrite default navbar styles to make room at the top of the browser page for our custom header... */
.navbar-fixed-top {
top:50px !important;
}
#dataverse-header-block {
padding-top: 150px;
}

/* Place narrow custom header at the top of the page... */
#custom-header {
background: #414141;
min-height: 44px;
position: fixed;
right: 0;
left: 0;
z-index: 930;
padding-top: 8px;
}
#custom-header a.cst-hdr-link {
line-height: 32px;
color: #BAC5C6;
font-weight: bold;
}
</style>
<div id="custom-header">
<div class="container">
<p class="text-right">
<a class="pull-left" href="https://dataverse.org" title="SAMPLE IMAGE LINK" target="_blank"><img src="/var/www/dataverse/branding/sample.png" alt="SAMPLE IMAGE"/></a>
<a class="cst-hdr-link" href="https://dataverse.org" title="SAMPLE HEADER LINK" target="_blank">SAMPLE HEADER LINK</a>
</p>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@

<style>
/* NOTE: You can use the custom CSS configuration to move this CSS your own stylesheet... */

/* Custom CSS for the custom homepage... */
div.jumbotron h1 {color:#C55B28;}
</style>

<div class="jumbotron">
<h1>Hello, world!</h1>
<p>Welcome to our Dataverse.</p>
<p><a class="btn btn-primary btn-lg" href="/dataverse/root" role="button">Browse Data</a></p>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
/* Add any CSS necessary for your custom content */

.navbar-default {
background-color: gold;
background-image: none;
}
90 changes: 89 additions & 1 deletion doc/sphinx-guides/source/installation/config.rst
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ Customizing the Root Dataverse

As the person installing Dataverse you may or may not be a local metadata expert. You may want to have others sign up for accounts and grant them the "Admin" role at the root dataverse to configure metadata fields, templates, browse/search facets, guestbooks, etc. For more on these topics, consult the :doc:`/user/dataverse-management` section of the User Guide.

You are also welcome to adjust the theme of the root dataverse by adding a logo or changing header colors, etc.

Once this configuration is complete, your Dataverse installation should be ready for users to start playing with. That said, there are many more configuration options available, which will be explained below.

Persistent Identifiers and Publishing Datasets
Expand Down Expand Up @@ -220,6 +222,70 @@ Then run the create command:

``./asadmin $ASADMIN_OPTS create-jvm-options "\-Ddataverse.files.storage-driver-id=swift"``

.. _Branding Your Installation:

Branding Your Installation
--------------------------

The name of your root dataverse is the brand of your installation of Dataverse and appears in various places such as notifications. Notifications and support links also contain the name of your support team, which will either be "[YourBrand] Support" or a name of your choosing when you configure a name for the ``:SystemEmail`` database setting described below.

Dataverse provides configurable options for easy-to-add (and maintain) custom branding for your Dataverse installation. Downloadable sample HTML and CSS files are provided below which you can edit as you see fit. It's up to you to create a directory in which to store these files, such as ``/var/www/dataverse`` in the examples below.

You can add a custom welcome/homepage as well as other custom content, to further brand your installation and make it your own. Here are the custom branding and content options you can add:

- Custom welcome/homepage
- Logo image to navbar
- Header
- Footer
- CSS stylesheet

Custom Homepage
++++++++++++++++

Dataverse allows you to use a custom homepage or welcome page in place of the default root dataverse page. This allows for complete control over the look and feel of your installation's homepage.

Download this sample: :download:`custom-homepage.html </_static/installation/files/var/www/dataverse/branding/custom-homepage.html>` and place it at ``/var/www/dataverse/branding/custom-homepage.html``. Then run this curl command:

``curl -X PUT -d '/var/www/dataverse/branding/custom-homepage.html' http://localhost:8080/api/admin/settings/:HomePageCustomizationFile``

Note that the ``custom-homepage.html`` file provided has a "Browse Data" button that assumes that your root dataverse still has an alias of "root". While you were branding your root dataverse, you may have changed the alias to "harvard" or "librascholar" or whatever and you should adjust the ``custom-homepage.html`` file as needed.

For more background on what this curl command above is doing, see the "Database Settings" section below. If you decide you'd like to remove this setting, use the following curl command:

``curl -X DELETE http://localhost:8080/api/admin/settings/:HomePageCustomizationFile``

Custom Navbar Logo
+++++++++++++++++++

Dataverse allows you to replace the default Dataverse icon and name branding in the navbar with your own custom logo. Note that this logo is separate from the *root dataverse theme* logo.

Create a "navbar" folder in your Glassfish "logos" directory and place your custom logo there. By Glassfish default, it'll be located at ``/usr/local/glassfish4/glassfish/domains/domain1/docroot/logos/navbar/logo.png``. Then run this curl command:

``curl -X PUT -d '/logos/navbar/logo.png' http://localhost:8080/api/admin/settings/:LogoCustomizationFile``

Note that the logo is expected to be small enough to fit comfortably in the navbar, perhaps only 30 pixels high.

Custom Header
+++++++++++++

Download this sample: :download:`custom-header.html </_static/installation/files/var/www/dataverse/branding/custom-header.html>` and place it at ``/var/www/dataverse/branding/custom-header.html``. Then run this curl command:

``curl -X PUT -d '/var/www/dataverse/branding/custom-header.html' http://localhost:8080/api/admin/settings/:HeaderCustomizationFile``

Custom Footer
+++++++++++++

Download this sample: :download:`custom-footer.html </_static/installation/files/var/www/dataverse/branding/custom-footer.html>` and place it at ``/var/www/dataverse/branding/custom-footer.html``. Then run this curl command:

``curl -X PUT -d '/var/www/dataverse/branding/custom-footer.html' http://localhost:8080/api/admin/settings/:FooterCustomizationFile``

Custom CSS Stylesheet
+++++++++++++++++++++

Download this sample: :download:`custom-stylesheet.css </_static/installation/files/var/www/dataverse/branding/custom-stylesheet.css>` and place it at ``/var/www/dataverse/branding/custom-stylesheet.css``. Then run this curl command:

``curl -X PUT -d '/var/www/dataverse/branding/custom-stylesheet.css' http://localhost:8080/api/admin/settings/:StyleCustomizationFile``

Going Live: Launching Your Production Deployment
------------------------------------------------

Expand Down Expand Up @@ -392,10 +458,12 @@ This JVM setting is also part of **handles** configuration. The Handle.Net insta
Database Settings
-----------------

These settings are stored in the ``setting`` table but can be read and modified via the "admin" endpoint of the :doc:`/api/native-api` for easy scripting.
These settings are stored in the ``setting`` database table but can be read and modified via the "admin" endpoint of the :doc:`/api/native-api` for easy scripting.

The most commonly used configuration options are listed first.

The pattern you will observe in curl examples below is that an HTTP ``PUT`` is used to add or modify a setting. If you perform an HTTP ``GET`` (the default when using curl), the output will contain the value of the setting, if it has been set. You can also do a ``GET`` of all settings with ``curl http://localhost:8080/api/admin/settings`` which you may want to pretty-print by piping the output through a tool such as jq by appending ``| jq .``. If you want to remove a setting, use an HTTP ``DELETE`` such as ``curl -X DELETE http://localhost:8080/api/admin/settings/:GuidesBaseUrl`` .

:BlockedApiPolicy
+++++++++++++++++

Expand Down Expand Up @@ -439,6 +507,26 @@ This is the email address that "system" emails are sent from such as password re

Note that only the email address is required, which you can supply without the ``<`` and ``>`` signs, but if you include the text, it's the way to customize the name of your support team, which appears in the "from" address in emails as well as in help text in the UI.

:HomePageCustomizationFile
++++++++++++++++++++++++++

See :ref:`Branding Your Installation` above.

:HeaderCustomizationFile
++++++++++++++++++++++++

See :ref:`Branding Your Installation` above.

:FooterCustomizationFile
++++++++++++++++++++++++

See :ref:`Branding Your Installation` above.

:StyleCustomizationFile
+++++++++++++++++++++++

See :ref:`Branding Your Installation` above.

:FooterCopyright
++++++++++++++++

Expand Down
5 changes: 0 additions & 5 deletions src/main/java/Bundle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -90,11 +90,6 @@ 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=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; {0}
footer.widget.datastored=Data is stored at {0}.
footer.widget.login=Log in to
Expand Down
160 changes: 160 additions & 0 deletions src/main/java/edu/harvard/iq/dataverse/CustomizationFilesServlet.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
/*
* 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.customization.CustomizationConstants;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.nio.file.Path;
import java.nio.file.Paths;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import edu.harvard.iq.dataverse.settings.SettingsServiceBean;
import javax.ejb.EJB;

/**
*
* @author skraffmi
*/
@WebServlet(name = "CustomizationFilesServlet", urlPatterns = {"/CustomizationFilesServlet"})
public class CustomizationFilesServlet extends HttpServlet {

@EJB
SettingsServiceBean settingsService;


/**
* 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 {
response.setContentType("text/html;charset=UTF-8");

String customFileType = request.getParameter("customFileType");
String filePath = getFilePath(customFileType);

Path physicalPath = Paths.get(filePath);
try {
File fileIn = physicalPath.toFile();
if (fileIn != null) {
FileInputStream inputStream = new FileInputStream(fileIn);

BufferedReader in = new BufferedReader(new InputStreamReader(inputStream));
String line;

StringBuilder responseData = new StringBuilder();
try (PrintWriter out = response.getWriter()) {

while ((line = in.readLine()) != null) {
responseData.append(line);
out.println(line);
}
}

inputStream.close();


} else {
/*
If the file doesn't exist or it is unreadable we don't care
*/
}

} catch (Exception e) {
/*
If the file doesn't exist or it is unreadable we don't care
*/
}

}

private String getFilePath(String fileTypeParam){

String nonNullDefaultIfKeyNotFound = "";

if (fileTypeParam.equals(CustomizationConstants.fileTypeHomePage)) {

// Homepage
return settingsService.getValueForKey(SettingsServiceBean.Key.HomePageCustomizationFile, nonNullDefaultIfKeyNotFound);

} else if (fileTypeParam.equals(CustomizationConstants.fileTypeHeader)) {

// Header
return settingsService.getValueForKey(SettingsServiceBean.Key.HeaderCustomizationFile, nonNullDefaultIfKeyNotFound);

} else if (fileTypeParam.equals(CustomizationConstants.fileTypeFooter)) {

// Footer
return settingsService.getValueForKey(SettingsServiceBean.Key.FooterCustomizationFile, nonNullDefaultIfKeyNotFound);

} else if (fileTypeParam.equals(CustomizationConstants.fileTypeStyle)) {

// Style (css)
return settingsService.getValueForKey(SettingsServiceBean.Key.StyleCustomizationFile, nonNullDefaultIfKeyNotFound);

} else if (fileTypeParam.equals(CustomizationConstants.fileTypeLogo)) {

// Logo for installation - appears in header
return settingsService.getValueForKey(SettingsServiceBean.Key.LogoCustomizationFile, nonNullDefaultIfKeyNotFound);
}


return "";
}

// <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 "Short description";
}// </editor-fold>

}
Loading

0 comments on commit ec23367

Please sign in to comment.