Forum OpenACS Development: Media package ideas

Collapse
Posted by Tom Jackson on

I am working on a new package to allow me to attach media -- images, movies, links, etc. to other content.

Please take a look at the current media package datamodel and comment.

Collapse
3: Re: Media package ideas (response to 1)
Posted by Alfred Werner on
Maybe just call the table mime_types rather than un_media_types and map it to the mime.types file? Might have other applications that way. Maybe even pull it out, make it ref-mime-types and make it a prerequisite? :)
Collapse
2: Re: Media package ideas (response to 1)
Posted by Mark Aufflick on
I don't see how that data model allows you to specify that the media is attached to anything - or would you expect that to be done elsewhere?

After my time in the midgard php CMS, i have gotten used to having media arbitrarily attached to any object - and for CMS style applications it's "a good thing".

My feedback would be, rather than having a media package, which seems somewhat limited, why not an "attachment" package - so you basically store a blob + metadata and link it to an acs_object.

Seems basically the same, but caters for every possible circumstance. Of course you would specify standard metadata to store for common media eg/ mime type for everything & height/width for images.

Thinking objectly (and ripping from midgard shamelessly), the object & api would be something like:

Class attachment {
 var $id;
 var $pid; // context in acs speak
 var $score; // for forced sort orderd
 var $name;
 var $title;
 var $location; // midgard uses file-based blobs
                // we should store the blob in the content repositary
                // does CR let us choose db vs. file system on a per blob or per package basis?
 var $mimetype;
 var $sitegroup; // package_id in acs speak
 var $author;
 var $created;

 function new();
 function delete();
 function update();

 function get();
 function open();
 function serve();
 function stat();

 function listparameters();
 function parameter();
 function searchparameters();

}
It works pretty well - the parameter functions use a system wide parameter table and allow for unlimited arbitrary key/value pair meta data to be applied, gotten and searched. In addition, the cms systems that use midgard apply standard metadata tags for things like image height/width.

Collapse
4: Re: Media package ideas (response to 1)
Posted by Jun Yamog on
Hi Tom,

Have you looked at CR ability to relate items?  The CR has a similar function of doing this.  Its worth a look, no more additional data model is needed.

Collapse
5: Re: Media package ideas (response to 1)
Posted by Mark Aufflick on
Jun, you are of course right:

https://openacs.org/doc/acs-content-repository/guide/object-relationships.html

I must be tired - I have read this doc page a dozen times - just haven't used the feature recently.

Collapse
6: Re: Media package ideas (response to 1)
Posted by Jun Yamog on
Hi Mark,

Here is how I used it

http://cvs.openacs.org/cvs/~checkout~/openacs-4/contrib/packages/bcms/tcl/bcms-item-procs.tcl?rev=1.1&content-type=text/plain

look at list_related_items, relate_item and unrelate_item

This still needs a lot of work, after my current project hopefully I can start working on it again.

Collapse
7: Re: Media package ideas (response to 1)
Posted by Dave Bauer on
Tom,

Why aren't you using the content repository. It already handles most of the features you need. It also handles storage a little more easily, allowing file system or database storage of the actual media.

Mark,

There is a movement to simplify the existing attachments package to do what you are suggesting. It's on my list as part of clearning up general comments.

So, in all, storing media in the content repository and using the existing cr_item_rels table to relate the media to an object seems the best way to go.

I definitely want to see this type of solution for future CMS work.

Collapse
8: Re: Media package ideas (response to 1)
Posted by Don Baccus on
Yeah, Dave and I have talked some about improving the attachments package so its simultaneously simpler (uses the existing CR mapping facility) and more useful (not tied to file storage, among other things, OF seemed to think that file-storage == content repository)

Tom ... the CR already has image, internal link (link to a CR item ala a Unix softlink), and external link (for URLs) types.

As Dave points out it makes it easy to store in either the db or file system, good flexibility to have (though I would assume most would store in the file system given the size of movies etc)

Also the CR allows for arbitrary mapping of a CR item to a given file, which means it could be used to map items already in the file system rather than make a special copy (static pages does this already)

So ... is there any particular reason you're not planning to use it?  Any overhead due to the item-revision pairing of objects will be overwhelmed by the storage of a movie!

Collapse
9: Re: Media package ideas (response to 1)
Posted by Tom Jackson on

Thanks for the feedback.

