[ANN] "Shards" extension

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

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:

    The RegionSet for the page edit screen.

    admin.page.edit

    The array of partials in the ‘main’ region.

    admin.page.edit.main
    admin.page.edit[:main] # equivalent
    admin.page.edit[‘main’] # equivalent

    Adds the ‘foo’ partial to the main region, before the ‘edit_form’

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:

    Radiant::AdminUI.class_eval { attr_accessor :events }
    admin.events = OpenStruct.new
    admin.events.index = Shards::RegionSet.new

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

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.

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

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

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.

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

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

Sean

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

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

Sean

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 :slight_smile:


Damien McKenna - Husband, father, geek.
[email protected] - http://www.mc-kenna.com/

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

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

Sean