Archives by Month?

I’m playing with Radiant on my Macbook. I installed Ruby 1.8.4, rb-
sqlite3 and more with Darwin Ports. Then rubygem. I did gem install.
Set up a Radiant site, edited database.yml for sqlite. Ran setup and
selected option 3, the blog example as per the Radiant demo. Then I
launched via Mongrel.

Well, it works. Fast and good. Lovely. Except for one thing. The
archives works, shows a list of posts. But the Archives by Month does
not work. I get no articles. Empty page for August 2006. Even tho’
there clearly should be. This is with a default, unedited install.

Does anyone know of anything obvious to check?

BTW, it may be IOTTMCO but why, in the admin page edit, are Save and
Save and Continue Editing both buttons, but Cancel is a plain link?

andrew

On 8/10/06, Andrew B. [email protected] wrote:

Does anyone know of anything obvious to check?

BTW, it may be IOTTMCO but why, in the admin page edit, are Save and
Save and Continue Editing both buttons, but Cancel is a plain link?

I don’t really know if it’s the case but in general, things that make
changes to stuff on the server should be post-requests.

Andrew,

Take a look at the demo site for help, specifically

<URL: http://demo.radiantcms.org/admin/pages/edit/10 >

This will show you how to set up the archive page properly, including
the proper behavior.

On 11/08/2006, at 1:32 AM, Nathan W. wrote:

Andrew,

Take a look at the demo site for help, specifically

<URL: http://demo.radiantcms.org/admin/pages/edit/10 >

This will show you how to set up the archive page properly, including
the proper behavior.

I’ll certainly check there but my point was that I am running Radiant
as downloaded and setup using setup_database. I did not do or change
anything else. So either: a) the download is different from the demo;
b) something about mongrel/sqlite/my-machine is causing an issue.

No mind. I’ll work through the demo pages and compare.

thanks

andrew

On 11/08/2006, at 7:28 AM, Nathan W. wrote:

By a “default, unedited install” do you mean that you have added
nothing to the archive page itself? If so, that’s your problem … you
still need a bit o’ code to get things running.

I mean that I selected Option 3 in setup. There was code in the %B %Y
Archives page that, on cursory inspection, seemed the same as that on
the demo site.

Lets drop it for now. I’ve updated Rails and Radiant and I’m starting
again. Which, as of last night was bombing out with Active Record
errors.

thanks

andrew

By a “default, unedited install” do you mean that you have added
nothing to the archive page itself? If so, that’s your problem … you
still need a bit o’ code to get things running.

On 11/08/2006, at 7:50 AM, Nathan W. wrote:

Just to make sure that I wasn’t losing it, I installed Rails 1.1.6,
reinstalled Radiant 0.5.1 using the gem, created a new radiant site
using option 3, and fired it up … it works for me.

I’ve just done the same and it doesn’t work :-(. I verified that the
page is exactly as per the demo. I get monthly archive links in the
sidebar for August and June, click on them, get an August 2006 page
with no articles.

Gotta be my setup.

Oh well.

BTW, I’m also having to run under Rails 1.1.5. When I edit
environment.rb to be 1.1.6, I get an error

can't activate rails (= 1.1.6), already activated rails-1.1.5]

(Gem::Exception)

andrew

Just to make sure that I wasn’t losing it, I installed Rails 1.1.6,
reinstalled Radiant 0.5.1 using the gem, created a new radiant site
using option 3, and fired it up … it works for me.

You didn’t happen to freeze the rails gem to your vendor directory at
any point, did you?

On 10/8/2006, “Nathan W.” [email protected] wrote:

You didn’t happen to freeze the rails gem to your vendor directory at
any point, did you?

No. Searching around, I think it’s I think it’s because Radiant 0.5.1
requires Rails 1.1.5.

I’ll try -u flag to unpack and then see.

thanks for all the help.

andrew

Andrew B. wrote:

BUT, STRFTIME(‘%m’ returns a character value, such as ‘06’, whereas
it’s being compared to the integer 6. I tested in sqlite3 and no rows
returned. Wow, 17 years of Oracle experience counts for something in
this Web world.

So, strftime needs to be wrapped with a string-to-integer conversion,
yes?

That sounds fine to me. Can you or someone else get me a unit test that
reproduces the problem? Maybe even a patch that fixes it?


John L.
http://wiseheartdesign.com

OK, I’m new to Rails and sqlite and MySQL, so this took me half an
hour but…

The development log showed this SQL:

SELECT * FROM pages WHERE (pages.parent_id = 4 AND ((((virtual = ‘f’)
and (status_id = 100)) AND (STRFTIME(’%m’, published_at) = 6)) AND
(STRFTIME(’%Y’, published_at) = 2006))) ORDER BY published_at DESC,
virtual DESC, title ASC

Which I traced to the archive_finder.rb in models. This line:

add_condition(options, “#{extract(‘month’, ‘published_at’)} = ?”,
month.to_i)

then these:

    when /sqlite/i
       case part
       when /year/i
         "STRFTIME('%Y', #{field})"
       when /month/i
         "STRFTIME('%m', #{field})"
       when /day/i
         "STRFTIME('%d', #{field})"
       end

BUT, STRFTIME(’%m’ returns a character value, such as ‘06’, whereas
it’s being compared to the integer 6. I tested in sqlite3 and no rows
returned. Wow, 17 years of Oracle experience counts for something in
this Web world.

So, strftime needs to be wrapped with a string-to-integer conversion,
yes?

andrew

I can’t do a proper Rails unit test, because I’ve yet to even write
my hello-world Rails app…

All I can do is tell you what I did, which is to run Radiant under
sqlite3 and mongrel on OS X 10.4.

Sorry.

FWIW, I think you just need to wrap the STRFTIME in a CAST:

CAST(STRFTIME(’%m’, published_at) AS INTEGER)

But I’m still just playing around so no hurry to fix from my
perspective.

andrew

Andrew B. wrote:

I can’t do a proper Rails unit test, because I’ve yet to even write
my hello-world Rails app…

All I can do is tell you what I did, which is to run Radiant under
sqlite3 and mongrel on OS X 10.4.

Sorry.

Not a problem. If someone else could verify this that would be great. If
not, I’ll get to it when I get to it. :slight_smile:


John L.
http://wiseheartdesign.com

On 11/08/2006, at 2:06 PM, John W. Long wrote:

reproduces the problem? Maybe even a patch that fixes it?
The unit tests were already broken for sqlite3 in regard to this
problem. I just put a patch on trac [1] to solve it. I’m also running
on OS X (10.3.9) and sqlite3 (from darwinports).

Also there was a typo in page_context.test.rb:

def test_tag_children_each_attributes_with_invalid_limit

should be:

def test_tag_children_each_attributes_with_invalid_order

I’ve put it in trac [2] so it doesn’t get forgotten :slight_smile:

Bodhi

[1] http://dev.radiantcms.org/radiant/ticket/257
[2] http://dev.radiantcms.org/radiant/ticket/258