'From Squeak3.2gamma of 15 January 2002 [latest update: #4827] on 5 May 2002 at 6:24:48 pm'! "Change Set: MailDB-Web Date: 5 May 2002 Author: ajr (Aaron Jon Reichow) A spiffy little Comanche module to web-enable your Celeste MailDB. See the class comment in MailDBModule for information on how to use it. "! Object subclass: #MailDBModule instanceVariableNames: 'mailDB ' classVariableNames: '' poolDictionaries: '' category: 'Network-Mail Reader'! !MailDBModule commentStamp: 'ajr 5/5/2002 15:45' prior: 0! MailDBModule is a Comanche module for browsing a MailDB, used by Celeste for storing email. I developed it under Squeak 3.2gamma and Comanche 4.9, but it should work in older and newer versions. For authorization support, you do need DictionaryHttpAuthorizationModule, which I obtained from: . Usage Examples: "Is you want authorization..." | s m users | s := ComancheNetService named: 'celesteDB' onPort: 9898. users := Dictionary new. users at: 'username' put: 'password'. "more than one user is possible!!" m := DictionaryHttpAuthorizationModule module: (MailDBModule newOn: (MailDB openOn: 'EMAIL')) realm: 'maildb' users: users. s module: m; start. "Without any authorization..." | s | s := ComancheNetService named: 'celesteDB' onPort: 9898. s module: (MailDBModule newOn: (MailDB openOn: 'EMAIL')); start.! !MailDBModule methodsFor: 'kom' stamp: 'ajr 5/5/2002 00:39'! categoryListTable | s | s _ WriteStream on: String new. s nextPutAll: '
Available Categories
'. ^ s contents! ! !MailDBModule methodsFor: 'kom' stamp: 'ajr 5/5/2002 00:04'! defaultResponse ^ (self standardHtmlHeader: 'Error!!'), 'Error in request. Start over. '! ! !MailDBModule methodsFor: 'kom' stamp: 'ajr 5/5/2002 16:54'! frontPage | s | s _ WriteStream on: String new. s nextPutAll: (self standardHtmlHeader: ('Categories in "', mailDB rootFilename, '"')); nextPutAll: '

MailDB Access

'; nextPutAll: self categoryListTable; nextPutAll: self searchFieldTable; nextPutAll: ''. ^ s contents! ! !MailDBModule methodsFor: 'kom' stamp: 'ajr 5/4/2002 20:02'! mailDB ^ mailDB! ! !MailDBModule methodsFor: 'kom' stamp: 'ajr 5/4/2002 20:02'! mailDB: aMailDB mailDB _ aMailDB! ! !MailDBModule methodsFor: 'kom' stamp: 'ajr 5/5/2002 18:12'! messagesIn: cat | s | s _ WriteStream on: String new. s nextPutAll: (self standardHtmlHeader: ('Messages in ', cat)); nextPutAll: '
Available Categories
';cr. (mailDB messagesIn: cat) do: [ :msgId | s nextPutAll: ''; nextPutAll: ''; nextPutAll: '' ]. s nextPutAll: '
MsgID From Subject
'; nextPutAll: msgId asString; nextPutAll: ''; nextPutAll: (mailDB getMessage: msgId) subject; nextPutAll: ''; nextPutAll: (mailDB getMessage: msgId) from; nextPutAll: '
'. ^ s contents! ! !MailDBModule methodsFor: 'kom' stamp: 'ajr 5/5/2002 15:48'! process: request | chunks | chunks _ request url findTokens: '/'. (request url = '/') ifTrue: [ ^ self frontPage ]. ((chunks size = 1) and: [mailDB allCategories includes: chunks first]) ifTrue: [ ^ self messagesIn: chunks first ]. ((chunks size = 2) and: [chunks first = 'full']) ifTrue: [ ^ self showFull: chunks second asInteger]. ((chunks size = 2) and: [chunks first = 'search']) ifTrue: [ ^ self search: chunks second ]. (chunks size = 2) ifTrue: [ ^ self showMessage: chunks second asInteger]. (request url = '/search/') ifTrue: [ ^ self search: (request postFields at: 'search') ]. ^ self defaultResponse! ! !MailDBModule methodsFor: 'kom' stamp: 'ajr 5/5/2002 18:12'! search: searchStr | msgs matching s | msgs _ mailDB messagesIn: '.all.'. matching _ OrderedCollection new: 4. s _ WriteStream on: String new. s nextPutAll: (self standardHtmlHeader: ('Messages matching ', searchStr)); nextPutAll: '
Available Categories
';cr. msgs do: [ :msgId | (searchStr match: (mailDB getText: msgId)) ifTrue: [ matching add: msgId ] ]. matching do: [ :msgId | s nextPutAll: ''; nextPutAll: ''; nextPutAll: '' ]. s nextPutAll: '
MsgID From Subject
'; nextPutAll: msgId asString; nextPutAll: ''; nextPutAll: (mailDB getMessage: msgId) subject; nextPutAll: ''; nextPutAll: (mailDB getMessage: msgId) from; nextPutAll: '
'. ^ s contents! ! !MailDBModule methodsFor: 'kom' stamp: 'ajr 5/5/2002 16:51'! searchFieldTable | s | s _ WriteStream on: String new. ^ s nextPutAll: '
Search
'; nextPutAll: '
'; nextPutAll: 'Use * and # as wildcards. For example, to search for "squeak," enter "*squeak*" in the input field.
'; contents! ! !MailDBModule methodsFor: 'kom' stamp: 'ajr 5/5/2002 00:11'! showFull: msgID | s | s _ WriteStream on: String new. s nextPutAll: (self standardHtmlHeader: ('Message #', msgID asString)); nextPutAll: '
';
		nextPutAll: (mailDB getMessage: msgID) text;
		nextPutAll: '
'. ^ s contents! ! !MailDBModule methodsFor: 'kom' stamp: 'ajr 5/5/2002 18:13'! showMessage: msgID | s | s _ WriteStream on: String new. s nextPutAll: (self standardHtmlHeader: ('Message #', msgID asString)); nextPutAll: '
From: '; nextPutAll: (mailDB getMessage: msgID) from; nextPutAll: '
Subject: '; nextPutAll: (mailDB getMessage: msgID) subject; nextPutAll: '
';
		nextPutAll: (mailDB getMessage: msgID) body content "asUnHtml";
		nextPutAll: '
'; nextPutAll: '
See Raw Text
'; nextPutAll: ''. ^ s contents! ! !MailDBModule methodsFor: 'kom' stamp: 'ajr 5/4/2002 23:42'! standardHtmlHeader ^ self standardHtmlHeader: ''! ! !MailDBModule methodsFor: 'kom' stamp: 'ajr 5/4/2002 23:56'! standardHtmlHeader: title ^ ' ', title, ''! ! !MailDBModule class methodsFor: 'as yet unclassified' stamp: 'ajr 5/4/2002 20:01'! newOn: aMailDB ^ self new mailDB: aMailDB! ! MailDBModule removeSelector: #categoryList! MailDBModule removeSelector: #showMessage!