Forum: Radiant CMS Simple blog too complex: what does this code do?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Martin O. (Guest)
on 2007-03-08 09:59
(Received via mailing list)
I have based http://smpl.se on the "simple blog" included in Radiant
0.6 RC1. There is one piece of code in the "Normal" layout that I
don't quite understand:

<r:if_url matches="^/articles/\d{4}/\d{2}/\d{2}/.+"><r:unless_url
matches="-archives/$"><p class="info">Posted by <r:author /> on
<r:date /></p></r:unless_url></r:if_url>

What does it do? I've created several "sections" based on the
'articles' section, with a different blog in each (I know I, I should
be using categories or tags). My 'articles' nodes ar called:

http://smpl.se/blog
http://smpl.se/bath
http://smpl.se/car

Do I need to do anything to that code? Should I remove it?

I feel that some of the default templates are a bit too complex. I'd
like to reduce the complexity by not requiring a new Radiant-user to
change a lot of regular expressions - often having to match several
expressions to each other.

I don't know if what I'm saying makes sense. I am a new user myself,
so I'm learning as I go.

Ideally I'd like to see a turnkey install of a simple but very
capable blogging engine, pared down to the bare esentials. The target
audience would be both people who want something simple so they can
start publishing right away, and the crowd who want something simple
that they can start building on.

I'm going to keep working on smpl.se and see what I come up with.
Right now it's a mess, but it'll get better. I'm only going to work
on pages, snippets and layouts: I'll leave the back end to you guys -
I'd love to talk about it though, if I have any questions or ideas.

Regards,

Martin O.
http://smpl.se
Mislav M. (Guest)
on 2007-03-08 12:08
(Received via mailing list)
On 3/8/07, Martin O. <removed_email_address@domain.invalid> wrote:
>
> There is one piece of code in the "Normal" layout that I
> don't quite understand:
>
> <r:if_url matches="^/articles/\d{4}/\d{2}/\d{2}/.+"><r:unless_url
> matches="-archives/$"><p class="info">Posted by <r:author /> on
> <r:date /></p></r:unless_url></r:if_url>


It's simple really - you read it out like English :)

If the current URL starts with "/articles/YYYY/MM/DD" (generic blog
format),
print out "Posted by [author] on [date]" in a paragraph. However, the
URL
must not end in "-archives/". This is because archives are pages with
that
URL format, too, but you don't want them to look like blog posts.
Martin O. (Guest)
on 2007-03-08 15:51
(Received via mailing list)
So what do I do to make it work with a "multi-blog" site? I need
something that matches /blog/YYYY/MM/DD, /blog/YYYY/MM/DD, /car/YYYY/
MM/DD, and I don't really want to have to change it or add to it
every time I add a new "project blog".

Regards,
Martin O.
http://smpl.se
Sean C. (Guest)
on 2007-03-08 15:54
(Received via mailing list)
Change the first part of the if_url to look like so:

<r:if_url
matches="^/(blog|car|whatever)/\d{4}/\d{2}/\d{2}/.+"><r:unless_url
matches="-archives/$"><p class="info">Posted by <r:author /> on
<r:date /></p></r:unless_url></r:if_url>

You can keep chaining on other "categories" with the | character.

Sean
Martin O. (Guest)
on 2007-03-08 17:09
(Received via mailing list)
Thanks! I know how to write regular expressions. I was wondering if
there was a way to make this more automatic. The DRY-principles
should apply to layouts as well, no? Can anyone think of a way to
reduce the number of places I need to change when I add a new project
blog. Right now I do this:

Create a new child of the root, say "food".
Copy the content from a previous blog, say "cars".
Change some stuff in the page content.
Create an RSS-feed.
Change the Normal layout.

I'd like to find a smarter and less redundant way to do this.

/Martin
http://smpl.se
Sean C. (Guest)
on 2007-03-08 17:12
(Received via mailing list)
You could replace anything inside those parens with an appropriate
character class... probably [\w-]+ would work.

Sean
Mislav M. (Guest)
on 2007-03-08 18:36
(Received via mailing list)
... or you could just use the regexp without the
first part: "/\d{4}/\d{2}/\d{2}/"
This topic is locked and can not be replied to.