From mneumann at ntecs.de Wed Jan 26 06:19:24 2005 From: mneumann at ntecs.de (Michael Neumann) Date: Wed Jan 26 06:16:37 2005 Subject: [Wee-talk] Re: Wee 0.4.1 In-Reply-To: References: <000501c50304$6eeac7c0$6401a8c0@khowe> <41F69150.6080608@ntecs.de> Message-ID: <41F77CBC.1030001@ntecs.de> Avi Bryant wrote: > On Tue, 25 Jan 2005 19:34:56 +0100, Michael Neumann wrote: > > >># note that css_class_for automatically prepends "css." to the >># property, image.src_for prepends "img." >>app.properties = { >> Pager => { >> 'css.pager' => 'webtable-paging', >> 'css.page-img' => 'webtable-page-img', >> 'img.first' => '/tmp/first.gif' >> } >>} >> >>If the lookup of properties turns out to be too slow, I might cache >>successful lookups. I also think about some kind of default_properties >>for a given class. > > >>What do you think of this property system? Do you think it's worthwhile? >>Any additional suggestions? > > > Meta: we should really start a mailing list for wee-dev or possibly > for some wider scope of "Wee and Seaside like frameworks". I could > ask the Seaside list if they would be interested in such discussions > happening there, if you like... I've CCed to wee-talk@rubyforge.org. If you could post there too? > As for the property system, specifically relating to CSS: I went > through a similar approach and then rejected it in favor of just using > CSS the way it was designed, which is to say, hardcoding the CSS > classes into a component and then having context-sensitive > stylesheets. To give you an idea of what I mean: the pager would > always use "paging" and "page-img", and the webtable would have a > "webtable" div around it, and then in your stylesheet you can have: > > .paging {/* default styles for pager */} > .webtable .paging {/* (additional) default styles for pager inside webtable */} > .myapp .webtable .paging {/* tweaks necessary for a specific application */} > > And so on. It's perhaps not quite so flexible (CSS isn't turing > complete, sadly...), but it's definitely more idiomatic. What do you > think? Yes, I think that's fine. Well, to avoid top-level collisions (".paging", e.g. if you have two Pager compoenents which look different), you could use a property, only for the toplevel element: r.div.css_class_for('css.pager').with { .. r.xxx.css_class( } That's probably better than using a property for every element. I had implemented a simpler approach before, which just calls #css_namespace of the component and uses this as prefix (but this isn't as flexible, and an #img_path method would be needed too...). Good news is, that the property system is completely optional. You need not use it! I'll leave it in and see where it's applicable and where not (hehe, should learn a little bit CSS2 before ;-). Regards, Michael From mneumann at ntecs.de Wed Jan 26 21:34:04 2005 From: mneumann at ntecs.de (Michael Neumann) Date: Wed Jan 26 21:31:16 2005 Subject: [Wee-talk] [ANN] Wee 0.5.0 Message-ID: <41F8531C.3040103@ntecs.de> Hi, Wee 0.5.0 is out. Have fun! Major changes are: * Support for live-updates (see examples/live-update.rb). Only client-side is missing (javascript). * Factored out all continuation-dependent code into wee/continuation. By default Wee uses no continuations until you require 'wee/continuation'. This has the nice effect, that non-continuation-based application now run a little bit faster and uses less memory. * Added an OgScaffolder class (see examples/og-test.rb). You can create/update/delete Og domain-objects. This was just a test for using Wee+Og. It's not a very advanced scaffolder. Nemo[1] can do better. * Added an experimental property system, which can make your components more independent of external resources (e.g. image-path). * Changed the status from alpha to beta ;-) I consider Wee now as pretty stable (run-time wise). Few code will probably change. For the full list of changes (since I started the ChangeLog) see [2]. == The Ultimate Hello World require 'wee' class HelloWorld < Wee::Component def click @clicks = (@clicks || 0) + 1 end def render r.h1.onclick_callback(:click).with("Hello World!") r.text "#{ @clicks || 'No' } clicks" end end # And start the WEBrick web-server require 'wee/utils' require 'wee/adaptors/webrick' app = Wee::Utils.app_for { c = HelloWorld.new c.add_decoration(Wee::PageDecoration.new(title="Hello World")) c } Wee::WEBrickAdaptor.register('/app' => app).start Make sure you run this application with the -rubygems option. Then point your browser to http://localhost:2000/app and click on the h1-header. Every time you click on it, you should see that the number of clicks increases. Have fun! == Future Work I am currently implementing Cookie-support and Page-less sessions (no backtracking). It's already done and works well, but needs some further refactoring. This let's you write dynamic web-sites whose URL looks like "http://blah.net/app" all the time. If you want you can change the URL after /app to whatever you want, but note that it's model is completely different that e.g. Rails. Wee does not has multiple controllers, it has exactly one root-component with as many sub-components and sub-sub-components as you like. A simple tutorial is also on my todo list ;-) == Documentation Look here [3]. Regards, Michael --------------------------------------------------------------------- [1] http://rubyforge.org/projects/nemo [2] http://www.ntecs.de/viewcvs/viewcvs/Wee/trunk/ChangeLog?view=auto [3] http://www.ntecs.de/viewcvs/viewcvs/*checkout*/Wee/trunk/doc/rdoc/index.html From mneumann at ntecs.de Wed Jan 26 21:43:24 2005 From: mneumann at ntecs.de (Michael Neumann) Date: Wed Jan 26 21:40:39 2005 Subject: [Wee-talk] Re: [ANN] Wee 0.5.0 In-Reply-To: <41F8531C.3040103@ntecs.de> References: <41F8531C.3040103@ntecs.de> Message-ID: <41F8554C.6090808@ntecs.de> Michael Neumann wrote: > Hi, > > Wee 0.5.0 is out. Have fun! Oops, I forgot to mention how to install it ;-) gem install wee And don't forget -rubygems or require 'rubygems' if you use Rubygems... Regards, Michael From cjs at cynic.net Wed Jan 26 22:25:44 2005 From: cjs at cynic.net (Curt Sampson) Date: Wed Jan 26 22:31:14 2005 Subject: [Wee-talk] Re: [ANN] Wee 0.5.0 In-Reply-To: <41F8554C.6090808@ntecs.de> References: <41F8531C.3040103@ntecs.de> <41F8554C.6090808@ntecs.de> Message-ID: On Thu, 27 Jan 2005, Michael Neumann wrote: > Oops, I forgot to mention how to install it ;-) > gem install wee How about a non-gem copy for those of us who use configuration management on our ruby code? cjs -- Curt Sampson +81 90 7737 2974 http://www.NetBSD.org Make up enjoying your city life...produced by BIC CAMERA From mneumann at ntecs.de Wed Jan 26 22:49:13 2005 From: mneumann at ntecs.de (Michael Neumann) Date: Wed Jan 26 22:46:24 2005 Subject: [Wee-talk] Re: [ANN] Wee 0.5.0 In-Reply-To: References: <41F8531C.3040103@ntecs.de> <41F8554C.6090808@ntecs.de> <41F860EF.1090708@ntecs.de> Message-ID: <41F864B9.6090409@ntecs.de> Joao Pedrosa wrote: > Hi, > > On Thu, 27 Jan 2005 12:33:17 +0900, Michael Neumann wrote: > >>Joao Pedrosa wrote: >> >>>Hi, >>> >>>On Thu, 27 Jan 2005 12:26:10 +0900, Curt Sampson wrote: >>> >>> >>>>On Thu, 27 Jan 2005, Michael Neumann wrote: >>>> >>>> >>>> >>>>>Oops, I forgot to mention how to install it ;-) >>>>>gem install wee >>>> >>>>How about a non-gem copy for those of us who use configuration >>>>management on our ruby code? >>> >>> >>>I second this. I particularly don't use gems. :-) >> >>No problem, will do. Hm, now the question is, which install.rb program I >>should use? Any hints? Can I expect rake (Ruby make) to be installed? > > > This one? > http://raa.ruby-lang.org/project/setup/ I've rolled on my own install.rb. Download the tar.gz from here: http://rubyforge.org/frs/?group_id=427 Then do a "ruby install.rb". Regards, Michael From mneumann at ntecs.de Wed Jan 26 23:13:03 2005 From: mneumann at ntecs.de (Michael Neumann) Date: Wed Jan 26 23:10:15 2005 Subject: [Wee-talk] Re: [ANN] Wee 0.5.0 In-Reply-To: <66b7e34b050126193953793203@mail.gmail.com> References: <41F8531C.3040103@ntecs.de> <66b7e34b050126193953793203@mail.gmail.com> Message-ID: <41F86A4F.10606@ntecs.de> Bill Atkins wrote: > What's the philosophy behind Wee? What are some of its features? Wee's core is very small (but powerful). Including lots of documentation the core is currently just 847 lines. That's where the name originally comes from. Features: * You don't have to care about the HTTP protocol, you don't have to build URL, add query parameters or name form-fields etc... * You can write real components. * Backtracking (Make the browsers back-button working fine) * It comes with a powerful programmatic HTML renderer. Example: # select an object from these items items = [1, 2, 3, 4] # the labels shown to the user labels = items.map {|i| i.to_s} # render it... callback is called with the choosen object from the # items array r.select_list(items).labels(labels).callback {|choosen| p choosen} # render a multi-select list, with objects 2 and 4 selected r.select_list(items).multi.labels(labels).selected([2,4]) Note that in the example above, you don't have to encode the items as you would probably have to in Rails. The items could be any object (Strings, Components... ANY object). * You can call other components. This replaces the current component until the called component returns. Note that this only affect the current component and not it's possible parent components. * You can add decorations to components, which is a very powerful concept. Useful for rendering header/footer around a component, or to prevent unauthorized access to a component etc... * Pure Ruby. What I like is that you don't have to switch between different files (controller and view). Both are dependent anyway. This makes it easier to distribute components, as they are usually only one file. That does not mean, that you can't use templates, you can! * Continuations! This is optional. Might lead to memory problems, but the last memory stress-test was quite positive... needs further testing. * Nemo: rubyforge.org/projects/nemo You can read more about it's features on that page: http://www.ntecs.de/viewcvs/viewcvs/*checkout*/Wee/trunk/doc/rdoc/index.html Stay tuned! I'm currently working on setting up a page dedicated to Wee: http://ruwee.de (it's empty yet). If you're interested in Wee, you might be also interested in Seaside2, Wee's big brother: www.seaside.st. Regards, Michael > Bill > > On Thu, 27 Jan 2005 11:34:19 +0900, Michael Neumann wrote: > >>Hi, >> >>Wee 0.5.0 is out. Have fun! >> >>Major changes are: >> >> * Support for live-updates (see examples/live-update.rb). Only >> client-side is missing (javascript). >> >> * Factored out all continuation-dependent code into wee/continuation. >> By default Wee uses no continuations until you require >> 'wee/continuation'. This has the nice effect, that >> non-continuation-based application now run a little bit faster and >> uses less memory. >> >> * Added an OgScaffolder class (see examples/og-test.rb). You can >> create/update/delete Og domain-objects. This was just a test for >> using Wee+Og. It's not a very advanced scaffolder. Nemo[1] can do >> better. >> >> * Added an experimental property system, which can make your >> components more independent of external resources (e.g. >> image-path). >> >> * Changed the status from alpha to beta ;-) >> I consider Wee now as pretty stable (run-time wise). Few code will >> probably change. >> >>For the full list of changes (since I started the ChangeLog) see [2]. >> >>== The Ultimate Hello World >> >> require 'wee' >> >> class HelloWorld < Wee::Component >> def click >> @clicks = (@clicks || 0) + 1 >> end >> >> def render >> r.h1.onclick_callback(:click).with("Hello World!") >> r.text "#{ @clicks || 'No' } clicks" >> end >> end >> >> # And start the WEBrick web-server >> require 'wee/utils' >> require 'wee/adaptors/webrick' >> >> app = Wee::Utils.app_for { >> c = HelloWorld.new >> c.add_decoration(Wee::PageDecoration.new(title="Hello World")) >> c >> } >> Wee::WEBrickAdaptor.register('/app' => app).start >> >>Make sure you run this application with the -rubygems option. Then point >>your browser to http://localhost:2000/app and click on the h1-header. >>Every time you click on it, you should see that the number of clicks >>increases. Have fun! >> >>== Future Work >> >>I am currently implementing Cookie-support and Page-less sessions (no >>backtracking). It's already done and works well, but needs some further >>refactoring. This let's you write dynamic web-sites whose URL looks like >>"http://blah.net/app" all the time. If you want you can change the URL >>after /app to whatever you want, but note that it's model is completely >>different that e.g. Rails. Wee does not has multiple controllers, it has >>exactly one root-component with as many sub-components and >>sub-sub-components as you like. >> >>A simple tutorial is also on my todo list ;-) >> >>== Documentation >> >>Look here [3]. >> >>Regards, >> >> Michael >> >>--------------------------------------------------------------------- >>[1] http://rubyforge.org/projects/nemo >>[2] http://www.ntecs.de/viewcvs/viewcvs/Wee/trunk/ChangeLog?view=auto >>[3] >>http://www.ntecs.de/viewcvs/viewcvs/*checkout*/Wee/trunk/doc/rdoc/index.html >> >> > > > From mneumann at ntecs.de Thu Jan 27 07:40:38 2005 From: mneumann at ntecs.de (Michael Neumann) Date: Thu Jan 27 07:37:50 2005 Subject: [Wee-talk] Re: [ANN] Wee 0.5.0 In-Reply-To: <6227EB6D-7024-11D9-A44F-000A95DF1FB4@yakima-herald.com> References: <41F8531C.3040103@ntecs.de> <41F8554C.6090808@ntecs.de> <6227EB6D-7024-11D9-A44F-000A95DF1FB4@yakima-herald.com> Message-ID: <41F8E146.8030807@ntecs.de> Ezra Zygmuntowicz wrote: > Michael- > Can you explain once more how to start a web app up after gem > installing wee? What am I supposed to do next? I'm not entirely sure > about how to proceed but I would like to check wee out. Okay, if you have put the example I gave in my announce post into file "hello.rb", then you start it like this: ruby -rubygems hello.rb Alternatively, set the RUBYOPT environment variable to -rubygems: export RUBYOPT=-rubygems Or for csh: setenv RUBYOPT -rubygems Then you can start hello.rb like this: ruby hello.rb The third way is to simply put this line require 'rubygems' at the top of hello.rb. Now you can start it like any other Ruby file (this should easily work on windows too). Hope this helps! Regards, Michael From mneumann at ntecs.de Thu Jan 27 11:29:38 2005 From: mneumann at ntecs.de (Michael Neumann) Date: Thu Jan 27 11:26:52 2005 Subject: [Wee-talk] Re: [Nitro] Re: fixed boolean In-Reply-To: References: <41F8F8AF.5080206@ntecs.de> <41F8FFF6.1080109@ntecs.de> <41F90A10.5050102@ntecs.de> Message-ID: <41F916F2.7070905@ntecs.de> George Moschovitis wrote: >>Could you give a little example on how you generate just a session-id? > > > Sure: > > # Calculates a unique id. > # > # The session id must be unique, a monotonically > # increasing function like time is appropriate. Random > # may produce equal ids? add a prefix (SALT) to stop > # hackers from creating session_ids. > > def create_id > now = Time.now > md5 = Digest::MD5.new > md5.update(now.to_s) > md5.update(now.usec.to_s) > md5.update(rand(0).to_s) > md5.update(Session.session_id_salt) > md5.hexdigest > end Thanks. Will use this as default session-id generator until I include ISAAC. >>I've now taken a look at your FormBuilder. How exactly can I define >>those meta-attributes? I saw, you use meta[:ui] == :textarea... >>Ah sorry, I found it already myself: >> >> prop_accessor :attr, :ui => :textarea >> >>will do. > > > As you can see the FormBuilder is under construction, If you have any > good ideas, let me know :) I do have some cool ideas for this, you > will see in Nitro 0.10.0 :) Mine is called OgScaffolder::Editor. I factored the rendering into following methods: * render (top level) -> calls render_property for each property -> then calls render_buttons * render_property -> calls render_label -> then calls depending on the property type one of render_numeric, render_string, render_bool etc. This makes it easier to customize layout. My editor also does not render a
tag, this can be done by adding a FormDecoration to the component. The advantage: You can put as many Editors on a page as you like, and when you hit a button, you don't loose what you entered in the other forms. If you click Save or Cancel, my editor returns (answers), so that you can use it like this: def show_editor call Editor.new(Customer.new), :on_answer end def on_answer(res) ... end Of course you can use it without using #call. But then you have to wrap it with a AnswerDecoration. Then I'll have a OgScaffolder::ListView which shows multiple domain-objects in a table. Regards, Michael From george.moschovitis at gmail.com Thu Jan 27 11:54:52 2005 From: george.moschovitis at gmail.com (George Moschovitis) Date: Thu Jan 27 12:50:14 2005 Subject: [Wee-talk] Re: [Nitro] Re: fixed boolean In-Reply-To: <41F916F2.7070905@ntecs.de> References: <41F8F8AF.5080206@ntecs.de> <41F8FFF6.1080109@ntecs.de> <41F90A10.5050102@ntecs.de> <41F916F2.7070905@ntecs.de> Message-ID: > Mine is called OgScaffolder::Editor. I factored the rendering into > ... > Then I'll have a OgScaffolder::ListView which shows multiple > domain-objects in a table. Seems to me, we are writing the same code twice :( For example I am planning to do a TableBuilder that does this. We should probably synchronize our efforts and build something together. But then again, perhaps it is better If you go alone and create your version, so we can compare the two aproaches afterwards. -g. PS: updating Nitro 'docs' right now, this is pain in the a**. -- www.rubyforge.com/projects/nitro www.joy.gr