...however, I hope we get to the point that the 100 top "simple" things can be as easy as:
<preview-with-more> <model:Recipe/> <count:10/> </preview-with-more> ..which will use the default cards, etc. Matt, I am confident you can do this for people like me with many brain cells killed over the past 30 years. :-) On Dec 3, 9:01 pm, Owen Dall <[email protected]> wrote: > Thanks much again, Matt, for your expertise! > > > > On Thu, Dec 3, 2009 at 8:07 PM, Matt Jones <[email protected]> wrote: > > > On Dec 3, 2009, at 6:08 PM, Dave Porter wrote: > > > > Hi Owen, Sorry yes this was a bit vague ! > > > > This is what is currently in the Cookbook index.dryml for the front > > > page > > > So the '<preview-with-more name="recent recipes" > > > with="&Recipe.recent"/ > > >> ' > > > > Is the code that is displaying the list of recipes on the front page. > > > > I need to understand how this works ? > > > To start with, you typically want to figure out the context the tag > > ends up running in. Here, the with= attribute is setting the context > > to Recipe.recent (a named scope on Recipe that sorts models in > > descending order by created_at - it's defined in automatic_scopes). > > The recent scope accepts the number of records to limit the source as > > a parameter, or defaults it to 6 (as in this case). > > > For the rest, track down the source of preview-with-more; you'll find > > it in rapid_plus.dryml (in the hobo plugin). As an aside, a good text > > editor with "Search all files" pointed at the hobo source is pretty > > much a standard tool - heck, it used to *be* the documentation. > > > Anyway, the source of preview-with-more: > > > <!-- Captures the common pattern of a list of "the first few" cards, > > along with a link to the rest. --> > > <def tag="preview-with-more" attrs="name"> > > <% name ||= collection_name.pluralize -%> > > <section class="#{name.gsub(' ', '-').dasherize} preview-with-more" > > param="default"> > > <h3 param="heading"><%= name.titleize %></h3> > > <a param="more">More <type-name plural lowercase/>...</a> > > <collection param/> > > <a action="new" if="&can_create?(this.new)" param="new-link">New < > > %= this.member_class.view_hints.model_name %></a> > > </section> > > </def> > > > Most of this should be pretty self-explanatory. The meat of the action > > here is in the collection tag. That's defined over in > > rapid_generics.dryml: > > > <def tag="collection"> > > <ul class="collection #{collection_name :dasherize => true}" merge- > > attrs unless="empty?"> > > <li param="item" class="#{scope.even_odd} #{model_id_class}" > > repeat="&select_viewable"> > > <do param="default"><card param/></do> > > </li> > > </ul> > > <empty-collection-message param="empty-message"/> > > </def> > > > This creates the actual list of Recipe cards; note that the card tag > > is just a default here, as calling the collection tag like this: > > > <collection> > > <some-tag /> > > </collection> > > > Will repeat some-tag instead of card. > > > Next you look up where the card for Recipe is defined; in this case, > > it's in app/views/taglibs/application.dryml (in the hobocookbook > > source): > > > <extend tag="card" for="Recipe"> > > <old-card merge without-count> > > <before-heading:><gravatar:user size='50' param/></before-heading:> > > <creator-link: replace><div param="user">By: <a:user/></div></ > > creator-link:> > > <append-body:> > > <div param="timestamp"> > > <if test="&this.created_at == this.updated_at"> > > <view:created-at.to-date/> > > </if> > > <else> > > Updated: <view:updated-at.to-date/> > > </else> > > </div> > > </append-body:> > > </old-card> > > </extend> > > > Note that this is extending the base card (autogenerated in app/views/ > > taglibs/auto/rapid/cards.dryml): > > > <def tag="card" for="Recipe"> > > <card class="recipe" param="default" merge> > > <header: param> > > <h4 param="heading"><a><name/></a></h4> > > </header:> > > <body: param> > > <a:user param="creator-link"/> > > <ht key="comments.collection.count" count="&this.comments.size"> > > <count:comments param/> > > </ht> > > </body:> > > </card> > > </def> > > > With the modifiers in the extended definition, the actual definition > > looks more like: > > > <def tag="card" for="Recipe"> > > <card class="recipe" param="default" merge> > > <gravatar:user size='50' param/> > > <header: param> > > <h4 param="heading"><a><name/></a></h4> > > </header:> > > <body: param> > > <div param="user">By: <a:user/></div> > > <ht key="comments.collection.count" count="&this.comments.size"> > > <count:comments param/> > > </ht> > > <div param="timestamp"> > > <if test="&this.created_at == this.updated_at"> > > <view:created-at.to-date/> > > </if> > > <else> > > Updated: <view:updated-at.to-date/> > > </else> > > </div> > > </body:> > > </card> > > </def> > > > One can follow this rabbit hole for quite a while longer, but I hope > > this helps! > > > --Matt Jones > > > -- > > > You received this message because you are subscribed to the Google Groups > > "Hobo Users" group. > > To post to this group, send email to [email protected]. > > To unsubscribe from this group, send email to > > [email protected]<hobousers%[email protected]> > > . > > For more options, visit this group at > >http://groups.google.com/group/hobousers?hl=en. > > -- > Thanks, > > Owen > > Owen Dall > Barquin International > 410-991-0811 -- You received this message because you are subscribed to the Google Groups "Hobo Users" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/hobousers?hl=en.
