Forum OpenACS Development: Associating photos with blog entries (or generically stuff with stuff)

Hi Folks,

I have an ugly hack that lets me attach a photo (from photo-album) to a lars-blogger entry (OpenACS 5.0b4).

You do not want to ask for the current code - it is truly an ugly hack.  I create a clipboard with the name of the blog entry and then send the user off to pick out photos and put them on that clipboard.  It breaks as soon as you change the name of the blog entry, and is totally exploitable by anyone who can create a clipboard in photo-album.  For a site with exactly two registered users, this doesn't much matter.  It has the advantage of requiring no new code in photo-album, only a couple new lines added to entry-chunk in lars-blogger, one tcl/adp pair to create the clipboard (just a hack of clipboard-ae), and no new data model.

Obviously, this ugly hack needs some work.

Easy option: add a database table that maps the lars-blogger entry_id to the photo-album clipboard id.  This would close the exploit and let the user rename the blog entry without breaking things (probably triggering a rename of the clipboard to keep from confusing the user).

HOWEVER, I have this suspicion that that is still doing it all wrong, and what I should really be doing is either:

(a) looking at acs_objects and making the photos children of the blog entry

(b) using acs_rels and defining relationships between photos and blog entries.

(c) asking if anyone already has code that does this. :)

Comments on options (a) or (b)?  I suspect I break a bunch of stuff by making the photos children of a blog entry (instead of an album).  Is this a reasonable thing to do with acs_rels?  (Or is acs_rels only for people and groups?)

Something fairly general might make it easier to attach photos to etp as well...

Cathy,

Look at cr_item_rels, which are acs-rels specifically for relating acs_objects to cr_items.

A client recently pointed me to a forum system that has something like our rich text widget to support including an image that is hosted somewhere else.

http://pub106.ezboard.com/fthekittenthewitchesandthebadwardrobe36671frm24

This is another possiblity for quick hack and could support use with photo book or with images hosted elsewhere.

If you are inside dotLRN there is the attachment functionality hooked up to forums. Though it maybe an example of how *not* to do it, I haven't looked at it recently.

The code in /contrib/packages/simulation/citybuild/object-edit uses cr rels to embed images in marked up text. In this case, the text is the content of a "sim_prop" or "sim_location" or "sim_character". An object can have up to 10 images associated with it (this arbitrary limit is set in the data model, like this:
select content_type__create_type(
    'sim_location',                -- content_type
    'content_revision',            -- supertype
    'Location',                    -- pretty_name,
    'Locations',                   -- pretty_plural
    'sim_locations',               -- table_name
    'location_id',                 -- id_column
    null                           -- name_method
);

select content_type__register_relation_type (
    'sim_location',                -- content_type
    'image',                       -- target_type
    'image',                       -- relation_tag
    0,                             -- min_n
    10                             -- max_n
);

When you select an image from the dropdown (which shows all cr_items with type 'image'; type is set when it is uploaded, in this case using the same object-edit form but with image instead of location selected), you get an xml snippet that can be pasted into the body context of the sim_location. Whenever the sim_location is rendered, this xml snippet is converted to <img src="etc etc etc">.

You can install simulation on a HEAD server, go to citybuild, and try it yourself, or ping me for a login on a stable test server.

If this is going in the right direction for you, let me know and I can explain in more detail.

It's on my long list of things I want to do ...

The nicest solution would be to:

1) migrate blogger to use CR

2) use cr_item_rels and the <relation> tag as mentioned by Dave and Joel.

Any volunteers for this?

I'm contemplating thinking about moving pinds.com to a 5.1 platform, and this is one of the features I really want in my new site. And being able to actually use it on a daily basis is a strong motivator for adding features. However, the process of moving data to the new platform is going to be fairly painful ... :(

/Lars

Doing a blogger to CR migration is probably beyond me, but I'm off to read docs & code. :)
Cathy,

Have you used the CR before? If not, please look at my CR docs. And ask lots of questions!

If you have, then forgive me!

<blockquote> A client recently pointed me to a forum system that has something
like our rich text widget to support including an image that is hosted
somewhere else.
</blockquote>

I guess that would be a huge security risk because of cross site scripting issues.

Hi folks,

Is there any progress on this subject?

Thanks

Ben