islandora_scholar
islandora_scholar copied to clipboard
Google Scholar submodule modification for properly taking custom xpaths for authors
This is a pull request to make sure Google Scholar submodule will properly use the custom XPath settings in admin/islandora/solution_pack_config/scholar/xpaths for generating Google Scholar metatags, especially for authors. In admin/islandora/solution_pack_config/scholar/xpaths, there are ways to set custom XPath for author information, including XPath for First Name, Last Name and one other fields just labeled as Authors. Currently in the file islandora_google_scholar.module, in line 43, it would just use “mods:name” as XPath and completely ignored what is set in the custom xpath settings. Furthermore, in line 50-54, it requires mods:role/mods:roleTerm and the roleTerm must be “author”. If roleTerms does not exist in MODS or the role is not author, it will not generate any information for authors. Since Google Scholar tags requires author information, it will not generate any Google Scholar tags if MODS does not match the hard-coded format exactly. Here is our sample MODS that current module will not be able to generate google scholar tags:
<name displayLabel="Creator(s)" type="personal"> <namePart type="given">Brian</namePart> <namePart type="given">M*****</namePart> <namePart type="family">G****</namePart> <displayForm>Brian M***** G*****</displayForm> <role> <roleTerm>Creator(s)</roleTerm> </role> </name>
There are situations that “name” in MODS could be editors or advisors. However, since in the admin panel for custom xpath stated this is the xpaths for author, the custom xpaths should be accepted as author without roleTerm restriction. I also made accommodations in the code for middle name since it will have a namePart type given.
All the other required fields in the google scholar module works as intended and is taking custom xpath settings from the admin panel. I have tested my code in our islandora staging environment and it is generating google scholar meta tags in html header.
What's new?
- variable_get('islandora_scholar_xpaths_authors_xpath') to get custom authors xpath while keeping mods:name as default.
- Ignore roleTerm in MODS since the custom xpath settings specific says it is for authors.
- Take mods:displayForm as a backup source for name if namePart type does not match “family” nor “given”.
- It will accommodate more than one “given” name as middle name is marked as “given” in MODS.
How should this be tested?
- Find an object in Islandora that’s covered by Islandora Scholar module.
- In admin/islandora/solution_pack_config/scholar/xpaths, set custom xpaths for authors.
- Visit the object page and check HTML header to make sure meta name="citation_author" exists and is showing the correct information.