New PubPubContent object.

This commit is contained in:
Offray Vladimir Luna Cárdenas 2023-05-21 20:30:03 -05:00
parent 9a4a87a45e
commit 4b0227454b
2 changed files with 49 additions and 1 deletions

View File

@ -82,10 +82,15 @@ PubPub >> exportMarkdeepFiles [
] ]
{ #category : #accessing } { #category : #accessing }
PubPub >> extractContents [ PubPub >> extractAllContentsRaw [
^ self frontPage xpath: '//div[@class="layout-pubs-block"]' ^ self frontPage xpath: '//div[@class="layout-pubs-block"]'
] ]
{ #category : #accessing }
PubPub >> extractRawTableOfContents [
^ self extractAllContentsRaw first xpath: '//div[contains(concat(" ",normalize-space(@class)," "), " pub-preview-component ")]'
]
{ #category : #accessing } { #category : #accessing }
PubPub >> folder [ PubPub >> folder [
^ folder ensureCreateDirectory ^ folder ensureCreateDirectory

View File

@ -0,0 +1,43 @@
Class {
#name : #PubPubContent,
#superclass : #Object,
#instVars : [
'title',
'language',
'url',
'thumbnail'
],
#category : #'MiniDocs-Model'
}
{ #category : #accessing }
PubPubContent >> fromXML: aXMLElement [
| image anchor|
image := aXMLElement contentNodes first xpath: './a/div'.
image
ifNotEmpty: [|style rawUrl|
style := (image first attributeAt: 'style').
rawUrl := (style splitOn: 'url') second.
self
thumbnail:(rawUrl copyFrom: 3 to: rawUrl size - 2)
].
anchor := (aXMLElement contentNodes second contentNodes first xpath: './div[@class="title-wrapper"]/a') first.
self
title: (anchor attributeAt: 'title');
url: (anchor attributeAt: 'title').
]
{ #category : #accessing }
PubPubContent >> thumbnail: anURL [
thumbnail := anURL
]
{ #category : #accessing }
PubPubContent >> title: anObject [
title := anObject
]
{ #category : #accessing }
PubPubContent >> url: anObject [
url := anObject
]