# Layouts, snippets and site assets on the file system?

**URL:** <https://www.ruby-forum.com/t/layouts-snippets-and-site-assets-on-the-file-system/137499>\
**Category:** Radiant CMS\
**Created:** [May 13, 2008, 6:18pm UTC](https://www.ruby-forum.com/t/layouts-snippets-and-site-assets-on-the-file-system/137499 "2008-05-13T18:18:53Z")\
**Posts on this page:** 15\
**Page:** 1

<div class="post-metadata">

**Author:** ![squeegy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/dec6dc/32.png) [@squeegy](https://www.ruby-forum.com/u/squeegy)\
**Post date:** [May 13, 2008, 6:18pm UTC](https://www.ruby-forum.com/t/layouts-snippets-and-site-assets-on-the-file-system/137499/1 "2008-05-13T18:18:53Z")

</div>

First off, what I have done so far in Radiant has been pretty inspiring.  
I usually hate CMS solutions due to their inflexibility. The super  
simple Radiant extension is a huge selling point for me. I intend to  
use a Radiant install as the base for projects since it gives me  
publishing, admin authentication, and admin architecture for almost no  
effort. I’m pretty experienced with Rails, but new to Radiant.

Maintaining layouts and snippets in the admin interface via text area is  
so much less fun than editing these things in Textmate. My current  
workflow is to use the “It’s all text” Firefox plugin to edit text area  
contents in Textmate. It’s not so bad, but I have switch to the browser  
and press the save button, then switch to my tab with the radiant app  
and refresh to see my changes. Its far more tedious than the usual  
cmd-s, cmd-tab, F5 I’m used to. Page content would change far more  
frequently and is a good fit for the database, in my opinion. Plus the  
regular, non-technical, maintainers of the site probably shouldn’t have  
access to changing layouts and snippets anyway.

So, I am looking for a way to store site structure files in the file  
system, version controlled and in a higher level template language like  
erb or haml. Then store page content in the database in radius format  
just like normal.

Is there an extension for that? Or is that even a good idea?

Thanks for the great tool,  
-Alex

---

<div class="post-metadata">

**Author:** ![squeegy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/dec6dc/32.png) [@squeegy](https://www.ruby-forum.com/u/squeegy)\
**Post date:** [May 13, 2008, 6:37pm UTC](https://www.ruby-forum.com/t/layouts-snippets-and-site-assets-on-the-file-system/137499/2 "2008-05-13T18:37:00Z")

</div>

Alex,

I’ve been promising for a long time, so I better own up on it. I wrote  
an extension for Digital Pulp that lets you import/export several models  
between the database and the file system so that they can be stored in a  
SCM. There are a number of other extensions that the DP devs and I have  
been wanting to export for a while. Although I have a few other things  
to do this Friday, I’ll put that on the to-dos as well.

Sean

---

<div class="post-metadata">

**Author:** ![squeegy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/dec6dc/32.png) [@squeegy](https://www.ruby-forum.com/u/squeegy)\
**Post date:** [May 28, 2008, 10:57pm UTC](https://www.ruby-forum.com/t/layouts-snippets-and-site-assets-on-the-file-system/137499/3 "2008-05-28T22:57:31Z")

</div>

Sean C. wrote:

> Alex,
> 
> I’ve been promising for a long time, so I better own up on it. I wrote  
> an extension for Digital Pulp that lets you import/export several models  
> between the database and the file system so that they can be stored in a  
> SCM. There are a number of other extensions that the DP devs and I have  
> been wanting to export for a while. Although I have a few other things  
> to do this Friday, I’ll put that on the to-dos as well.
> 
> Sean

Firstly, I realize I am in no position to demand anything!

I have been watching the git repo and the blog, and haven’t seen  
anything about this. Any progress that i missed?

Thanks.

---

<div class="post-metadata">

**Author:** ![squeegy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/dec6dc/32.png) [@squeegy](https://www.ruby-forum.com/u/squeegy)\
**Post date:** [May 13, 2008, 9:12pm UTC](https://www.ruby-forum.com/t/layouts-snippets-and-site-assets-on-the-file-system/137499/4 "2008-05-13T21:12:39Z")

</div>

Sean C. wrote:

> Alex,
> 
> I’ve been promising for a long time, so I better own up on it. I wrote  
> an extension for Digital Pulp that lets you import/export several models  
> between the database and the file system so that they can be stored in a  
> SCM. There are a number of other extensions that the DP devs and I have  
> been wanting to export for a while. Although I have a few other things  
> to do this Friday, I’ll put that on the to-dos as well.
> 
> Sean

Rock on. Thank you, I will keep an ear out!

---

<div class="post-metadata">

**Author:** ![squeegy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/dec6dc/32.png) [@squeegy](https://www.ruby-forum.com/u/squeegy)\
**Post date:** [June 14, 2008, 12:23am UTC](https://www.ruby-forum.com/t/layouts-snippets-and-site-assets-on-the-file-system/137499/5 "2008-06-14T00:23:46Z")

</div>

In parallel, it would be nice to add another basic user-level of  
“Designer”, for managing Snippets - in the absence of SCM/file support  
for layouts/partials.

In keeping designs and code DRY, we find ourselves using snippets to  
contain more than user-editable content, and use them heavily for  
fragments of design logic. As such, we want to keep day-to-day users far  
away from anything that can cause damage to the site.

Standard (Pages) -\> Designer (+ Snippets) -\> Administrator (+ Layouts,  
Users, etc)

Does the Developer flag do anything in production mode?

Thanks,  
Jon.

---

<div class="post-metadata">

**Author:** ![squeegy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/dec6dc/32.png) [@squeegy](https://www.ruby-forum.com/u/squeegy)\
**Post date:** [June 14, 2008, 3:51am UTC](https://www.ruby-forum.com/t/layouts-snippets-and-site-assets-on-the-file-system/137499/6 "2008-06-14T03:51:09Z")

</div>

Sean C. wrote:

> Alex,
> 
> I’ve been promising for a long time, so I better own up on it. I wrote  
> an extension for Digital Pulp that lets you import/export several models  
> between the database and the file system so that they can be stored in a  
> SCM. There are a number of other extensions that the DP devs and I have  
> been wanting to export for a while. Although I have a few other things  
> to do this Friday, I’ll put that on the to-dos as well.
> 
> Sean

Was this done via FUSE?

[http://redhanded.hobix.com/inspect/railsfsAfterACoupleMinutesOfToolingWithFuseWhoa.html](http://redhanded.hobix.com/inspect/railsfsAfterACoupleMinutesOfToolingWithFuseWhoa.html)

Seems like that’s the “Right” way. I’ve used FUSE extensively to mount  
remote filesystems via SSH and it works wonderfully.

–DJCP

---

<div class="post-metadata">

**Author:** ![squeegy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/dec6dc/32.png) [@squeegy](https://www.ruby-forum.com/u/squeegy)\
**Post date:** [June 14, 2008, 7:52pm UTC](https://www.ruby-forum.com/t/layouts-snippets-and-site-assets-on-the-file-system/137499/7 "2008-06-14T19:52:09Z")

</div>

Jonathan McCoy wrote:

> settings.

You just described the file\_system extension written for Redken to a T.  
I would like to release it but I’m not ready to support it yet or to  
detox the code.

Sean

---

<div class="post-metadata">

**Author:** ![squeegy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/dec6dc/32.png) [@squeegy](https://www.ruby-forum.com/u/squeegy)\
**Post date:** [June 14, 2008, 5:59pm UTC](https://www.ruby-forum.com/t/layouts-snippets-and-site-assets-on-the-file-system/137499/8 "2008-06-14T17:59:20Z")

</div>

Daniel Collis-puro wrote:

> Was this done via FUSE?
> 
> [http://redhanded.hobix.com/inspect/railsfsAfterACoupleMinutesOfToolingWithFuseWhoa.html](http://redhanded.hobix.com/inspect/railsfsAfterACoupleMinutesOfToolingWithFuseWhoa.html)
> 
> Seems like that’s the “Right” way. I’ve used FUSE extensively to mount  
> remote filesystems via SSH and it works wonderfully.
> 
> –DJCP

Highly unlikely. FUSE is a modular file system API - basically a simple  
means to build your own file system without actually having to do  
anything majorly complex. Although yes, what you linked to would be a  
cool solution - it still lacks version control. You’d also have to make  
it uber-bespoke to Radiant, and to each model in the Radiant schema,  
otherwise you’ll be working with YAML etc. If somebody did build a FUSE  
interface for Radiant, it would be nice if each page is represented by a  
folder, with files corresponding to each page part, with the extension  
being the filter used. A meta file could contain the overall page  
settings.

eg:

/welcome/ (path is slug)  
/welcome/page.meta (YAML settings for page)  
/welcome/body.textile  
/welcome/extended.smartypants  
/welcome/extended.html (plain/non-filtered)

and so forth…

The real goal here however, is to allow layouts and partials to exist in  
the filesystem (within the ‘app/view’ folder structure), which  
immediately allows you to use an SCM (SVN, CVS, GIT etc) either for the  
whole project, or as an SVN External (or GIT/CVS equivalent). My  
preference would be to allow both file system and DB based  
layouts/snippets to co-exist, with file system layouts taking precedence  
in case of name clashes. It’d be great to use HAML as well. I’d also  
add, support for Multi-Site would be highly desired.

Jon.

---

<div class="post-metadata">

**Author:** ![squeegy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/dec6dc/32.png) [@squeegy](https://www.ruby-forum.com/u/squeegy)\
**Post date:** [June 14, 2008, 11:30pm UTC](https://www.ruby-forum.com/t/layouts-snippets-and-site-assets-on-the-file-system/137499/9 "2008-06-14T23:30:06Z")

</div>

Gah! Shafted again! How long you gonna keep these awesome extensions  
under your wings? What detoxing needs to be done?

Sean C. wrote:

> Jonathan McCoy wrote:
> 
> > settings.
> 
> You just described the file\_system extension written for Redken to a T.  
> I would like to release it but I’m not ready to support it yet or to  
> detox the code.
> 
> Sean

---

<div class="post-metadata">

**Author:** ![squeegy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/dec6dc/32.png) [@squeegy](https://www.ruby-forum.com/u/squeegy)\
**Post date:** [June 17, 2008, 1:24pm UTC](https://www.ruby-forum.com/t/layouts-snippets-and-site-assets-on-the-file-system/137499/10 "2008-06-17T13:24:33Z")

</div>

Jonathan McCoy wrote:

> In parallel, it would be nice to add another basic user-level of  
> “Designer”, for managing Snippets - in the absence of SCM/file support  
> for layouts/partials.
> 
> In keeping designs and code DRY, we find ourselves using snippets to  
> contain more than user-editable content, and use them heavily for  
> fragments of design logic. As such, we want to keep day-to-day users far  
> away from anything that can cause damage to the site.
> 
> Standard (Pages) -\> Designer (+ Snippets) -\> Administrator (+ Layouts,  
> Users, etc)
> 
> Does the Developer flag do anything in production mode?
> 
> Thanks,  
> Jon.

I’ve monkey-patched a frozen version of Radiant (0.6.7) with some of the  
functionality I lusted for above. No testing or a “designer” flag (just  
put snippets on the Admin/Dev level). I’d be more inclined to assemble  
patches and tests (to the spec above) if anybody else was interested in  
it being pushed into the trunk?

Would be nice to review the user levels available - or if we’re all  
feeling code-happy, granular access control. I can foresee the need for  
the following roles at least:

1. Content Monkey (pages + preferences)
2. Designer (+ layouts + snippets)
3. Developer (+ extensions)
4. Administrator (+ user management)

In hindsight to my previous post, I’d keep the developer flag for the  
benefit of extensions/plugins that need technical setup. Another  
question, is whether flags are more desirable than a user-level number  
(ie 1 to 4) or even a class-name, which can be mapped out to a role  
name. A popup list with userlevels can be used instead. It removes the  
uncertainty of having admin flagged, but developer unflagged -\> what  
rights does the user have?!

I am having trouble finding where the user-level is set for the tab  
display - I’ve traced back through all the libraries, but can’t seem to  
find (or rather see) where snippets (or rather other admin/dev tabs) are  
set…

Cheers,  
Jon.

---

<div class="post-metadata">

**Author:** ![squeegy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/dec6dc/32.png) [@squeegy](https://www.ruby-forum.com/u/squeegy)\
**Post date:** [July 31, 2008, 8:30am UTC](https://www.ruby-forum.com/t/layouts-snippets-and-site-assets-on-the-file-system/137499/11 "2008-07-31T08:30:00Z")

</div>

On 14 Jun 2008, at 18:51, Sean C. wrote:

> > to each page part, with the extension being the filter used. A meta  
> > file could contain the overall page settings.
> 
> You just described the file\_system extension written for Redken to a  
> T. I would like to release it but I’m not ready to support it yet  
> or to detox the code.

I asked Sean if I could have a go at detoxing his code myself. I’ve  
stripped out all of the Redken specific functionality, and got the  
extension working on a vanilla Radiant site (i.e. with no other  
extensions). Here it is:

[GitHub - nelstrom/radiant-file-system-extension: Save a Radiant site to the file system for easy editing and/or version control. Load from file system back into the database](http://github.com/nelstrom/radiant-file-system-extension/tree/master)

I’d be happy to hear any feedback.

Cheers,  
Drew

---

<div class="post-metadata">

**Author:** ![squeegy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/dec6dc/32.png) [@squeegy](https://www.ruby-forum.com/u/squeegy)\
**Post date:** [June 16, 2008, 11:44pm UTC](https://www.ruby-forum.com/t/layouts-snippets-and-site-assets-on-the-file-system/137499/12 "2008-06-16T23:44:37Z")

</div>

Sean C. wrote:

> Jonathan McCoy wrote:
> 
> > settings.
> 
> You just described the file\_system extension written for Redken to a T.  
> I would like to release it but I’m not ready to support it yet or to  
> detox the code.
> 
> Sean

Nice!

My next mission is to design/build a platform for content delivery (the  
binary kind) - basically a front end for managing content (videos,  
images, PDF’s etc), engines to maintain and distribute the content  
(faux-RAID), and a delivery mechanism (caching HTTP app). Keen to find a  
solution using Radiant, but failing that will build a plugin for the  
integration.

Jon.

---

<div class="post-metadata">

**Author:** ![squeegy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/dec6dc/32.png) [@squeegy](https://www.ruby-forum.com/u/squeegy)\
**Post date:** [July 31, 2008, 11:15am UTC](https://www.ruby-forum.com/t/layouts-snippets-and-site-assets-on-the-file-system/137499/13 "2008-07-31T11:15:04Z")

</div>

Nice work, Andrew. I wonder how hard it would to get this extension to  
also dump and load SnS text assets. Not that any of the extensions  
should have a dependency on the other, but the file-system-extension  
could perhaps check for the presence of SnS and dump that too, if  
present?

Cheers,  
Casper

---

<div class="post-metadata">

**Author:** ![squeegy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/dec6dc/32.png) [@squeegy](https://www.ruby-forum.com/u/squeegy)\
**Post date:** [July 31, 2008, 3:06pm UTC](https://www.ruby-forum.com/t/layouts-snippets-and-site-assets-on-the-file-system/137499/14 "2008-07-31T15:06:27Z")

</div>

Nice - thanks, Sean

---

<div class="post-metadata">

**Author:** ![squeegy](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/dec6dc/32.png) [@squeegy](https://www.ruby-forum.com/u/squeegy)\
**Post date:** [July 31, 2008, 3:01pm UTC](https://www.ruby-forum.com/t/layouts-snippets-and-site-assets-on-the-file-system/137499/15 "2008-07-31T15:01:46Z")

</div>

When I designed the extension, I toyed with the idea of providing a way  
for extensions to specify how to dump/load their own models. IIRC, you  
can just create an appropriately named module and then add the model to  
the constant array in the FileSystem module. You should probably do all  
of that in your extension file.

Sean
