From af4f84759c319c43e1880fc6dccc05f504a02bc1 Mon Sep 17 00:00:00 2001 From: tworrall Date: Thu, 2 May 2013 12:34:18 -0400 Subject: [PATCH] additional home page redesign changes --- .../loadedAtStartup/homePageDataGetters.n3 | 8 +- productMods/js/homePageMaps.js | 29 +++- productMods/js/homePageUtils.js | 116 +++++++------ .../freemarker/lib/lib-home-page.ftl | 159 ++++++++++++------ .../controller/ajax/GeoFocusMapLocations.java | 14 +- themes/wilma/templates/page-home.ftl | 61 ++----- 6 files changed, 221 insertions(+), 166 deletions(-) diff --git a/productMods/WEB-INF/ontologies/app/loadedAtStartup/homePageDataGetters.n3 b/productMods/WEB-INF/ontologies/app/loadedAtStartup/homePageDataGetters.n3 index dee142e5..30f4d155 100644 --- a/productMods/WEB-INF/ontologies/app/loadedAtStartup/homePageDataGetters.n3 +++ b/productMods/WEB-INF/ontologies/app/loadedAtStartup/homePageDataGetters.n3 @@ -8,13 +8,13 @@ @prefix vivoweb: . @prefix foaf: . -# research facility datagetter +# academic departments datagetter - display:hasDataGetter display:researchFacsDataGetter . + display:hasDataGetter display:academicDeptsDataGetter . -display:researchFacsDataGetter +display:academicDeptsDataGetter a ; - display:saveToVar "researchFacsDG" ; + display:saveToVar "academicDeptDG" ; display:query """ PREFIX rdfs: PREFIX rdf: diff --git a/productMods/js/homePageMaps.js b/productMods/js/homePageMaps.js index e6569743..1af75e4a 100644 --- a/productMods/js/homePageMaps.js +++ b/productMods/js/homePageMaps.js @@ -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(); + } } }); } diff --git a/productMods/js/homePageUtils.js b/productMods/js/homePageUtils.js index 26c1fd21..cdf2cd1a 100644 --- a/productMods/js/homePageUtils.js +++ b/productMods/js/homePageUtils.js @@ -3,71 +3,83 @@ $(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(); - + if ( $('section#home-geo-focus').length == 0 ) { $('section#home-stats').css("display","inline-block").css("margin-top","20px"); } function getFacultyMembers() { - - // 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 + 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 - // 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 = "

  • No faculty records found.
  • "; - $('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) { + + if ( results == null || results.individuals.length == 0 ) { + individualList = "

  • No faculty members found.
  • "; + $('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 = "placeholder image"; - $(this).prepend(imgHtml); - } - else { - $(this).children('img').load( function() { - adjustImageHeight($(this)); - }); - } - }); - var viewMore = "
    • "; + $(this).prepend(imgHtml); + } + else { + $(this).children('img').load( function() { + adjustImageHeight($(this)); + }); + } + }); + var viewMore = "
      • " + "View all ..."; - $('div#research-faculty-mbrs').append(viewMore); - } - }); + $('div#research-faculty-mbrs').append(viewMore); + } + }); + } + else { + individualList = "

      • No faculty members found.
      • "; + $('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 += "

      • No academic departments found.
      • "; + html = "

        • No academic departments found.
        "; } else if ( deptNbr > 6 ) { for ( var i=0;i<6;i++) { @@ -109,5 +121,5 @@ $(document).ready(function(){ } $('div#academic-depts').html(html); } - + }); diff --git a/productMods/templates/freemarker/lib/lib-home-page.ftl b/productMods/templates/freemarker/lib/lib-home-page.ftl index 6928fcc1..63853e69 100644 --- a/productMods/templates/freemarker/lib/lib-home-page.ftl +++ b/productMods/templates/freemarker/lib/lib-home-page.ftl @@ -12,6 +12,20 @@ +<#-- 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> +
        +

        Faculty

        +
         
        +
        + +
          +
        +
        +
        + + <#-- 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 /> - - <#-- Determine the active (selected) group --> - <#assign activeGroup = "" /> - <#if !classGroup??> - <#if group_index == 0> - <#assign activeGroup = selected /> +
        +

        Statistics

        + +
        <#-- Display the class group browse only if we have at least one populated class group --> <#if firstPopulatedClassGroup??> ${classGroupList} <#else> -

        There is currently no content in the system, or you need to create class groups and assign your classes to them.

        +

        There is currently no content in the system, or you need to create class groups and assign your classes to them.

        <#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)> -
      • ${class.individualCount!} ${class.name}s
      • +
        +

        Research

        +
          + <#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)> +
        • ${class.individualCount!} ${class.name}s
        • + + +
        • View all ...
        • -
        • View all ...
        • - - - <#if !foundClassGroup> -

        • No research records found.
        • - + <#if !foundClassGroup> +

        • No research content found.
        • + +
        +
        + + +<#-- Renders the html for the academic departments section on the home page. --> +<#-- Works in conjunction with the homePageUtils.js file --> +<#macro academicDeptsHtml> +
        +

        Departments

        +
        +
        +
        <#-- builds the "academic departments" box on the home page --> -<#macro academicDepartments> +<#macro listAcademicDepartments> + +<#-- 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> +
        +

        Geographic Focus

        + <#-- 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. --> + <#-- + + --> +
        +
        + Loading map information . . .    + + +
        +
        + <#-- +
        +
        + --> +
        + \ No newline at end of file diff --git a/src/edu/cornell/mannlib/vitro/webapp/controller/ajax/GeoFocusMapLocations.java b/src/edu/cornell/mannlib/vitro/webapp/controller/ajax/GeoFocusMapLocations.java index fe52f317..889ae168 100644 --- a/src/edu/cornell/mannlib/vitro/webapp/controller/ajax/GeoFocusMapLocations.java +++ b/src/edu/cornell/mannlib/vitro/webapp/controller/ajax/GeoFocusMapLocations.java @@ -62,20 +62,22 @@ 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\": \"\","; String previousLabel = ""; - + for (Map 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; diff --git a/themes/wilma/templates/page-home.ftl b/themes/wilma/templates/page-home.ftl index 1cf1aee7..7007da15 100644 --- a/themes/wilma/templates/page-home.ftl +++ b/themes/wilma/templates/page-home.ftl @@ -49,7 +49,9 @@ - filter search + + filter search +
        • All
        • @@ -63,60 +65,25 @@ <@widget name="login" /> -
          -

          Research

          -
            - <@lh.researchClasses /> + + <@lh.researchClasses /> -
          -
          + + <@lh.facultyMbrHtml /> -
          -

          Faculty

          -
           
          -
          - -
            -
          - -
          -
          - -
          -

          Departments

          -
          -
          + + <@lh.academicDeptsHtml /> <#if geoFocusMapsEnabled > -
          -

          Geographic Focus

          -
          - Global Research |  - US Research |  - <#-- NY Research --> -
          -
          -
          - Loading map information . . .    - - -
          -
          -
          -
          -
          + + <@lh.geographicFocusHtml /> -
          -

          Statistics

          + + <@lh.allClassGroups vClassGroups! /> -
            - <@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 /> \ No newline at end of file