feat(dpg): copy / share article as Markdown #52
Labels
No labels
area/architecture
area/build-ci
area/bytecode
area/code-quality
area/docs
area/extension
area/fingerprint
area/security
area/tests
Bug report
Feature request
review
sev/low
sev/medium
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
midas/midas-patches#52
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
feat: copy / share article as Markdown in DPG apps
Part of #16. Affects both DPG Edition (de Volkskrant, AD, Trouw, Het Parool) and Kubus (De Gelderlander, De Stentor, Tubantia, ED, BD, BN DeStem, PZC).
Feature description
Add an option/button to copy or share articles as formatted Markdown in DPG news apps.
The exported Markdown should capture the full article structure:
# Title)> *Intro*)## Heading)> Quote+ author))This enables readers to easily archive, take notes (in e.g. Obsidian, Logseq, Notion) or share cleanly formatted articles without ad clutter.
Technical findings & architecture
DPG Media operates two distinct Android news platforms across its titles (see
docs/apps/gelderlander.md#platform-guide-recognizing-dpg-edition-vs-kubus):1. DPG Edition Platform (de Volkskrant, AD, Trouw, Het Parool)
Researched on de Volkskrant (
be.persgroep.android.news.mobilevk) 7.52.0.nl.persgroep.edition.*), unobfuscated Kotlin classes with full metadata.nl.persgroep.edition.article.domain.model.Article:header:nl.persgroep.edition.article.domain.model.Header(BasicHeader,PlusHeader,ColumnHeader):title:HeaderTitle(text = ...)intro:HeaderIntro(text = ...)byline:HeaderByline(authorByline = ...)media:HeaderMedia.Image(image = ...)(header lead image)body:List<nl.persgroep.edition.article.domain.model.Block>:Block.ParagraphBlock(content: String): body text with HTML formatting (<b>,<i>,<a href="...">,<p>). Rendered viaHtmlTextKt.Block.SubHeaderBlock(content: String): section subheaders.Block.ImageBlock(image: Image):image.akamaiImage.url,image.caption,image.credits,image.alt.Block.QuoteBlock(content: String, author: String, organisation: String).Block.ListBlock,Block.QuestionBlock,Block.AnswerBlock.publication:Publication(publicationDate = ...)url: canonical web URL (String).nl.persgroep.edition.article.data.converters.ArticleDtoMapper.invoke(ArticleDto): Article.ArticleViewModel:getCurrentArticle(): Article?returns this domain model.ArticleBottomToolbar/ActionPillrenders action icons (ToolbarViewData.ToolbarAction.Share).ArticleToolbarDelegateImpl.onShareClicked(ToolbarState.ArticleToolbar)which emitsShareEvent.ViewData(shareTitle, shareMessage).MainActivity.handleIntentEvent(NavigationEvent.Intent.Share)->getIntentNavigator$app().share(this, shareViewData).ToolbarState.ArticleToolbarandShareEvent.ViewDatacurrently only contain the article title and URL; they do not carry the body blocks. The full article object lives inArticleDtoMapper/ArticleViewModel.2. Kubus Platform (De Gelderlander, De Stentor, Tubantia, ED, BD, etc.)
Researched on De Gelderlander (
com.mecom.gelderlander.nl) 9.21.1.com.p000kubusapp.*). R8 obfuscates app code intodefpackage, but keeps network Moshi models incom.kubus.module.network.model.*unobfuscated.com.kubus.module.network.model.ArticleDetailResponse:metadata:com.kubus.module.network.model.Metadata(title,author,url,publicationDate, etc.).components:List<com.kubus.module.network.model.ArticleComponent>:Paragraph(properties: Paragraph.Properties):properties.getContent()(HTML formatted string).Title(properties: Title.Properties).Intro(properties: Intro.Properties).SubHeader(properties: SubHeader.Properties).PictureComponent(properties: PictureComponent.Properties):properties.getUrl(),properties.getCaption(),properties.getSource().Quote(properties: Quote.Properties):properties.getContent(),properties.getAuthor().ListComponent,Question,Answer.r20.b()mapsArticleDetailResponsetoj20(componentsList: List<i30>, metadata: y30, presentation: t40).g20.a(ArticleComponent): i30andg20.b(List<ArticleComponent>): List<i30>.ArticlePagerFragment-> navigation flow emitsn50.c(j20)(ShareArticle).ArticlePagerFragment.V0(j20 articleDetail)-> callsha2.h(Context, j20).ha2.h(Context, j20)constructsIntent.ACTION_SENDwithtitle + "\n\n" + urland callscontext.startActivity(Intent.createChooser(...)).j20passed toha2.hhasj20.getMetadata()andj20.c()(presentation componentsList<i30>), whileArticleDetailResponsehas the original unobfuscated Moshi components.Markdown formatter design (
extensions/extension)Create a shared formatter in Java (e.g.
nl.midasvo.extension.markdown.ArticleMarkdownFormatter):<b>,<strong>->**...**<i>,<em>->*...*<a href="(url)">(text)</a>->[(text)]((url))<br>,<p>,</p>-> newlines&->&,"->",'->',<-><,>->>, ->).<span>,<div>, etc.).SubHeader:\n\n## {text}\n\nParagraph:\n\n{formattedText}\n\nQuote:\n\n> "{quote}"\n> — *{author}*\n\nImage:\n\n\n*{caption} (Beeld: {credits})*\n\nList: bullet points* {item}\nQ&A:### {question}\n\n{answer}\n\nUI / UX options to trigger the action
Consider the following three options:
Option A: Intercept the Share Action / Show Chooser (Recommended)
ClipboardManagerand displays a short Toast: "Artikel gekopieerd als Markdown".ACTION_SENDwith the full Markdown text inEXTRA_TEXT.ACTION_SENDwith just title + URL.Option B: Dedicated in-app button
ToolbarViewState.Content'sactionslist increateToolbarArticleContent, or add a button above/below the article.ShareButtonswere removed (at the bottom of the article body) with a styled "Kopieer als Markdown" button, or add a menu item in the top bar.Option C: Long-press on Share button
Proposed implementation steps
extensions/extension):ArticleMarkdownFormatter: unit-tested standalone conversion logic.MidasArticleStore: holds the latest active article data (or directly converts during hook).MidasShareHelper: handles clipboard copy (ClipboardManager) with Toast, and/or launches custom chooser.BooleanSetting COPY_ARTICLE_MARKDOWN = new BooleanSetting("copy_article_markdown", true)toMidasSettings.java.volkskrant):Articlewhen created inArticleDtoMapper.invoke(ArticleDto): Article(or inArticleRepositoryImpl.fetchArticle).ArticleToolbarDelegateImpl.onShareClickedorMainActivity.handleIntentEvent(NavigationEvent.Intent.Share): pass the cached article toMidasShareHelper.gelderlander):ArticleDetailResponseis mapped, or hookha2.h(Context, j20):ha2.h: inspectj20, extract content (or retrieve cached Moshi components), and delegate toMidasShareHelper.copy_article_markdown, category "Artikelen", default on).docs/apps/volkskrant.mdanddocs/apps/gelderlander.mdwith findings and hook points.Definition of done
.\gradlew.bat buildAndroidpasses..\scripts\patch-install.ps1 -NoInstallapplies on both apps.docs/apps/volkskrant.mdanddocs/apps/gelderlander.md.Opgeleverd in #54 (gemerged naar dev, gaat mee in de volgende stable release).