appendFormat: text request: request response: response shelf: shelf book: book page: page | append content today string color signPos colorPos firstNonTagPos tailingBlanks lastNotBlankPos | content _ String streamContents: [:stream | (text includes: $_) ifTrue: [ "_ means appends are seperated by lines" stream nextPutAll: '<hr width=20% align=left>']. string _ (((book settingsAt: 'saveFormatter') format: (request fieldsKey: 'append') request: request response: response shelf: shelf book: book page: page)) asString. (lastNotBlankPos _ string findLast: [:c | c isSeparator not]) > 0 ifTrue: [tailingBlanks _ string last: (string size - lastNotBlankPos)]. (text includes: $%) ifTrue: [ "% means appends color tag" color _ ((signPos _ string reverse findString: '--') > 0 and: [ ((colorPos _ string lastIndexOf: $%) > 0) and: [ (colorPos _ string size - colorPos) < signPos]]) ifTrue: [self estimBrowerColor: (string copyLast: colorPos) withoutTrailingBlanks asLowercase] ifFalse: [nil]. color ifNotNil: [ firstNonTagPos _ string findFirst: [ :ch | (('-#!!=|@_' includes: ch) or: [ch isSeparator]) not ]. firstNonTagPos > 1 ifTrue: [stream nextPutAll: (string first: firstNonTagPos - 1)]. stream nextPutAll: '<font color=', color, '>'. string _ string copyFrom: firstNonTagPos to: string size - colorPos - 1]]. stream nextPutAll: string withoutTrailingBlanks. color ifNotNil: [stream nextPutAll: '</font>']. (text includes: $@) ifTrue: [ "@ means appends include timestamps" today _ Date today. stream nextPutAll: ' <tt><em><font color=gray>- '; nextPutAll: today yyyymmdd; nextPutAll: ', '; nextPutAll: Time now print24. stream nextPutAll: '</font></em></tt>']. stream nextPutAll: (tailingBlanks ifNil: ['']), String cr]. "+ means appends are self replicating ^ means append areas stay at top and appends go down" append _ text, String cr. ^((text occurrencesOf: $+) > 1) ifTrue: [append, content, append] ifFalse: [(text includes: $^) ifTrue: [append, content] ifFalse: [content, append]]
このページを編集 (2329 bytes)
以下の 1 ページから参照されています。 |
This page has been visited 2153 times.