Alias Page Extension

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

Questions, comments, and bug reports welcome.

~~ Brian

Hi Brian,

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

Regards,
Erik.

Brian G. schreef:

Post: [email protected]
Search: http://radiantcms.org/mailing-list/search/
Site: http://lists.radiantcms.org/mailman/listinfo/radiant


Erik van Oosten

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

Thanks Brian,

That is unfortunate for me, I was looking for the reverse :frowning:

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.

Thanks Brian,

That is unfortunate for me, I was looking for the reverse :frowning:

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

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

Dan.

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

(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

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

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.

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

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

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.

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.

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]

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

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.

On Mon, May 26, 2008 at 10:16 PM, Steven S.
[email protected] 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://nimboo.net

On Tue, May 27, 2008 at 5:37 PM, Steven S.
[email protected] 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://nimboo.net

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?

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

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)