
# fileIn("s8/library/swiki/swiki.st")
smalltalk.addClass("SwikiCodeRobot",smalltalk.EventManager,["options","categories","loader","verbose","deferred","aborted","currentPages","chunkStream"],"swiki")
setattr(smalltalk.SwikiCodeRobot,"$classVariableNames","Fetch")

setattr(smalltalk.SwikiCodeRobot,"$comment","""
		A robot walking swiki pages.
		The default behavior will select pages in the swiki by category,
		 sort the pages and evaluate/process code chunks in the pages.
		It can be used for testing, API validation, etc.
		See pages in s8-media swiki for more information.
		Use cases:
			(SwikiCodeRobot @ #test) process: #s8-media tagged: #metatest
			(SwikiCodeRobot @ #api) process: #s8-media tagged: #( #apple #WebKit )
	""")

smalltalk.bind(smalltalk.SwikiCodeRobot,"initializeOptions",0
,smalltalk.__f__("""(self):
	#SwikiCodeRobot>>#initializeOptions
	smalltalk.basic_at_put(self,"@options",self.defaultOptions()) 
	return self 
""","SwikiCodeRobot_initializeOptions")
,"initialize","""initializeOptions
		" Private - Initialize the options of the receiver. "
	
		options := self defaultOptions""",nil)

smalltalk.bind(smalltalk.SwikiCodeRobot,"options",0
,smalltalk.__f__("""(self):
	#SwikiCodeRobot>>#options
	if smalltalk.b(smalltalk.isNil_(getattr(self,"@options",nil))):
		self.initializeOptions() 
	 
	return getattr(self,"@options",nil) 
""","SwikiCodeRobot_options")
,"accessing","""options
		" Return the options of the receiver. "
	
		options isNil ifTrue: [ self initializeOptions ].
		^options""",nil)

smalltalk.bind(smalltalk.SwikiCodeRobot,"options:",0
,smalltalk.__f__("""(self,anObject):
	#SwikiCodeRobot>>#options:
	smalltalk.basic_at_put(self,"@options",anObject) 
	return self 
""","SwikiCodeRobot_options_")
,"accessing","""options: anObject
		" Set the options of the receiver. "
	
		options := anObject""",nil)

smalltalk.bind(smalltalk.SwikiCodeRobot,"initializeCategories",0
,smalltalk.__f__("""(self):
	#SwikiCodeRobot>>#initializeCategories
	smalltalk.basic_at_put(self,"@categories",self.defaultCategories()) 
	return self 
""","SwikiCodeRobot_initializeCategories")
,"initialize","""initializeCategories
		" Private - Initialize the categories of the receiver. "
	
		categories := self defaultCategories""",nil)

smalltalk.bind(smalltalk.SwikiCodeRobot,"categories",0
,smalltalk.__f__("""(self):
	#SwikiCodeRobot>>#categories
	if smalltalk.b(smalltalk.isNil_(getattr(self,"@categories",nil))):
		self.initializeCategories() 
	 
	return getattr(self,"@categories",nil) 
""","SwikiCodeRobot_categories")
,"accessing","""categories
		" Return the categories of the receiver. "
	
		categories isNil ifTrue: [ self initializeCategories ].
		^categories""",nil)

smalltalk.bind(smalltalk.SwikiCodeRobot,"categories:",0
,smalltalk.__f__("""(self,anObject):
	#SwikiCodeRobot>>#categories:
	smalltalk.basic_at_put(self,"@categories",anObject) 
	return self 
""","SwikiCodeRobot_categories_")
,"accessing","""categories: anObject
		" Set the categories of the receiver. "
	
		categories := anObject""",nil)

smalltalk.bind(smalltalk.SwikiCodeRobot,"initializeVerbose",0
,smalltalk.__f__("""(self):
	#SwikiCodeRobot>>#initializeVerbose
	smalltalk.basic_at_put(self,"@verbose",smalltalk.true) 
	return self 
""","SwikiCodeRobot_initializeVerbose")
,"initialize","""initializeVerbose
		" Private - Initialize the verbose of the receiver. "
	
		verbose := true""",nil)

smalltalk.bind(smalltalk.SwikiCodeRobot,"verbose",0
,smalltalk.__f__("""(self):
	#SwikiCodeRobot>>#verbose
	if smalltalk.b(smalltalk.isNil_(getattr(self,"@verbose",nil))):
		self.initializeVerbose() 
	 
	return getattr(self,"@verbose",nil) 
""","SwikiCodeRobot_verbose")
,"accessing","""verbose
		" Return the verbose of the receiver. "
	
		verbose isNil ifTrue: [ self initializeVerbose ].
		^verbose""",nil)

smalltalk.bind(smalltalk.SwikiCodeRobot,"verbose:",0
,smalltalk.__f__("""(self,anObject):
	#SwikiCodeRobot>>#verbose:
	smalltalk.basic_at_put(self,"@verbose",anObject) 
	return self 
""","SwikiCodeRobot_verbose_")
,"accessing","""verbose: anObject
		" Set the verbose of the receiver. "
	
		verbose := anObject""",nil)

smalltalk.bind(smalltalk.SwikiCodeRobot,"initializeDeferred",0
,smalltalk.__f__("""(self):
	#SwikiCodeRobot>>#initializeDeferred
	smalltalk.basic_at_put(self,"@deferred",self.defaultDeferred()) 
	return self 
""","SwikiCodeRobot_initializeDeferred")
,"initialize","""initializeDeferred
		" Private - Initialize the deferred of the receiver. "
	
		deferred := self defaultDeferred""",nil)

smalltalk.bind(smalltalk.SwikiCodeRobot,"deferred",0
,smalltalk.__f__("""(self):
	#SwikiCodeRobot>>#deferred
	if smalltalk.b(smalltalk.isNil_(getattr(self,"@deferred",nil))):
		self.initializeDeferred() 
	 
	return getattr(self,"@deferred",nil) 
""","SwikiCodeRobot_deferred")
,"accessing","""deferred
		" Return the deferred of the receiver. "
	
		deferred isNil ifTrue: [ self initializeDeferred ].
		^deferred""",nil)

smalltalk.bind(smalltalk.SwikiCodeRobot,"deferred:",0
,smalltalk.__f__("""(self,anObject):
	#SwikiCodeRobot>>#deferred:
	smalltalk.basic_at_put(self,"@deferred",anObject) 
	return self 
""","SwikiCodeRobot_deferred_")
,"accessing","""deferred: anObject
		" Set the deferred of the receiver. "
	
		deferred := anObject""",nil)

smalltalk.bind(smalltalk.SwikiCodeRobot,"initializeAborted",0
,smalltalk.__f__("""(self):
	#SwikiCodeRobot>>#initializeAborted
	smalltalk.basic_at_put(self,"@aborted",smalltalk.false) 
	return self 
""","SwikiCodeRobot_initializeAborted")
,"initialize","""initializeAborted
		" Private - Initialize the aborted of the receiver. "
	
		aborted := false""",nil)

smalltalk.bind(smalltalk.SwikiCodeRobot,"aborted",0
,smalltalk.__f__("""(self):
	#SwikiCodeRobot>>#aborted
	if smalltalk.b(smalltalk.isNil_(getattr(self,"@aborted",nil))):
		self.initializeAborted() 
	 
	return getattr(self,"@aborted",nil) 
""","SwikiCodeRobot_aborted")
,"accessing","""aborted
		" Return the aborted of the receiver. "
	
		aborted isNil ifTrue: [ self initializeAborted ].
		^aborted""",nil)

smalltalk.bind(smalltalk.SwikiCodeRobot,"aborted:",0
,smalltalk.__f__("""(self,anObject):
	#SwikiCodeRobot>>#aborted:
	smalltalk.basic_at_put(self,"@aborted",anObject) 
	return self 
""","SwikiCodeRobot_aborted_")
,"accessing","""aborted: anObject
		" Set the aborted of the receiver. "
	
		aborted := anObject""",nil)

smalltalk.bind(smalltalk.SwikiCodeRobot.__class__,"fetch:",0
,smalltalk.__f__("""(self,aBlock):
	#SwikiCodeRobot class>>#fetch:
	smalltalk.SwikiCodeRobot.classVariableAt_put_("Fetch",aBlock) 
	return self 
""","SwikiCodeRobot_class_fetch_")
,"constants","""fetch: aBlock
	" Set the fetch block to get contents.
	aBlock will be a 2 arguments block:
		- the URL to access
		- the action to perform whith contents)
	Note that fetch block will set the robot to deferred mode.
	"

	Fetch := aBlock""",nil)

smalltalk.bind(smalltalk.SwikiCodeRobot.__class__,"fetch",0
,smalltalk.__f__("""(self):
	#SwikiCodeRobot class>>#fetch
	return smalltalk.SwikiCodeRobot.classVariableAt_("Fetch") 
""","SwikiCodeRobot_class_fetch")
,"constants","""fetch
	" Returns the fetch block (or nil). "

	^Fetch""",nil)

smalltalk.bind(smalltalk.SwikiCodeRobot.__class__,"@","_at"
,smalltalk.__f__("""(self,what):
	#SwikiCodeRobot class>>#@
	def __blk1__(_s8_rec):
		def __blk2__():
			def __blk3__():
				return what.asArrayOfSubstrings() 
			def __blk4__():
				return what.asArray() 
			return smalltalk.if_true_false_(what.isString(),smalltalk.blk(__blk3__,0),smalltalk.blk(__blk4__,0)) 
		_s8_rec.when_do_(smalltalk.String("needsCategories"),smalltalk.blk(__blk2__,0)) 
		return _s8_rec.yourself() 
	return __blk1__(self.new()) 
""","SwikiCodeRobot_class__at")
,"instantiation","""@ what
	" Return an instance of the receiver. "

	^self new
		when: #needsCategories do: [
			what isString
			ifTrue: [ what asArrayOfSubstrings ]
			ifFalse: [ what asArray ]
		];
		yourself""",nil)

smalltalk.bind(smalltalk.SwikiCodeRobot.__class__,"for:",0
,smalltalk.__f__("""(self,what):
	#SwikiCodeRobot class>>#for:
	return self._at(what) 
""","SwikiCodeRobot_class_for_")
,"instantiation","""for: what
	" Return an instance of the receiver. "

	^self @ what""",nil)

smalltalk.bind(smalltalk.SwikiCodeRobot.__class__,"process:",0
,smalltalk.__f__("""(self,where):
	#SwikiCodeRobot class>>#process:
	return self._at_gt(where) 
""","SwikiCodeRobot_class_process_")
,"process","""process: where
	" Process the contents at where. "

	^self @> where""",nil)

smalltalk.bind(smalltalk.SwikiCodeRobot.__class__,"@>","_at_gt"
,smalltalk.__f__("""(self,where):
	#SwikiCodeRobot class>>#@>
	return self.new()._at_gt(where) 
""","SwikiCodeRobot_class__at_gt")
,"process","""@> where
	" Process the contents at where.
	See instance side comment.
	"

	^self new @> where""",nil)

