# \[ANN\] "Shards" extension

**URL:** <https://www.ruby-forum.com/t/ann-shards-extension/114896>\
**Category:** Radiant CMS\
**Created:** [September 18, 2007, 5:06pm UTC](https://www.ruby-forum.com/t/ann-shards-extension/114896 "2007-09-18T17:06:36Z")\
**Posts on this page:** 12\
**Page:** 1

<div class="post-metadata">

**Author:** ![smc7000](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ed655f/32.png) [@smc7000](https://www.ruby-forum.com/u/smc7000)\
**Post date:** [September 18, 2007, 5:06pm UTC](https://www.ruby-forum.com/t/ann-shards-extension/114896/1 "2007-09-18T17:06:36Z")

</div>

It’s been a long time coming, but here it is.

\*\* The facets branch functionality is now available as an extension! \*\*

[http://dev.radiantcms.org/svn/radiant/trunk/extensions/shards](http://dev.radiantcms.org/svn/radiant/trunk/extensions/shards)

The latest contract I’ve been working on is using Radiant, and they  
needed this functionality. The extension will work on 0.6.2, but I  
highly recommend using edge for the sake of bugfixes.

There have been some significant changes in the API that I should warn  
you about if you used the facets branch before:

- ‘facets-lite’ is still supported. Existing extensions that use this  
should not break.

- Some of the region names may have been changed or added.

- There are no more ‘plain’ partials. Everything exists in a region or  
is rendered directly from a template.

- Use content\_for :page\_scripts and content\_for :page\_css to insert  
inline Javascripts and CSS, respectively. content\_for appends to its  
result anyway, so it was not necessary to keep ‘additional\_javascripts’  
and ‘additional\_styles’ in the API. If you have external files, you can  
still use ‘include\_javascript’ and ‘include\_stylesheet’.

- Regions are still accessible from the ‘admin’ object, but are accessed  
like so:

partial  
admin.page.edit.add :main, ‘foo’, :before =\> ‘edit\_form’

# Adds the ‘foo’ partial to the main region, after the ‘edit\_header’

partial  
admin.page.edit.add :main, ‘foo’, :after =\> ‘edit\_header’

- Regions are blank by default, so you can reference a region without it  
being pre-existing.

- Any controller/action may have regions that are rendered. These are  
determined by the controller name and template name. See the  
implementation of the ‘render\_region’ helper for details.

- If you want to add your own controllers and actions/templates, add an  
attr\_accessor to Radiant::AdminUI with the controller name, fill that  
attribute with an OpenStruct, then assign Shards::RegionSet objects to  
the struct by template name. For example, if I have an “events”  
controller and I want to add regions to its “index” template, I would do  
this in the ‘activate’ method of my extension:

You can pass a block to RegionSet.new, which will yield itself to the  
block.

- The only pages that can be modified out-of-box at the moment are:
  - Page edit/new (as before)
  - Page index (limited)

The core of the API is pretty solid and well tested, but I would  
entertain any patches that extend the reach into the other areas of the  
administration interface.

Cheers,

Sean

---

<div class="post-metadata">

**Author:** ![smc7000](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ed655f/32.png) [@smc7000](https://www.ruby-forum.com/u/smc7000)\
**Post date:** [September 24, 2007, 11:20am UTC](https://www.ruby-forum.com/t/ann-shards-extension/114896/2 "2007-09-24T11:20:28Z")

</div>

Hi everybody.

just few thoughts on this subject.  
maybe everything can be much more simple?

i understand that it is very cool when you install extension and yore  
administrative part is full of new buttons and toys to play with but why  
exactly do we need it in this way?

basically my suggestion is to give extensions more freedom - just put a  
new  
tab for each extension and let it work as expected without any  
interference  
with others

you need to reorder pages? click on reorder tab and modify the tree as  
you  
want.  
you need to manage your galleries? galleries tab will show you only  
gallery  
type pages.  
same for page attachments - each page can be expanded to see attached  
files.

as for filters - same thing. when you go to page edit you will have a  
tab  
for each filter.

---

<div class="post-metadata">

**Author:** ![smc7000](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ed655f/32.png) [@smc7000](https://www.ruby-forum.com/u/smc7000)\
**Post date:** [September 24, 2007, 4:40pm UTC](https://www.ruby-forum.com/t/ann-shards-extension/114896/3 "2007-09-24T16:40:34Z")

</div>

Keymone wrote:

> tab for each extension and let it work as expected without any interference  
> with others

They already have this ability. The primary reasons for adding  
flexibility to the administration interface is to promote a workflow  
that makes sense. Reordering pages seems like something that should be  
intimate with the page-related workflow. Yes, another tab is easier,  
but it may not be the most intuitive solution.

One feature my client needs is a “popup” menu on the “Add Child” button  
to select a specific page-template before opening the edit interface.  
That couldn’t be done without some way to inject code into the sitemap  
page.

> you need to reorder pages? click on reorder tab and modify the tree as you  
> want.  
> you need to manage your galleries? galleries tab will show you only gallery  
> type pages.  
> same for page attachments - each page can be expanded to see attached files.
> 
> as for filters - same thing. when you go to page edit you will have a tab  
> for each filter.

I understand your concern. It’s easy to get a bloated mess, but it  
should be the responsibility of individual extension designers to make  
sure their modifications add meaningfully to the interface and don’t  
detract from it.

Sean

---

<div class="post-metadata">

**Author:** ![smc7000](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ed655f/32.png) [@smc7000](https://www.ruby-forum.com/u/smc7000)\
**Post date:** [September 24, 2007, 8:02pm UTC](https://www.ruby-forum.com/t/ann-shards-extension/114896/4 "2007-09-24T20:02:06Z")

</div>

I ran into that error earlier. I thought I had committed the fix, but  
I’ll do it asap. Thanks for the heads up.

Sean

---

<div class="post-metadata">

**Author:** ![smc7000](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ed655f/32.png) [@smc7000](https://www.ruby-forum.com/u/smc7000)\
**Post date:** [September 24, 2007, 7:08pm UTC](https://www.ruby-forum.com/t/ann-shards-extension/114896/5 "2007-09-24T19:08:57Z")

</div>

Ideally, no extension would alter the other views, but for most  
situations this isn’t practical. I thinks the shards extension is  
actually a very elegant way to handle this issue.

But is it just me or does it give a “no method error” when the  
children are expanded? I have tried it on a fresh install, but keep  
getting an error. I am using the gem, updated to edge and no other  
extensions.

NoMethodError in Admin/page#children

Showing vendor/extensions/shards/app/views/admin/page/\_node.rhtml  
where line #39 raised:

Any ideas?

Keith B.

---

<div class="post-metadata">

**Author:** ![smc7000](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ed655f/32.png) [@smc7000](https://www.ruby-forum.com/u/smc7000)\
**Post date:** [September 24, 2007, 8:28pm UTC](https://www.ruby-forum.com/t/ann-shards-extension/114896/6 "2007-09-24T20:28:10Z")

</div>

> I ran into that error earlier. I thought I had committed the fix, but  
> I’ll do it asap. Thanks for the heads up.
> 
> Sean

Thanks Sean, it works just fine now.

Keith

---

<div class="post-metadata">

**Author:** ![smc7000](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ed655f/32.png) [@smc7000](https://www.ruby-forum.com/u/smc7000)\
**Post date:** [September 24, 2007, 9:22pm UTC](https://www.ruby-forum.com/t/ann-shards-extension/114896/7 "2007-09-24T21:22:20Z")

</div>

Thanks again, Keith. A lot of the template code was copied wholesale  
from facets, which was slightly out of date. Fixed.

Sean

---

<div class="post-metadata">

**Author:** ![smc7000](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ed655f/32.png) [@smc7000](https://www.ruby-forum.com/u/smc7000)\
**Post date:** [September 24, 2007, 8:34pm UTC](https://www.ruby-forum.com/t/ann-shards-extension/114896/8 "2007-09-24T20:34:10Z")

</div>

> I ran into that error earlier. I thought I had committed the fix, but  
> I’ll do it asap. Thanks for the heads up.

Sean,

I found another minor bug, but one that drives us all nuts: the tree  
doesn’t stay open on the Pages index.  
You forgot the json on the page tree:

It is:

// ); // ]]\>

but should be

// ); // ]]\>

And as long as I am being picky, the loading spinner doesn’t shut  
off. I haven’t figured out.

Now I am going to get to actually using this!

Keith

---

<div class="post-metadata">

**Author:** ![smc7000](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ed655f/32.png) [@smc7000](https://www.ruby-forum.com/u/smc7000)\
**Post date:** [September 25, 2007, 5:36pm UTC](https://www.ruby-forum.com/t/ann-shards-extension/114896/9 "2007-09-25T17:36:58Z")

</div>

I’ll talk to John about it. He may have some goals for the point  
release.

Sean

---

<div class="post-metadata">

**Author:** ![smc7000](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ed655f/32.png) [@smc7000](https://www.ruby-forum.com/u/smc7000)\
**Post date:** [September 25, 2007, 5:32pm UTC](https://www.ruby-forum.com/t/ann-shards-extension/114896/10 "2007-09-25T17:32:56Z")

</div>

On Sep 24, 2007, at 3:18 PM, Sean C. wrote:

> Thanks again, Keith. A lot of the template code was copied wholesale  
> from facets, which was slightly out of date. Fixed.

Any chance of releasing another point release soon, it seems that  
you’ve made many fixes lately over the 0.6.2 codebase? Thanks 🙂

–  
Damien McKenna - Husband, father, geek.  
removed\_email\_address@domain.invalid - [http://www.mc-kenna.com/](http://www.mc-kenna.com/)

---

<div class="post-metadata">

**Author:** ![smc7000](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ed655f/32.png) [@smc7000](https://www.ruby-forum.com/u/smc7000)\
**Post date:** [September 30, 2007, 6:24am UTC](https://www.ruby-forum.com/t/ann-shards-extension/114896/11 "2007-09-30T06:24:10Z")

</div>

I get an error when adding a page part. Even with a fresh install from  
the trunk. Can someone confirm this?

Output: [Parked at Loopia](http://pastie.caboo.se/102145.txt)

---

<div class="post-metadata">

**Author:** ![smc7000](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/ed655f/32.png) [@smc7000](https://www.ruby-forum.com/u/smc7000)\
**Post date:** [September 30, 2007, 5:42pm UTC](https://www.ruby-forum.com/t/ann-shards-extension/114896/12 "2007-09-30T17:42:02Z")

</div>

Thank you, I will fix that right away. It happened on several other  
actions as well.

Sean
