SystemOrganization addCategory: #'TextLint-Seaside'! !TLMarkup methodsFor: '*textlint-seaside' stamp: 'lr 10/26/2010 13:25'! renderTextOn: html html span class: 'markup'; with: [ super renderTextOn: html ]! ! !TLElement methodsFor: '*textlint-seaside' stamp: 'lr 10/25/2010 20:51'! renderStarts: starts stops: stops on: html self children do: [ :each | each renderStarts: starts stops: stops on: html ]! ! !TLSyntacticElement methodsFor: '*textlint-seaside' stamp: 'lr 11/3/2010 15:30'! renderStart: aFailure on: html html anchor name: aFailure element start printString; with: [ ]. html document openTag: 'a' attributes: (WAHtmlAttributes new at: 'class' put: 'problem'; at: 'href' put: '#' , aFailure rule class name; at: 'title' put: aFailure rule name , ': ' , aFailure rule rationale; yourself) closed: false! ! !TLSyntacticElement methodsFor: '*textlint-seaside' stamp: 'lr 10/26/2010 13:24'! renderStarts: starts stops: stops on: html [ starts notEmpty and: [ starts first element start <= self start ] ] whileTrue: [ self renderStart: starts removeFirst on: html ]. self renderTextOn: html. [ stops notEmpty and: [ stops first element stop <= self stop ] ] whileTrue: [ self renderStop: stops removeFirst on: html ]! ! !TLSyntacticElement methodsFor: '*textlint-seaside' stamp: 'lr 11/3/2010 15:24'! renderStop: aFailure on: html html document closeTag: 'a'! ! !TLSyntacticElement methodsFor: '*textlint-seaside' stamp: 'lr 10/26/2010 13:24'! renderTextOn: html html text: self text! ! WAComponent subclass: #TLRootComponent instanceVariableNames: 'checker results' classVariableNames: '' poolDictionaries: '' category: 'TextLint-Seaside'! !TLRootComponent class methodsFor: 'initialization' stamp: 'lr 10/25/2010 22:28'! initialize | application | application := WAAdmin register: self asApplicationAt: 'textlint'. application preferenceAt: #serverPath put: '/'. WAAdmin defaultDispatcher defaultName: 'textlint'. WAAdmin applicationDefaults removeParent: WADevelopmentConfiguration instance! ! !TLRootComponent methodsFor: 'actions' stamp: 'lr 10/26/2010 13:20'! analyze: aString checker := TLTextLintChecker new. checker addStyle: TLWritingStyle scientificPaperStyle. results := [ checker check: (aString first: (aString size min: self maximumSize)) ] valueWithin: self maximumTime onTimeout: [ #() ]! ! !TLRootComponent methodsFor: 'configuration' stamp: 'lr 10/26/2010 13:29'! maximumSize "200k should be enough for most papers." ^ 1024 * 1024 // 4! ! !TLRootComponent methodsFor: 'configuration' stamp: 'lr 10/26/2010 13:29'! maximumTime "If this takes more than 8 seconds there is something wrong." ^ 8 seconds! ! !TLRootComponent methodsFor: 'rendering' stamp: 'lr 10/25/2010 20:32'! renderBodyOn: html html form: [ results isNil ifTrue: [ self renderTextOn: html ] ifFalse: [ self renderResultOn: html ] ]! ! !TLRootComponent methodsFor: 'rendering' stamp: 'lr 10/25/2010 19:25'! renderContentOn: html html div class: 'head'; with: [ self renderHeadOn: html ]. html div class: 'body'; with: [ self renderBodyOn: html ]. html div class: 'foot'; with: [ self renderFootOn: html ]! ! !TLRootComponent methodsFor: 'rendering' stamp: 'lr 10/26/2010 21:40'! renderFootOn: html html paragraph: [ html anchor url: 'http://scg.unibe.ch/research/textlint'; with: 'TextLint'. html text: ' is a '. html anchor url: 'http://scg.unibe.ch/staff/fabrizioperin/'; with: 'Fabrizio Perin'. html text: ', '. html anchor url: 'http://www.lukas-renggli.ch/'; with: 'Lukas Renggli'. html text: ', and '. html anchor url: 'http://www.jorgeressia.com/'; with: 'Jorge Ressia'. html text: ' production.'. html break. html text: 'Powered by '. html anchor url: 'http://www.pharo-project.org/'; with: 'Pharo Smalltalk'. html text: ', '. html anchor url: 'http://www.seaside.st/'; with: 'Seaside'. html text: ', and '. html anchor url: 'http://www.mirandabanda.org/'; with: 'Cog'. html text: '.' ]! ! !TLRootComponent methodsFor: 'rendering' stamp: 'lr 10/26/2010 12:53'! renderHeadOn: html html heading level: 1; with: [ html span: self title ]. html paragraph: (results isNil ifTrue: [ 'TextLint is a tool to check your scientific writing for common style errors. To give it a try paste your plain text, HTML or LaTeX source into the input field below and click on "analyze text".' ] ifFalse: [ results isEmpty ifTrue: [ 'Congratulations!! TextLint could not discover any issues in your text.' ] ifFalse: [ 'TextLint discovered ' , (results size printString) , ' possible issue' , (results size > 1 ifTrue: [ 's' ] ifFalse: [ '' ]) , ' in your text. Hover with the mouse over the issues to display a tooltip with the explanation of the problem.' ] ]) ! ! !TLRootComponent methodsFor: 'rendering' stamp: 'lr 11/3/2010 15:54'! renderListOn: html | groups | html unorderedList: [ groups := results groupedBy: [ :each | each rule class ]. groups := groups values sorted: [ :a :b | a first rule name < b first rule name ]. groups do: [ :failures | | rule | rule := failures first rule. html listItem: [ html heading level: 3; with: [ html anchor name: rule class name. html text: rule name ]. html paragraph: [ html withLineBreaks: rule rationale ]. html orderedList: [ failures do: [ :failure | html listItem: [ html anchor url: '#' , failure element start printString; with: (failure element text truncate: 120) ] ] ] ] ] ]! ! !TLRootComponent methodsFor: 'rendering' stamp: 'lr 11/3/2010 15:32'! renderResultOn: html | starts stops | starts := results sortBy: [ :a :b | a element start < b element start ]. stops := results sortBy: [ :a :b | a element stop < b element stop ]. html div class: 'list'; with: [ self renderListOn: html ]. html div class: 'result'; with: [ checker document renderStarts: starts stops: stops on: html ]. html paragraph class: 'buttons'; with: [ html submitButton callback: [ results := nil ]; with: 'Go Back' ]! ! !TLRootComponent methodsFor: 'rendering' stamp: 'lr 11/3/2010 16:02'! renderTextOn: html html div: [ html textArea value: (checker isNil ifFalse: [ checker document text ]); callback: [ :value | self analyze: value ] ]. html paragraph class: 'buttons'; with: [ html submitButton onClick: 'this.disabled=true; this.value=''Please Wait''; document.forms[0].submit(); return false;'; with: 'Analyze Text' ]! ! !TLRootComponent methodsFor: 'accessing' stamp: 'lr 11/3/2010 16:03'! style ^ '.head, .body, .foot { width: 800px; margin: 0 auto; } .head h1 { width: 263px; height: 100px; background-image: url("http://textlint.lukas-renggli.ch/images/logo.png"); } .head h1 span { display: none; } .body textarea, .body div.result { padding: 0; resize: none; width: 800px; height: 600px; line-height: 1.5; border: 1px solid #bbb; font: 1em "andale mono", "lucida console", monospace; } .body div.list { resize: none; overflow: auto; width: 810px; height: 200px; line-height: 1.5; border: 1px solid #bbb; border-bottom: none; } .body div.list ul { padding: 0; margin: 0; } .body div.list ul li { list-style-type: none; } .body div.list ul li h3 { margin: 0; padding: 5px; background: #eee; } .body div.list ul li p { margin: 0; padding: 5px; } .body div.list ol { margin: 0; padding: 0 0 10px 5px; } .body div.list ol li { margin: 0; padding: 0 0 0 10px; list-style-type: none; } .body div.result { overflow: auto; height: 400px; padding: 5px; white-space: pre-wrap; white-space: -moz-pre-wrap !!important; white-space: -pre-wrap; white-space: -o-pre-wrap; word-wrap: break-word; } .body div.result .markup { color: gray; } .body div.result .problem { border-bottom: 1px dotted red; color: red; text-decoration: none; } .body div.result .problem:hover { background: #fbe3e4; } .body p.buttons { text-align: center; padding-top: 10px; } .foot p { font-size: 0.8em; text-align: center; }'! ! !TLRootComponent methodsFor: 'accessing' stamp: 'lr 10/25/2010 19:23'! title ^ 'TextLint'! ! !TLRootComponent methodsFor: 'updating' stamp: 'lr 11/3/2010 15:43'! updateRoot: aHtmlRoot super updateRoot: aHtmlRoot. aHtmlRoot beHtml5. aHtmlRoot title: self title. aHtmlRoot stylesheet url: 'http://textlint.lukas-renggli.ch/blueprint/screen.css'! ! TLRootComponent initialize!