Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove article-id from uu disclaimer #565

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Part of NDLA article-api
* Copyright (C) 2024 NDLA
*
* See LICENSE
*/

package no.ndla.articleapi.db.migration

import no.ndla.articleapi.db.HtmlMigration
import org.jsoup.nodes.Element

class V55__RemoveArticleIdFromUUDisclaimer extends HtmlMigration {
override val convertVisualElement: Boolean = true
override def convertHtml(doc: Element, language: String): Element = {
doc
.select("ndlaembed[data-resource='uu-disclaimer']")
.forEach(embed => {
val hasArticleId = embed.hasAttr("data-article-id")
if (hasArticleId) {
embed.removeAttr(
"data-article-id"
): Unit
}
})
doc
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Part of NDLA article-api
* Copyright (C) 2024 NDLA
*
* See LICENSE
*/

package no.ndla.articleapi.db.migration

import no.ndla.articleapi.{TestEnvironment, UnitSuite}

class V55__RemoveArticleIdFromUUDisclaimerTest extends UnitSuite with TestEnvironment {
test("That article-id is removed from uu-disclaimer") {
val migration = new V55__RemoveArticleIdFromUUDisclaimer
val oldArticle =
"""<section><ndlaembed data-resource="uu-disclaimer" data-disclaimer="Dette innholdet er ikke universelt utformet, og noen brukere kan derfor ha problemer med å oppfatte og forstå det." data-article-id="38293"><p>Hallo!</p></ndlaembed></section>"""
val newArticle =
"""<section><ndlaembed data-resource="uu-disclaimer" data-disclaimer="Dette innholdet er ikke universelt utformet, og noen brukere kan derfor ha problemer med å oppfatte og forstå det."><p>Hallo!</p></ndlaembed></section>"""

migration.convertContent(oldArticle, "nb") should be(newArticle)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Part of NDLA draft-api
* Copyright (C) 2024 NDLA
*
* See LICENSE
*/

package no.ndla.draftapi.db.migration

import no.ndla.draftapi.db.HtmlMigration
import org.jsoup.nodes.Element

class V66__RemoveArticleIdFromUUDisclaimer extends HtmlMigration {
override val convertVisualElement: Boolean = true
override def convertHtml(doc: Element, language: String): Element = {
doc
.select("ndlaembed[data-resource='uu-disclaimer']")
.forEach(embed => {
val hasArticleId = embed.hasAttr("data-article-id")
if (hasArticleId) {
embed.removeAttr(
"data-article-id"
): Unit
}
})
doc
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
/*
* Part of NDLA draft-api
* Copyright (C) 2024 NDLA
*
* See LICENSE
*/

package no.ndla.draftapi.db.migration

import no.ndla.draftapi.{TestEnvironment, UnitSuite}

class V66__RemoveArticleIdFromUUDisclaimerTest extends UnitSuite with TestEnvironment {
test("That article-id is removed from uu-disclaimer") {
val migration = new V66__RemoveArticleIdFromUUDisclaimer
val oldArticle =
"""<section><ndlaembed data-resource="uu-disclaimer" data-disclaimer="Dette innholdet er ikke universelt utformet, og noen brukere kan derfor ha problemer med å oppfatte og forstå det." data-article-id="38293"><p>Hallo!</p></ndlaembed></section>"""
val newArticle =
"""<section><ndlaembed data-resource="uu-disclaimer" data-disclaimer="Dette innholdet er ikke universelt utformet, og noen brukere kan derfor ha problemer med å oppfatte og forstå det."><p>Hallo!</p></ndlaembed></section>"""

migration.convertContent(oldArticle, "nb") should be(newArticle)
}
}
7 changes: 0 additions & 7 deletions validation/src/main/resources/embed-tag-rules.json
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,6 @@
"validation": {
"required": true
}
},
{
"name": "data-article-id",
"validation": {
"required": false,
"dataType": "NUMBER"
}
}
],
"children": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,7 @@ class EmbedTagValidatorTest extends UnitSuite {
val tag = generateTagWithAttrsAndChildren(
Map(
TagAttribute.DataResource -> ResourceType.UuDisclaimer.toString,
TagAttribute.DataDisclaimer -> "Dette er en disclaimer",
TagAttribute.DataArticleId -> "123"
TagAttribute.DataDisclaimer -> "Dette er en disclaimer"
),
generateTagWithAttrs(
Map(
Expand All @@ -270,8 +269,7 @@ class EmbedTagValidatorTest extends UnitSuite {
val tag = generateTagWithAttrsAndChildren(
Map(
TagAttribute.DataResource -> ResourceType.UuDisclaimer.toString,
TagAttribute.DataDisclaimer -> "Dette er en disclaimer",
TagAttribute.DataArticleId -> "123"
TagAttribute.DataDisclaimer -> "Dette er en disclaimer"
),
"""
|<p>Her er en disclaimer</p>
Expand Down
Loading