Starting to add wiki JSON query capabilites.

This commit is contained in:
Offray Vladimir Luna Cárdenas 2017-06-06 10:27:57 +00:00
parent 5c86e98aae
commit 48968316c6

View File

@ -7,8 +7,8 @@ Class {
#name : #FossilRepo,
#superclass : #Object,
#instVars : [
'url',
'local'
'local',
'remote'
],
#category : #Fossil
}
@ -24,24 +24,17 @@ FossilRepo >> checkinsFor: relativeFilePath [
^ (((self jsonDataFor: relativeFilePath) at: 'payload') at: 'checkins')
]
{ #category : #querying }
FossilRepo >> jsonDataFor: aFileName [
| answer |
answer := NeoJSONReader fromString: (self jsonStringFor: aFileName).
(answer keys includes: 'resultText') ifTrue: [
(answer at: 'resultText') = 'File entry not found.'
ifTrue: [
self inform: 'WARNING! ', (answer at: 'resultText'),
' Verify the file path you are entering'.
^ self]
].
^ answer
{ #category : #wiki }
FossilRepo >> jsonDataFor: anUrlSegment [
^ ZnClient new
get: (self wikiRoot addPathSegment: anUrlSegment);
contents.
]
{ #category : #querying }
FossilRepo >> jsonStringFor: aFileName [
| queryForJSONData |
queryForJSONData := self url addPathSegments: #('json' 'finfo').
queryForJSONData := self remote addPathSegments: #('json' 'finfo').
queryForJSONData queryAt: 'name' put: aFileName.
^ (ZnEasy get: queryForJSONData) contents.
]
@ -63,12 +56,27 @@ FossilRepo >> local: aLocalFilePath [
local := aLocalFilePath
]
{ #category : #accessing }
FossilRepo >> url [
^ url
{ #category : #wiki }
FossilRepo >> pageList [
^ NeoJSONReader fromString: (self jsonDataFor: 'list')
]
{ #category : #accessing }
FossilRepo >> url: aString [
url := aString asUrl
FossilRepo >> remote [
^ remote
]
{ #category : #accessing }
FossilRepo >> remote: anUrlString [
remote := anUrlString asUrl
]
{ #category : #wiki }
FossilRepo >> wikiRoot [
^ self jsonRoot addPathSegment: 'wiki'
]
{ #category : #wiki }
FossilRepo >> wikiTimeline [
^ NeoJSONReader fromString: (self jsonDataFor: 'timeline')
]