smalltalk.bind(smalltalk.SwikiCodeRobot,"@>","_at_gt"
,smalltalk.__f__("""(self,where):
	#SwikiCodeRobot>>#@>
	def __blk1__():
		return where.isString() 
	if smalltalk.b(smalltalk.boolean_or_(where.isNumber(),smalltalk.blk(__blk1__,0))):
		return self.processPageAt_(where) 
	 
	if not smalltalk.b(where.isArray()):
		return self.error_(smalltalk.String("Invalid argument.")) 
	 
	if smalltalk.b(smalltalk.isObject_equalTo_(where.size(),smalltalk.Number(1))):
		return self.processPageAt_(where.first()) 
	 
	if smalltalk.b(smalltalk.isObject_equalTo_(where.size(),smalltalk.Number(2))):
		return self._at_gt(smalltalk.object_comma_(smalltalk.Array.with_(self.defaultSwiki()),where)) 
	 
	return (self).__class__._at(where.second()).process_tagged_(where.first(),where.last()) 
""","SwikiCodeRobot__at_gt")
,"process","""@> where
	" Process the contents at where.
	where can be:
		aNumber or aString pointing to a page to process.
		anArray as
			#(swikiName category tag)
			#(category tag)
			#(page)
	"

	(where isNumber or: [ where isString ]) ifTrue: [
		^self processPageAt: where
	].
	where isArray ifFalse: [ ^self error: 'Invalid argument.' ].
	where size = 1 ifTrue: [ ^self processPageAt: where first ].
	where size = 2 ifTrue: [ ^self @> ((Array with: self defaultSwiki),where) ].
	^(self class @ where second) process: where first tagged: where last""",nil)

smalltalk.bind(smalltalk.SwikiCodeRobot.__class__,"constructEventsTriggered",0
,smalltalk.__f__("""(self):
	#SwikiCodeRobot class>>#constructEventsTriggered
	return smalltalk.object_comma_(smalltalk.newArray(["evaluate:","running:","testLine:","needsActionLine:","endLines","startTimes:","endTimes:","needsOptions","needsCategories","sortPages:","needsCommandsIn:","load:","needsFileContents:","startPages:","startPage:stream:","endPage:"]),smalltalk.superReceiver(smalltalk.SwikiCodeRobot.__class__,self).constructEventsTriggered()) 
""","SwikiCodeRobot_class_constructEventsTriggered")
,"events","""constructEventsTriggered
	" Private - Return the events managed by instances of the receiver. "

	^#(	#evaluate: #running:
		#testLine: #needsActionLine: #endLines
		#startTimes: #endTimes: 
		#needsOptions #needsCategories
		#sortPages: #needsCommandsIn:
		#load: #needsFileContents:
		#startPages: #startPage:stream: #endPage:
	) , super constructEventsTriggered""",nil)

smalltalk.bind(smalltalk.SwikiCodeRobot,"defaultSwikiOptions",0
,smalltalk.__f__("""(self):
	#SwikiCodeRobot>>#defaultSwikiOptions
	__0__=smalltalk.newContext()
	__0__.swikiHost=nil
	__0__.swikiPort=nil
	__0__.swikiPort=smalltalk.Number(80) 
	__0__.swikiHost=smalltalk.String("swiki.smalltalking.net") 
	if smalltalk.b(smalltalk.Smalltalk.includesKey_(smalltalk.String("U8Object"))):
		__1__=smalltalk.newContext()
		__1__.home=nil
		__1__.home=smalltalk.U8Object.swikiHostURL().fromLast_(smalltalk.String("://")).upTo_(smalltalk.String("/")) 
		if smalltalk.b(__1__.home.includes_(smalltalk.String(":"))):
			__0__.swikiPort=__1__.home.fromLast_(smalltalk.String(":")).asNumber() 
		 
		__0__.swikiHost=__1__.home.upTo_(smalltalk.String(":")) 
	 
	return smalltalk.object_comma_(smalltalk.String("host")._minus_gt(__0__.swikiHost),smalltalk.String("port")._minus_gt(__0__.swikiPort)) 
""","SwikiCodeRobot_defaultSwikiOptions")
,"defaults","""defaultSwikiOptions
	" Private - Return the literals used for swiki configuration. "

	| swikiHost swikiPort |
	swikiPort := 80.
	swikiHost := 'swiki.smalltalking.net'.
	(Smalltalk includesKey: #U8Object) ifTrue: [ | home |
		home := (U8Object swikiHostURL fromLast: '://') upTo: $/.
		(home includes: $:) ifTrue: [
			swikiPort := (home fromLast: $:) asNumber.
		].
		swikiHost := home upTo: $:
	].
	^(#host -> swikiHost) ,(#port -> swikiPort)""",nil)

smalltalk.bind(smalltalk.SwikiCodeRobot,"defaultOptions",0
,smalltalk.__f__("""(self):
	#SwikiCodeRobot>>#defaultOptions
	def __blk1__():
		return self.defaultSwikiOptions() 
	return self.triggerEvent_ifNotHandled_(smalltalk.String("needsOptions"),smalltalk.blk(__blk1__,0)) 
""","SwikiCodeRobot_defaultOptions")
,"defaults","""defaultOptions
	" Private - Return the literals used for default configuration. "

	^self triggerEvent: #needsOptions ifNotHandled: [
		self defaultSwikiOptions
	]""",nil)

smalltalk.bind(smalltalk.SwikiCodeRobot,"defaultSwiki",0
,smalltalk.__f__("""(self):
	#SwikiCodeRobot>>#defaultSwiki
	return smalltalk.String("s8-media") 
""","SwikiCodeRobot_defaultSwiki")
,"defaults","""defaultSwiki
	" Private - Return the default swiki name. "

	^#s8-media""",nil)

smalltalk.bind(smalltalk.SwikiCodeRobot,"defaultDeferred",0
,smalltalk.__f__("""(self):
	#SwikiCodeRobot>>#defaultDeferred
	def __blk1__():
		return self.hasNodeJS() 
	return smalltalk.boolean_or_(self.hasFetch(),smalltalk.blk(__blk1__,0)) 
""","SwikiCodeRobot_defaultDeferred")
,"defaults","""defaultDeferred
	" Private - Return true if the receiver run in deferred mode. "

	^self hasFetch or: [ self hasNodeJS ]""",nil)

smalltalk.bind(smalltalk.SwikiCodeRobot,"defaultCategories",0
,smalltalk.__f__("""(self):
	#SwikiCodeRobot>>#defaultCategories
	def __blk1__():
		return smalltalk.Array.new() 
	return self.triggerEvent_ifNotHandled_(smalltalk.String("needsCategories"),smalltalk.blk(__blk1__,0)) 
""","SwikiCodeRobot_defaultCategories")
,"defaults","""defaultCategories
	" Private - Return the literals used to filter pages of interest.
	The default answer is an empty array (all pages starting with [ are of interest).
	The subclasses can refine the result to select pages marked with a category before the [ (tag) field.
	"

	^self triggerEvent: #needsCategories ifNotHandled: [ Array new ]""",nil)

smalltalk.bind(smalltalk.SwikiCodeRobot,"hasFetch",0
,smalltalk.__f__("""(self):
	#SwikiCodeRobot>>#hasFetch
	return smalltalk.notNil_((self).__class__.fetch()) 
""","SwikiCodeRobot_hasFetch")
,"testing","""hasFetch
	" Private - Returns true if the execution environment provides a fetch function. "

	^self class fetch notNil""",nil)

smalltalk.bind(smalltalk.SwikiCodeRobot,"hasNodeJS",0
,smalltalk.__f__("""(self):
	_s8Ret_=smalltalk.newContext()
	try:
		#SwikiCodeRobot>>#hasNodeJS
		__0__=smalltalk.newContext()
		def __blk1__():
			return smalltalk.raise_result_(_s8Ret_,smalltalk.false) 
		__0__.sentinel=nil
		__0__.sentinel=smalltalk.Smalltalk.nativeObjectAt_ifAbsent_(smalltalk.String("process"),smalltalk.blk(__blk1__,0)) 
		if smalltalk.b(smalltalk.isNil_(smalltalk.basic_at_(__0__.sentinel,smalltalk.String("version")))):
			smalltalk.raise_result_(_s8Ret_,smalltalk.false) 
		 
		smalltalk.raise_result_(_s8Ret_,smalltalk.true) 
	except Exception as __ex:
		if smalltalk.exception_at(__ex,_s8Ret_):
			return smalltalk.exceptionResult_(__ex)
		raise __ex
	
""","SwikiCodeRobot_hasNodeJS")
,"testing","""hasNodeJS
	" Private - Returns true if the execution environment is running NodeJS. "

	| sentinel |
	sentinel := Smalltalk nativeObjectAt: #process ifAbsent: [ ^false ].
	(sentinel basicAt: #version) isNil ifTrue: [ ^false ].
	^true""",nil)

smalltalk.bind(smalltalk.SwikiCodeRobot,"http:do:ifAbsent:",0
,smalltalk.__f__("""(self,httpOptions,dataBlock,aBlock):
	#SwikiCodeRobot>>#http:do:ifAbsent:
	__0__=smalltalk.newContext()
	def __blk1__(response):
		__1__=smalltalk.newContext()
		def __blk2__(_s8_rec):
			def __blk3__(chunk):
				__1__.content=smalltalk.object_comma_(__1__.content,chunk)
				return __1__.content 
			smalltalk.nativeCall(_s8_rec,smalltalk.String("setEncoding"),smalltalk.String("utf8")) 
			return smalltalk.nativeCall(_s8_rec,smalltalk.String("on"),smalltalk.String("data"),smalltalk.blk(__blk3__,1)) 
		def __blk4__():
			return dataBlock.evaluateWith_(__1__.content) 
		__1__.content=nil
		__1__.content=smalltalk.String("") 
		__blk2__(response) 
		return smalltalk.nativeCall(response,smalltalk.String("on"),smalltalk.String("end"),smalltalk.blk(__blk4__,0)) 
	def __blk5__(ex):
		return self.error_(smalltalk.asObject_(ex.stack)) 
	__0__.request=nil
	__0__.http=nil
	if smalltalk.b(self.hasFetch()):
		return (self).__class__.fetch().value_value_(self.urlFromOptions_(httpOptions),dataBlock) 
	 
	if not smalltalk.b(self.hasNodeJS()):
		return aBlock.evaluate() 
	 
	__0__.http=smalltalk.nativeCall(require,nil,smalltalk.String("http")) 
	if smalltalk.b(smalltalk.isNil_(__0__.http)):
		return aBlock.evaluate() 
	 
	__0__.request=smalltalk.nativeCall(__0__.http,smalltalk.String("request"),httpOptions.json(),smalltalk.blk(__blk1__,1)) 
	smalltalk.nativeCall(__0__.request,smalltalk.String("on"),smalltalk.String("error"),smalltalk.blk(__blk5__,1)) 
	request.end() 
	return nil 
""","SwikiCodeRobot_http_do_ifAbsent_")
,"http","""http: httpOptions do: dataBlock ifAbsent: aBlock
	" Private - Evaluates the dataBlock with data obtained accessing server options. "

	| request http |
	self hasFetch ifTrue: [
		^self class fetch
			value: (self urlFromOptions: httpOptions)
			value: dataBlock
	].
	self hasNodeJS ifFalse: [ ^aBlock evaluate ].
	http := # #require: #http. 
	http isNil ifTrue: [ ^aBlock evaluate ].
	request := http #request: httpOptions json doing: [:response| | content |
		content := ''.
		response
			#setEncoding: #utf8;
			#on: #data do: [:chunk| content := content, chunk ].
		response #on: #end do: [ dataBlock evaluateWith: content ].
	].
	request #on: #error do: [:ex| self error: "ex#message ," ex#stack ].
	{'request.end()' lua'self:invalidMessage()'}.
	^nil""",nil)

