Hello Monks

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)

I'd like to be able to pull logs (they really aren't articles, more just "notes") based on the URL, e.g. http://address/$year/$month/$date/$title so http://address/2014/01/10/foo-bar-baz would pull the log from 10 Jan. 2014 about foo bar baz.

In something like dancer, this is really easy to do with route "placeholders", e.g.:

get '/:year/:month/:day' => sub { my $year = params->{year}; my $month = params->{month}; ... }

or

get '/*/*/*' => sub { my ($year, $month, $day) = splat; ... }

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...?)

(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))

EDIT:

Maybe this is something: http://search.cpan.org/~ether/Catalyst-Manual-5.9007/lib/Catalyst/Manual/Intro.pod#URL_Path_Handling

But that seems like it would look for a specific string in that parameter, so I'd need 12 routes... e.g.,

sub jan : Regex('^01$') { my ($self, $context, $bar, $baz) = @_; } sub feb : Regex('^02$') { my ($self, $context, $bar, $baz) = @_; }

Which is not what I'm trying to accomplish. (There has to be a better way)

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


In reply to [Catalyst] How do you handle "URL Parameters" (aka advanced "route matching") by three18ti

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.