Commit 24c02d84 authored by Emmanuel Raviart's avatar Emmanuel Raviart

Add OpenGraph description (for compatibility with Discourse).

parent 7b9bb5a3
......@@ -105,10 +105,9 @@ update msg ({ fields } as model) authentication language =
cmd =
Ports.setDocumentMetatags
{ title =
"Edit Collection"
-- TODO i18n
{ description = I18n.translate language I18n.CollectionEditDescription
, imageUrl = Constants.logoUrl
, title = I18n.translate language I18n.CollectionEditTitle
}
in
( newModel, cmd )
......
......@@ -92,8 +92,9 @@ update msg model language =
cmds =
[ Ports.setDocumentMetatags
{ title = I18n.translate language I18n.ActivationTitle
{ description = I18n.translate language I18n.ActivationDescription
, imageUrl = Constants.logoUrl
, title = I18n.translate language I18n.ActivationTitle
}
, Ports.storeAuthentication (Ports.userToUserForPort (Just user))
, ForParent (Activate user)
......
......@@ -4,7 +4,7 @@ import Authenticator.Model
import Card.Types exposing (..)
import Dict exposing (Dict)
import Http
import I18n exposing (getImageUrlOrOgpLogo, getName)
import I18n exposing (getImageUrlOrOgpLogo, getName, getOneString)
import Ports
import Requests
import Task
......@@ -71,8 +71,11 @@ update msg ({ editedProperty } as model) authentication language =
cmd =
Ports.setDocumentMetatags
{ title = getName language card body.data.values
{ description =
getOneString language descriptionKeys card body.data.values
|> Maybe.withDefault (I18n.translate language I18n.MissingDescription)
, imageUrl = getImageUrlOrOgpLogo language body.data.id body.data.cards body.data.values
, title = getName language card body.data.values
}
in
( newModel, cmd )
......
......@@ -2,6 +2,7 @@ module Collection.State exposing (..)
import Authenticator.Model
import Constants
import Dict exposing (Dict)
import Http
import I18n exposing (getImageUrlOrOgpLogo, getName)
import Ports
......@@ -35,12 +36,19 @@ update msg model authentication language =
newModel =
{ model | collection = Data (Loaded body) }
collection =
case Dict.get body.data.id body.data.collections of
Nothing ->
Debug.crash ("Collection not found id=" ++ body.data.id)
Just collection ->
collection
cmd =
Ports.setDocumentMetatags
{ title =
"Collection"
-- TODO i18n
, imageUrl = Constants.logoUrl
{ description = collection.description
, imageUrl = collection.logo |> Maybe.withDefault Constants.logoUrl
, title = collection.name
}
in
( newModel, cmd )
......
......@@ -37,10 +37,9 @@ update msg model authentication language =
cmd =
Ports.setDocumentMetatags
{ title =
"Collections"
-- TODO i18n
{ description = I18n.translate language I18n.CollectionsDescription
, imageUrl = Constants.logoUrl
, title = I18n.translate language I18n.CollectionsTitle
}
in
( newModel, cmd )
......
This diff is collapsed.
......@@ -433,7 +433,7 @@ urlUpdate location model =
case parseLocation location of
Just ((I18nRouteWithLanguage language localizedRoute) as route) ->
let
indexRoute translationId =
indexRoute titleSymbol descriptionSymbol =
let
getLocalizedString value =
case value.value of
......@@ -487,8 +487,9 @@ urlUpdate location model =
newModel
! [ Cmd.map translateSearchMsg searchCmd
, Ports.setDocumentMetatags
{ title = I18n.translate language translationId
{ description = I18n.translate language descriptionSymbol
, imageUrl = Constants.logoUrl
, title = I18n.translate language titleSymbol
}
]
......@@ -497,8 +498,9 @@ urlUpdate location model =
AboutRoute ->
( model
, Ports.setDocumentMetatags
{ title = I18n.translate language I18n.About
{ description = I18n.translate language I18n.AboutDescription
, imageUrl = Constants.logoUrl
, title = I18n.translate language I18n.About
}
)
......@@ -572,19 +574,21 @@ urlUpdate location model =
FaqRoute ->
( model
, Ports.setDocumentMetatags
{ title = I18n.translate language I18n.Faq
{ description = I18n.translate language I18n.FaqDescription
, imageUrl = Constants.logoUrl
, title = I18n.translate language I18n.Faq
}
)
HomeRoute ->
indexRoute I18n.Home
indexRoute I18n.HomeTitle I18n.HomeDescription
NotFoundRoute _ ->
( model
, Ports.setDocumentMetatags
{ title = I18n.translate language I18n.PageNotFound
{ description = I18n.translate language I18n.PageNotFoundDescription
, imageUrl = Constants.logoUrl
, title = I18n.translate language I18n.PageNotFound
}
)
......@@ -605,7 +609,7 @@ urlUpdate location model =
( model, Cmd.map translateCardMsg childCmd )
OrganizationsIndexRoute ->
indexRoute (I18n.Organization I18n.Plural)
indexRoute (I18n.Organization I18n.Plural) I18n.OrganizationsDescription
NewOrganizationRoute ->
let
......@@ -622,8 +626,10 @@ urlUpdate location model =
cmd =
Ports.setDocumentMetatags
{ title = I18n.translate language I18n.AddNewOrganization
{ description =
I18n.translate language I18n.AddNewOrganizationDescription
, imageUrl = Constants.logoUrl
, title = I18n.translate language I18n.AddNewOrganization
}
in
( newModel, cmd )
......@@ -645,7 +651,7 @@ urlUpdate location model =
( model, Cmd.map translateCardMsg childCmd )
ToolsIndexRoute ->
indexRoute (I18n.Tool I18n.Plural)
indexRoute (I18n.Tool I18n.Plural) I18n.ToolsDescription
NewToolRoute ->
let
......@@ -662,8 +668,10 @@ urlUpdate location model =
cmd =
Ports.setDocumentMetatags
{ title = I18n.translate language I18n.AddNewTool
{ description =
I18n.translate language I18n.AddNewToolDescription
, imageUrl = Constants.logoUrl
, title = I18n.translate language I18n.AddNewTool
}
in
( newModel, cmd )
......@@ -685,7 +693,7 @@ urlUpdate location model =
( model, Cmd.map translateCardMsg childCmd )
UseCasesIndexRoute ->
indexRoute (I18n.UseCase I18n.Plural)
indexRoute (I18n.UseCase I18n.Plural) I18n.UseCasesDescription
NewUseCaseRoute ->
let
......@@ -702,7 +710,9 @@ urlUpdate location model =
cmd =
Ports.setDocumentMetatags
{ title = I18n.translate language I18n.AddNewUseCase
{ description =
I18n.translate language I18n.AddNewUseCaseDescription
, title = I18n.translate language I18n.AddNewUseCase
, imageUrl = Constants.logoUrl
}
in
......
......@@ -87,8 +87,9 @@ type alias DataIdsBody =
type alias DocumentMetatags =
{ title : String
{ description : String
, imageUrl : String
, title : String
}
......
......@@ -37,8 +37,9 @@ update msg model authentication language =
cmd =
Ports.setDocumentMetatags
{ title = authentication.name
{ description = I18n.translate language I18n.UserProfileDescription
, imageUrl = Constants.logoUrl
, title = authentication.name
}
in
( newModel, cmd )
......
......@@ -11,6 +11,7 @@
<title>OGP Toolbox</title>
<meta property="og:description" content="Digital solutions to improve democracy">
<meta property="og:image" content="">
<meta property="og:site_name" content="OGP Toolbox">
<meta property="og:title" content="OGP Toolbox">
......
......@@ -10,6 +10,7 @@
<title>OGP Toolbox</title>
<meta property="og:description" content="Digital solutions to improve democracy">
<meta property="og:image" content="">
<meta property="og:site_name" content="OGP Toolbox">
<meta property="og:title" content="OGP Toolbox">
......
......@@ -41,6 +41,13 @@ var main = Elm.Main.embed(document.getElementById('main'), flags);
// Ports
main.ports.setDocumentMetatags.subscribe(function(metatags) {
if (metatags.hasOwnProperty('description')) {
var element = document.head.querySelector('meta[property="og:description"]');
if (element) {
element.setAttribute('content', metatags.description);
}
}
if (metatags.hasOwnProperty('imageUrl')) {
var element = document.head.querySelector('meta[property="og:image"]');
if (element) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment