From: Noam W. <nwe...@er...> - 2009-01-29 19:24:53
|
Sounds good, Bodo! -----Original Message----- From: Bodo Schulze <bo...@le...> Date: Thu, 29 Jan 2009 19:08:48 To: <nwe...@er...> Cc: Bodo Schulze<bo...@le...>; krang-devel<kra...@li...> Subject: Re: [Krang-devel] story->url vs. $story->preview_url Yes, Noam, I stick to named parameters, even if it's not obvious what the hell could be added later. Too many times this need arose when I was sure it would not! And thanx for the "Site" hint! Bodo > I like that, Bodo - I agree it's clearer and easier. In fact, since there's a > single parameter, I'm not sure even the "object" key is necessary, but I gue > ss named parameters make sense in case a second argument is added later. Noam > P.S. It would work for Site objects, too! > -----Original Message----- > From: Bodo Schulze <bo...@le...> > > Date: Thu, 29 Jan 2009 17:54:01 > To: Noam Weinstein<nwe...@er...> > Cc: Bodo Schulze<bo...@le...>; krang-devel<kra...@li...urcefor > ge.net> > Subject: Re: [Krang-devel] story->url vs. $story->preview_url > > > Hey Noam, I'm happy you brought this up again. It pushed me to think > about my insatisfaction with Krang::URL. Maybe we can do just better > than > > my $url = pkg('URL')->real_url(object => $story, publisher => $publisher); > > It's a bit verbose, and lengthy to type. So how about this: > > $publisher->url_for(object => $story); > $publisher->url_for(object => $media); > $publisher->url_for(object => $category); > $publisher->url_for(object => $whatever_has_the_required_methods); > > 'real_url' is somewhat mysterious, while 'url_for', begin invoked on the > publisher object, clearly indicates that we need the URL for publishing > (to preview). It almost reads as an English sentence. > > Make sense? > > Bodo > > > Oh - great! I didn't remember this had been added; guess I've been stuck in > > > old code for too long... > > > > Thanks for the heads-up, Bodo - > > Noam > > > > -------------------------------------------------- > > From: "Bodo Schulze" <bo...@le...> > > Sent: Monday, January 26, 2009 7:57 AM > > To: "Noam Weinstein" <nwe...@er...> > > Cc: "Bodo Schulze" <bo...@le...>; "krang-devel" > > <kra...@li...> > > Subject: Re: [Krang-devel] story->url vs. $story->preview_url > > > > > Hey Noam, > > > > > > you might want to check out Krang::URL > > > > > > Thanx! > > > > > > Bodo > > > > > >> On the topic of convenience methods, does anyone else find themselves > > >> endlessly writing > > >> > > >> my $story_url = $publisher->is_preview ? $story->preview_url : > > >> $story->url; > > >> > > >> ? > > >> > > >> If so, how about an optional parameter to Krang::Story->url and > > >> Krang::Media->url, as in > > >> > > >> my $story_url = $story->url($publisher); > > >> > > >> and > > >> > > >> my $media_url = $media->url($publisher); > > >> > > >> They wouldn't have any effect unless $publisher->is_preview == 1, in > > >> which > > >> case they would pass the call to preview_url > > >> > > >> ? > > >> > > >> -------------------------------------------------- > > >> From: "Bodo Schulze" <bo...@le...> > > >> Sent: Wednesday, January 21, 2009 5:28 PM > > >> To: "Noam Weinstein" <nwe...@er...> > > >> Cc: "Bodo Schulze" <bo...@le...>; "krang-devel" > > >> <kra...@li...> > > >> Subject: Re: [Krang-devel] Proposal for two optional arguments > > >> to$story->category() > > >> > > >> > Will do if nobody objects. Any other thoughts on this? > > >> > > > >> > Bodo > > >> > > > >> >> Sounds good to me! Also might be nice to have an option that returns > > >> >> just > > >> >> the depth, like > > >> >> $story->category(depth_only => 1) ? > > >> >> > > >> >> -------------------------------------------------- > > >> >> From: "Bodo Schulze" <bo...@le...> > > >> >> Sent: Wednesday, January 21, 2009 2:19 PM > > >> >> To: "krang-devel" <kra...@li...> > > >> >> Subject: [Krang-devel] Proposal for two optional arguments > > >> >> to$story->category() > > >> >> > > >> >> > Hi guys, > > >> >> > > > >> >> > in my publishing code I often have to make decisions based on the > > >> >> > position of a story in the category tree, e.g. do something if the > > >> >> > story > > >> >> > has a primary category being equal or living below category /xyz > > >> >> > > > >> >> > It's a pain to code this over and over again. So how about adding > > >> >> > these > > >> >> > signatures to $story->category(): > > >> >> > > > >> >> > $story->category(level => $num); > > >> >> > $story->category(level => $num, dir_only => 1); > > >> >> > > > >> >> > Level 0 would be the root category, level 1 the first level categor > y > > >> >> > and > > >> >> > so on. Would return the category or undef if the category does not > > >> >> > exist. > > >> >> > > > >> >> > Given 'dir_only' it would return just the category's directory or > > >> >> > the > > >> >> > empty string (if the category does not exist). > > >> >> > > > >> >> > Make sense? > > >> >> > > > >> >> > Warmest, > > >> >> > > > >> >> > Bodo > > >> >> > > > >> >> > ------------------------------------------------------------------- > -- > > --- > > >> --- > > >> >> --- > > >> >> > This SF.net email is sponsored by: > > >> >> > SourcForge Community > > >> >> > SourceForge wants to tell your story. > > >> >> > http://p.sf.net/sfu/sf-spreadtheword > > >> >> > _______________________________________________ > > >> >> > Krang-devel mailing list > > >> >> > Kra...@li... > > >> >> > https://lists.sourceforge.net/lists/listinfo/krang-devel > > >> >> > > > >> > > > >> > > >> ------------------------------------------------------------------------ > -- > > --- > > >> - > > >> This SF.net email is sponsored by: > > >> SourcForge Community > > >> SourceForge wants to tell your story. > > >> http://p.sf.net/sfu/sf-spreadtheword > > >> _______________________________________________ > > >> Krang-devel mailing list > > >> Kra...@li... > > >> https://lists.sourceforge.net/lists/listinfo/krang-devel > > > > > ----------------------------------------------------------------------------- > - > This SF.net email is sponsored by: > SourcForge Community > SourceForge wants to tell your story. > http://p.sf.net/sfu/sf-spreadtheword > _______________________________________________ > Krang-devel mailing list > Kra...@li... > https://lists.sourceforge.net/lists/listinfo/krang-devel |