perlquestion
three18ti
<p>Hello Monks</p>
<p>I'm working on an internal application, I think calling it a blog "engine" is a bit too generous... I'm basically looking to build a very basic "web log" (literally, where we can log our work via web interface)</p>
<p>I'd like to be able to pull logs (they really aren't articles, more just "notes") based on the URL, e.g. <c>http://address/$year/$month/$date/$title</c> so <c>http://address/2014/01/10/foo-bar-baz</c> would pull the log from 10 Jan. 2014 about foo bar baz.</p>
<p>In something like dancer, this is really easy to do with route "placeholders", e.g.: </p>
<code>
get '/:year/:month/:day' => sub {
my $year = params->{year};
my $month = params->{month};
...
}
</code>
<p>or</p>
<code>
get '/*/*/*' => sub {
my ($year, $month, $day) = splat;
...
}
</code>
<p>is there any way to do something similar in Catalyst? From my googling, it seems like "chained actions" are the way to go for this behavior, but they always seem like a black magic and make debugging a terrible pain in the arse... (maybe I'm just doing it wrong...?)</p>
<p>(I'm certainly not set on Catalyst, I've not done anything really advanced with either Dancer or Catalyst, for instance: https://github.com/three18ti/NetTools, but I can't for the life of me get Dancer to play nice with Moose (I'd prefer to deal with objects for everything since I'm using HTML::FormHandler and a couple other OO modules), and I like Catalyst better because I can break out my logic into multiple files instead of having everything in one gigantic file like Dancer requires (or well, seems to require, if I can break out my logic into multiple "controllers" like I can with Catalyst, then I'm doing it wrong. None of the dancer tutorials I've seen make use of this feature))</p>
<p>EDIT: </p>
<p>Maybe this is something: http://search.cpan.org/~ether/Catalyst-Manual-5.9007/lib/Catalyst/Manual/Intro.pod#URL_Path_Handling</p>
<p>But that seems like it would look for a specific string in that parameter, so I'd need 12 routes... e.g.,</p>
<code>
sub jan : Regex('^01$') { my ($self, $context, $bar, $baz) = @_; }
sub feb : Regex('^02$') { my ($self, $context, $bar, $baz) = @_; }
</code>
<p>Which is not what I'm trying to accomplish. (There has to be a better way)</p>
<p>EDIT 2: maybe I should just use get parameters: http://search.cpan.org/~ether/Catalyst-Manual-5.9007/lib/Catalyst/Manual/Intro.pod#Query_Parameter_Processing</p>