Merge pull request 'New PubPubContent object.' (!2) from gt-crashes/2 into master

Reviewed-on: #2
This commit is contained in:
Offray Vladimir Luna Cárdenas 2023-05-22 01:39:33 +00:00
commit 4944923069
2 changed files with 49 additions and 1 deletions

View File

@ -82,10 +82,15 @@ PubPub >> exportMarkdeepFiles [
]
{ #category : #accessing }
PubPub >> extractContents [
PubPub >> extractAllContentsRaw [
^ 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 }
PubPub >> folder [
^ 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
]