additional home page redesign changes

This commit is contained in:
tworrall 2013-05-02 12:34:18 -04:00
parent 94e23fef67
commit af4f84759c
6 changed files with 221 additions and 166 deletions

View file

@ -8,13 +8,13 @@
@prefix vivoweb: <http://vivoweb.org/ontology#> .
@prefix foaf: <http://xmlns.com/foaf/0.1/> .
# research facility datagetter
# academic departments datagetter
<freemarker:researchFacilities.ftl> display:hasDataGetter display:researchFacsDataGetter .
<freemarker:lib-home-page.ftl> display:hasDataGetter display:academicDeptsDataGetter .
display:researchFacsDataGetter
display:academicDeptsDataGetter
a <java:edu.cornell.mannlib.vitro.webapp.utils.dataGetter.SparqlQueryDataGetter> ;
display:saveToVar "researchFacsDG" ;
display:saveToVar "academicDeptDG" ;
display:query """
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>

View file

@ -310,16 +310,27 @@ $(document).ready(function(){
action: "getGeoFocusLocations",
},
complete: function(xhr, status) {
var results = $.parseJSON(xhr.responseText);
$.each(results, function() {
var locale = this.properties.popupContent;
this.geometry.coordinates = getLatLong(locale);
this.properties.mapType = getMapType(locale);
researchAreas["features"].push(this);
});
buildGlobalMap();
$('div#timeIndicator').hide();
var results = $.parseJSON(xhr.responseText);
if ( results.length == 0 ) {
var html = "There are currently no researchers with a defined geographic focus.";
$('section#home-geo-focus div#timeIndicator span').html(html);
$('section#home-geo-focus').css("height","175px");
$('section#home-geo-focus div#timeIndicator').css("margin-top","50px");
$('section#home-geo-focus div#mapGlobal').hide();
$('section#home-geo-focus div#mapUS').hide();
$('section#home-geo-focus div#mapState').hide();
}
else {
$.each(results, function() {
var locale = this.properties.popupContent;
this.geometry.coordinates = getLatLong(locale);
this.properties.mapType = getMapType(locale);
researchAreas["features"].push(this);
});
buildGlobalMap();
$('div#timeIndicator').hide();
}
}
});
}

View file

@ -3,7 +3,11 @@
$(document).ready(function(){
$.extend(this, urlsBase);
// $.extend(this, facultyMemberCount);
$.extend(this, facultyMemberCount);
// this will ensure that the hidden classgroup input is cleared if the back button is used
// to return to th ehome page from the search results
$('input[name="classgroup"]').val("");
getFacultyMembers();
buildAcademicDepartments();
@ -13,61 +17,69 @@ $(document).ready(function(){
}
function getFacultyMembers() {
var individualList = "";
if ( facultyMemberCount > 0 ) {
// determine the row at which to start the solr query
var rowStart = Math.floor((Math.random()*facultyMemberCount)+1)-1;
var diff;
var pageSize = 4; // the number of faculty to display on the home page
// determine the row at which to start the solr query
var rowStart = Math.floor((Math.random()*facultyMemberCount)+1)-1;
var diff;
var pageSize = 4; // the number of faculty to display on the home page
// in case the random number is equal to or within 3 of the facultyMemberCount
if ( (rowStart + (pageSize-1)) > facultyMemberCount ) {
diff = (rowStart + (pageSize-1)) - facultyMemberCount;
if ( diff == 0 ) {
rowStart = rowStart - (pageSize-1);
// in case the random number is equal to or within 3 of the facultyMemberCount
if ( (rowStart + (pageSize-1)) > facultyMemberCount ) {
diff = (rowStart + (pageSize-1)) - facultyMemberCount;
if ( diff == 0 ) {
rowStart = rowStart - (pageSize-1);
}
else {
rowStart = rowStart - diff;
}
}
else {
rowStart = rowStart - diff;
}
}
var dataServiceUrl = urlsBase + "/dataservice?getRandomSolrIndividualsByVClass=1&vclassId=";
var url = dataServiceUrl + encodeURIComponent("http://vivoweb.org/ontology/core#FacultyMember");
url += "&page=" + rowStart + "&pageSize=" + pageSize;
var dataServiceUrl = urlsBase + "/dataservice?getRandomSolrIndividualsByVClass=1&vclassId=";
var url = dataServiceUrl + encodeURIComponent("http://vivoweb.org/ontology/core#FacultyMember");
url += "&page=" + rowStart + "&pageSize=" + pageSize;
$.getJSON(url, function(results) {
var individualList = "";
if ( results == null || results.individuals.length == 0 ) {
individualList = "<p><li>No faculty records found.</li></p>";
$('div#tempSpacing').hide();
$('div#research-faculty-mbrs ul#facultyThumbs').append(individualList);
}
else {
var vclassName = results.vclass.name;
$.each(results.individuals, function(i, item) {
var individual = results.individuals[i];
individualList += individual.shortViewHtml;
});
$('div#tempSpacing').hide();
$('div#research-faculty-mbrs ul#facultyThumbs').append(individualList);
$.getJSON(url, function(results) {
$.each($('div#research-faculty-mbrs ul#facultyThumbs li.individual'), function() {
if ( $(this).children('img').length == 0 ) {
var imgHtml = "<img width='60' alt='placeholder image' src='" + urlsBase + "/images/placeholders/person.bordered.thumbnail.jpg'>";
$(this).prepend(imgHtml);
}
else {
$(this).children('img').load( function() {
adjustImageHeight($(this));
});
}
});
var viewMore = "<ul id='viewMoreFac'><li><a href='"
if ( results == null || results.individuals.length == 0 ) {
individualList = "<p><li>No faculty members found.</li></p>";
$('div#tempSpacing').hide();
$('div#research-faculty-mbrs ul#facultyThumbs').append(individualList);
}
else {
var vclassName = results.vclass.name;
$.each(results.individuals, function(i, item) {
var individual = results.individuals[i];
individualList += individual.shortViewHtml;
});
$('div#tempSpacing').hide();
$('div#research-faculty-mbrs ul#facultyThumbs').append(individualList);
$.each($('div#research-faculty-mbrs ul#facultyThumbs li.individual'), function() {
if ( $(this).children('img').length == 0 ) {
var imgHtml = "<img width='60' alt='placeholder image' src='" + urlsBase + "/images/placeholders/person.bordered.thumbnail.jpg'>";
$(this).prepend(imgHtml);
}
else {
$(this).children('img').load( function() {
adjustImageHeight($(this));
});
}
});
var viewMore = "<ul id='viewMoreFac'><li><a href='"
+ urlsBase
+ "/people/%23http://vivoweb.org/ontology/core%23FacultyMember' alt='view all faculty'>"
+ "View all ...</a></li?</ul>";
$('div#research-faculty-mbrs').append(viewMore);
}
});
$('div#research-faculty-mbrs').append(viewMore);
}
});
}
else {
individualList = "<p><li>No faculty members found.</li></p>";
$('div#tempSpacing').hide();
$('div#research-faculty-mbrs ul#facultyThumbs').append(individualList);
$('div#research-faculty-mbrs ul#facultyThumbs').css("padding", "1.0em 0 0.825em 0.75em");
}
}
function adjustImageHeight(theImg) {
@ -87,7 +99,7 @@ $(document).ready(function(){
var index = Math.floor((Math.random()*deptNbr)+1)-1;
if ( deptNbr == 0 ) {
html += "<p><li>No academic departments found.</li></p>";
html = "<ul style='list-style:none'><p><li style='padding-top:0.3em'>No academic departments found.</li></p></ul>";
}
else if ( deptNbr > 6 ) {
for ( var i=0;i<6;i++) {

View file

@ -12,6 +12,20 @@
</#list>
</#macro>
<#-- Renders the html for the faculty member section on the home page. -->
<#-- Works in conjunction with the homePageUtils.js file, which contains the ajax call. -->
<#macro facultyMbrHtml>
<section id="home-faculty-mbrs" class="home-sections" >
<h4>Faculty</h4>
<div id="tempSpacing">&nbsp;</div>
<div id="research-faculty-mbrs">
<!-- populated via an ajax call -->
<ul id="facultyThumbs">
</ul>
</div>
</section>
</#macro>
<#-- We need the faculty count in order to randomly select 4 faculty using a solr query -->
<#macro facultyMemberCount classGroups>
<#assign foundClassGroup = false />
@ -39,49 +53,51 @@
<#-- Loop through classGroups first so we can account for situations when all class groups are empty -->
<#assign selected = 'class="selected" ' />
<#assign classGroupList>
<#list classGroups as group>
<#-- Only display populated class groups -->
<#if (group.individualCount > 0)>
<#-- Catch the first populated class group. Will be used later as the default selected class group -->
<#if !firstPopulatedClassGroup??>
<#assign firstPopulatedClassGroup = group />
</#if>
<#-- Determine the active (selected) group -->
<#assign activeGroup = "" />
<#if !classGroup??>
<#if group_index == 0>
<#assign activeGroup = selected />
<section id="home-stats" class="home-sections" >
<h4>Statistics</h4>
<ul id="stats">
<#assign groupCount = 1>
<#list classGroups as group>
<#if (groupCount > 6) >
<#break/>
</#if>
<#elseif classGroup.uri == group.uri>
<#assign activeGroup = selected />
</#if>
<#if group.displayName != "equipment" && group.displayName != "locations" && group.displayName != "courses" >
<li>
<a href="#">
<p class="stats-count">
<#if (group.individualCount > 10000) >
<#assign overTen = group.individualCount/1000>
${overTen?round}<span>k</span>
<#elseif (group.individualCount > 1000)>
<#assign underTen = group.individualCount/1000>
${underTen?string("0.#")}<span>k</span>
<#else>
${group.individualCount}<span>&nbsp;</span>
</#if>
</p>
<p class="stats-type">${group.displayName?capitalize}</p>
</a>
</li>
</#if>
</#if>
</#list>
<#-- Only display populated class groups -->
<#if (group.individualCount > 0)>
<#-- Catch the first populated class group. Will be used later as the default selected class group -->
<#if !firstPopulatedClassGroup??>
<#assign firstPopulatedClassGroup = group />
</#if>
<#if group.displayName != "equipment" && group.displayName != "courses" >
<li>
<a href="#">
<p class="stats-count">
<#if (group.individualCount > 10000) >
<#assign overTen = group.individualCount/1000>
${overTen?round}<span>k</span>
<#elseif (group.individualCount > 1000)>
<#assign underTen = group.individualCount/1000>
${underTen?string("0.#")}<span>k</span>
<#else>
${group.individualCount}<span>&nbsp;</span>
</#if>
</p>
<p class="stats-type">${group.displayName?capitalize}</p>
</a>
</li>
<#assign groupCount = groupCount + 1>
</#if>
</#if>
</#list>
</ul>
</section>
</#assign>
<#-- Display the class group browse only if we have at least one populated class group -->
<#if firstPopulatedClassGroup??>
${classGroupList}
<#else>
<h3>There is currently no content in the system, or you need to create class groups and assign your classes to them.</h3>
<h3 id="noContentMsg">There is currently no content in the system, or you need to create class groups and assign your classes to them.</h3>
<#if user.loggedIn>
<#if user.hasSiteAdminAccess>
@ -97,24 +113,39 @@
<#-- builds the "research" box on the home page -->
<#macro researchClasses classGroups=vClassGroups>
<#assign foundClassGroup = false />
<#list classGroups as group>
<#if (group.individualCount > 0) && group.displayName == "research" >
<#assign foundClassGroup = true />
<#list group.classes as class>
<#if (class.name == "Academic Article" || class.name == "Book" || class.name == "Conference Paper" ||class.name == "Media Contribution" || class.name == "Report" || class.name == "Library Collection") && (class.individualCount > 0)>
<li role="listitem"><span>${class.individualCount!}</span>&nbsp;<a href='${urls.base}/individuallist?vclassId=${class.uri?replace("#","%23")!}'>${class.name}s</a></li>
<section id="home-research" class="home-sections">
<h4>Research</h4>
<ul>
<#list classGroups as group>
<#if (group.individualCount > 0) && group.displayName == "research" >
<#assign foundClassGroup = true />
<#list group.classes as class>
<#if (class.name == "Academic Article" || class.name == "Book" || class.name == "Conference Paper" ||class.name == "Media Contribution" || class.name == "Report" || class.name == "Library Collection") && (class.individualCount > 0)>
<li role="listitem"><span>${class.individualCount!}</span>&nbsp;<a href='${urls.base}/individuallist?vclassId=${class.uri?replace("#","%23")!}'>${class.name}s</a></li>
</#if>
</#list>
<li><a href="${urls.base}/research" alt="view all research">View all ...</a></li>
</#if>
</#list>
<li><a href="${urls.base}/research" alt="view all research">View all ...</a></li>
</#if>
</#list>
<#if !foundClassGroup>
<p><li>No research records found.</li></p>
</#if>
<#if !foundClassGroup>
<p><li>No research content found.</li></p>
</#if>
</ul>
</section>
</#macro>
<#-- Renders the html for the academic departments section on the home page. -->
<#-- Works in conjunction with the homePageUtils.js file -->
<#macro academicDeptsHtml>
<section id="home-academic-depts" class="home-sections">
<h4>Departments</h4>
<div id="academic-depts">
</div>
</section>
</#macro>
<#-- builds the "academic departments" box on the home page -->
<#macro academicDepartments>
<#macro listAcademicDepartments>
<script>
var academicDepartments = [
<#if academicDeptDG?has_content>
@ -129,3 +160,33 @@ var academicDepartments = [
var urlsBase = "${urls.base}";
</script>
</#macro>
<#-- renders the "geographic focus" section on the home page. works in -->
<#-- conjunction with the homePageMaps.js and latLongJson.js files, as well -->
<#-- as the leaflet javascript library. -->
<#macro geographicFocusHtml>
<section id="home-geo-focus" class="home-sections">
<h4>Geographic Focus</h4>
<#-- map controls allow toggling between multiple map types: e.g., global, country, state/province. -->
<#-- VIVO default is for only a global display, though the javascript exists to support the other -->
<#-- types. See map documentation for additional information on how to implement additional types. -->
<#--
<div id="mapControls">
<a id="globalLink" class="selected" href="javascript:">Global Research</a>&nbsp;|&nbsp;
<a id="usLink" href="javascript:">US Research</a>&nbsp;|&nbsp;
<a id="stateLink" href="javascript:">State-wide Research</a>
</div>
-->
<div id="researcherTotal"></div>
<div id="timeIndicator">
<span>Loading map information . . .&nbsp;&nbsp;&nbsp;
<img src="${urls.images}/indicatorWhite.gif">
</span>
</div>
<div id="mapGlobal" class="mapArea"></div>
<#--
<div id="mapUS" class="mapArea"></div>
<div id="mapState" class="mapArea"></div>
-->
</section>
</#macro>

View file

@ -62,7 +62,6 @@ public class GeoFocusMapLocations extends AbstractAjaxResponder {
try {
geoLocations = getGeoLocations(vreq);
// String response = "{\"type\": \"FeatureCollection\",\"features\": [";
String response = "[";
String geometry = "{\"geometry\": {\"type\": \"Point\",\"coordinates\": \"\"},";
String typeProps = "\"type\": \"Feature\",\"properties\": {\"mapType\": \"\",";
@ -71,11 +70,14 @@ public class GeoFocusMapLocations extends AbstractAjaxResponder {
for (Map<String, String> map: geoLocations) {
String label = map.get("label");
String html = map.get("count");
String uri = UrlBuilder.urlEncode(map.get("location"));
String uri = map.get("location");
if ( uri != null ) {
uri = UrlBuilder.urlEncode(uri);
}
Integer count = Integer.parseInt(map.get("count"));
String radius = String.valueOf(calculateRadius(count));
if ( !label.equals(previousLabel) ) {
if ( label != null && !label.equals(previousLabel) ) {
String tempStr = geometry; //+label
tempStr += typeProps //+ label
+ "\"popupContent\": \""
@ -91,7 +93,9 @@ public class GeoFocusMapLocations extends AbstractAjaxResponder {
previousLabel = label;
}
}
response = response.substring(0, response.lastIndexOf(","));
if ( response.lastIndexOf(",") > 0 ) {
response = response.substring(0, response.lastIndexOf(","));
}
response += " ]";
log.debug(response);
return response;

View file

@ -49,7 +49,9 @@
<input type="hidden" name="classgroup" class="search-homepage" value="" autocapitalize="off" />
</div>
<a class="filter-search filter-default" href="#" title="Filter search"><span class="displace">filter search</span></a>
<a class="filter-search filter-default" href="#" title="Filter search">
<span class="displace">filter search</span>
</a>
<ul id="filter-search-nav">
<li><a class="active" href="">All</a></li>
@ -63,60 +65,25 @@
<@widget name="login" />
<section id="home-research" class="home-sections">
<h4>Research</h4>
<ul>
<@lh.researchClasses />
<!-- List of research classes: e.g., articles, books, collections, conference papers -->
<@lh.researchClasses />
</ul>
</section>
<!-- List of four randomly selected faculty members -->
<@lh.facultyMbrHtml />
<section id="home-faculty-mbrs" class="home-sections" >
<h4>Faculty</h4>
<div id="tempSpacing">&nbsp;</div>
<div id="research-faculty-mbrs">
<!-- populated via an ajax call -->
<ul id="facultyThumbs">
</ul>
</div>
</section>
<section id="home-academic-depts" class="home-sections">
<h4>Departments</h4>
<div id="academic-depts"></div>
</section>
<!-- List of randomly selected academic departments -->
<@lh.academicDeptsHtml />
<#if geoFocusMapsEnabled >
<section id="home-geo-focus" class="home-sections">
<h4>Geographic Focus</h4>
<div id="mapControls">
<a id="globalLink" class="selected" href="javascript:">Global Research</a>&nbsp;|&nbsp;
<a id="usLink" href="javascript:">US Research</a>&nbsp;|&nbsp;
<#-- <a id="stateLink" href="javascript:">NY Research</a> -->
</div>
<div id="researcherTotal"></div>
<div id="timeIndicator">
<span>Loading map information . . .&nbsp;&nbsp;&nbsp;
<img src="${urls.images}/indicatorWhite.gif">
</span>
</div>
<div id="mapGlobal" class="mapArea"></div>
<div id="mapUS" class="mapArea"></div>
<div id="mapState" class="mapArea"></div>
</section>
<!-- Map display of researchers' areas of geographic focus. Must be enabled in runtime.properties -->
<@lh.geographicFocusHtml />
</#if>
<section id="home-stats" class="home-sections" >
<h4>Statistics</h4>
<ul id="stats">
<@lh.allClassGroups vClassGroups! />
</ul>
</section>
<!-- Statistical information relating to property groups and their classes; displayed horizontally, not vertically-->
<@lh.allClassGroups vClassGroups! />
<#include "footer.ftl">
<#-- builds a json object that is used by js to render the academic departments section -->
<@lh.academicDepartments />
<@lh.listAcademicDepartments />
</body>
</html>