Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
gargantext.org
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
2
Issues
2
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
gargantext
gargantext.org
Commits
ba0c67b5
Commit
ba0c67b5
authored
Aug 21, 2024
by
Fabien Maniere
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
translations config and integration - with site.hs!
parent
a9a41e35
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
47 additions
and
15 deletions
+47
-15
site.hs
gargantext-org-website/site.hs
+47
-15
No files found.
gargantext-org-website/site.hs
View file @
ba0c67b5
...
...
@@ -12,19 +12,18 @@ import Hakyll.Contrib.I18n
,
translationContext
)
import
Data.List
(
sortBy
)
import
Data.List.Split
(
splitOn
)
import
Data.Ord
(
comparing
)
import
Data.Text
(
pack
)
import
Data.Time.Clock
(
getCurrentTime
)
import
Data.Time.Format
(
formatTime
,
defaultTimeLocale
)
import
Network.URI
(
parseURI
,
uriAuthority
,
uriRegName
)
import
Debug.Trace
(
trace
)
--------------------------------------------------------------------------------
main
::
IO
()
main
=
hakyllWith
config
$
do
match
"*/translation.yml"
$
compile
translationCompiler
-- Static files
match
(
"js/*"
.||.
"images/*"
.||.
"favicon/*"
.||.
"css/fonts/*"
)
$
do
route
idRoute
...
...
@@ -34,7 +33,10 @@ main = hakyllWith config $ do
route
idRoute
compile
compressCssCompiler
-- Pages
-- Translations
match
"*/translation.yml"
$
compile
translationCompiler
-- match (fromList ["about.rst", "contact.markdown"]) $ do
-- route $ setExtension "html"
-- compile $ pandocCompiler
...
...
@@ -64,22 +66,32 @@ main = hakyllWith config $ do
-- >>= loadAndApplyTemplate "templates/default.html" archiveCtx
-- >>= relativizeUrls
match
"tiles/**"
$
do
-- Content
match
"*/tiles/**"
$
do
compile
pandocCompiler
match
"index.html"
$
do
-- Pages
match
"*/index.html"
$
do
route
idRoute
compile
$
do
defaultTranslation
<-
loadBody
"templates/translation.yml"
makeItem
$
Redirect
$
translate
defaultTranslation
"DEFAULT_LANGUAGE"
-- allTiles <- loadAll "*/tiles/**"
-- let tilesList = map (toFilePath . itemIdentifier) allTiles
-- trace ("Tiles items: " ++ show tilesList) $ return ()
discoverPresentation
<-
loadAll
"tiles/discover/presentation/*"
discoverVideos
<-
loadAll
"tiles/discover/videos/*"
lang
<-
extractLanguage
<$>
getUnderlying
-- trace ("Extracted language: " ++ lang) $ return ()
learnFormations
<-
loadAll
"tiles/learn/formations/*"
learnDocumentation
<-
loadAll
"tiles/learn/documentation/*"
learnTools
<-
loadAll
"tiles/learn/tools/*"
discoverPresentation
<-
loadAll
$
fromGlob
$
lang
++
"*/tiles/discover/presentation/*"
discoverVideos
<-
loadAll
$
fromGlob
$
lang
++
"/tiles/discover/videos/*"
learnFormations
<-
loadAll
$
fromGlob
$
lang
++
"/tiles/learn/formations/*"
learnDocumentation
<-
loadAll
$
fromGlob
$
lang
++
"/tiles/learn/documentation/*"
learnTools
<-
loadAll
$
fromGlob
$
lang
++
"/tiles/learn/tools/*"
servers
<-
loadAll
$
fromGlob
$
lang
++
"/tiles/connect/*"
let
discoverPresentationList
=
map
(
toFilePath
.
itemIdentifier
)
discoverPresentation
trace
(
"discoverPresentation items: "
++
show
discoverPresentationList
)
$
return
()
currentYear
<-
unsafeCompiler
getCurrentYear
let
indexCtx
=
...
...
@@ -89,7 +101,9 @@ main = hakyllWith config $ do
listField
"learnFormations"
postCtx
(
return
learnFormations
)
`
mappend
`
listField
"learnDocumentation"
postCtx
(
return
learnDocumentation
)
`
mappend
`
listField
"learnTools"
postCtx
(
return
learnTools
)
`
mappend
`
listField
"servers"
postCtx
(
return
servers
)
`
mappend
`
constField
"year"
currentYear
`
mappend
`
translationContext
`
mappend
`
defaultContext
getResourceBody
...
...
@@ -97,7 +111,15 @@ main = hakyllWith config $ do
>>=
loadAndApplyTemplate
"templates/default.html"
indexCtx
>>=
relativizeUrls
match
"templates/*"
$
compile
templateBodyCompiler
-- Redirections
create
[
"index.html"
]
$
do
route
idRoute
compile
$
do
defaultTranslation
<-
loadBody
"templates/translation.yml"
makeItem
$
Redirect
$
translate
defaultTranslation
"DEFAULT_LANGUAGE"
-- Templates
match
"templates/**"
$
compile
templateBodyCompiler
--------------------------------------------------------------------------------
...
...
@@ -105,6 +127,7 @@ postCtx :: Context String
postCtx
=
dateField
"date"
"%B %e, %Y"
`
mappend
`
domainUrlField
`
mappend
`
translationContext
`
mappend
`
defaultContext
domainUrlField
::
Context
String
...
...
@@ -120,6 +143,15 @@ getDomainUrl url = case parseURI url >>= uriAuthority of
getCurrentYear
::
IO
String
getCurrentYear
=
formatTime
defaultTimeLocale
"%Y"
<$>
getCurrentTime
extractLanguage
::
Identifier
->
String
extractLanguage
id
=
let
path
=
toFilePath
id
segments
=
splitOn
"/"
path
langSegment
=
head
$
filter
(
not
.
null
)
segments
in
langSegment
config
::
Configuration
config
=
defaultConfiguration
{
previewPort
=
7000
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a 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