Skip to content

Commit

Permalink
Merge branch 'develop' into 6437-file-pg-preview-tab-ui
Browse files Browse the repository at this point in the history
  • Loading branch information
mheppler committed Dec 9, 2019
2 parents ccf4a4d + 4f1bfea commit 0dacda6
Show file tree
Hide file tree
Showing 11 changed files with 88 additions and 58 deletions.
34 changes: 24 additions & 10 deletions src/main/java/edu/harvard/iq/dataverse/util/BundleUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@
import java.util.ResourceBundle;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.Map;
import java.util.HashMap;
import javax.faces.context.FacesContext;

public class BundleUtil {
Expand All @@ -18,6 +20,8 @@ public class BundleUtil {

private static final String defaultBundleFile = "Bundle";

private static final Map<String, ClassLoader> classLoaderCache = new HashMap<String, ClassLoader>();

public static String getStringFromBundle(String key) {
return getStringFromBundle(key, null);
}
Expand Down Expand Up @@ -87,22 +91,32 @@ public static ResourceBundle getResourceBundle(String propertyFileName, Locale c
if (filesRootDirectory == null || filesRootDirectory.isEmpty()) {
bundle = ResourceBundle.getBundle("propertyFiles/" +propertyFileName, currentLocale);
} else {
File bundleFileDir = new File(filesRootDirectory);
URL[] urls = null;
try {
urls = new URL[]{bundleFileDir.toURI().toURL()};
} catch (Exception e) {
e.printStackTrace();
return null;
}

ClassLoader loader = new URLClassLoader(urls);
ClassLoader loader = getClassLoader(filesRootDirectory);
bundle = ResourceBundle.getBundle(propertyFileName, currentLocale, loader);
}

return bundle ;
}

private static ClassLoader getClassLoader(String filesRootDirectory) {
if (classLoaderCache.containsKey(filesRootDirectory)){
return classLoaderCache.get(filesRootDirectory);
}

File bundleFileDir = new File(filesRootDirectory);
URL[] urls = null;
try {
urls = new URL[]{bundleFileDir.toURI().toURL()};
} catch (Exception e) {
e.printStackTrace();
return null;
}

ClassLoader loader = new URLClassLoader(urls);
classLoaderCache.put(filesRootDirectory, loader);
return loader;
}

public static Locale getCurrentLocale() {
if (FacesContext.getCurrentInstance() == null) {
String localeEnvVar = System.getenv().get("LANG");
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/propertyFiles/Bundle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1231,7 +1231,7 @@ metrics.title=Metrics
metrics.title.tip=View more metrics information
metrics.dataset.title=Dataset Metrics
metrics.dataset.tip.default=Aggregated metrics for this dataset.
metrics.dataset.tip.makedatacount=Metrics collected using Make Data Count standards.
metrics.dataset.tip.makedatacount=Metrics collected using <a href="https://makedatacount.org/counter-code-of-practice-for-research-data/" target="_blank" rel="noopener"/>Make Data Count</a> standards.
metrics.dataset.views.tip=Dataset views are combined with both aggregated file views and file downloads.
metrics.dataset.downloads.default.tip=Total aggregated downloads of files in this dataset.
metrics.dataset.downloads.makedatacount.tip=Each file downloaded is counted as 1, and added to the total download count.
Expand Down
10 changes: 8 additions & 2 deletions src/main/webapp/dataset.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -383,8 +383,14 @@
<div id="metrics-block">
<div id="metrics-heading">
#{bundle['metrics.dataset.title']}
<span class="glyphicon glyphicon-question-sign tooltip-icon" data-toggle="tooltip" data-placement="auto top"
data-original-title="#{settingsWrapper.makeDataCountDisplayEnabled ? bundle['metrics.dataset.tip.makedatacount'] : bundle['metrics.dataset.tip.default']}"></span>
<ui:fragment rendered="#{!settingsWrapper.makeDataCountDisplayEnabled}">
<span class="glyphicon glyphicon-question-sign tooltip-icon" data-toggle="tooltip" data-placement="auto top"
data-trigger="hover" data-original-title="#{bundle['metrics.dataset.tip.default']}"></span>
</ui:fragment>
<ui:fragment rendered="#{settingsWrapper.makeDataCountDisplayEnabled}">
<a tabindex="0" role="button" class="glyphicon glyphicon-question-sign tooltip-icon" data-toggle="popover" data-placement="auto top"
data-trigger="focus" data-html="true" data-content="#{bundle['metrics.dataset.tip.makedatacount']}"></a>
</ui:fragment>
</div>
<div id="metrics-body">
<!-- Classic downloads -->
Expand Down
4 changes: 2 additions & 2 deletions src/main/webapp/dataverse.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -547,8 +547,8 @@
</div>
</div>
<!-- Featured Dataverses Carousel -->
<div id="carouselBlocksWrapper" jsf:rendered="#{!empty DataversePage.carouselFeaturedDataverses}">
<div id="featuredDataversesBlock">
<div id="carouselBlocksWrapper" class="row" jsf:rendered="#{!empty DataversePage.carouselFeaturedDataverses}">
<div id="featuredDataversesBlock" class="col-xs-12">
<div class="customNavigation">
<a class="btn prev1" title="#{bundle['dataverse.page.pre']}"><span class="glyphicon glyphicon-chevron-left"/></a>
</div>
Expand Down
Loading

0 comments on commit 0dacda6

Please sign in to comment.