Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Genesys PGR
Genesys Backend
Commits
9a0714d4
Commit
9a0714d4
authored
Nov 08, 2014
by
Matija Obreza
Browse files
Sitemap index, Localized sitemaps
<a title="" added for /wiews/{instCode}
parent
5cf6468d
Changes
5
Hide whitespace changes
Inline
Side-by-side
src/main/java/org/genesys2/server/servlet/controller/CountryController.java
View file @
9a0714d4
...
...
@@ -137,7 +137,6 @@ public class CountryController extends BaseController {
return
"redirect:/explore"
;
}
@RequestMapping
(
"/{country}/overview"
)
public
String
viewData
(
HttpServletRequest
request
,
@PathVariable
(
value
=
"country"
)
String
countryStr
)
throws
UnsupportedEncodingException
{
...
...
@@ -146,9 +145,10 @@ public class CountryController extends BaseController {
if
(
country
==
null
)
{
throw
new
ResourceNotFoundException
();
}
AppliedFilters
appliedFilters
=
new
AppliedFilters
();
appliedFilters
.
add
(
new
AppliedFilter
().
setFilterName
(
FilterConstants
.
ORGCTY_ISO3
).
addFilterValue
(
new
FilterHandler
.
LiteralValueFilter
(
country
.
getCode3
())));
AppliedFilters
appliedFilters
=
new
AppliedFilters
();
appliedFilters
.
add
(
new
AppliedFilter
().
setFilterName
(
FilterConstants
.
ORGCTY_ISO3
).
addFilterValue
(
new
FilterHandler
.
LiteralValueFilter
(
country
.
getCode3
())));
return
"forward:/explore/overview?filter="
+
URLEncoder
.
encode
(
appliedFilters
.
toString
(),
"UTF8"
);
}
...
...
src/main/java/org/genesys2/server/servlet/controller/SitemapXMLController.java
View file @
9a0714d4
...
...
@@ -16,9 +16,20 @@
package
org.genesys2.server.servlet.controller
;
import
java.util.List
;
import
javax.servlet.http.HttpServletResponse
;
import
org.genesys2.server.model.impl.Country
;
import
org.genesys2.server.model.impl.Crop
;
import
org.genesys2.server.model.impl.FaoInstitute
;
import
org.genesys2.server.service.CropService
;
import
org.genesys2.server.service.GeoService
;
import
org.genesys2.server.service.InstituteService
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.context.i18n.LocaleContextHolder
;
import
org.springframework.data.domain.PageRequest
;
import
org.springframework.stereotype.Controller
;
import
org.springframework.web.bind.annotation.RequestMapping
;
import
org.springframework.web.bind.annotation.RequestMethod
;
...
...
@@ -30,15 +41,23 @@ import org.springframework.web.bind.annotation.ResponseBody;
* @author Matija Obreza, matija.obreza@croptrust.org
*/
@Controller
@RequestMapping
(
"/sitemap.xml"
)
public
class
SitemapXMLController
{
@Value
(
"${base.url}"
)
private
String
baseUrl
;
@Autowired
private
GeoService
geoService
;
@Autowired
private
InstituteService
instituteService
;
@Autowired
private
CropService
cropService
;
private
static
class
SitemapPage
{
String
url
;
String
freq
=
"
daily
"
;
String
freq
=
"
always
"
;
Double
priority
;
public
SitemapPage
(
String
url
)
{
...
...
@@ -58,31 +77,111 @@ public class SitemapXMLController {
}
private
final
static
SitemapPage
[]
sitemaps
=
new
SitemapPage
[]
{
new
SitemapPage
(
"/sitemap-content.xml"
),
new
SitemapPage
(
"/sitemap-geo.xml"
),
new
SitemapPage
(
"/sitemap-wiews.xml"
),
new
SitemapPage
(
"/sitemap-crop.xml"
)
};
private
final
SitemapPage
[]
sitemapPages
=
new
SitemapPage
[]
{
new
SitemapPage
(
"/welcome"
,
1.0
),
new
SitemapPage
(
"/content/about"
,
"monthly"
,
0.2
),
new
SitemapPage
(
"/explore/overview"
,
1.0
),
new
SitemapPage
(
"/wiews/active"
,
1.0
),
new
SitemapPage
(
"/content/terms"
,
1.0
),
new
SitemapPage
(
"/explore"
,
1.0
),
new
SitemapPage
(
"/org/"
)
};
new
SitemapPage
(
"/explore/overview"
,
1.0
),
new
SitemapPage
(
"/wiews/active"
,
1.0
),
new
SitemapPage
(
"/content/terms"
,
1.0
),
new
SitemapPage
(
"/explore"
,
1.0
),
new
SitemapPage
(
"/org/"
)
};
@RequestMapping
(
value
=
"/sitemap.xml"
,
method
=
RequestMethod
.
GET
)
public
@ResponseBody
String
sitemapsXml
(
HttpServletResponse
response
)
{
response
.
setContentType
(
"text/xml"
);
final
StringBuffer
sb
=
new
StringBuffer
();
sb
.
append
(
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
);
sb
.
append
(
"<sitemapindex xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">"
);
for
(
final
SitemapPage
page
:
sitemaps
)
{
sb
.
append
(
" <sitemap>"
);
sb
.
append
(
" <loc>"
).
append
(
baseUrl
).
append
(
response
.
encodeURL
(
page
.
url
)).
append
(
"</loc>"
);
sb
.
append
(
" </sitemap>"
);
}
sb
.
append
(
"</sitemapindex>"
);
return
sb
.
toString
();
}
@RequestMapping
(
method
=
RequestMethod
.
GET
)
@RequestMapping
(
value
=
"/sitemap-content.xml"
,
method
=
RequestMethod
.
GET
)
public
@ResponseBody
String
sitemapXml
(
HttpServletResponse
response
)
{
String
sitemapContentXml
(
HttpServletResponse
response
)
{
return
writeSitemap
(
response
,
sitemapPages
);
}
@RequestMapping
(
value
=
"/sitemap-geo.xml"
,
method
=
RequestMethod
.
GET
)
public
@ResponseBody
String
sitemapGeoXml
(
HttpServletResponse
response
)
{
response
.
setContentType
(
"text/xml"
);
final
StringBuffer
sb
=
new
StringBuffer
();
sb
.
append
(
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
);
sb
.
append
(
"<urlset xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd\" xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">"
);
for
(
final
SitemapPage
page
:
sitemapPages
)
{
sb
.
append
(
" <url>"
);
sb
.
append
(
" <loc>"
).
append
(
baseUrl
).
append
(
page
.
url
).
append
(
"</loc>"
);
if
(
page
.
freq
!=
null
)
{
sb
.
append
(
" <changefreq>"
).
append
(
page
.
freq
).
append
(
"</changefreq>"
);
}
if
(
page
.
priority
!=
null
)
{
sb
.
append
(
" <priority>"
).
append
(
page
.
priority
).
append
(
"</priority>"
);
}
sb
.
append
(
" </url>"
);
List
<
Country
>
activeCountries
=
geoService
.
listActive
(
LocaleContextHolder
.
getLocale
());
for
(
Country
country
:
activeCountries
)
{
writePage
(
response
,
sb
,
new
SitemapPage
(
"/geo/"
+
country
.
getCode3
().
toUpperCase
()));
}
sb
.
append
(
"</urlset>"
);
return
sb
.
toString
();
}
@RequestMapping
(
value
=
"/sitemap-wiews.xml"
,
method
=
RequestMethod
.
GET
)
public
@ResponseBody
String
sitemapWiewsXml
(
HttpServletResponse
response
)
{
response
.
setContentType
(
"text/xml"
);
final
StringBuffer
sb
=
new
StringBuffer
();
sb
.
append
(
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
);
sb
.
append
(
"<urlset xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd\" xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">"
);
for
(
FaoInstitute
institute
:
instituteService
.
listActive
(
new
PageRequest
(
0
,
Integer
.
MAX_VALUE
)))
{
writePage
(
response
,
sb
,
new
SitemapPage
(
"/wiews/"
+
institute
.
getCode
().
toUpperCase
()));
}
sb
.
append
(
"</urlset>"
);
return
sb
.
toString
();
}
@RequestMapping
(
value
=
"/sitemap-crop.xml"
,
method
=
RequestMethod
.
GET
)
public
@ResponseBody
String
sitemapCropXml
(
HttpServletResponse
response
)
{
response
.
setContentType
(
"text/xml"
);
final
StringBuffer
sb
=
new
StringBuffer
();
sb
.
append
(
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
);
sb
.
append
(
"<urlset xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd\" xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">"
);
for
(
Crop
crop
:
cropService
.
listCrops
())
{
writePage
(
response
,
sb
,
new
SitemapPage
(
"/c/"
+
crop
.
getShortName
()
+
"/data"
));
}
sb
.
append
(
"</urlset>"
);
return
sb
.
toString
();
}
private
String
writeSitemap
(
HttpServletResponse
response
,
SitemapPage
[]
pages
)
{
response
.
setContentType
(
"text/xml"
);
final
StringBuffer
sb
=
new
StringBuffer
();
sb
.
append
(
"<?xml version=\"1.0\" encoding=\"UTF-8\"?>"
);
sb
.
append
(
"<urlset xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation=\"http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd\" xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\">"
);
for
(
final
SitemapPage
page
:
pages
)
{
writePage
(
response
,
sb
,
page
);
}
sb
.
append
(
"</urlset>"
);
return
sb
.
toString
();
}
private
void
writePage
(
HttpServletResponse
response
,
final
StringBuffer
sb
,
final
SitemapPage
page
)
{
sb
.
append
(
" <url>"
);
sb
.
append
(
" <loc>"
).
append
(
baseUrl
).
append
(
response
.
encodeURL
(
page
.
url
)).
append
(
"</loc>"
);
if
(
page
.
freq
!=
null
)
{
sb
.
append
(
" <changefreq>"
).
append
(
page
.
freq
).
append
(
"</changefreq>"
);
}
if
(
page
.
priority
!=
null
)
{
sb
.
append
(
" <priority>"
).
append
(
page
.
priority
).
append
(
"</priority>"
);
}
sb
.
append
(
" </url>"
);
}
}
src/main/resources/content/language.properties
View file @
9a0714d4
...
...
@@ -164,6 +164,11 @@ faoInstitute.uniqueAcceNumbs.false=The same accession number may be used in sepa
faoInstitute.requests.mailto
=
Email address for material requests:
faoInstitute.allow.requests
=
Allow material requests
faoInstitute.sgsv
=
Code SGSV
faoInstitute.data-title
=
Database of information on accessions maintained at {0}
faoInstitute.overview-title
=
Overview of information on accessions maintained at {0}
faoInstitute.datasets-title
=
Characterization and evaluation data provided by {0}
faoInstitute.meta-description
=
Overview of plant genetic resources maintained in collections at {0} ({1}) genebank
faoInstitute.link-species-data
=
View information on {2} accessions at {0} ({1})
view.accessions
=
Browse accessions
view.datasets
=
View datasets
...
...
src/main/webapp/WEB-INF/decorator/main.jsp
View file @
9a0714d4
...
...
@@ -13,7 +13,6 @@
<meta
charset=
"utf-8"
/>
<meta
http-equiv=
"X-UA-Compatible"
content=
"IE=edge"
/>
<meta
name=
"viewport"
content=
"width=device-width, initial-scale=1.0"
/>
<meta
name=
"description"
content=
"Genesys, global database on plant genetic resources, accession database, order seeds, request for genebank material"
/>
<meta
name=
"author"
content=
"Global Crop Diversity Trust"
/>
<!-- CSRF protection-->
...
...
@@ -50,6 +49,7 @@
<![endif]-->
<sitemesh:write
property=
"head"
/>
<meta
name=
"description"
content=
"accession, genebank, Genesys, global database on plant genetic resources, accession database, order seeds, request for genebank material"
/>
</head>
<body>
...
...
src/main/webapp/WEB-INF/jsp/wiews/details.jsp
View file @
9a0714d4
...
...
@@ -4,12 +4,15 @@
<html>
<head>
<title><spring:message
code=
"faoInstitutes.page.profile.title"
arguments=
"
${
faoInstitute
.
fullName
}
"
argumentSeparator=
"|"
/></title>
<title><c:out
value=
"
${
faoInstitute
.
fullName
}
"
/><c:if
test=
"
${
faoInstitute
.
acronym
!=
''
}
"
>
| ${faoInstitute.acronym}
</c:if>
|
<c:out
value=
"
${
faoInstitute
.
code
}
"
/></title>
<meta
name=
"description"
content=
"
<spring:message
code=
"faoInstitute.meta-description"
arguments=
"
${
faoInstitute
.
fullName
}
|${faoInstitute.acronym}"
argumentSeparator=
"|"
/>
"
/>
<meta
name=
"keywords"
content=
"${faoInstitute.acronym}, ${faoInstitute.fullName}, ${faoInstitute.code}"
/>
</head>
<body
typeof=
"schema:Organization"
>
<h1>
<img
class=
"country-flag bigger"
src=
"
<c:url
value=
"
${
cdnFlagsUrl
}
"
/>
/${faoInstitute.country.code3.toUpperCase()}.png"
/>
<span
property=
"schema:Organization#name"
><c:out
value=
"
${
faoInstitute
.
fullName
}
"
/></span>
<c:if
test=
"
${
faoInstitute
.
acronym
!=
''
}
"
>
—
${faoInstitute.acronym}
</c:if>
<small><c:out
value=
"
${
faoInstitute
.
code
}
"
/></small>
</h1>
...
...
@@ -29,13 +32,13 @@
<div
class=
"jumbotron"
>
<spring:message
code=
"faoInstitutes.stat.accessionCount"
arguments=
"
${
countByInstitute
}
"
/>
<c:if
test=
"
${
countByInstitute
gt
0
}
"
>
<a
href=
"
<c:url
value=
"/wiews/${faoInstitute.code}/data"
/>
"
><spring:message
code=
"view.accessions"
/></a>
<a
href=
"
<c:url
value=
"/wiews/${faoInstitute.code}/overview"
/>
"
><spring:message
code=
"data-overview.short"
/></a>
<a
title=
"
<spring:message
code=
"faoInstitute.data-title"
arguments=
"
${
faoInstitute
.
fullName
}
"
/>
"
href=
"
<c:url
value=
"/wiews/${faoInstitute.code}/data"
/>
"
><spring:message
code=
"view.accessions"
/></a>
<a
title=
"
<spring:message
code=
"faoInstitute.overview-title"
arguments=
"
${
faoInstitute
.
fullName
}
"
/>
"
href=
"
<c:url
value=
"/wiews/${faoInstitute.code}/overview"
/>
"
><spring:message
code=
"data-overview.short"
/></a>
</c:if>
<br
/>
<spring:message
code=
"faoInstitutes.stat.datasetCount"
arguments=
"
${
datasetCount
}
"
/>
<c:if
test=
"
${
datasetCount
gt
0
}
"
>
<a
href=
"
<c:url
value=
"/wiews/${faoInstitute.code}/datasets"
/>
"
><spring:message
code=
"view.datasets"
/></a>
<a
title=
"
<spring:message
code=
"faoInstitute.datasets-title"
arguments=
"
${
faoInstitute
.
fullName
}
"
/>
"
href=
"
<c:url
value=
"/wiews/${faoInstitute.code}/datasets"
/>
"
><spring:message
code=
"view.datasets"
/></a>
</c:if>
</div>
...
...
@@ -136,7 +139,7 @@
<ul
class=
"funny-list statistics"
>
<c:forEach
items=
"
${
statisticsGenus
.
content
}
"
var=
"stat"
varStatus=
"status"
>
<li
class=
"clearfix ${status.count % 2 == 0 ? 'even' : 'odd'}"
><span
class=
"stats-number"
><fmt:formatNumber
value=
"
${
stat
[
1
]
}
"
/></span>
<a
href=
"
<c:url
value=
"/wiews/${faoInstitute.code
.toLowerCase()
}/t/${stat[0]}"
/>
"
><c:out
value=
"
${
stat
[
0
]
}
"
/></a></li>
<li
class=
"clearfix ${status.count % 2 == 0 ? 'even' : 'odd'}"
><span
class=
"stats-number"
><fmt:formatNumber
value=
"
${
stat
[
1
]
}
"
/></span>
<a
title=
"
<spring:message
code=
"faoInstitute.link-species-data"
arguments=
"
${
faoInstitute
.
fullName
}
|${faoInstitute.acronym}|${stat[0]}"
argumentSeparator=
"|"
/>
"
href=
"
<c:url
value=
"/wiews/${faoInstitute.code}/t/${stat[0]}"
/>
"
><c:out
value=
"
${
stat
[
0
]
}
"
/></a></li>
</c:forEach>
</ul>
</div>
...
...
@@ -150,7 +153,7 @@
<ul
class=
"funny-list statistics"
>
<c:forEach
items=
"
${
statisticsTaxonomy
.
content
}
"
var=
"stat"
varStatus=
"status"
>
<li
class=
"clearfix ${status.count % 2 == 0 ? 'even' : 'odd'}"
><span
class=
"stats-number"
><fmt:formatNumber
value=
"
${
stat
[
1
]
}
"
/></span>
<a
href=
"
<c:url
value=
"/wiews/${faoInstitute.code}/t/${stat[0].genus}/${stat[0].species}"
/>
"
><c:out
value=
"
${
stat
[
0
].
taxonName
}
"
/></a></li>
<li
class=
"clearfix ${status.count % 2 == 0 ? 'even' : 'odd'}"
><span
class=
"stats-number"
><fmt:formatNumber
value=
"
${
stat
[
1
]
}
"
/></span>
<a
title=
"
<spring:message
code=
"faoInstitute.link-species-data"
arguments=
"
${
faoInstitute
.
fullName
}
|${faoInstitute.acronym}|${stat[0].genus} ${stat[0].species}"
argumentSeparator=
"|"
/>
"
href=
"
<c:url
value=
"/wiews/${faoInstitute.code}/t/${stat[0].genus}/${stat[0].species}"
/>
"
><c:out
value=
"
${
stat
[
0
].
taxonName
}
"
/></a></li>
</c:forEach>
</ul>
</div>
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment