# \[PREVIEW\] Snapshot extension: serve Radiant sites statically

**URL:** <https://www.ruby-forum.com/t/preview-snapshot-extension-serve-radiant-sites-statically/118215>\
**Category:** Radiant CMS\
**Created:** [October 24, 2007, 9:12pm UTC](https://www.ruby-forum.com/t/preview-snapshot-extension-serve-radiant-sites-statically/118215 "2007-10-24T21:12:56Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![Aitor\_Garay-Romero](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ac8455/32.png) [@Aitor\_Garay-Romero](https://www.ruby-forum.com/u/Aitor_Garay-Romero)\
**Post date:** [October 24, 2007, 9:12pm UTC](https://www.ruby-forum.com/t/preview-snapshot-extension-serve-radiant-sites-statically/118215/1 "2007-10-24T21:12:56Z")

</div>

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](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](http://localhost:8080) where you can test the snapshot  
- profit! 🙂

```
Comments etc. welcomed.

/AITOR

```

---

<div class="post-metadata">

**Author:** ![Aitor\_Garay-Romero](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ac8455/32.png) [@Aitor\_Garay-Romero](https://www.ruby-forum.com/u/Aitor_Garay-Romero)\
**Post date:** [October 24, 2007, 9:59pm UTC](https://www.ruby-forum.com/t/preview-snapshot-extension-serve-radiant-sites-statically/118215/2 "2007-10-24T21:59:46Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Aitor\_Garay-Romero](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ac8455/32.png) [@Aitor\_Garay-Romero](https://www.ruby-forum.com/u/Aitor_Garay-Romero)\
**Post date:** [October 25, 2007, 5:58am UTC](https://www.ruby-forum.com/t/preview-snapshot-extension-serve-radiant-sites-statically/118215/3 "2007-10-25T05:58:32Z")

</div>

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](http://localhost:8080) where you can test the snapshot  
> - profit! 🙂
> 
> ```
> 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.

---

<div class="post-metadata">

**Author:** ![Aitor\_Garay-Romero](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ac8455/32.png) [@Aitor\_Garay-Romero](https://www.ruby-forum.com/u/Aitor_Garay-Romero)\
**Post date:** [October 25, 2007, 9:10am UTC](https://www.ruby-forum.com/t/preview-snapshot-extension-serve-radiant-sites-statically/118215/4 "2007-10-25T09:10:15Z")

</div>

The attachment is here: [http://aitor.name/snapshot.tar.gz](http://aitor.name/snapshot.tar.gz)

```
 /AITOR

```

---

<div class="post-metadata">

**Author:** ![Aitor\_Garay-Romero](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ac8455/32.png) [@Aitor\_Garay-Romero](https://www.ruby-forum.com/u/Aitor_Garay-Romero)\
**Post date:** [October 26, 2007, 7:19am UTC](https://www.ruby-forum.com/t/preview-snapshot-extension-serve-radiant-sites-statically/118215/5 "2007-10-26T07:19:09Z")

</div>

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/](http://2008.rubyenrails.nl/)

> **[Day to day stuff](http://day-to-day-stuff.blogspot.com/)**
>
> Experiences from a hard core JVM programmer. Likes to keep things simple.

---

<div class="post-metadata">

**Author:** ![Aitor\_Garay-Romero](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ac8455/32.png) [@Aitor\_Garay-Romero](https://www.ruby-forum.com/u/Aitor_Garay-Romero)\
**Post date:** [October 25, 2007, 6:19am UTC](https://www.ruby-forum.com/t/preview-snapshot-extension-serve-radiant-sites-statically/118215/6 "2007-10-25T06:19:36Z")

</div>

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

- Aitor Garay-Romero [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) [2007-10-24 21:11:52 +0200]:

> 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](http://localhost:8080) where you can test the snapshot  
> - profit! 🙂
> 
> ```
> Comments etc. welcomed.
> 
> /AITOR
> 
> ```

> * * *
> 
> Radiant mailing list  
> Post: removed\_email\_address@domain.invalid  
> Search: [http://radiantcms.org/mailing-list/search/](http://radiantcms.org/mailing-list/search/)  
> Site: [http://lists.radiantcms.org/mailman/listinfo/radiant](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 removed\_email\_address@domain.invalid  
KOREA

---

<div class="post-metadata">

**Author:** ![Aitor\_Garay-Romero](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ac8455/32.png) [@Aitor\_Garay-Romero](https://www.ruby-forum.com/u/Aitor_Garay-Romero)\
**Post date:** [October 26, 2007, 6:06pm UTC](https://www.ruby-forum.com/t/preview-snapshot-extension-serve-radiant-sites-statically/118215/7 "2007-10-26T18:06:50Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Aitor\_Garay-Romero](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ac8455/32.png) [@Aitor\_Garay-Romero](https://www.ruby-forum.com/u/Aitor_Garay-Romero)\
**Post date:** [October 28, 2007, 6:40pm UTC](https://www.ruby-forum.com/t/preview-snapshot-extension-serve-radiant-sites-statically/118215/8 "2007-10-28T18:40:15Z")

</div>

@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
```

---

<div class="post-metadata">

**Author:** ![Aitor\_Garay-Romero](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ac8455/32.png) [@Aitor\_Garay-Romero](https://www.ruby-forum.com/u/Aitor_Garay-Romero)\
**Post date:** [October 29, 2007, 2:11am UTC](https://www.ruby-forum.com/t/preview-snapshot-extension-serve-radiant-sites-statically/118215/9 "2007-10-29T02:11:12Z")

</div>

> ```
> 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.

---

<div class="post-metadata">

**Author:** ![Aitor\_Garay-Romero](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ac8455/32.png) [@Aitor\_Garay-Romero](https://www.ruby-forum.com/u/Aitor_Garay-Romero)\
**Post date:** [November 4, 2007, 5:40pm UTC](https://www.ruby-forum.com/t/preview-snapshot-extension-serve-radiant-sites-statically/118215/10 "2007-11-04T17:40:46Z")

</div>

Hi Aitor,

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

On 10/25/07, Aitor Garay-Romero [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) 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: removed\_email\_address@domain.invalid  
> Search: [http://radiantcms.org/mailing-list/search/](http://radiantcms.org/mailing-list/search/)  
> Site: [http://lists.radiantcms.org/mailman/listinfo/radiant](http://lists.radiantcms.org/mailman/listinfo/radiant)

–  
Regards,  
Hiram

Blog: [http://hiramchirino.com](http://hiramchirino.com)

---

<div class="post-metadata">

**Author:** ![Aitor\_Garay-Romero](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ac8455/32.png) [@Aitor\_Garay-Romero](https://www.ruby-forum.com/u/Aitor_Garay-Romero)\
**Post date:** [October 30, 2007, 10:34am UTC](https://www.ruby-forum.com/t/preview-snapshot-extension-serve-radiant-sites-statically/118215/11 "2007-10-30T10:34:55Z")

</div>

Thanks Daniel !

```
/AITOR
```

---

<div class="post-metadata">

**Author:** ![Aitor\_Garay-Romero](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/a/ac8455/32.png) [@Aitor\_Garay-Romero](https://www.ruby-forum.com/u/Aitor_Garay-Romero)\
**Post date:** [December 15, 2007, 11:22am UTC](https://www.ruby-forum.com/t/preview-snapshot-extension-serve-radiant-sites-statically/118215/12 "2007-12-15T11:22:07Z")

</div>

The repository is online at [http://snapshot.rubyforge.org/svn/](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

```