smalltalk.bind(smalltalk.SwikiCodeRobot,"withHttp:do:",0
,smalltalk.__f__("""(self,httpOptions,dataBlock):
	#SwikiCodeRobot>>#withHttp:do:
	__0__=smalltalk.newContext()
	def __blk1__(response):
		__1__=smalltalk.newContext()
		def __blk2__(_s8_rec):
			def __blk3__(chunk):
				__1__.content=smalltalk.object_comma_(__1__.content,chunk)
				return __1__.content 
			smalltalk.nativeCall(_s8_rec,smalltalk.String("setEncoding"),smalltalk.String("utf8")) 
			return smalltalk.nativeCall(_s8_rec,smalltalk.String("on"),smalltalk.String("data"),smalltalk.blk(__blk3__,1)) 
		def __blk4__():
			return dataBlock.evaluateWith_(__1__.content) 
		__1__.content=nil
		__1__.content=smalltalk.String("") 
		__blk2__(response) 
		return smalltalk.nativeCall(response,smalltalk.String("on"),smalltalk.String("end"),smalltalk.blk(__blk4__,0)) 
	def __blk5__(ex):
		return self.error_(smalltalk.asObject_(ex.stack)) 
	__0__.request=nil
	__0__.http=nil
	if smalltalk.b(self.hasFetch()):
		return (self).__class__.fetch().value_value_(self.urlFromOptions_(httpOptions),dataBlock) 
	 
	if not smalltalk.b(self.hasNodeJS()):
		return self.error_(smalltalk.String("Accessing swiki using HTTP - Require Node.js execution environment.")) 
	 
	__0__.http=smalltalk.nativeCall(require,nil,smalltalk.String("http")) 
	__0__.request=smalltalk.nativeCall(__0__.http,smalltalk.String("request"),httpOptions.json(),smalltalk.blk(__blk1__,1)) 
	smalltalk.nativeCall(__0__.request,smalltalk.String("on"),smalltalk.String("error"),smalltalk.blk(__blk5__,1)) 
	request.end() 
	return nil 
""","SwikiCodeRobot_withHttp_do_")
,"http","""withHttp: httpOptions do: dataBlock
	" Private - Evaluates the dataBlock with data obtained accessing server options. "

	| request http |
	self hasFetch ifTrue: [
		^self class fetch
			value: (self urlFromOptions: httpOptions)
			value: dataBlock
	].
	self hasNodeJS ifFalse: [
		^self error: 'Accessing swiki using HTTP - Require Node.js execution environment.'
	].
	http := # #require: #http.
	request := http #request: httpOptions json doing: [:response| | content |		
		content := ''.
		response
			#setEncoding: #utf8;
			#on: #data do: [:chunk| content := content, chunk ].
		response #on: #end do: [ dataBlock evaluateWith: content ].
	].
	request #on: #error do: [:ex| self error: "ex#message ," ex#stack ].	
	{'request.end()' lua'self:invalidMessage()'}.
	^nil""",nil)

smalltalk.bind(smalltalk.SwikiCodeRobot,"urlFromOptions:",0
,smalltalk.__f__("""(self,theOptions):
	#SwikiCodeRobot>>#urlFromOptions:
	return smalltalk.object_comma_(smalltalk.object_comma_(smalltalk.object_comma_(smalltalk.object_comma_(smalltalk.object_comma_(smalltalk.String("http://"),theOptions._at(smalltalk.String("host"))),smalltalk.String(":")),theOptions._at(smalltalk.String("port"))),smalltalk.String("/")),theOptions._at(smalltalk.String("path"))) 
""","SwikiCodeRobot_urlFromOptions_")
,"utilities","""urlFromOptions: theOptions
	" Private - Returns the url set in theOptions. "

	^'http://'
		,(theOptions @ #host)
		,':' ,(theOptions @ #port)
		,'/' ,(theOptions @ #path)""",nil)

smalltalk.bind(smalltalk.SwikiCodeRobot,"withOptions:do:",0
,smalltalk.__f__("""(self,theOptions,dataBlock):
	#SwikiCodeRobot>>#withOptions:do:
	def __blk1__():
		__1__=smalltalk.newContext()
		__1__.text=nil
		__1__.text=self.fileContentsAt_(self.urlFromOptions_(theOptions)) 
		return dataBlock.value_(__1__.text) 
	self.http_do_ifAbsent_(theOptions,dataBlock,smalltalk.blk(__blk1__,0)) 
	return self 
""","SwikiCodeRobot_withOptions_do_")
,"utilities","""withOptions: theOptions do: dataBlock
	" Private - Evaluates the dataBlock with data obtained accessing server options. "

	self http: theOptions do: dataBlock ifAbsent: [
		| text |
		text := self fileContentsAt: (self urlFromOptions: theOptions).
		dataBlock value: text
	]""",nil)

smalltalk.bind(smalltalk.SwikiCodeRobot,"withSwiki:page:do:",0
,smalltalk.__f__("""(self,swikiName,pageNumber,dataBlock):
	#SwikiCodeRobot>>#withSwiki:page:do:
	if smalltalk.b(self.aborted()):
		return nil 
	 
	self.withOptions_do_(smalltalk.object_comma_(smalltalk.object_comma_(smalltalk.object_comma_(self.options(),smalltalk.String("method")._minus_gt(smalltalk.String("GET"))),smalltalk.String("path")._minus_gt(smalltalk.object_comma_(smalltalk.object_comma_(swikiName,smalltalk.String("/")),pageNumber))),smalltalk.String("agent")._minus_gt(smalltalk.false)),dataBlock) 
	return self 
""","SwikiCodeRobot_withSwiki_page_do_")
,"utilities","""withSwiki: swikiName page: pageNumber do: dataBlock
	" Private - Evaluates the dataBlock with data obtained from swikipage. "

	self aborted ifTrue: [ ^nil ].
	self	withOptions: self options
			,(#method -> 'GET')
			,(#path -> (swikiName,'/',pageNumber))
			,(#agent ->false)
		do: dataBlock""",nil)

smalltalk.bind(smalltalk.SwikiCodeRobot,"is:includedIn:",0
,smalltalk.__f__("""(self,tag,tags):
	_s8Ret_=smalltalk.newContext()
	try:
		#SwikiCodeRobot>>#is:includedIn:
		if smalltalk.b(tag.isArray()):
			def __blk1__(one):
				return smalltalk.booleanNot_(self.is_includedIn_(one,tags)) 
			def __blk2__():
				return smalltalk.raise_result_(_s8Ret_,smalltalk.true) 
			tag.detect_ifNone_(smalltalk.blk(__blk1__,1),smalltalk.blk(__blk2__,0)) 
			smalltalk.raise_result_(_s8Ret_,smalltalk.false) 
		 
		smalltalk.raise_result_(_s8Ret_,tags.includes_(tag)) 
	except Exception as __ex:
		if smalltalk.exception_at(__ex,_s8Ret_):
			return smalltalk.exceptionResult_(__ex)
		raise __ex
	
""","SwikiCodeRobot_is_includedIn_")
,"tags","""is: tag includedIn: tags
	" Private - Return true if the tag matches tags. "

	tag isArray ifTrue: [
		tag	detect: [:one| (self is: one includedIn: tags) not ]
			ifNone: [ ^true ].
		^false
	].
	^tags includes: tag""",nil)

smalltalk.bind(smalltalk.SwikiCodeRobot,"tagSeparator",0
,smalltalk.__f__("""(self):
	#SwikiCodeRobot>>#tagSeparator
	return smalltalk.String(",") 
""","SwikiCodeRobot_tagSeparator")
,"tags","""tagSeparator
	" Private - Return the tags separator. "

	^$,""",nil)

smalltalk.bind(smalltalk.SwikiCodeRobot,"tagsFrom:",0
,smalltalk.__f__("""(self,aStream):
	#SwikiCodeRobot>>#tagsFrom:
	return self.categoryAndTagsFrom_(aStream).last() 
""","SwikiCodeRobot_tagsFrom_")
,"tags","""tagsFrom: aStream
	" Private - Return the tags read from title stream. "

	^(self categoryAndTagsFrom: aStream) last""",nil)

smalltalk.bind(smalltalk.SwikiCodeRobot,"tagsInTitle:",0
,smalltalk.__f__("""(self,title):
	#SwikiCodeRobot>>#tagsInTitle:
	return self.categoryAndTagsInTitle_(title).last() 
""","SwikiCodeRobot_tagsInTitle_")
,"tags","""tagsInTitle: title
	" Private - Return the tags read from title string. "

	^(self categoryAndTagsInTitle: title) last""",nil)

smalltalk.bind(smalltalk.SwikiCodeRobot,"categoryAndTagsFrom:",0
,smalltalk.__f__("""(self,aStream):
	#SwikiCodeRobot>>#categoryAndTagsFrom:
	__0__=smalltalk.newContext()
	def __blk1__():
		return smalltalk.booleanNot_(self.categories().includes_(__0__.category)) 
	def __blk2__(each):
		return each.trimBlanks() 
	def __blk3__(each):
		return each.notEmpty() 
	__0__.category=nil
	__0__.category=aStream.upTo_(smalltalk.String("[")).trimBlanks() 
	if smalltalk.b(smalltalk.boolean_and_(self.categories().notEmpty(),smalltalk.blk(__blk1__,0))):
		return smalltalk.Array.with_with_(__0__.category,smalltalk.newArray([])) 
	 
	return smalltalk.Array.with_with_(__0__.category,aStream.upTo_(smalltalk.String("]")).asArrayOfSubstringsSeparatedBy_(self.tagSeparator()).collect_(smalltalk.blk(__blk2__,1)).select_(smalltalk.blk(__blk3__,1))) 
""","SwikiCodeRobot_categoryAndTagsFrom_")
,"tags","""categoryAndTagsFrom: aStream
	" Private - Return the tags read from title stream. "

	| category |
	category := (aStream upTo: $[) trimBlanks.
	(self categories notEmpty
		and: [ (self categories includes: category) not])
		ifTrue: [ ^Array with: category with: #() ].
	^Array	with: category
		with: ((((aStream upTo: $])
			asArrayOfSubstringsSeparatedBy: self tagSeparator)
			collect: [:each| each trimBlanks ])
			select: [:each| each notEmpty ])""",nil)

smalltalk.bind(smalltalk.SwikiCodeRobot,"categoryAndTagsInTitle:",0
,smalltalk.__f__("""(self,title):
	#SwikiCodeRobot>>#categoryAndTagsInTitle:
	return self.categoryAndTagsFrom_(title.stream()) 
""","SwikiCodeRobot_categoryAndTagsInTitle_")
,"tags","""categoryAndTagsInTitle: title
	" Private - Return an array with category and the tags read from title string. "

	^self categoryAndTagsFrom: title stream""",nil)

smalltalk.bind(smalltalk.SwikiCodeRobot,"title:matches:",0
,smalltalk.__f__("""(self,indexEntry,tag):
	#SwikiCodeRobot>>#title:matches:
	__0__=smalltalk.newContext()
	__0__.tags=nil
	__0__.tags=self.tagsInTitle_(indexEntry.last()) 
	if smalltalk.b(__0__.tags.isEmpty()):
		return smalltalk.false 
	 
	if smalltalk.b(smalltalk.isNil_(tag)):
		return smalltalk.true 
	 
	return self.is_includedIn_(tag,__0__.tags) 
""","SwikiCodeRobot_title_matches_")
,"tags","""title: indexEntry matches: tag
	" Private - Return true if the indexEntry matches tag. "

	| tags |
	tags := self tagsInTitle: indexEntry last.
	tags isEmpty ifTrue: [ ^false ].
	tag isNil ifTrue: [ ^true ].
	^self is: tag includedIn: tags""",nil)

smalltalk.bind(smalltalk.SwikiCodeRobot,"pagesIn:matching:",0
,smalltalk.__f__("""(self,stream,tag):
	#SwikiCodeRobot>>#pagesIn:matching:
	__0__=smalltalk.newContext()
	def __blk1__():
		return stream.atEnd() 
	def __blk2__(entry):
		return self.title_matches_(entry,tag) 
	__0__.result=nil
	__0__.line=nil
	__0__.pageNumber=nil
	__0__.boolean=nil
	__0__.title=nil
	__0__.result=smalltalk.Array.new() 
	while not smalltalk.b(smalltalk.blk(__blk1__,0)()):
		__0__.pageNumber=stream.upTo_(smalltalk.String.tab()).asNumber() 
		__0__.boolean=stream.upTo_(smalltalk.String.tab()) 
		__0__.title=stream.nextLine().trimBlanks() 
		__0__.result.add_(smalltalk.Array.with_with_(__0__.pageNumber,__0__.title)) 
	 
	return self.sortedPages_(__0__.result.select_(smalltalk.blk(__blk2__,1))) 
""","SwikiCodeRobot_pagesIn_matching_")
,"tags","""pagesIn: stream matching: tag
	" Private - Returns the pages defined in index stream matching tag.
	The default implementation parse index stream selecting pages matching tag field.
	"

	| result line pageNumber boolean title |
	result := Array new.
	[stream atEnd] whileFalse: [
		pageNumber := (stream upTo: String tab) asNumber.
		boolean := stream upTo: String tab.
		title := stream nextLine trimBlanks.
		result add: (Array with: pageNumber with: title)
	].
	^self sortedPages: (result select: [:entry| self title: entry matches: tag ])""",nil)

smalltalk.bind(smalltalk.SwikiCodeRobot,"htmlEncodings",0
,smalltalk.__f__("""(self):
	#SwikiCodeRobot>>#htmlEncodings
	return smalltalk.newArray([["&lt;","<"],["&gt;",">"],["&amp;","&"]]) 
""","SwikiCodeRobot_htmlEncodings")
,"private","""htmlEncodings
	" Private - Return the encoded characters table. "

	^#(
		#( '&lt;' #< )
		#( '&gt;' #> )
		#( '&amp;' #& )
	)""",nil)

smalltalk.bind(smalltalk.SwikiCodeRobot,"nextChunkIn:",0
,smalltalk.__f__("""(self,stream):
	#SwikiCodeRobot>>#nextChunkIn:
	__0__=smalltalk.newContext()
	def __blk1__(_s8_rec):
		_s8_rec.upTo_(smalltalk.object_comma_(smalltalk.object_comma_(__0__.open,__0__.tag),__0__.close)) 
		return _s8_rec.upTo_(smalltalk.object_comma_(smalltalk.object_comma_(smalltalk.object_comma_(__0__.open,__0__.bar),__0__.tag),__0__.close)) 
	def __blk2__(total,each):
		return total.replace_with_(each.first(),each.second()) 
	__0__.open=nil
	__0__.tag=nil
	__0__.close=nil
	__0__.bar=nil
	__0__.code=nil
	__0__.open=smalltalk.String("<") 
	__0__.close=smalltalk.String(">") 
	__0__.bar=smalltalk.String("/") 
	__0__.tag=smalltalk.String("pre") 
	__0__.code=__blk1__(stream) 
	return self.htmlEncodings().inject_into_(__0__.code,smalltalk.blk(__blk2__,2)) 
""","SwikiCodeRobot_nextChunkIn_")
,"private","""nextChunkIn: stream
	" Return the next chunk of code in stream. "

	| open tag close bar code |
	open := #<. close := #>. bar := #/. tag := #pre.
	code := stream upTo: open,tag,close; upTo: open,bar,tag,close.
	^self htmlEncodings inject: code
		into: [:total :each| total replace: each first with: each second ]""",nil)

smalltalk.bind(smalltalk.SwikiCodeRobot,"lineTest:",0
,smalltalk.__f__("""(self,expression):
	#SwikiCodeRobot>>#lineTest:
	__0__=smalltalk.newContext()
	__0__.result=nil
	__0__.result=expression.stream().fileInto_(self) 
	if smalltalk.b(smalltalk.isObject_equalTo_(smalltalk.true,__0__.result)):
		return smalltalk.String("ok") 
	 
	if smalltalk.b(smalltalk.isObject_equalTo_(smalltalk.false,__0__.result)):
		return self.note_(smalltalk.object_comma_(smalltalk.String("FAILED - "),expression)) 
	 
	return __0__.result 
""","SwikiCodeRobot_lineTest_")
,"lineTests","""lineTest: expression
	" Private - Evaluate the test expression. "

	| result |
	result := expression stream fileInto: self.
	true = result ifTrue: [ ^#ok ].
	false = result ifTrue: [ ^self note: 'FAILED - ' ,expression ].
	^result""",nil)

smalltalk.bind(smalltalk.SwikiCodeRobot,"running:",0
,smalltalk.__f__("""(self,aTitle):
	#SwikiCodeRobot>>#running:
	def __blk1__():
		return self.note_(aTitle) 
	self.triggerEvent_with_ifNotHandled_(smalltalk.String("running:"),aTitle,smalltalk.blk(__blk1__,0)) 
	return smalltalk.true 
""","SwikiCodeRobot_running_")
,"lineTests","""running: aTitle
	" Test - Notify we are running test aTitle. "

	self triggerEvent: #running: with: aTitle ifNotHandled: [
		self note: aTitle.
	].
	^true""",nil)

smalltalk.bind(smalltalk.SwikiCodeRobot,"testLine:",0
,smalltalk.__f__("""(self,expression):
	#SwikiCodeRobot>>#testLine:
	def __blk1__():
		return self.lineTest_(expression) 
	self.triggerEvent_with_ifNotHandled_(smalltalk.String("testLine:"),expression,smalltalk.blk(__blk1__,0)) 
	return self 
""","SwikiCodeRobot_testLine_")
,"lineTests","""testLine: expression
	" Private - Evaluate the test expression. "

	self triggerEvent: #testLine: with: expression ifNotHandled: [
		self lineTest: expression
	]""",nil)

smalltalk.bind(smalltalk.SwikiCodeRobot,"startTimes:",0
,smalltalk.__f__("""(self,code):
	#SwikiCodeRobot>>#startTimes:
	self.triggerEvent_with_(smalltalk.String("startTimes:"),self.savedTimes()) 
	return self 
""","SwikiCodeRobot_startTimes_")
,"timeTests","""startTimes: code
	" Private - Start tracking time evaluating line tests. "

	self triggerEvent: #startTimes: with: self savedTimes """,nil)

smalltalk.bind(smalltalk.SwikiCodeRobot,"endTimes:",0
,smalltalk.__f__("""(self,code):
	#SwikiCodeRobot>>#endTimes:
	self.triggerEvent_with_(smalltalk.String("endTimes:"),self.savedTimes()) 
	return self 
""","SwikiCodeRobot_endTimes_")
,"timeTests","""endTimes: code
	" Private - Finish tracking time evaluating line tests. "

	self triggerEvent: #endTimes: with: self savedTimes """,nil)

smalltalk.bind(smalltalk.SwikiCodeRobot,"resetTimes",0
,smalltalk.__f__("""(self):
	#SwikiCodeRobot>>#resetTimes
	return self.savedTimes().removeAll() 
""","SwikiCodeRobot_resetTimes")
,"timeTests","""resetTimes
	" Reset the times collected. "

	^self savedTimes removeAll """,nil)

smalltalk.bind(smalltalk.SwikiCodeRobot,"savedTimes",0
,smalltalk.__f__("""(self):
	#SwikiCodeRobot>>#savedTimes
	def __blk1__():
		return smalltalk.PoolDictionary.new() 
	return self.basicAt_ifAbsentPut_(smalltalk.String("$savedTimes"),smalltalk.blk(__blk1__,0)) 
""","SwikiCodeRobot_savedTimes")
,"timeTests","""savedTimes
	" Return the collected times spent evaluating line tests. "

	^self basicAt: '$savedTimes' ifAbsentPut: [PoolDictionary new] """,nil)

smalltalk.bind(smalltalk.SwikiCodeRobot,"jlTime:count:",0
,smalltalk.__f__("""(self,action,count):
	#SwikiCodeRobot>>#jlTime:count:
	__0__=smalltalk.newContext()
	def __blk1__():
		def __blk2__():
			return self.invalidMessage_(smalltalk.String("jlTime:count:")) 
		return smalltalk.times_repeat_(count,smalltalk.blk(__blk2__,0)) 
	__0__.blk=nil
	__0__.blk=self.callableOf_(action) 
	self.invalidMessage_(smalltalk.String("jlTime:count:")) 
	smalltalk.Smalltalk.gc() 
	return smalltalk.blk(__blk1__,0).ms() 
""","SwikiCodeRobot_jlTime_count_")
,"timeTests","""jlTime: action count: count
	" Private - Returns the time spent evaluating expression in a loop (count times). "

	| blk |
	blk := self callableOf: action.
	{''jl' Base.invokelatest(blk) '}.
	Smalltalk gc.
	^[ count timesRepeat: [
		{''jl' Base.invokelatest(blk) '}.
	] ] ms """,nil)

smalltalk.bind(smalltalk.SwikiCodeRobot,"ms:count:",0
,smalltalk.__f__('''(self,expression,count):
	#SwikiCodeRobot>>#ms:count:
	__0__=smalltalk.newContext()
	__0__.nativeSelector=nil
	__0__.nativeSelector=smalltalk.object_comma_(self.nativeLanguage(),smalltalk.String("Time:count:")).asSymbol() 
	if smalltalk.b(smalltalk.responds_to_(self,(__0__.nativeSelector))):
		__1__=smalltalk.newContext()
		__1__.action=nil
		__1__.action=smalltalk.object_comma_(smalltalk.object_comma_(smalltalk.String("[ "),expression),smalltalk.String(" ]")).doIt() 
		return self.perform_withArguments_(__0__.nativeSelector,smalltalk.Array.with_with_(__1__.action,count)) 
	 
	return smalltalk.object_comma_(smalltalk.object_comma_(smalltalk.object_comma_(smalltalk.object_comma_(smalltalk.String("Smalltalk gc. ["),count),smalltalk.String(" timesRepeat: [")),expression),smalltalk.String("""]
		]ms rounded""")).doIt() 
''',"SwikiCodeRobot_ms_count_")
,"timeTests","""ms: expression count: count
	" Private - Returns the time spent evaluating expression in a loop (count times).
	Note expression must be a valid statements expression.
	"

	| nativeSelector |
	nativeSelector := (self nativeLanguage ,'Time:count:') asSymbol.
	(self respondsTo: nativeSelector) ifTrue: [ | action |
		action := ('[ ' ,expression ,' ]') doIt.
		^self perform: nativeSelector withArguments: (Array
			with: action with: count)
	].
	^('Smalltalk gc. ['
	,count ,' timesRepeat: [' ,expression ,']
	]ms rounded') doIt""",nil)

smalltalk.bind(smalltalk.SwikiCodeRobot,"saveTime:",0
,smalltalk.__f__("""(self,expression):
	#SwikiCodeRobot>>#saveTime:
	__0__=smalltalk.newContext()
	__0__.count=nil
	__0__.stream=nil
	__0__.count=smalltalk.Number(1000) 
	__0__.stream=expression.stream() 
	if smalltalk.b(__0__.stream.peekForAll_(smalltalk.String("##"))):
		__0__.count=smalltalk.Number.readFrom_(__0__.stream) 
	 
	__0__.stream.skipSeparators() 
	if smalltalk.b(__0__.stream.atEnd()):
		return nil 
	 
	self.savedTimes().at_put_(expression,self.ms_count_(__0__.stream.upToEnd(),__0__.count)) 
	return self 
""","SwikiCodeRobot_saveTime_")
,"timeTests","""saveTime: expression
	" Private - Track time evaluating expression. "

	| count stream |
	count := 1000.
	stream := expression stream.
	(stream peekForAll: '##') ifTrue: [ count := Number readFrom: stream ].
	stream skipSeparators.
	stream atEnd ifTrue: [ ^nil ].
	self savedTimes at: expression put: (self ms: stream upToEnd count: count) """,nil)

smalltalk.bind(smalltalk.SwikiCodeRobot,"timesAction:",0
,smalltalk.__f__("""(self,code):
	#SwikiCodeRobot>>#timesAction:
	def __blk1__(expression):
		def __blk2__():
			return self.endTimes_(code) 
		def __blk3__():
			return self.saveTime_(expression) 
		return smalltalk.if_true_false_(smalltalk.isNil_(expression),smalltalk.blk(__blk2__,0),smalltalk.blk(__blk3__,0)) 
	self.startTimes_(code) 
	return smalltalk.blk(__blk1__,1) 
""","SwikiCodeRobot_timesAction_")
,"timeTests","""timesAction: code
	" Private - Return the action to evaluate to track time spent evaluating line tests. "

	self startTimes: code.
	^[:expression|
		expression isNil
		ifTrue: [ self endTimes: code ]
		ifFalse: [ self saveTime: expression ]
	]""",nil)

smalltalk.bind(smalltalk.SwikiCodeRobot,"testLines:in:",0
,smalltalk.__f__("""(self,code,page):
	#SwikiCodeRobot>>#testLines:in:
	__0__=smalltalk.newContext()
	def __blk1__():
		def __blk2__():
			return self.timesAction_(code) 
		return smalltalk.if_true_false_(code.peekForAll_(smalltalk.String("times")),smalltalk.blk(__blk2__,0),nil) 
	def __blk3__():
		return code.atEnd() 
	__0__.action=nil
	__0__.action=self.triggerEvent_with_ifNotHandled_(smalltalk.String("needsActionLine:"),code,smalltalk.blk(__blk1__,0)) 
	while not smalltalk.b(smalltalk.blk(__blk3__,0)()):
		__1__=smalltalk.newContext()
		def __blk4__():
			def __blk5__(_s8_rec):
				_s8_rec.next() 
				return _s8_rec.nextChunk() 
			return __blk5__(code) 
		def __blk6__():
			return code.nextLine().upTo_(smalltalk.String('"')) 
		def __blk7__():
			def __blk8__():
				return self.testLine_(__1__.line) 
			def __blk9__():
				return __0__.action.evaluateWith_(__1__.line) 
			return smalltalk.if_true_false_(smalltalk.isNil_(__0__.action),smalltalk.blk(__blk8__,0),smalltalk.blk(__blk9__,0)) 
		__1__.line=nil
		code.skipSeparators() 
		__1__.line=smalltalk.if_true_false_(smalltalk.isObject_equalTo_(code.peek(),smalltalk.String("!")),smalltalk.blk(__blk4__,0),smalltalk.blk(__blk6__,0)) 
		smalltalk.if_true_false_(__1__.line.trimBlanks().notEmpty(),smalltalk.blk(__blk7__,0),nil) 
	 
	if smalltalk.b(smalltalk.notNil_(__0__.action)):
		__0__.action.evaluateWith_(nil) 
	 
	self.triggerEvent_(smalltalk.String("endLines")) 
	return self 
""","SwikiCodeRobot_testLines_in_")
,"lineTests","""testLines: code in: page
	" Private - Evaluate the test lines in code stream. "

	| action |
	action := self triggerEvent: #needsActionLine: with: code ifNotHandled: [
		(code peekForAll: #times) ifTrue: [ self timesAction: code]
	].
	[code atEnd] whileFalse: [ | line |
		code skipSeparators.
		line := code peek = $!
			ifTrue: [ code next; nextChunk ]
			ifFalse: [ code nextLine upTo: $" ].
		line trimBlanks notEmpty ifTrue: [
			action isNil
			ifTrue: [ self testLine: line ]
			ifFalse: [ action evaluateWith: line ]
		]
	].
	action notNil ifTrue: [ action evaluateWith: nil ].
	self triggerEvent: #endLines""",nil)

smalltalk.bind(smalltalk.SwikiCodeRobot,"fileInCode:in:",0
,smalltalk.__f__("""(self,code,page):
	#SwikiCodeRobot>>#fileInCode:in:
	__0__=smalltalk.newContext()
	__0__.codeStream=nil
	__0__.commentStart=nil
	__0__.codeStream=code.stream() 
	if smalltalk.b(smalltalk.isObject_equalTo_(__0__.codeStream.peek(),smalltalk.String("."))):
		__0__.codeStream.next() 
		return self.testLines_in_(__0__.codeStream,page) 
	 
	__0__.commentStart=smalltalk.String(" ").asComment().upTo_(smalltalk.String(" ")) 
	if smalltalk.b(__0__.codeStream.peekForAll_(__0__.commentStart)):
		self.note_(__0__.codeStream.nextLine()) 
		return smalltalk.Smalltalk.current().eval_(__0__.codeStream.upToEnd()) 
	 
	if smalltalk.b(smalltalk.isObject_equalTo_(__0__.codeStream.peek(),smalltalk.String('"'))):
		def __blk1__(_s8_rec):
			_s8_rec.next() 
			return _s8_rec.upTo_(smalltalk.String('"')) 
		self.note_(__blk1__(__0__.codeStream)) 
	 
	return __0__.codeStream.fileInto_(self) 
""","SwikiCodeRobot_fileInCode_in_")
,"private","""fileInCode: code in: page
	" Private - FileIn the code in code string. "

	| codeStream commentStart |
	codeStream := code stream.
	codeStream peek = $. ifTrue: [ "code starting with $. enter line mode"
		codeStream next.
		^self testLines: codeStream in: page
	].

	commentStart := $  asComment upTo: $ .
	(codeStream peekForAll: commentStart) ifTrue: [ "native eval mode"
		self note: codeStream nextLine.
		^Smalltalk current eval: codeStream upToEnd
	].

	codeStream peek = $" ifTrue: [
		self note: (codeStream next; upTo: $")
	].
	^codeStream fileInto: self""",nil)

smalltalk.bind(smalltalk.SwikiCodeRobot,"evaluateCode:in:",0
,smalltalk.__f__("""(self,code,page):
	#SwikiCodeRobot>>#evaluateCode:in:
	def __blk1__():
		def __blk2__():
			return self.fileInCode_in_(code,page) 
		return self.triggerEvent_with_ifNotHandled_(smalltalk.String("evaluate:"),code,smalltalk.blk(__blk2__,0)) 
	def __blk3__(ex):
		return self.note_(smalltalk.object_comma_(smalltalk.object_comma_(smalltalk.object_comma_(smalltalk.String("Error evaluating code in "),smalltalk.printString_(page)),smalltalk.String(":")),ex.messageText())) 
	smalltalk.blk(__blk1__,0).on_do_(smalltalk.Error,smalltalk.blk(__blk3__,1)) 
	return self 
""","SwikiCodeRobot_evaluateCode_in_")
,"private","""evaluateCode: code in: page
	" Private - Evaluate the code in code string.
	The default action fileIn the code.
	"

	[	self	triggerEvent: #evaluate: with: code
			ifNotHandled: [ self fileInCode: code in: page ]
	] on: Error do: [:ex|
		self note: 'Error evaluating code in '
			,page printString ,':'
			,ex messageText
	]""",nil)

smalltalk.bind(smalltalk.SwikiCodeRobot,"processPage:contents:",0
,smalltalk.__f__("""(self,page,stream):
	#SwikiCodeRobot>>#processPage:contents:
	def __blk1__():
		return stream.atEnd() 
	smalltalk.basic_at_put(self,"@chunkStream",stream) 
	self.triggerEvent_withArguments_(smalltalk.String("startPage:stream:"),smalltalk.Array.with_with_(page,getattr(self,"@chunkStream",nil))) 
	while not smalltalk.b(smalltalk.blk(__blk1__,0)()):
		__1__=smalltalk.newContext()
		__1__.chunk=nil
		__1__.chunk=self.nextChunkIn_(stream) 
		self.evaluateCode_in_(__1__.chunk,page) 
	 
	self.triggerEvent_with_(smalltalk.String("endPage:"),page) 
	return self 
""","SwikiCodeRobot_processPage_contents_")
,"private","""processPage: page contents: stream
	" Private - Process the page contents (in stream). "

	chunkStream := stream.
	self	triggerEvent: #startPage:stream:
		withArguments: (Array with: page with: chunkStream).
	[stream atEnd] whileFalse: [ | chunk |
		chunk := self nextChunkIn: stream.
		self evaluateCode: chunk in: page.
	].
	self triggerEvent: #endPage: with: page""",nil)

smalltalk.bind(smalltalk.SwikiCodeRobot,"processPagesDeferred:in:",0
,smalltalk.__f__("""(self,pages,swikiName):
	#SwikiCodeRobot>>#processPagesDeferred:in:
	__0__=smalltalk.newContext()
	def __blk1__(data):
		def __blk2__():
			return self.processPages_in_(pages,swikiName) 
		if smalltalk.b(self.verbose()):
			self.note_(smalltalk.printString_(__0__.current.last())) 
		 
		if smalltalk.b(smalltalk.isNil_(data)):
			self.error_(smalltalk.object_comma_(smalltalk.String("Can't read contents at "),smalltalk.printString_(__0__.current.last()))) 
		 
		self.processPage_contents_(__0__.current,data.stream()) 
		return smalltalk.blk(__blk2__,0).valueDeferred_(smalltalk.Number(300)) 
	__0__.current=nil
	if smalltalk.b(pages.isEmpty()):
		return self 
	 
	if not smalltalk.b(self.deferred()):
		return self.processPages_in_(pages,swikiName) 
	 
	__0__.current=pages.removeFirst() 
	self.withSwiki_page_do_(swikiName,__0__.current.first(),smalltalk.blk(__blk1__,1)) 
	return self 
""","SwikiCodeRobot_processPagesDeferred_in_")
,"private","""processPagesDeferred: pages in: swikiName
	" Private - Process the pages found in swiki swikiName. "

	| current |
	pages isEmpty ifTrue: [ ^self ].
	self deferred ifFalse: [ ^self processPages: pages in: swikiName ].
	current := pages removeFirst.
	self withSwiki: swikiName page: current first do: [:data|
		self verbose ifTrue: [ self note: current last printString ].
		data isNil ifTrue: [ self error: 'Can''t read contents at ',current last printString ].
		self processPage: current contents: data stream.
		[ self processPages: pages in: swikiName ] valueDeferred: 300
	]""",nil)

smalltalk.bind(smalltalk.SwikiCodeRobot,"processPagesIterative:in:",0
,smalltalk.__f__("""(self,pages,swikiName):
	#SwikiCodeRobot>>#processPagesIterative:in:
	__0__=smalltalk.newContext()
	def __blk1__():
		def __blk2__():
			return smalltalk.booleanNot_(self.deferred()) 
		return smalltalk.boolean_and_(pages.notEmpty(),smalltalk.blk(__blk2__,0)) 
	__0__.current=nil
	while smalltalk.b(smalltalk.blk(__blk1__,0)()):
		def __blk3__(data):
			if smalltalk.b(self.verbose()):
				self.note_(smalltalk.printString_(__0__.current.last())) 
			 
			if smalltalk.b(smalltalk.isNil_(data)):
				self.error_(smalltalk.object_comma_(smalltalk.String("Can't read contents at "),smalltalk.printString_(__0__.current.last()))) 
			 
			return self.processPage_contents_(__0__.current,data.stream()) 
		__0__.current=pages.removeFirst() 
		self.withSwiki_page_do_(swikiName,__0__.current.first(),smalltalk.blk(__blk3__,1)) 
	 
	if smalltalk.b(pages.notEmpty()):
		self.processPages_in_(pages,swikiName) 
	 
	return self 
""","SwikiCodeRobot_processPagesIterative_in_")
,"private","""processPagesIterative: pages in: swikiName
	" Private - Process the pages found in swiki swikiName. "

	| current |
	[pages notEmpty and: [ self deferred not ]] whileTrue: [
		current := pages removeFirst.
		self withSwiki: swikiName page: current first do: [:data|
			self verbose ifTrue: [ self note: current last printString ].
			data isNil ifTrue: [ self error: 'Can''t read contents at ',current last printString ].
			self processPage: current contents: data stream.
		].
	].
	pages notEmpty ifTrue: [
		self processPages: pages in: swikiName
	]""",nil)

smalltalk.bind(smalltalk.SwikiCodeRobot,"processPages:in:",0
,smalltalk.__f__("""(self,pages,swikiName):
	#SwikiCodeRobot>>#processPages:in:
	def __blk1__():
		return self.processPagesDeferred_in_(pages,swikiName) 
	def __blk2__():
		return self.processPagesIterative_in_(pages,swikiName) 
	smalltalk.basic_at_put(self,"@currentPages",pages) 
	self.triggerEvent_with_(smalltalk.String("startPages:"),getattr(self,"@currentPages",nil)) 
	return smalltalk.if_true_false_(self.deferred(),smalltalk.blk(__blk1__,0),smalltalk.blk(__blk2__,0)) 
""","SwikiCodeRobot_processPages_in_")
,"private","""processPages: pages in: swikiName
	" Private - Process the pages found in swiki swikiName. "

	currentPages := pages.
	self triggerEvent: #startPages: with: currentPages.
	^self deferred
		ifTrue: [ self processPagesDeferred: pages in: swikiName ]
		ifFalse: [ self processPagesIterative: pages in: swikiName ]""",nil)

smalltalk.bind(smalltalk.SwikiCodeRobot,"sortedPages:",0
,smalltalk.__f__("""(self,entries):
	#SwikiCodeRobot>>#sortedPages:
	def __blk1__():
		return self.defaultSortedPages_(entries) 
	return self.triggerEvent_with_ifNotHandled_(smalltalk.String("sortPages:"),entries,smalltalk.blk(__blk1__,0)) 
""","SwikiCodeRobot_sortedPages_")
,"sorting","""sortedPages: entries
	" Private - Return the page entries sorted by scanning precedence. "

	^self	triggerEvent: #sortPages: with: entries
		ifNotHandled: [ self defaultSortedPages: entries ]""",nil)

smalltalk.bind(smalltalk.SwikiCodeRobot,"commandsIn:",0
,smalltalk.__f__("""(self,title):
	#SwikiCodeRobot>>#commandsIn:
	def __blk1__():
		return self.defaultCommandsIn_(title) 
	return self.triggerEvent_with_ifNotHandled_(smalltalk.String("needsCommandsIn:"),title,smalltalk.blk(__blk1__,0)) 
""","SwikiCodeRobot_commandsIn_")
,"commands","""commandsIn: title
	" Private - Return the commands obtained from title. "

	^self triggerEvent: #needsCommandsIn: with: title ifNotHandled: [
		self defaultCommandsIn: title
	]""",nil)

smalltalk.bind(smalltalk.SwikiCodeRobot,"defaultCommandsIn:",0
,smalltalk.__f__("""(self,title):
	#SwikiCodeRobot>>#defaultCommandsIn:
	def __blk1__(total,each):
		return smalltalk.object_comma_(smalltalk.object_comma_(total,each),smalltalk.String(" ")) 
	return title.asArrayOfSubstrings().inject_into_(smalltalk.String(""),smalltalk.blk(__blk1__,2)).trimBlanks() 
""","SwikiCodeRobot_defaultCommandsIn_")
,"commands","""defaultCommandsIn: title
	" Private - Return the commands obtained from title. "

	^(title asArrayOfSubstrings inject: ''
		into: [:total :each| total ,each ,' ' ]) trimBlanks""",nil)

smalltalk.bind(smalltalk.SwikiCodeRobot,"prologueKeys",0
,smalltalk.__f__("""(self):
	#SwikiCodeRobot>>#prologueKeys
	return smalltalk.newArray(["prologue","home","index","definitions","definition"]) 
""","SwikiCodeRobot_prologueKeys")
,"sorting","""prologueKeys
	" Private - Return the commands used to sort pages. "

	^#(	prologue
		home index
		definitions definition
	)""",nil)

smalltalk.bind(smalltalk.SwikiCodeRobot,"epilogueKeys",0
,smalltalk.__f__("""(self):
	#SwikiCodeRobot>>#epilogueKeys
	return smalltalk.newArray(["body","methods","code","doIt","evaluate","fail","epilogue"]) 
""","SwikiCodeRobot_epilogueKeys")
,"sorting","""epilogueKeys
	" Private - Return the commands used to sort pages. "

	^#(	body methods
		code doIt evaluate
		fail epilogue
	)""",nil)

smalltalk.bind(smalltalk.SwikiCodeRobot,"defaultSortedPages:",0
,smalltalk.__f__("""(self,entries):
	#SwikiCodeRobot>>#defaultSortedPages:
	__0__=smalltalk.newContext()
	def __blk1__(tuple):
		__1__=smalltalk.newContext()
		def __blk2__(_s8_rec):
			_s8_rec.upTo_(smalltalk.String("]")) 
			return _s8_rec.upToEnd() 
		__1__.title=nil
		__1__.title=__blk2__(tuple.last().stream()) 
		return __0__.map.at_put_(self.commandsIn_(__1__.title),tuple) 
	def __blk3__(key,where):
		def __blk4__():
			where.add_(__0__.map.at_(key)) 
			return __0__.map.removeKey_(key) 
		return smalltalk.if_true_false_(__0__.map.includesKey_(key),smalltalk.blk(__blk4__,0),nil) 
	def __blk5__(key):
		return __0__.add.value_value_(key,__0__.result) 
	def __blk6__(key):
		return __0__.add.value_value_(key,__0__.epilogue) 
	def __blk7__(each):
		return __0__.addResult.value_(each) 
	def __blk8__(each):
		return __0__.addEpilogue.value_(each) 
	def __blk9__(key):
		return __0__.result.add_(__0__.map.at_(key)) 
	__0__.map=nil
	__0__.result=nil
	__0__.add=nil
	__0__.addResult=nil
	__0__.epilogue=nil
	__0__.addEpilogue=nil
	__0__.result=smalltalk.Array.new() 
	__0__.epilogue=smalltalk.Array.new() 
	__0__.map=smalltalk.Dictionary.new() 
	entries.do_(smalltalk.blk(__blk1__,1)) 
	__0__.add=smalltalk.blk(__blk3__,2) 
	__0__.addResult=smalltalk.blk(__blk5__,1) 
	__0__.addEpilogue=smalltalk.blk(__blk6__,1) 
	self.prologueKeys().do_(smalltalk.blk(__blk7__,1)) 
	self.epilogueKeys().do_(smalltalk.blk(__blk8__,1)) 
	__0__.map.keys().sorted().do_(smalltalk.blk(__blk9__,1)) 
	__0__.result=smalltalk.object_comma_(__0__.result,__0__.epilogue) 
	return __0__.result 
""","SwikiCodeRobot_defaultSortedPages_")
,"sorting","""defaultSortedPages: entries
	" Private - Return the page entries sorted by default scanning precedence. "

	| map result add addResult epilogue addEpilogue |
	result := Array new.
	epilogue := Array new. 
	map := Dictionary new.
	entries do: [:tuple| | title |
		title := tuple last stream upTo: $]; upToEnd.
		map at: (self commandsIn: title) put: tuple
	].
	add := [:key :where| (map includesKey: key) ifTrue: [
			where add: (map at: key).
			map removeKey: key
		].
	].
	addResult := [:key| add value: key value: result ].
	addEpilogue := [:key| add value: key value: epilogue ].

	self prologueKeys do: [:each| addResult value: each ].
	self epilogueKeys do: [:each| addEpilogue value: each ].

	map keys sorted do: [:key| result add: (map at: key) ].
	result := result ,epilogue.

	"self note: 'Sorted pages = ' ,result printString."
	^result""",nil)

smalltalk.bind(smalltalk.SwikiCodeRobot,"processPageAt:",0
,smalltalk.__f__("""(self,url):
	#SwikiCodeRobot>>#processPageAt:
	if smalltalk.b(url.isNumber()):
		return self.processPageAt_(smalltalk.printString_(url)) 
	 
	if not smalltalk.b(url.includes_(smalltalk.String("/"))):
		__1__=smalltalk.newContext()
		def __blk1__(data):
			__2__=smalltalk.newContext()
			__2__.pages=nil
			__2__.pages=smalltalk.Array.with_(__1__.page) 
			return self.processPages_in_(__2__.pages,__1__.swikiName) 
		__1__.swikiName=nil
		__1__.page=nil
		__1__.swikiName=self.defaultSwiki() 
		__1__.page=smalltalk.Array.with_with_(url,url) 
		return self.withSwiki_page_do_(__1__.swikiName,__1__.page.first(),smalltalk.blk(__blk1__,1)) 
	 
	return self.processPage_contents_(smalltalk.Array.with_(url),self.fileNameAt_(url).fileContents().stream()) 
""","SwikiCodeRobot_processPageAt_")
,"executing","""processPageAt: url
	" Process code in the swiki page at url. "

	url isNumber ifTrue: [ ^self processPageAt: url printString ].
	(url includes: $/) ifFalse: [ | swikiName page |
		swikiName := self defaultSwiki.
		page := Array with: url with: url.
		^self	withSwiki: swikiName page: page first
			do: [:data| | pages |
				pages := Array with: page.
				self processPages: pages in: swikiName
			]
	].

	^self	processPage: (Array with: url)
		contents: (self fileNameAt: url) fileContents stream""",nil)

smalltalk.bind(smalltalk.SwikiCodeRobot,"process:",0
,smalltalk.__f__("""(self,swikiName):
	#SwikiCodeRobot>>#process:
	return self.process_tagged_(swikiName,nil) 
""","SwikiCodeRobot_process_")
,"executing","""process: swikiName
	" Access the swiki to process code from pages. "

	^self process: swikiName tagged: nil""",nil)

smalltalk.bind(smalltalk.SwikiCodeRobot,"process:tagged:",0
,smalltalk.__f__("""(self,swikiName,tag):
	#SwikiCodeRobot>>#process:tagged:
	def __blk1__(pages):
		return self.processPages_in_(pages,swikiName) 
	self.withPagesIn_tagged_do_(swikiName,tag,smalltalk.blk(__blk1__,1)) 
	return smalltalk.String("Ok") 
""","SwikiCodeRobot_process_tagged_")
,"executing","""process: swikiName tagged: tag
	" Access swiki to run code from pages matching tag. "

	self	withPagesIn: swikiName tagged: tag
		do: [:pages| self processPages: pages in: swikiName ].
	^#Ok""",nil)

smalltalk.bind(smalltalk.SwikiCodeRobot,"withPagesIn:tagged:do:",0
,smalltalk.__f__("""(self,swikiName,tag,aBlock):
	#SwikiCodeRobot>>#withPagesIn:tagged:do:
	def __blk1__(data):
		__1__=smalltalk.newContext()
		__1__.pages=nil
		if smalltalk.b(smalltalk.isNil_(data)):
			self.error_(smalltalk.object_comma_(smalltalk.String("Can't read pages of "),swikiName)) 
		 
		__1__.pages=self.pagesIn_matching_(data.stream(),tag) 
		return aBlock.evaluateWith_(__1__.pages) 
	self.withSwiki_page_do_(swikiName,smalltalk.String(".pages"),smalltalk.blk(__blk1__,1)) 
	return self 
""","SwikiCodeRobot_withPagesIn_tagged_do_")
,"executing","""withPagesIn: swikiName tagged: tag do: aBlock
	" Evaluate aBlock with the pages matching tag in swikiName. "

	self withSwiki: swikiName page: '.pages' do: [:data| | pages |
		data isNil ifTrue: [ self error: 'Can''t read pages of ',swikiName ].
		pages := self pagesIn: data stream matching: tag.
		aBlock evaluateWith: pages
	]""",nil)

smalltalk.bind(smalltalk.SwikiCodeRobot,"withPagesIn:category:do:",0
,smalltalk.__f__("""(self,swikiName,categ,aBlock):
	#SwikiCodeRobot>>#withPagesIn:category:do:
	def __blk1__(data):
		__1__=smalltalk.newContext()
		__1__.pages=nil
		if smalltalk.b(smalltalk.isNil_(data)):
			self.error_(smalltalk.object_comma_(smalltalk.String("Can't read pages of "),swikiName)) 
		 
		__1__.pages=self.pagesIn_matchingCategory_(data.stream(),categ) 
		return aBlock.evaluateWith_(__1__.pages) 
	self.withSwiki_page_do_(swikiName,smalltalk.String(".pages"),smalltalk.blk(__blk1__,1)) 
	return self 
""","SwikiCodeRobot_withPagesIn_category_do_")
,"executing","""withPagesIn: swikiName category: categ do: aBlock
	" Evaluate aBlock with the pages matching category in swikiName. "

	self withSwiki: swikiName page: '.pages' do: [:data| | pages |
		data isNil ifTrue: [ self error: 'Can''t read pages of ',swikiName ].
		pages := self pagesIn: data stream matchingCategory: categ.		
		aBlock evaluateWith: pages
	]""",nil)

smalltalk.bind(smalltalk.SwikiCodeRobot,"pagesIn:matchingCategory:",0
,smalltalk.__f__("""(self,stream,categ):
	#SwikiCodeRobot>>#pagesIn:matchingCategory:
	__0__=smalltalk.newContext()
	def __blk1__():
		return stream.atEnd() 
	__0__.result=nil
	__0__.cat=nil
	__0__.pageNumber=nil
	__0__.boolean=nil
	__0__.title=nil
	__0__.tuple=nil
	__0__.tag=nil
	__0__.result=smalltalk.Array.new() 
	while not smalltalk.b(smalltalk.blk(__blk1__,0)()):
		def __blk2__():
			return __0__.result.add_(smalltalk.Array.with_with_with_(__0__.pageNumber,__0__.cat,__0__.tag)) 
		__0__.pageNumber=stream.upTo_(smalltalk.String.tab()).asNumber() 
		__0__.boolean=stream.upTo_(smalltalk.String.tab()) 
		__0__.title=stream.nextLine().trimBlanks() 
		__0__.tuple=self.categoryAndTagsFrom_(__0__.title.stream()) 
		__0__.cat=__0__.tuple.first() 
		__0__.tag=__0__.tuple.second() 
		smalltalk.if_true_false_(smalltalk.isObject_equalTo_(__0__.cat,categ),smalltalk.blk(__blk2__,0),nil) 
	 
	return __0__.result 
""","SwikiCodeRobot_pagesIn_matchingCategory_")
,"tags","""pagesIn: stream matchingCategory: categ
	" Private - Returns the pages defined in index stream matching category.
	The default implementation parse index stream selecting pages matching category field.
	"

	| result cat pageNumber boolean title tuple tag |
	result := Array new.
	[stream atEnd] whileFalse: [ 
		pageNumber := (stream upTo: String tab) asNumber.
		boolean := stream upTo: String tab.
		title := stream nextLine trimBlanks.
		tuple := self categoryAndTagsFrom:  title stream.
		cat := tuple first.
		tag := tuple second.
		cat = categ ifTrue:[
			result add: (Array with: pageNumber with: cat with: tag)
		]
	].
	^result""",nil)

smalltalk.bind(smalltalk.SwikiCodeRobot,"do:withPagesIn:tagged:",0
,smalltalk.__f__("""(self,aBlock,swikiName,tag):
	#SwikiCodeRobot>>#do:withPagesIn:tagged:
	return self.withPagesIn_tagged_do_(swikiName,tag,aBlock) 
""","SwikiCodeRobot_do_withPagesIn_tagged_")
,"obsolete","""do: aBlock withPagesIn: swikiName tagged: tag
	" Evaluate aBlock with the pages matching tag in swikiName. "

	^self withPagesIn: swikiName tagged: tag do: aBlock""",nil)

smalltalk.bind(smalltalk.SwikiCodeRobot,"u8ServicePathName",0
,smalltalk.__f__("""(self):
	#SwikiCodeRobot>>#u8ServicePathName
	if smalltalk.b(smalltalk.Smalltalk.includesKey_(smalltalk.String("U8Object"))):
		return smalltalk.object_comma_(smalltalk.U8Object.home(),smalltalk.String("/profile/")) 
	 
	return smalltalk.String("http://u8.smalltalking.net/profile/") 
""","SwikiCodeRobot_u8ServicePathName")
,"filenames","""u8ServicePathName
	" Private - Returns the root path name for U8 service files. "

	(Smalltalk includesKey: #U8Object) ifTrue: [
		^U8Object home ,'/profile/'
	].
	^'http://u8.smalltalking.net/profile/'""",nil)

smalltalk.bind(smalltalk.SwikiCodeRobot,"swikiServicePathName",0
,smalltalk.__f__("""(self):
	#SwikiCodeRobot>>#swikiServicePathName
	def __blk1__():
		return smalltalk.U8Object.swikiHostURL() 
	def __blk2__():
		return smalltalk.String("http://swiki.smalltalking.net/") 
	return smalltalk.if_true_false_(smalltalk.Smalltalk.includesKey_(smalltalk.String("U8Object")),smalltalk.blk(__blk1__,0),smalltalk.blk(__blk2__,0)) 
""","SwikiCodeRobot_swikiServicePathName")
,"filenames","""swikiServicePathName
	" Private - Returns the root path name for swiki service files. "

	^(Smalltalk includesKey: #U8Object)
	ifTrue: [ U8Object swikiHostURL ]
	ifFalse: [ 'http://swiki.smalltalking.net/' ]""",nil)

smalltalk.bind(smalltalk.SwikiCodeRobot,"fileNameAt:",0
,smalltalk.__f__("""(self,aPlace):
	#SwikiCodeRobot>>#fileNameAt:
	if smalltalk.b(smalltalk.isObject_equalTo_(aPlace.indexOf_(smalltalk.String("u8:")),smalltalk.Number(1))):
		return smalltalk.object_comma_(self.u8ServicePathName(),aPlace.copyFrom_to_(smalltalk.Number(4),aPlace.size())) 
	 
	if smalltalk.b(smalltalk.isObject_equalTo_(aPlace.indexOf_(smalltalk.String("swiki:")),smalltalk.Number(1))):
		return smalltalk.object_comma_(self.swikiServicePathName(),aPlace.copyFrom_to_(smalltalk.Number(7),aPlace.size()).copyWithout_(smalltalk.String(" "))) 
	 
	return aPlace 
""","SwikiCodeRobot_fileNameAt_")
,"filenames","""fileNameAt: aPlace
	" Private - Return the complete path for file at aPlace. "

	(aPlace indexOf: #u8:) = 1 ifTrue: [
		^self u8ServicePathName
			,(aPlace copyFrom: 4 to: aPlace size)
	].
	(aPlace indexOf: #swiki:) = 1 ifTrue: [
		^self swikiServicePathName
			,((aPlace copyFrom: 7 to: aPlace size)
				copyWithout: $ )
	].
	^aPlace""",nil)

smalltalk.bind(smalltalk.SwikiCodeRobot,"load:",0
,smalltalk.__f__("""(self,fileName):
	#SwikiCodeRobot>>#load:
	__0__=smalltalk.newContext()
	def __blk1__():
		return self.basicLoad_(self.fileNameAt_(fileName)) 
	__0__.index=nil
	__0__.index=fileName.lastIndexOf_(smalltalk.String(".")) 
	if smalltalk.b(smalltalk.isObject_equalTo_(__0__.index,smalltalk.Number(0))):
		return self.load_(smalltalk.object_comma_(fileName,smalltalk.String(".st.js"))) 
	 
	return self.triggerEvent_with_ifNotHandled_(smalltalk.String("load:"),fileName,smalltalk.blk(__blk1__,0)) 
""","SwikiCodeRobot_load_")
,"loading","""load: fileName
	" Private - Load the file at fileName. "

	| index |
	index := fileName lastIndexOf: $. .
	index = 0 ifTrue: [ ^self load: fileName ,'.st.js' ].
	^self triggerEvent: #load: with: fileName ifNotHandled: [
		self basicLoad: (self fileNameAt: fileName)
	]""",nil)

smalltalk.bind(smalltalk.SwikiCodeRobot,"fileContentsAt:",0
,smalltalk.__f__("""(self,fileName):
	#SwikiCodeRobot>>#fileContentsAt:
	def __blk1__():
		return fileName.fileContents() 
	return self.triggerEvent_with_ifNotHandled_(smalltalk.String("needsFileContents:"),fileName,smalltalk.blk(__blk1__,0)) 
""","SwikiCodeRobot_fileContentsAt_")
,"loading","""fileContentsAt: fileName
	" Private - Return the contents of the file at fileName. "

	^self
		triggerEvent: #needsFileContents:
		with: fileName
		ifNotHandled: [ fileName fileContents ]""",nil)

smalltalk.bind(smalltalk.SwikiCodeRobot,"loadedWithConfiguration:",0
,smalltalk.__f__("""(self,fileName):
	#SwikiCodeRobot>>#loadedWithConfiguration:
	if not smalltalk.b(smalltalk.Smalltalk.includesKey_(smalltalk.String("U8Configuration"))):
		return smalltalk.false 
	 
	if not smalltalk.b(smalltalk.responds_to_(smalltalk.U8Configuration,(smalltalk.String("default")))):
		return smalltalk.false 
	 
	return smalltalk.U8Configuration.default().loadFile_(fileName) 
""","SwikiCodeRobot_loadedWithConfiguration_")
,"loading","""loadedWithConfiguration: fileName
	" Private - Return true if the file at fileName has been loaded with U8Configuration. "

	(Smalltalk includesKey: #U8Configuration) ifFalse: [ ^false ].
	(U8Configuration respondsTo: #default) ifFalse: [ ^false ].
	^U8Configuration default loadFile: fileName""",nil)

