Small Reddit, A Seaside Sample Application
By Ramon Leon - 20 April 2007 under Magritte, Programming, Seaside, Smalltalk
I just uploaded a simple reddit clone sample Seaside application to SqueakSource. It's meant be a very simple reference application to learn from, it's only about 4 hours work total. There are comments throughout, and various techniques are used to demonstrate different ways of doing things. Some forms are generated directly via Seaside and some other by Magritte. Persistence is implement in image using dictionaries and collections.
Features include login, register, add entry, vote on entry, comment on entry, comment on comment. There are probably a few bugs. I'm not making any claims of best practice, only showing various ways I accomplish things to suite my needs.
Hopefully such an application will make Seaside more approachable for the newbie and help ease the lack of documentation available. I know when I first started learning, I was far more interested in actual samples than outdated documents. Enjoy!
UPDATE: Loading this code requires that you create a repository in Monticello. Just create a new HTTP repository with the following template using the +Repository button.
MCHttpRepository location: 'http://www.squeaksource.com/SmallReddit' user: '' password: ''
Once done, you can open the repository, select the package, and load it. It will create an application on localhost at /seaside/smallReddit, on whatever port you're running Seaside on. You could also just download the mcz file directly and drag and drop it into your squeak image, at which point you'll be prompted and asked what you'd like to do.
See my previous screencast about using Monticello for a quick visual on using Monticello.
Comments (automatically disabled after 1 year)
Where TimeStamp responds to what?
Try DateAndTime, in 3.9 TimeStamp subclasses it, which is where the #- implementation is.
Thanks for sharing this example ! I need all the examples I can find at this point :)
Is it called "Small Reddit" because the textareas are so small ? :)
Seriously, I'm new to Seaside and Squeak/Smalltalk programming and I'm looking through the docs, but haven't found where the textarea sizes are set. Can you give me a hint ?
Mike
The text sizes aren't set anywhere, that kind of stuff belongs in CSS. Style it however you like. It's called Small Reddit as in Smalltalk Reddit.
Ramon,
So much for my humour ;)
Do know what the syntax is for what I need to put in the style selector to change the textarea size ?
I've googled for 'css textarea' .. 'texarea css' and other variations / tutorials, but haven't found the right 'magic' words. There is not much documentatoin on the Seaside site either. I'm digging through the Pier application to see how the textareas have been setup but haven't found it yet either.
If not ... I'll keep looking :)
Mike
Oh, my bad, CSS is pretty simple. To style all tags of a type, just use the tag name
textarea {width:200px;}
to style a specific tag by name, use its id
#notesField {width:200px;}
to style it by class, assign a class to the tag, and create a CSS class for it
.bigTextAreas {width:200px;}
I just take it for granted that anyone getting into programming in Seaside, already has a decent knowledge of basic CSS. I can't imagine learning Seaside before learning CSS, it wouldn't make sense.
Thanks very much for that info, it will help me a lot.
Mike
I am a bit like some of these other guys and finding it a bit hard to figure out where and what methods are the best to do things with.
I am using Magritte to handle the generic input form that we have which has about 20 fields. They are basically a pulldown menu and then a possible comment on the result. (this is for a safety application) By default Margritte lays them down one after the other in a list style. We want to have it displayed in 2-3 columns across so that it all fits on one screen. Is this something that magritte can do or do we need to a totally custom screen? I keep finding references in the magritte area that says just set a custom rendering together and override the defaults but can't find any descriptions or examples of what this might look like and am just not bright enough to figure it out on my own. Any pointing in the right direction would be appreciated. Nice work.
On the class side of your model, or your model base class, just do this...
descriptionContainer ^super descriptionContainer componentRenderer: YourCustomRenderer; yourself
Have a look at MATableRenderer and MACssRenderer to see how to write a renderer.
Using SmallReddit with the latest squeak-web image from damien.cassou and the 3.10 vm, I get a walkback: MessageNotUnderstood: WAMessageDecoration>>onAnswer:
* WAMessageDecoration(Object)>>doesNotUnderstand: #onAnswer:
self a WAMessageDecoration
temps
aMessage onAnswer: [] in SRSmallRedditHome(WAComponent)>>show:onAnswer:delegation: {[:value | aDelegation re...etc...
inst vars
next a WAStateHolder(a MAValidationDecoration)
message 'Submit New Article'
* SRSmallRedditHome(WAComponent)>>show:onAnswer:delegation:
self a SRSmallRedditHome
temps
aComponent a WAMessageDecoration
aBlock an AnswerContinuation
aDelegation a WADelegation
event nil
value nil
inst vars
decoration a WAStateHolder(a WAAnswerHandler)
errors nil
pagedEntries a WABatchedList
* SRSmallRedditHome(WAComponent)>>show:onAnswer:
self a SRSmallRedditHome
temps
aComponent a WAMessageDecoration
aBlock an AnswerContinuation
inst vars
decoration a WAStateHolder(a WAAnswerHandler)
errors nil
pagedEntries a WABatchedList
Ah, OK, fixed, it'll run in Seaside 2.8 now, SqueakSource updated.
It needs a new image, where TimeStamp responds to -