# Alias Page Extension

**URL:** <https://www.ruby-forum.com/t/alias-page-extension/88420>\
**Category:** Radiant CMS\
**Created:** [March 10, 2007, 11:15pm UTC](https://www.ruby-forum.com/t/alias-page-extension/88420 "2007-03-10T23:15:11Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![bguan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/8edcca/32.png) [@bguan](https://www.ruby-forum.com/u/bguan)\
**Post date:** [March 10, 2007, 11:15pm UTC](https://www.ruby-forum.com/t/alias-page-extension/88420/1 "2007-03-10T23:15:11Z")

</div>

I’ve updated my alias behavior to an page type extension and added  
tests.

[http://silverinsanity.com/~benji/radiant/alias\_page-0.1.tar.gz](http://silverinsanity.com/~benji/radiant/alias_page-0.1.tar.gz)

Questions, comments, and bug reports welcome.

~~ Brian

---

<div class="post-metadata">

**Author:** ![bguan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/8edcca/32.png) [@bguan](https://www.ruby-forum.com/u/bguan)\
**Post date:** [March 11, 2007, 8:43pm UTC](https://www.ruby-forum.com/t/alias-page-extension/88420/2 "2007-03-11T20:43:47Z")

</div>

Hi Brian,

What does the extension do exactly?  
Is there a bit of documentation?

Regards,  
Erik.

Brian G. schreef:

> 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)

–  
Erik van Oosten

> **[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:** ![bguan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/8edcca/32.png) [@bguan](https://www.ruby-forum.com/u/bguan)\
**Post date:** [March 12, 2007, 2:53am UTC](https://www.ruby-forum.com/t/alias-page-extension/88420/3 "2007-03-12T02:53:24Z")

</div>

On Mar 11, 2007, at 3:41 PM, Erik van Oosten wrote:

> What does the extension do exactly?  
> Is there a bit of documentation?

Sorry about the terseness.

Mark a page as an Alias Page, and add a source part. The source part  
is a path (not a URL) to another page in the system. Whenever the  
system asks for that page, it will return the source page. It will,  
however, search for it’s  
own children before the source’s.

I plan to use this in conjunction with the virtual domain extension  
to have the same page under multiple domains.

There is something resembling documentation in the code.

~~ Brian

---

<div class="post-metadata">

**Author:** ![bguan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/8edcca/32.png) [@bguan](https://www.ruby-forum.com/u/bguan)\
**Post date:** [March 12, 2007, 9:43am UTC](https://www.ruby-forum.com/t/alias-page-extension/88420/4 "2007-03-12T09:43:54Z")

</div>

Thanks Brian,

That is unfortunate for me, I was looking for the reverse ☹

I hoped to find an extension that would re-direct to another page so I  
can  
maintain some URLs when I migrate to Radiant.

Regards,  
Erik.

---

<div class="post-metadata">

**Author:** ![bguan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/8edcca/32.png) [@bguan](https://www.ruby-forum.com/u/bguan)\
**Post date:** [March 13, 2007, 12:35am UTC](https://www.ruby-forum.com/t/alias-page-extension/88420/5 "2007-03-13T00:35:38Z")

</div>

> Thanks Brian,
> 
> That is unfortunate for me, I was looking for the reverse ☹
> 
> I hoped to find an extension that would re-direct to another  
> page so I can  
> maintain some URLs when I migrate to Radiant.
> 
> Regards,  
> Erik.

I’ve taken the approach of having a separate table mapping urls to page  
numbers and a file not found behaviour that performs  
redirects for old mappings (I also trawl through my server logs for 404s  
and correct any repeated spelling mistakes / truncations) -  
I’ve left it as a separate table that I maintain by hand so as not to  
confuse the page tree.

[http://soxbox.no-ip.org/radiant/svn/extensions/x\_groggy/app/models/groggy\_file\_not\_found\_page.rb](http://soxbox.no-ip.org/radiant/svn/extensions/x_groggy/app/models/groggy_file_not_found_page.rb)

(Note that I also had to have a custom index page so that it could look  
at my custom file not found type).

Dan.

---

<div class="post-metadata">

**Author:** ![bguan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/8edcca/32.png) [@bguan](https://www.ruby-forum.com/u/bguan)\
**Post date:** [March 13, 2007, 8:33am UTC](https://www.ruby-forum.com/t/alias-page-extension/88420/6 "2007-03-13T08:33:23Z")

</div>

Thanks Daniel, that’s brilliant!

```
 Erik.

```

Daniel S. schreef:

> I’ve taken the approach of having a separate table mapping urls to page numbers and a file not found behaviour that performs  
> redirects for old mappings (I also trawl through my server logs for 404s and correct any repeated spelling mistakes / truncations) -  
> I’ve left it as a separate table that I maintain by hand so as not to confuse the page tree.
> 
> [http://soxbox.no-ip.org/radiant/svn/extensions/x\_groggy/app/models/groggy\_file\_not\_found\_page.rb](http://soxbox.no-ip.org/radiant/svn/extensions/x_groggy/app/models/groggy_file_not_found_page.rb)
> 
> (Note that I also had to have a custom index page so that it could look at my custom file not found type).
> 
> Dan.

–  
Erik van Oosten

> **[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:** ![bguan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/8edcca/32.png) [@bguan](https://www.ruby-forum.com/u/bguan)\
**Post date:** [March 13, 2007, 5:09pm UTC](https://www.ruby-forum.com/t/alias-page-extension/88420/7 "2007-03-13T17:09:47Z")

</div>

On Mar 12, 2007, at 7:26 PM, Daniel S. wrote:

> I’ve taken the approach of having a separate table mapping urls to  
> page numbers and a file not found behaviour that performs  
> redirects for old mappings (I also trawl through my server logs for  
> 404s and correct any repeated spelling mistakes / truncations) -  
> I’ve left it as a separate table that I maintain by hand so as not  
> to confuse the page tree.
> 
> [http://soxbox.no-ip.org/radiant/svn/extensions/x\_groggy/app/models/](http://soxbox.no-ip.org/radiant/svn/extensions/x_groggy/app/models/)  
> groggy\_file\_not\_found\_page.rb

That rocks. It would be great if you could make that a separate  
extension with an interface to manage the redirect table. (Hint,  
hint. ~\_^)

> (Note that I also had to have a custom index page so that it could  
> look at my custom file not found type).

Wouldn’t something like this in core be better? (COMPLETELY UNTESTED)

# ----- 8\< ----- Index: page.rb

— page.rb (revision 352)  
+++ page.rb (working copy)  
@@ -135,7 +135,8 @@  
return found if found  
end  
end

- 

```
 children.find(:first, :conditions => "class_name =

```

‘FileNotFoundPage’")

- 

```
 not_found = Object.subclasses_of( FileNotFoundPage ) +

```

[‘FileNotFoundPage’]

- 

```
 children.find(:first, :conditions => ["class_name IN (?)",

```

not\_found])  
end  
end

@@ -251,4 +252,4 @@

end  
----- 8\< -----

~~ Brian

---

<div class="post-metadata">

**Author:** ![bguan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/8edcca/32.png) [@bguan](https://www.ruby-forum.com/u/bguan)\
**Post date:** [March 14, 2007, 12:16am UTC](https://www.ruby-forum.com/t/alias-page-extension/88420/8 "2007-03-14T00:16:02Z")

</div>

> That rocks. It would be great if you could make that a separate  
> extension with an interface to manage the redirect table. (Hint,  
> hint. ~\_^)

Well, you’re free to take my code and clean it up (Hint, hint).

The extension works great for regular pages but not so well for pages  
that can be referenced by multiple urls - ie, my gigs page is  
a single page that filters gigs based on the last part of the url -  
since my mapping is from url to page id and not url to url, that  
means I can’t redirect to those individual state filters. My comics page  
(AlphabetPage) is a similar beast.

The reasoning behind this is that these old urls are likely to be  
referenced well into the future and I wanted it to be robust in  
the face of reparenting.

I had a brief discussion a week or two ago about having a page url table  
that would map urls to pages for fast lookup and would also  
remain persistant so that if a page moves, there would still be a  
reference in the lookup table for that page so that it’s old url  
would also work. There’s a few problems with that approach, but it’s  
something that I’d like to try fleshing out to see if those  
problems are surmountable - I think that might be the way to go for  
providing page aliases.

Dan.

---

<div class="post-metadata">

**Author:** ![bguan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/8edcca/32.png) [@bguan](https://www.ruby-forum.com/u/bguan)\
**Post date:** [March 14, 2007, 12:24am UTC](https://www.ruby-forum.com/t/alias-page-extension/88420/9 "2007-03-14T00:24:05Z")

</div>

> > (Note that I also had to have a custom index page so that it could  
> > look at my custom file not found type).
> 
> Wouldn’t something like this in core be better? (COMPLETELY UNTESTED)
> 
> # ----- 8\< ----- Index: page.rb
> 
> — page.rb (revision 352)  
> +++ page.rb (working copy)

Yeah, I was thinking of putting pretty much that into the core, but was  
going to mull over it for a week to see if I could think of  
something better. Something about using IN bothers me a little, but I  
don’t think that feeling is justified (just a voice in the  
back of my mind saying “OMG!! what if you have like a bajillion  
different not found page types? That would suck” - I try not to  
listen to that voice though, he’s a bit of a doofus).

Dan.

---

<div class="post-metadata">

**Author:** ![bguan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/8edcca/32.png) [@bguan](https://www.ruby-forum.com/u/bguan)\
**Post date:** [March 14, 2007, 2:36am UTC](https://www.ruby-forum.com/t/alias-page-extension/88420/10 "2007-03-14T02:36:16Z")

</div>

On Mar 13, 2007, at 6:50 PM, Daniel S. wrote:

> “OMG!! what if you have like a bajillion different not found page  
> types? That would suck”

True, and subclasses\_of is a bit of a slow operation (iterates over  
every class in ObjectSpace). Might be better to have a registration  
method instead.

class MyNotFoundPage \< Page  
not\_found\_class  
end

That way the class array is assembled once, and the IN itself should  
be relatively quick (It’s a common DB operation).

~~ Brian

---

<div class="post-metadata">

**Author:** ![bguan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/8edcca/32.png) [@bguan](https://www.ruby-forum.com/u/bguan)\
**Post date:** [March 14, 2007, 3:44am UTC](https://www.ruby-forum.com/t/alias-page-extension/88420/11 "2007-03-14T03:44:24Z")

</div>

> True, and subclasses\_of is a bit of a slow operation (iterates over  
> every class in ObjectSpace). Might be better to have a registration  
> method instead.
> 
> class MyNotFoundPage \< Page  
> not\_found\_class  
> end

Are you sure that’s what subclasses\_of does? I know that there’s  
definitely a method on ActiveRecord::Base that keeps track of  
subclasses as their created - maybe it’s called something else -  
descendants maybe? - I can’t remember, but I’m pretty sure it  
exists.

Dan.

---

<div class="post-metadata">

**Author:** ![bguan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/8edcca/32.png) [@bguan](https://www.ruby-forum.com/u/bguan)\
**Post date:** [March 14, 2007, 4:04am UTC](https://www.ruby-forum.com/t/alias-page-extension/88420/12 "2007-03-14T04:04:25Z")

</div>

> > Are you sure that’s what subclasses\_of does? I know that  
> > there’s definitely a method on ActiveRecord::Base that  
> > keeps track of  
> > subclasses as their created - maybe it’s called something  
> > else - descendants maybe? - I can’t remember, but I’m pretty sure it  
> > exists.
> 
> lounge groggy # ruby script/console  
> Loading development environment.
> 
> > > Page.descendants

Well, that’s just an alias for subclasses\_of. I found the code that I  
remembered seeing - it was for tracking of subclasses by  
observers - where for some reason the list of subclasses is stored by  
each observer rather than by the observee.

Dan.

---

<div class="post-metadata">

**Author:** ![bguan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/8edcca/32.png) [@bguan](https://www.ruby-forum.com/u/bguan)\
**Post date:** [March 14, 2007, 3:56am UTC](https://www.ruby-forum.com/t/alias-page-extension/88420/13 "2007-03-14T03:56:25Z")

</div>

> Are you sure that’s what subclasses\_of does? I know that  
> there’s definitely a method on ActiveRecord::Base that keeps track of  
> subclasses as their created - maybe it’s called something  
> else - descendants maybe? - I can’t remember, but I’m pretty sure it  
> exists.

lounge groggy # ruby script/console  
Loading development environment.

> > Page.descendants  
> > =\> [AtomPage, AlphabetIndexPage, AlphabetPage, GroggyFileNotFoundPage,  
> > GroggyRootPage, GroggyFestivalPage, GroggyArticlePage,  
> > GigParentPage, ArchivePage, EnvDumpPage, ArchiveDayIndexPage,  
> > ArchiveMonthIndexPage, FileNotFoundPage, ArchiveYearIndexPage,  
> > VenuePage]
> 
> > FileNotFoundPage.descendants  
> > =\> [GroggyFileNotFoundPage]

---

<div class="post-metadata">

**Author:** ![bguan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/8edcca/32.png) [@bguan](https://www.ruby-forum.com/u/bguan)\
**Post date:** [March 14, 2007, 10:43am UTC](https://www.ruby-forum.com/t/alias-page-extension/88420/14 "2007-03-14T10:43:03Z")

</div>

Hello,  
I’m working on a Gallery extension…i created a gallery section in  
the admin panel (to manage files uploading / sorting etc) and a  
Gallery page type…  
when I create a gallery page i use shomething like this in the body  
part:

\<r:gallery:if\_index\>

- 

- ![]()" /\>

if request\_uri is shomething like:

/gallery\_page/

…it displays the galleries list…

if it is:

/gallery\_page/:id

it displays the list of images/files in the selected gallery.

I use this code because the body part is displayed by default…  
It could be better to split the code in different part…in the body  
part the code for the galleries and in a ‘gallery’ part  
the code used to display the list of files…and then render the right  
part if in the request\_uri there is the id or not…  
is it possible using some hack in my gallery model? or i can use  
another method?

thx

* * *

Andrea F.

Think BigChief: [http://think.bigchief.it](http://think.bigchief.it)

---

<div class="post-metadata">

**Author:** ![bguan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/8edcca/32.png) [@bguan](https://www.ruby-forum.com/u/bguan)\
**Post date:** [May 28, 2008, 10:41am UTC](https://www.ruby-forum.com/t/alias-page-extension/88420/15 "2008-05-28T10:41:16Z")

</div>

I am, great job of moving it to git. Very easy to get and install. I  
thought maybe there are some requirements like imagemagick and  
rmagick. I don’t have those gems installed so if they’re needed it  
makes sense, I guess. If they are needed seems like it would be a  
good idea to add that to the readme file.

---

<div class="post-metadata">

**Author:** ![bguan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/8edcca/32.png) [@bguan](https://www.ruby-forum.com/u/bguan)\
**Post date:** [May 28, 2008, 2:48am UTC](https://www.ruby-forum.com/t/alias-page-extension/88420/16 "2008-05-28T02:48:54Z")

</div>

On Mon, May 26, 2008 at 10:16 PM, Steven S.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I installed .6.7 and then I tried to use the gallery extension with some  
> difficulties. It all seemed to install properly but uploaded images aren’t  
> added to the gallery. The images are uploaded, It’s just that my gallery  
> says 0 files and of course there’s nothing in the gallery. Anyone else have  
> this problem?

It’s strange, are you using the latest version of the gallery?

–  
Andrea F.  
[http://gravityblast.com](http://gravityblast.com) - [http://nimboo.net](http://nimboo.net)

---

<div class="post-metadata">

**Author:** ![bguan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/8edcca/32.png) [@bguan](https://www.ruby-forum.com/u/bguan)\
**Post date:** [May 28, 2008, 10:53am UTC](https://www.ruby-forum.com/t/alias-page-extension/88420/17 "2008-05-28T10:53:39Z")

</div>

On Tue, May 27, 2008 at 5:37 PM, Steven S.  
[removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> I am, great job of moving it to git. Very easy to get and install. I  
> thought maybe there are some requirements like imagemagick and rmagick. I  
> don’t have those gems installed so if they’re needed it makes sense, I  
> guess. If they are needed seems like it would be a good idea to add that to  
> the readme file.

Yeah you need at least rmagick or mini\_magick.  
You are right, I’m going to add it in the README file.  
Thank you very much and let me know if it works.

–  
Andrea F.  
[http://gravityblast.com](http://gravityblast.com) - [http://nimboo.net](http://nimboo.net)

---

<div class="post-metadata">

**Author:** ![bguan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/8edcca/32.png) [@bguan](https://www.ruby-forum.com/u/bguan)\
**Post date:** [May 28, 2008, 11:11am UTC](https://www.ruby-forum.com/t/alias-page-extension/88420/18 "2008-05-28T11:11:21Z")

</div>

Oh, mini\_magick might be better. I’m hosting on Joyent and they don’t  
have rmagick. They don’t have mini\_magick either but I might be able  
to freeze that one in. What changes do I need to make to have it work  
with mini\_magick?

---

<div class="post-metadata">

**Author:** ![bguan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/8edcca/32.png) [@bguan](https://www.ruby-forum.com/u/bguan)\
**Post date:** [May 28, 2008, 11:23am UTC](https://www.ruby-forum.com/t/alias-page-extension/88420/19 "2008-05-28T11:23:44Z")

</div>

Are you sure Joyent doesn’t have RMagick?

I have a couple of Radiant sites there using both my own extensions  
and Sean’s page\_attachments with RMagick. Mini\_magick does not work  
there, even if you freeze the gem.

I just discovered Paperclip,  
[http://www.thoughtbot.com/projects/paperclip](http://www.thoughtbot.com/projects/paperclip)  
. It resizes images without RMagick or Mini\_magick, just using the  
image\_magick library itself. I have a prototype extension based on it,  
though it is not a full fledged gallery like Andrea’s.

Keith B.  
[http://keithbingman.com](http://keithbingman.com)

---

<div class="post-metadata">

**Author:** ![bguan](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/8edcca/32.png) [@bguan](https://www.ruby-forum.com/u/bguan)\
**Post date:** [May 28, 2008, 11:34am UTC](https://www.ruby-forum.com/t/alias-page-extension/88420/20 "2008-05-28T11:34:19Z")

</div>

That’s sad news about mini\_magick not working at Joyent even if you  
freeze it in. I guess the available gems depends on what server  
you’re on. I’m on Spring and here is the list of gems:

\*\*\* LOCAL GEMS \*\*\*

actionmailer (2.0.2)  
actionpack (2.0.2)  
activerecord (2.0.2)  
activeresource (2.0.2)  
activesupport (2.0.2)  
BlueCloth (1.0.0)  
capistrano (2.2.0)  
cgi\_multipart\_eof\_fix (2.5.0)  
daemons (1.0.10)  
extensions (0.6.0)  
fast\_xs (0.6)  
fastthread (1.0.1)  
ferret (0.11.6)  
filesystem (0.1.0)  
gem\_plugin (0.2.3)  
gruff (0.3.1)  
highline (1.4.0)  
hoe (1.5.1)  
hpricot (0.6)  
log4r (1.0.5)  
mime-types (1.15)  
mongrel (1.1.4)  
mongrel\_cluster (1.0.5)  
needle (1.3.0)  
needle-extras (1.0.0)  
net-sftp (1.1.1)  
net-ssh (1.1.2)  
postgres (0.7.9.2008.01.28)  
rails (2.0.2)  
rake (0.8.1)  
RedCloth (3.0.4)  
ruby-json (1.1.2)  
ruby-openid (2.0.4)  
ruby-yadis (0.3.4)  
rubyforge (0.4.5)  
rubygems-update (1.0.1)  
syntax (1.0.0)  
tzinfo (0.3.8)

[Next page](https://www.ruby-forum.com/t/alias-page-extension/88420.md?page=2)