Sorry for some of the naming of the tables, I was in the process of moving them to a separate package, and I didn't get everything updated.

When I started working on this I only thought about images and movies, so the name media seemed like it would work, but yesterday, after the datamodel had been sitting around since Sept. 8, I realized that that was kind misleading. A number of places I looked on the internet included pdf and word documents as media, but the point of the package is to attach things to other things. Attachments seemed better, and I didn't realize that there was already an Attachments package.

I need to be able to attach things to any database table row, and I need multiple 'anchor' points per row in many cases. However, the anchor points don't need to correspond to table columns, they can be arbitrarily named.

Although the media table includes a blob column, I have decided to remove that, as I noted. The storage of media objects (I guess 'attachments' is better) is not in the basic tables for the package. The storage could be in the CR, or in the filesystem.

The package must provide direct access to the attachments, images, for instance, need to be referenced in an img tag.

I'll look at the current Attachments package, but it sounds like it doesn't address all these requirements.

Collapse
10: Re: Media package ideas (response to 1)
Posted by Don Baccus on
If you use the CR correctly you can reference by URL (i.e. IMG tag) so it solves that part of the problem, too ...
Collapse
11: Re: Media package ideas (response to 1)
Posted by Tom Jackson on

I've revised a little the datamodel and included it in a new file. Since there is already an Attachments package, I am sticking with Media. But I'm using the terminology of anchor to refer to the points you can attach objects.

This is much more involved than the Attachments package, because I need to be able to attach to non acs_objects, and to multiple 'anchors' per object.

I'm still considering if I should revise other parts of my main package to use acs_objects where I didn't really want to, and simplify further by only allowing anchors that correspond to the attributes of these acs_objects. There are probably more benefits to this approach.

I was concerned that if I use the 'attach to acs_object attributes' approach, I would not be able to attach to the row, but I could just use the id column for this purpose.

Assuming this approach, would every attribute of every object be an anchor point? Possibly a mapping table from media types to the anchor points would allow you to specify what kinds of media could be attached to each attribute. The mapping table could also include max_size and other configuration parameters for the attachments.

If the CR is used, is there a generic type? Having image, extlink, etc. is a great start, but would I need to hand write a type handler for every specific type?

I'll spend the weekend mulling through the CR again to see what is possible.

Collapse
12: Re: Media package ideas (response to 11)
Posted by Tilmann Singer on
Tom, the problem I see with your request for comments is that you just posted a datamodel, but not what it is supposed to do. There is some information about that in your later comments, but it's hard to make helpful comments if you don't present some kind of design and/or requirements document first.

For example it would be nice to know why you need to attach files to arbitrary rows and not acs_objects instead - what kind of application would need that?

Also I don't see how you are making use of the CR in the revised datamodel (media-2-create.sql.txt).

<blockquote> The storage could be in the CR, or in the filesystem.
</blockquote>

Please note that, as Dave said already,  when using the CR you can choose wether it should store the data in the db or in the filesystem. No need to reimplement that functionality.

Collapse
14: Re: Media package ideas (response to 12)
Posted by Tom Jackson on

The main requirement of the package would be to provide a simple method for the developer to allow users to attach media to other database objects, and to make it easy to display these attachments as links or inline content.

I'll prepare a requirements document to explain the datamodel.

The reason to attach to something other than acs_objects is that, personally I use a lot of support tables that don't need to be acs_objects, which would benefit from media attachments.

For example, some developer might use the list of the states in grouping users. When listing the users, they might want to have a little icon with the shape of the state. The developer could use the media package to associate the icons with the state data. It should also be possible to package this data up for general use.

Another user might be reading the forums and want to provide a link from a post to another thread, or to some relevant document. The forum template could be modified to include a simple tag that would provide a link to the media UI so a user could add the link, or other document.

I might want to allow users to include multiple pictures of themselves, or about subjects of interest. They should be able to visit their workspace and find a link to let them add new photos.

I'm guessing that if I used the CR, my media table id column would have to reference cr_revisions instead of acs_objects. What I am not sure about is that if I have many different media types, how will the other attributes be stored, since they can't all be in the media table?

Collapse
Posted by Dave Bauer on
Tom,

Check out https://openacs.org/api-doc/proc-view?proc=publish%3a%3ahandle%5fbinary%5ffile publish::handle_binary_file and related tcl procs in the content repository libray. These will publish a file to the filesystem and return a template with a link or the address of the link you can use.