Merge pull request 'gt-crashes/2' (!3) from gt-crashes/2 into master

Reviewed-on: #3
This commit is contained in:
Offray Vladimir Luna Cárdenas 2023-05-22 01:59:35 +00:00
commit 356ee754bf
2 changed files with 45 additions and 1 deletions

View File

@ -91,6 +91,13 @@ PubPub >> extractRawTableOfContents [
^ self extractAllContentsRaw first xpath: '//div[contains(concat(" ",normalize-space(@class)," "), " pub-preview-component ")]'
]
{ #category : #accessing }
PubPub >> extractTableOfContents [
^ self extractRawTableOfContents collect: [:each |
PubPubContent fromXML: each
]
]
{ #category : #accessing }
PubPub >> folder [
^ folder ensureCreateDirectory

View File

@ -10,6 +10,11 @@ Class {
#category : #'MiniDocs-Model'
}
{ #category : #accessing }
PubPubContent class >> fromXML: anXMLElement [
^ self new fromXML: anXMLElement
]
{ #category : #accessing }
PubPubContent >> fromXML: aXMLElement [
| image anchor|
@ -24,7 +29,29 @@ image
anchor := (aXMLElement contentNodes second contentNodes first xpath: './div[@class="title-wrapper"]/a') first.
self
title: (anchor attributeAt: 'title');
url: (anchor attributeAt: 'title').
url: (anchor attributeAt: 'href').
]
{ #category : #accessing }
PubPubContent >> id [
^ (self url splitOn: $/) last
]
{ #category : #accessing }
PubPubContent >> printOn: aStream [
super printOn: aStream.
aStream
nextPutAll: '( ', self title,' | ', self id, ' )'
]
{ #category : #accessing }
PubPubContent >> shortName [
| sanitized |
sanitized := (self title splitOn: $:) first.
sanitized := sanitized copyReplaceAll: '' with: ''.
sanitized := sanitized asCamelCase.
sanitized at: 1 put: sanitized first asLowercase.
^ sanitized
]
{ #category : #accessing }
@ -32,11 +59,21 @@ PubPubContent >> thumbnail: anURL [
thumbnail := anURL
]
{ #category : #accessing }
PubPubContent >> title [
^ title
]
{ #category : #accessing }
PubPubContent >> title: anObject [
title := anObject
]
{ #category : #accessing }
PubPubContent >> url [
^url
]
{ #category : #accessing }
PubPubContent >> url: anObject [
url := anObject