From: Timothy H. <tim...@ma...> - 2002-09-06 18:03:21
|
On Friday, September 6, 2002, at 01:17 PM, Ken Anderson wrote: > At 12:27 AM 9/6/2002, david may wrote: >> A wiki would be nice. I'd like Snippets of code and best practices >> for entry level schemers. Like the one you just posted;-) > > Yes, that would be a nice. I've been planning to write a couple of > examples of using Jscheme ... > > >> The first task is to write something parse up the input >> Any pointers some good teaching on that? > > Can you give more of a specification? Do you want to tokenize some > data? There are several nice ways to do that. I've got a demo wiki in Jscheme that is a few years old (It doesn't use the nice {[...]} notation for quasi-strings. I could send you the webapp if you want to play with it, or use it as a base for a really good wiki.... Below is an example of the tokenization code that converts CamelWords and http://web.addresses into wiki-links ... The key procedure is the camel procedure with five parameters (and I just noticed that the fifth is never used....) It returns true if the string starts with a Capital letter and consists entirely of letters and digits, and if it has a lowercase letter followed (eventually) by an uppercase letter. Note the use of the StringTokenizer to isolate the whitespace. > (define (Wiki-translate S) > > (define (isCamel T) > (define (isLetters I N T) > (if (>= I N) #t > (if (not (Character.isLetterOrDigit (.charAt T I))) > #f > (isLetters (+ I 1) N T)))) > (define (camel I N State T Upper) > (if (>= I N) #f > (if (not(Character.isLetterOrDigit (.charAt T I))) #f > (case State > ((lower?) (if (Character.isLowerCase (.charAt T I)) > (camel (+ 1 I) N 'upper? T Upper) > (camel (+ 1 I) N 'lower? T Upper))) > ((upper?) (if (Character.isUpperCase (.charAt T I)) > (isLetters I N T) > (camel (+ 1 I) N 'upper? T Upper))))))) > (define value > (and (Character.isUpperCase (.charAt T 0)) > (camel 0 (.length T) 'lower? T (.toUpperCase T)))) > value) > > (define (process T) > (cond ((isCamel T) > (string-append "<a href=\"wiki.servlet?mode=view&name=" > T > "\" target=_top>" > T > "</a>")) > ((.startsWith T "http://") > (string-append > "<a href=\"" > T > "\"> " > T > "</a>")) > (else T))) > > (define (processtokens Tokenizer buf) > (if (not (.hasMoreElements Tokenizer)) (.toString buf) > (begin (.append buf (process (.nextToken Tokenizer))) > (processtokens Tokenizer buf)))) > (processtokens (java.util.StringTokenizer. S " \t\n\r" #t) > (java.lang.StringBuffer.))) > This is used as follows: > > (Wiki-translate "This is a WikiWiki from http://jscheme.sf.net ... > PrettyCool huh?") > "This is a <a href=\"wiki.servlet?mode=view&name=WikiWiki\" > target=_top>WikiWiki</a> from <a href=\"http://jscheme.sf.net\"> > http://jscheme.sf.net</a> ... <a hre\ > f=\"wiki.servlet?mode=view&name=PrettyCool\" target=_top>PrettyCool</a> > huh?" The wiki.servlet generates a frame containing the full path of the named file and and a frame of action buttons (view,edit, ...) Any file that ends in .wiki is automatically redirected to a corresponding call to wiki.servlet Again if you want to see the full code, I can send it to you. It would be nice to redesign/rewrite the code with good comments.... ---Tim--- > >> davud >> >> >>>>> "Ken" == Ken Anderson <kan...@bb...> writes: >> >> Ken> Hi David, Tim has done a lot of nice web stuff for his >> Ken> course. We played with a wiki about a year ago, and i >> Ken> thought it was great. We should have an ongoing Wiki for >> Ken> Jscheme. Jscheme is great for writing web pages. There is a >> Ken> (<> ...) in elf/html-gen.scm. >> >> Ken> THere is also the {[]} syntax which is generally about as >> Ken> easy to use. >> >> Ken> I've be displaying histograms that grovel over 100,000 items >> Ken> with less than 12 lines of code: >> >> Ken> (define (histogram-table name rows) {<table border=1> <tr><td >> Ken> align=right>Count</td> <td align=left>[name]</td></tr> [(map >> Ken> (lambda (row) { <tr><td align=right>[(car row)]</td> <td >> Ken> align=left>[(cadr row)]</td></tr>}) rows)] </table>}) >> >> Ken> (define (histogram what items) (let ((what (default what >> Ken> 'none))) (sort (map* (project length (unique what)) (group-by >> Ken> what items)) (comparator > car)))) >> >> Ken> k >> >> Ken> At 06:53 PM 9/5/2002, david may wrote: >> >> Not much activity on this list lately .. perhaps I accidentally >> >> unsubscribed?? >> >> >> >> Anyhow I am "on the bench" right now and playing around with >> >> wikis. I was exploring a jsp wiki and as usual my first 10 >> >> minutes with JSP are "hey this is cool" and then it degenerates >> >> into a $@%# mess. Seems to me like jscheme would be a good >> >> choice to do a wiki in.. So I am going to look into it a >> >> little. Anybody else interested in this? >> >> >> >> >> >> >> >> >> >> ------------------------------------------------------- >> >> This sf.net email is sponsored by: OSDN - Tired of that same >> >> old cell phone? Get a new here for FREE! >> >> https://www.inphonic.com/r.asp?r=sourceforge1&refcode1=vs3390 >> >> _______________________________________________ Jscheme-devel >> >> mailing list Jsc...@li... >> >> https://lists.sourceforge.net/lists/listinfo/jscheme-devel >> >> >> ------------------------------------------------------- >> This sf.net email is sponsored by: OSDN - Tired of that same old >> cell phone? Get a new here for FREE! >> https://www.inphonic.com/r.asp?r=sourceforge1&refcode1=vs3390 >> _______________________________________________ >> Jscheme-devel mailing list >> Jsc...@li... >> https://lists.sourceforge.net/lists/listinfo/jscheme-devel > > > > ------------------------------------------------------- > This sf.net email is sponsored by: OSDN - Tired of that same old > cell phone? Get a new here for FREE! > https://www.inphonic.com/r.asp?r=sourceforge1&refcode1=vs3390 > _______________________________________________ > Jscheme-devel mailing list > Jsc...@li... > https://lists.sourceforge.net/lists/listinfo/jscheme-devel > |