Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
N
Nos Hs2023
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
Språksamlingane
stadnamn
Nos Hs2023
Commits
1408c631
Commit
1408c631
authored
4 years ago
by
esikkala
Browse files
Options
Downloads
Patches
Plain Diff
Compress sitemap generator's output
parent
ffb08886
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/server/sitemap_generator/SitemapGenerator.js
+30
-14
30 additions, 14 deletions
src/server/sitemap_generator/SitemapGenerator.js
src/server/sparql/SparqlQueriesGeneral.js
+1
-1
1 addition, 1 deletion
src/server/sparql/SparqlQueriesGeneral.js
with
31 additions
and
15 deletions
src/server/sitemap_generator/SitemapGenerator.js
+
30
−
14
View file @
1408c631
import
{
backendSearchConfig
}
from
'
../sparql/sampo/BackendSearchConfig
'
import
{
createWriteStream
}
from
'
fs
'
import
{
resolve
}
from
'
path
'
//
import { createGzip } from 'zlib'
import
{
createGzip
}
from
'
zlib
'
// import { Readable } from 'stream'
import
{
has
}
from
'
lodash
'
import
{
...
...
@@ -11,7 +11,7 @@ import {
import
{
sitemapQuery
}
from
'
../sparql/SparqlQueriesGeneral
'
import
{
runSelectQuery
}
from
'
../sparql/SparqlApi
'
const
outputDir
=
'
./src/server/sitemap_generator/sitemap
'
const
outputDir
=
'
./src/server/sitemap_generator/sitemap
_output
'
const
baseURL
=
'
https://sampo-ui.demo.seco.cs.aalto.fi/en
'
const
sitemapURL
=
'
https://sampo-ui.demo.seco.cs.aalto.fi/sitemap
'
...
...
@@ -30,27 +30,35 @@ const getURLs = async resultClasses => {
// for it to write the sitemap urls to and the expected url where that sitemap will be hosted
getSitemapStream
:
index
=>
{
const
sitemapStream
=
new
SitemapStream
({
hostname
:
baseURL
})
const
fileName
=
`sitemap-
${
index
}
.xml`
const
fileName
=
`sitemap-
${
index
}
.xml
.gz
`
sitemapStream
//
.pipe(createGzip()) // compress the output
of the sitemap
.
pipe
(
createWriteStream
(
resolve
(
`
${
outputDir
}
/
${
fileName
}
`
)))
// write it to sitemap-NUMBER.xml
.
pipe
(
createGzip
())
// compress the output
.
pipe
(
createWriteStream
(
resolve
(
`
${
outputDir
}
/
${
fileName
}
`
)))
// write it to sitemap-NUMBER.xml
.gz
return
[
`
${
sitemapURL
}
/
${
fileName
}
`
,
sitemapStream
]
}
})
sitemapStream
//
.pipe(createGzip())
.
pipe
(
createWriteStream
(
resolve
(
`
${
outputDir
}
/sitemap-index.xml`
)))
.
pipe
(
createGzip
())
// compress the output
.
pipe
(
createWriteStream
(
resolve
(
`
${
outputDir
}
/sitemap-index.xml
.gz
`
)))
// write it to sitemap-index.xml.gz
// Process each resultClass
// Add portal's main level URLs to sitemap
sitemapStream
.
write
({
url
:
baseURL
})
sitemapStream
.
write
({
url
:
`
${
baseURL
}
/about`
})
sitemapStream
.
write
({
url
:
`
${
baseURL
}
/instructions`
})
sitemapStream
.
write
({
url
:
`
${
baseURL
}
/feedback`
})
// Then process each resultClass
for
(
const
resultClass
of
resultClasses
)
{
const
searchMode
=
resultClass
.
searchMode
?
resultClass
.
searchMode
:
'
faceted-search
'
// Add perspective URL to sitemap
sitemapStream
.
write
({
url
:
`
${
baseURL
}
/
${
resultClass
.
perspectiveID
}
/
${
searchMode
}
`
})
if
(
resultClass
.
hasSearchPerspective
)
{
// If there is a search perspective, add it's URL to sitemap
const
searchMode
=
resultClass
.
searchMode
?
resultClass
.
searchMode
:
'
faceted-search
'
sitemapStream
.
write
({
url
:
`
${
baseURL
}
/
${
resultClass
.
perspectiveID
}
/
${
searchMode
}
`
})
}
const
response
=
await
queryInstancePageURLs
(
resultClass
)
// Add instance page URLs to sitemap
response
.
data
.
forEach
(
item
=>
sitemapStream
.
write
(
item
))
...
...
@@ -76,13 +84,21 @@ const resultClasses = []
for
(
let
[
resultClass
,
config
]
of
Object
.
entries
(
backendSearchConfig
))
{
if
(
config
.
includeInSitemap
)
{
let
rdfType
let
hasSearchPerspective
if
(
!
has
(
config
,
'
facetClass
'
))
{
rdfType
=
config
.
rdfType
config
=
backendSearchConfig
[
config
.
perspectiveID
]
hasSearchPerspective
=
false
}
else
{
rdfType
=
config
.
facetClass
hasSearchPerspective
=
true
}
resultClasses
.
push
({
endpoint
:
config
.
endpoint
,
perspectiveID
:
resultClass
,
rdfType
:
config
.
facetClass
hasSearchPerspective
,
rdfType
})
}
}
...
...
This diff is collapsed.
Click to expand it.
src/server/sparql/SparqlQueriesGeneral.js
+
1
−
1
View file @
1408c631
...
...
@@ -133,5 +133,5 @@ export const sitemapQuery = `
?uri a ?resultClass .
BIND(CONCAT("/<PERSPECTIVE>/page/", REPLACE(STR(?uri), "^.*
\\\\
/(.+)", "$1")) AS ?url)
}
LIMIT 10
0
#
LIMIT 10
`
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment