Skip to content

Commit

Permalink
ZFIN-9405: SEO: Handle error "Duplicate without user-selected canonic…
Browse files Browse the repository at this point in the history
…al" (ZFIN#1195)

* ZFIN-9405: Add canonical URLs for entities
* ZFIN-9405: Add title for fish phenotype pages
* ZFIN-9405: Remove user agent
* Move logic for resolving canonical URLs into the JSP function
  • Loading branch information
rtaylorzfin authored Nov 15, 2024
1 parent 66c6a6d commit dfd5230
Show file tree
Hide file tree
Showing 19 changed files with 194 additions and 240 deletions.
1 change: 1 addition & 0 deletions home/WEB-INF/tags/layout/page.tag
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@

<title>${title}</title>

${zfn:getCanonical()}
<link rel="stylesheet" href="${zfn:getAssetPath("style.css")}">

<!-- jquery is loaded via CDN here instead being part of the webpack bundle so that
Expand Down
12 changes: 12 additions & 0 deletions home/WEB-INF/tld/zfin-fn.tld
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,18 @@
<function-signature>java.lang.String getAssetPath(java.lang.String)</function-signature>
</function>

<function>
<name>getProperty</name>
<function-class>org.zfin.framework.presentation.ZfinJSPFunctions</function-class>
<function-signature>java.lang.String getProperty(java.lang.String)</function-signature>
</function>

<function>
<name>getCanonical</name>
<function-class>org.zfin.framework.presentation.ZfinJSPFunctions</function-class>
<function-signature>java.lang.String getCanonical()</function-signature>
</function>

<function>
<name>isFlagEnabled</name>
<function-class>org.zfin.framework.featureflag.FeatureFlags</function-class>
Expand Down
8 changes: 8 additions & 0 deletions home/robots.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,14 @@ Disallow: /cgi-bin/webdriver?MIval=aa-your_input_welcome.apg
Disallow: /action/phenotype/statement/
Disallow: /action/phenotype/statement-popup/

#More popups:
Disallow: /action/api/marker/ZDB-*/citations.tsv
Disallow: /action/api/marker/ZDB-*/citations.tsv
Disallow: /action/expression/experiment-popup/
Disallow: /action/fish/fish-detail-popup/
Disallow: /action/ontology/term-detail-popup/
Disallow: /action/marker/gene-product-description/ZDB-*

