[PREVIEW] Snapshot extension: serve Radiant sites statically

Hi!,

Find it attached to this message.

The basic idea of the snapshot extension is to generate a local copy 

of
all pages in Radiant’s database. This allows to deploy a complete site
as
static files to the web server, where it can be served statically by the
web
server (Apache…) without a running Radiant instance. It’s useful for
deployment of Radiant sites to cheap hosting servers where there isn’t
Rails
support. Also high traffic sites will benefit.

All this works if the rendered pages depend only on the state of the 

DB
at snapshot creation time. It won’t work on a blog site where users can
post comments, for example. Neither won’t work if “non deterministic”
tags
are used, like and . Also care must be taken
with
the back_door extension. Well, in these cases the extension “will work”
in
the sense that the pages are generated, but obviously they will be
“stale”
since they are “fixed” and don’t represent their “dynamic” version.

Although it looks quite a hard requirement, in practice most of the

sites generated by CMSs are “static” (think on most company sites). I
have
developed this extension for myself, i will use it in a few sites i’m
developing. It works like a charm in the sites i have tested it.

It will take me a few weeks to finalize the extension, but i publish 

it
now so it can be tested and commented by everyone. Remains to be done:
documentation, usage examples ( Apache’s .htaccess, etc.), minor extra
functionality and general clean-up.

This extension comes from the ideas i commented in thread

http://www.ruby-forum.com/topic/124798 .

USAGE (assuming the cwd is the root of the Radiant site 

(RAILS_ROOT)):

- install extension
- execute "rake -T | grep snapshot" to see the taks and their

description (it’s controlled with Rake tasks)
- the default configuration should be correct for quick test, check
it
at “vendor/extensions/snapshot/config/snapshot.yaml”
- if you need to update the configuration, run “rake
snapshot:create_config” and edit the file in “config/snapshot.yaml”
- execute “rake snapshot:create”, all the site will be dumped to
“snapshot/” (by default “production” database)
- execute “rake snapshot:serve” to start a local web server on
http://localhost:8080 where you can test the snapshot
- profit! :slight_smile:

Comments etc. welcomed.

/AITOR

This looks very interesting, but I think the LIst scrubs
attachments. At least I didn’t get it. Can you post it somewhere? I
would love to try it. It would solve a few problems I have been
having…

Thanks.

Keith

Aitor Garay-Romero wrote:

developed this extension for myself, i will use it in a few sites i’m
USAGE (assuming the cwd is the root of the Radiant site (RAILS_ROOT)):
- execute “rake snapshot:serve” to start a local web server on
http://localhost:8080 where you can test the snapshot
- profit! :slight_smile:

Comments etc. welcomed.

/AITOR

Sounds like a really good idea! I think it’s a great idea for sites
that are managed by us, rather than the clients. I have a new answer to
the FAQ on static sites with Rails. I think this gives a very good
combination.

Thanks Aitor.

Cheers,
Mohit.
10/25/2007 | 11:57 AM.

The attachment is here: http://aitor.name/snapshot.tar.gz

 /AITOR

A URL was posted earlier today.

Regards,
Erik.

Saji Njarackalazhikam H. wrote:

Hi Aitor,

I would like to use this extension. However I could find any attachment in the
message. Could it be retrieved by ftp or some similar service?

saji


Erik van Oosten
http://2008.rubyenrails.nl/

Hi Aitor,

I would like to use this extension. However I could find any attachment
in the
message. Could it be retrieved by ftp or some similar service?

saji

developed this extension for myself, i will use it in a few sites i’m
USAGE (assuming the cwd is the root of the Radiant site (RAILS_ROOT)):
- execute “rake snapshot:serve” to start a local web server on
http://localhost:8080 where you can test the snapshot
- profit! :slight_smile:

Comments etc. welcomed.

/AITOR

Radiant mailing list
Post: [email protected]
Search: http://radiantcms.org/mailing-list/search/
Site: http://lists.radiantcms.org/mailman/listinfo/radiant


Saji N. Hameed

APEC Climate Center +82 51 668 7470
National Pension Corporation Busan Building 12F
Yeonsan 2-dong, Yeonje-gu, BUSAN 611705 [email protected]
KOREA

I just installed and started playing around with this plugin.
Basically, it works just great, but it does have one limitation,
which may not effect most people, but is a big thing for me.

It doesn’t parse through Virtual Pages, but just renders them with
their “literal” urls. I am talking about Archive pages and other
pages that don’t literally exist, which I actually use a lot these
days (mostly for a tagging extension I am working on). I realize this
is a small nitpick, but it would be great to figure out how to do this.

Other than that, really cool. I have a few simpler projects which
just don’t warrant an installation of Radiant that would be greatly
served by this.

Nice work.

Keith B.

@Keith:

 I'm glad that the extension is useful.  I take note of the virtual 

page
problem you comment and will look at it before releasing the first
official
version of the extension.

 I don't have experience with virtual pages so may be i ask you for

support. A good opportunity to learn more, indeed.

 /AITOR
 I'm glad that the extension is useful.  I take note of 

the virtual page
problem you comment and will look at it before releasing the
first official
version of the extension.

 I don't have experience with virtual pages so may be i 

ask you for
support. A good opportunity to learn more, indeed.

Basically, you’d need to extend virtual pages to be able to return
a list of urls at which they may be rendered. For example, the
ArchiveYearIndex virtual page would need to define something like:

def valid_urls
first = parent.children.find(:first, :order =>
‘updated_at’).updated_at.year
last = parent.children.find(:first, :order =>
‘updated_at’).updated_at.year
(first…last).map {|year|
“#{parent.url}/#{year}/”
}
end

And then you could render each of those (the first and last calculations
there
are a little primitive, look at my admin_tree_children extension for
better calcs).

Then you just render each of those urls.

(the same logic would also be useful for cache-clearing when those pages
are
edited).

Dan.

Hi Aitor,

It might be worth putting up a project for this extension at
http://code.google.com/hosting/

On 10/25/07, Aitor Garay-Romero [email protected] wrote:

The basic idea of the snapshot extension is to generate a local copy

the back_door extension. Well, in these cases the extension “will work” in
documentation, usage examples ( Apache’s .htaccess, etc.), minor extra
description (it’s controlled with Rake tasks)
Comments etc. welcomed.

/AITOR

Radiant mailing list
Post: [email protected]
Search: http://radiantcms.org/mailing-list/search/
Site: http://lists.radiantcms.org/mailman/listinfo/radiant


Regards,
Hiram

Blog: http://hiramchirino.com

Thanks Daniel !

/AITOR

The repository is online at http://snapshot.rubyforge.org/svn/ .

Note that this is a preview version.  Let's see if i can release a

proper initial version soon.

/AITOR