smalltalk.bind(smalltalk.SwikiCodeRobot,"basicLoad:",0
,smalltalk.__f__("""(self,fileName):
	#SwikiCodeRobot>>#basicLoad:
	__0__=smalltalk.newContext()
	__0__.ext=nil
	__0__.index=nil
	__0__.code=nil
	if smalltalk.b(self.loadedWithConfiguration_(fileName)):
		return self 
	 
	__0__.code=self.fileContentsAt_(fileName) 
	if smalltalk.b(smalltalk.isNil_(__0__.code)):
		return self.error_(smalltalk.object_comma_(smalltalk.String("Code not found at "),fileName)) 
	 
	__0__.index=fileName.lastIndexOf_(smalltalk.String(".")) 
	__0__.ext=fileName.copyFrom_to_(__0__.index._plus(smalltalk.Number(1)),fileName.size()).asLowercase() 
	if smalltalk.b(smalltalk.isObject_equalTo_(__0__.ext,smalltalk.String("st"))):
		return __0__.code.stream().fileIn() 
	 
	if smalltalk.b(smalltalk.isObject_equalTo_(__0__.ext,smalltalk.String("js"))):
		return smalltalk.Compiler.new().eval_(__0__.code) 
	 
	return self.error_(smalltalk.object_comma_(smalltalk.String("Invalid file extension "),__0__.ext.asLiteral())) 
""","SwikiCodeRobot_basicLoad_")
,"loading","""basicLoad: fileName
	" Private - Load the file at fileName. "

	| ext index code |
	(self loadedWithConfiguration: fileName) ifTrue: [ ^self ].
	code := self fileContentsAt: fileName.
	code isNil ifTrue: [
		^self error: 'Code not found at ', fileName
	].
	index := fileName lastIndexOf: $..
	ext := (fileName copyFrom: index + 1 to: fileName size) asLowercase.
	ext = #st ifTrue: [ ^code stream fileIn ].
	ext = #js ifTrue: [ ^Compiler new eval: code ].
	^self error: 'Invalid file extension ',ext asLiteral""",nil)

smalltalk.bind(smalltalk.SwikiCodeRobot,"require:in:ifAbsent:",0
,smalltalk.__f__("""(self,names,places,errorBlock):
	_s8Ret_=smalltalk.newContext()
	try:
		#SwikiCodeRobot>>#require:in:ifAbsent:
		__0__=smalltalk.newContext()
		def __blk1__(each):
			return self.fileNameAt_(each) 
		def __blk2__():
			def __blk3__():
				return __0__.remaining.notEmpty() 
			return smalltalk.boolean_and_(__0__.what.notEmpty(),smalltalk.blk(__blk3__,0)) 
		def __blk4__(each):
			def __blk5__():
				return smalltalk.raise_result_(_s8Ret_,errorBlock.evaluateWith_(each)) 
			return smalltalk.Smalltalk.at_ifAbsent_(each,smalltalk.blk(__blk5__,0)) 
		__0__.what=nil
		__0__.result=nil
		__0__.remaining=nil
		if smalltalk.b(names.isString()):
			def __blk6__():
				return smalltalk.isObject_equalTo_(__0__.what.size(),smalltalk.Number(1)) 
			__0__.what=names.asArrayOfSubstrings() 
			__0__.result=self.require_in_ifAbsent_(__0__.what,places,errorBlock) 
			if smalltalk.b(smalltalk.boolean_and_(smalltalk.notNil_(__0__.result),smalltalk.blk(__blk6__,0))):
				smalltalk.raise_result_(_s8Ret_,__0__.result.first()) 
			 
			smalltalk.raise_result_(_s8Ret_,__0__.result) 
		 
		if smalltalk.b(places.isString()):
			smalltalk.raise_result_(_s8Ret_,self.require_in_ifAbsent_(names,smalltalk.Array.with_(places),errorBlock)) 
		 
		__0__.what=names.asArray().copy() 
		__0__.remaining=places.collect_(smalltalk.blk(__blk1__,1)) 
		while smalltalk.b(smalltalk.blk(__blk2__,0)()):
			def __blk7__(each):
				return smalltalk.Smalltalk.includesKey_(each) 
			def __blk8__():
				return self.load_(__0__.remaining.removeFirst()) 
			__0__.what=__0__.what.reject_(smalltalk.blk(__blk7__,1)) 
			smalltalk.if_true_false_(__0__.what.notEmpty(),smalltalk.blk(__blk8__,0),nil) 
		 
		__0__.result=names.collect_(smalltalk.blk(__blk4__,1)) 
		smalltalk.raise_result_(_s8Ret_,__0__.result) 
	except Exception as __ex:
		if smalltalk.exception_at(__ex,_s8Ret_):
			return smalltalk.exceptionResult_(__ex)
		raise __ex
	
""","SwikiCodeRobot_require_in_ifAbsent_")
,"tools","""require: names in: places ifAbsent: errorBlock
	" Ensure the globals in names are present.
	If there is a name missing, will try to load code from places
	 until all the names are present.
	Return the objects with that names or the result of evaluating errorBlock.
	"

	| what result remaining |
	names isString ifTrue: [
		what := names asArrayOfSubstrings.
		result := self require: what in: places ifAbsent: errorBlock.
		(result notNil and: [ what size = 1 ]) ifTrue: [ ^result first ].
		^result
	].
	places isString ifTrue: [
		^self
			require: names
			in: (Array with: places)
			ifAbsent: errorBlock
	].
	what := names asArray copy.
	remaining := places collect: [:each| self fileNameAt: each ].
	[what notEmpty and: [remaining notEmpty]] whileTrue: [
		what := what reject: [:each| Smalltalk includesKey: each ].
		what notEmpty ifTrue: [ self load: remaining removeFirst ].
	].
	result := names collect: [:each|
		Smalltalk at: each ifAbsent: [ ^errorBlock evaluateWith: each ]
	].
	^result""",nil)

smalltalk.bind(smalltalk.SwikiCodeRobot,"require:ifAbsent:",0
,smalltalk.__f__("""(self,names,aBlock):
	#SwikiCodeRobot>>#require:ifAbsent:
	return self.require_in_ifAbsent_(names,smalltalk.newArray([]),aBlock) 
""","SwikiCodeRobot_require_ifAbsent_")
,"tools","""require: names ifAbsent: aBlock
	" Ensure the globals in names are present.
	If a name do not exist returns the result of evaluating aBlock
	"

	^self require: names in: #() ifAbsent: aBlock""",nil)

smalltalk.bind(smalltalk.SwikiCodeRobot,"require:in:",0
,smalltalk.__f__("""(self,names,places):
	#SwikiCodeRobot>>#require:in:
	def __blk1__(aName):
		def __blk2__():
			return smalltalk.object_comma_(smalltalk.String(" in "),smalltalk.printString_(places)) 
		def __blk3__():
			return smalltalk.String("") 
		return self.error_(smalltalk.object_comma_(smalltalk.object_comma_(smalltalk.String("Missing global #"),aName),smalltalk.if_true_false_(places.notEmpty(),smalltalk.blk(__blk2__,0),smalltalk.blk(__blk3__,0)))) 
	return self.require_in_ifAbsent_(names,places,smalltalk.blk(__blk1__,1)) 
""","SwikiCodeRobot_require_in_")
,"tools","""require: names in: places
	" Ensure the globals in names are present. "

	^self require: names in: places ifAbsent: [:aName|
		self error: 'Missing global #' ,aName
			,(places notEmpty
				ifTrue: [' in ',places printString]
				ifFalse: [''])
	]""",nil)

smalltalk.bind(smalltalk.SwikiCodeRobot,"require:",0
,smalltalk.__f__("""(self,names):
	#SwikiCodeRobot>>#require:
	return self.require_in_(names,smalltalk.newArray([])) 
""","SwikiCodeRobot_require_")
,"tools","""require: names
	" Ensure the globals in names are present. "

	^self require: names in: #()""",nil)

smalltalk.bind(smalltalk.SwikiCodeRobot,"abort",0
,smalltalk.__f__("""(self):
	#SwikiCodeRobot>>#abort
	self.aborted_(smalltalk.true) 
	return self.cancelFileIn() 
""","SwikiCodeRobot_abort")
,"executing","""abort
	" Abort current execution. "

	self aborted: true.
	^self cancelFileIn""",nil)

smalltalk.bind(smalltalk.SwikiCodeRobot,"abortPage",0
,smalltalk.__f__("""(self):
	#SwikiCodeRobot>>#abortPage
	if smalltalk.b(smalltalk.notNil_(getattr(self,"@chunkStream",nil))):
		getattr(self,"@chunkStream",nil).upToEnd() 
	 
	return self.error_(smalltalk.String("Page execution aborted")) 
""","SwikiCodeRobot_abortPage")
,"executing","""abortPage
	" Abort execution of the page. "

	chunkStream notNil ifTrue: [ chunkStream upToEnd ].
	^self error: 'Page execution aborted'""",nil)

smalltalk.bind(smalltalk.SwikiCodeRobot,"selectPages:",0
,smalltalk.__f__("""(self,aBlock):
	#SwikiCodeRobot>>#selectPages:
	if smalltalk.b(aBlock.isString()):
		def __blk1__(page):
			return page.last().includes_(aBlock) 
		return self.selectPages_(smalltalk.blk(__blk1__,1)) 
	 
	if smalltalk.b(smalltalk.isNil_(getattr(self,"@currentPages",nil))):
		return self 
	 
	getattr(self,"@currentPages",nil).removeAll_(getattr(self,"@currentPages",nil).reject_(aBlock)) 
	return self 
""","SwikiCodeRobot_selectPages_")
,"pages","""selectPages: aBlock
	" Set the pages of the receiver with the pages selected with aBlock. "

	aBlock isString ifTrue: [
		^self selectPages: [:page| page last includes: aBlock ]
	].
	currentPages isNil ifTrue: [ ^self ].
	currentPages removeAll: (currentPages reject: aBlock)""",nil)

smalltalk.bind(smalltalk.SwikiCodeRobot,"rejectPages:",0
,smalltalk.__f__("""(self,aBlock):
	#SwikiCodeRobot>>#rejectPages:
	if smalltalk.b(aBlock.isString()):
		def __blk1__(page):
			return page.last().includes_(aBlock) 
		return self.rejectPages_(smalltalk.blk(__blk1__,1)) 
	 
	if smalltalk.b(smalltalk.isNil_(getattr(self,"@currentPages",nil))):
		return self 
	 
	getattr(self,"@currentPages",nil).removeAll_(getattr(self,"@currentPages",nil).select_(aBlock)) 
	return self 
""","SwikiCodeRobot_rejectPages_")
,"pages","""rejectPages: aBlock
	" Set the pages of the receiver with the pages rejected with aBlock. "

	aBlock isString ifTrue: [
		^self rejectPages: [:page| page last includes: aBlock ]
	].
	currentPages isNil ifTrue: [ ^self ].
	currentPages removeAll: (currentPages select: aBlock)""",nil)