Disallow: /downloads/archive
Disallow: /downloads/archive/*

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,13 @@ public String results(Model model, @ModelAttribute("criteria") ExpressionSearchC
}

model.addAttribute("criteria", criteria);
model.addAttribute(LookupStrings.DYNAMIC_TITLE, "Expression Search Results");

if (criteria.getTitle() != null) {
model.addAttribute(LookupStrings.DYNAMIC_TITLE, criteria.getTitle());
} else {
model.addAttribute(LookupStrings.DYNAMIC_TITLE, "Expression Search Results");
}

return "expression/results";
}

Expand Down
218 changes: 6 additions & 212 deletions source/org/zfin/expression/presentation/ExpressionSearchCriteria.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
package org.zfin.expression.presentation;


import lombok.Getter;
import lombok.Setter;
import org.zfin.marker.Marker;

import java.util.Arrays;
import java.util.List;
import java.util.Map;

@Setter
@Getter
public class ExpressionSearchCriteria {

private String authorField;
Expand Down Expand Up @@ -40,223 +44,13 @@ public class ExpressionSearchCriteria {
private String linkWithImagesOnly;
private boolean hasMatchingText;

private String title;

public List<String> getAnatomy() {
if (anatomyTermNames == null || anatomyTermNames.equals("")) { return null; }
return Arrays.asList(anatomyTermNames.split("\\|"));
}

public String getAuthorField() {
return authorField;
}

public void setAuthorField(String authorField) {
this.authorField = authorField;
}

public JournalTypeOption getJournalType() {
return journalType;
}

public void setJournalType(JournalTypeOption journalType) {
this.journalType = journalType;
}

public boolean isOnlyReporter() {
return onlyReporter;
}

public void setOnlyReporter(boolean onlyReporter) {
this.onlyReporter = onlyReporter;
}

public String getGeneField() {
return geneField;
}

public void setGeneField(String geneField) {
this.geneField = geneField;
}

public void setGeneZdbID(String geneZdbID) {
this.geneZdbID = geneZdbID;
}

public String getGeneZdbID() {
return geneZdbID;
}

public void setGeneZdbId(String geneZdbID) {
this.geneZdbID = geneZdbID;
}

public Marker getGene() {
return gene;
}

public void setGene(Marker gene) {
this.gene = gene;
}

public String getTargetGeneField() {
return targetGeneField;
}

public void setTargetGeneField(String targetGeneField) {
this.targetGeneField = targetGeneField;
}

public boolean isOnlyFiguresWithImages() {
return onlyFiguresWithImages;
}

public void setOnlyFiguresWithImages(boolean onlyFiguresWithImages) {
this.onlyFiguresWithImages = onlyFiguresWithImages;
}

public boolean isOnlyWildtype() {
return onlyWildtype;
}

public void setOnlyWildtype(boolean onlyWildtype) {
this.onlyWildtype = onlyWildtype;
}

public Map<String, String> getStages() {
return stages;
}

public void setStages(Map<String, String> stages) {
this.stages = stages;
}

public String getStartStageId() {
return startStageId;
}

public void setStartStageId(String startStageId) {
this.startStageId = startStageId;
}

public String getEndStageId() {
return endStageId;
}

public void setEndStageId(String endStageId) {
this.endStageId = endStageId;
}

public String getAssayName() {
return assayName;
}

public void setAssayName(String assayName) {
this.assayName = assayName;
}

public String getFish() {
return fish;
}

public void setFish(String fish) {
this.fish = fish;
}

public String getAnatomyTermNames() {
return anatomyTermNames;
}

public void setAnatomyTermNames(String anatomyTermNames) {
this.anatomyTermNames = anatomyTermNames;
}

public String getAnatomyTermIDs() {
return anatomyTermIDs;
}

public void setAnatomyTermIDs(String anatomyTermIDs) {
this.anatomyTermIDs = anatomyTermIDs;
}

public boolean isIncludeSubstructures() {
return includeSubstructures;
}

public void setIncludeSubstructures(boolean includeSubstructures) {
this.includeSubstructures = includeSubstructures;
}

public List<GeneResult> getGeneResults() {
return geneResults;
}

public void setGeneResults(List<GeneResult> geneResults) {
this.geneResults = geneResults;
}

public List<FigureResult> getFigureResults() {
return figureResults;
}

public void setFigureResults(List<FigureResult> figureResults) {
this.figureResults = figureResults;
}

public List<ImageResult> getImageResults() {
return imageResults;
}

public void setImageResults(List<ImageResult> imageResults) {
this.imageResults = imageResults;
}

public long getNumFound() {
return numFound;
}

public void setNumFound(long numFound) {
this.numFound = numFound;
}

public long getPubCount() {
return pubCount;
}

public void setPubCount(long pubCount) {
this.pubCount = pubCount;
}

public Integer getRows() {
return rows;
}

public void setRows(Integer rows) {
this.rows = rows;
}

public Integer getPage() {
return page;
}

public void setPage(Integer page) {
this.page = page;
}

public String getLinkWithImagesOnly() {
return linkWithImagesOnly;
}

public void setLinkWithImagesOnly(String linkWithImagesOnly) {
this.linkWithImagesOnly = linkWithImagesOnly;
}

public boolean isHasMatchingText() {
return hasMatchingText;
}

public void setHasMatchingText(boolean hasMatchingText) {
this.hasMatchingText = hasMatchingText;
}

public enum JournalTypeOption {
DIRECT("Show only direct submission data"),
PUBLISHED("Show only published literature"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,7 @@ public static class LinkBuilder {
private ExpressionSearchCriteria.JournalTypeOption journalType = ExpressionSearchCriteria.JournalTypeOption.ALL;
private boolean onlyFiguresWithImages;
private boolean onlyReporter;
private String title;

public LinkBuilder gene(Marker gene) {
this.gene = gene;
Expand Down Expand Up @@ -645,6 +646,11 @@ public LinkBuilder author(String author) {
return this;
}

public LinkBuilder title(String title) {
this.title = title;
return this;
}

public String build() {
URLCreator url = new URLCreator("/action/expression/results");
addIfNotNull(url, "geneField", geneField);
Expand Down Expand Up @@ -674,6 +680,7 @@ public String build() {
addIfTrue(url, "onlyWildtype", wildtypeOnly);
addIfTrue(url, "onlyReporter", onlyReporter);
addIfTrue(url, "onlyFiguresWithImages", onlyFiguresWithImages);
addIfNotNull(url, "title", title);
return url.getURL();
}

Expand Down
6 changes: 0 additions & 6 deletions source/org/zfin/figure/presentation/FigureViewController.java
Original file line number Diff line number Diff line change
@@ -1,12 +1,10 @@
package org.zfin.figure.presentation;

import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.zfin.expression.Figure;
import org.zfin.expression.FigureService;
import org.zfin.figure.repository.FigureRepository;
Expand All @@ -15,14 +13,10 @@
import org.zfin.marker.Clone;
import org.zfin.marker.presentation.OrganizationLink;
import org.zfin.mutant.PhenotypeWarehouse;
import org.zfin.publication.Publication;
import org.zfin.publication.repository.PublicationRepository;
import org.zfin.repository.RepositoryFactory;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

import static org.zfin.repository.RepositoryFactory.getPhenotypeRepository;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ protected String showPhenotypeSummary(@RequestParam(value = "fishID", required =
model.addAttribute("phenotypeSummaryCriteria", summaryCriteria);
Fish fish = getMutantRepository().getFish(fishID);
model.addAttribute("fish", fish);
model.addAttribute(LookupStrings.DYNAMIC_TITLE, "Phenotype Summary");
model.addAttribute(LookupStrings.DYNAMIC_TITLE, "Phenotype Summary: " + fish.getName());
return "fish/fish-phenotype-figure-summary";
}
}
Loading

0 comments on commit dfd5230

Please sign in to comment.