Resync. detached copy.

This commit is contained in:
Offray Vladimir Luna Cárdenas 2021-08-05 08:54:45 -05:00
parent f317287ed6
commit cf7de346b0
2 changed files with 100 additions and 1 deletions

View File

@ -0,0 +1,34 @@
Class {
#name : #FedWikiItem,
#superclass : #Object,
#instVars : [
'text',
'id',
'type'
],
#category : #'TiddlyWiki-Model'
}
{ #category : #accessing }
FedWikiItem >> fromDictionary: aDictionary [
text := aDictionary at: 'text'.
id := aDictionary at: 'id'.
type := aDictionary at: 'type'.
]
{ #category : #accessing }
FedWikiItem >> printOn: aStream [
super printOn: aStream.
aStream
nextPutAll: '( ',self type, ' | ', self text, ' )'
]
{ #category : #accessing }
FedWikiItem >> text [
^ text
]
{ #category : #accessing }
FedWikiItem >> type [
^ type
]

View File

@ -2,26 +2,91 @@ Class {
#name : #FedWikiPage, #name : #FedWikiPage,
#superclass : #Object, #superclass : #Object,
#instVars : [ #instVars : [
'url' 'url',
'title',
'story',
'journal',
'importJournal'
], ],
#category : #'TiddlyWiki-Model' #category : #'TiddlyWiki-Model'
} }
{ #category : #accessing }
FedWikiPage >> dataDictionary [
| dataUrl |
self isView ifFalse: [
self inform: 'Please provide a view url for the FedWiki page.'.
^ self].
dataUrl := self scheme , '://', self host, '/', self titleSegmentUrl, '.json'.
^ STONJSON fromString: dataUrl asUrl retrieveContents
]
{ #category : #accessing }
FedWikiPage >> fromDataDictionary [
title := self dataDictionary at: 'title'.
story := self dataDictionary at: 'story'.
self importJournal ifTrue: [ journal := self dataDictionary at: 'journal'].
]
{ #category : #accessing } { #category : #accessing }
FedWikiPage >> host [ FedWikiPage >> host [
^ self url host ^ self url host
] ]
{ #category : #accessing }
FedWikiPage >> importJournal [
^ importJournal ifNil: [ importJournal := false ]
]
{ #category : #accessing }
FedWikiPage >> importJournal: aBoolean [
importJournal := aBoolean
]
{ #category : #accessing } { #category : #accessing }
FedWikiPage >> isView [ FedWikiPage >> isView [
^ self url firstPathSegment = 'view' ^ self url firstPathSegment = 'view'
] ]
{ #category : #accessing }
FedWikiPage >> jsonData [
| dataUrl |
self isView ifFalse: [
self inform: 'Please provide a view url for the FedWiki page.'.
^ self].
dataUrl := self scheme , '://', self host, self titleSegmentUrl, '.json'
]
{ #category : #accessing }
FedWikiPage >> printOn: aStream [
super printOn: aStream.
aStream
nextPutAll: '( ', self title, ' | ', self story size asString, ' items story )'
]
{ #category : #accessing } { #category : #accessing }
FedWikiPage >> scheme [ FedWikiPage >> scheme [
^ self url scheme ^ self url scheme
] ]
{ #category : #accessing }
FedWikiPage >> story [
^ story
]
{ #category : #accessing }
FedWikiPage >> title [
^ title.
]
{ #category : #accessing }
FedWikiPage >> titleSegmentUrl [
self isView ifFalse: [
self inform: 'Please provide a view url for the FedWiki page.'.
^ self].
^ self url segments last.
]
{ #category : #accessing } { #category : #accessing }
FedWikiPage >> url [ FedWikiPage >> url [
^ url ^ url