Skip to content
node79 edited this page Aug 16, 2010 · 9 revisions

Template Differences from 1.8 to 1.10

There were several API changes going from version 1.8 to 1.10 of Bricolage.
If you have templates in version 1.8, going to 1.10 will sometimes require
some adjustments to be made.


Rough mapping (fixme)

1.8:
 my $element = Bric::Biz::AssetType->lookup({id => $element_id});
1.10:
 my $element = Bric::Biz::ElementType->lookup({id => $element_id});

$element->is_active, $element->get_top_level work the same..
get_output_channels. get_containers.

1.8:
 foreach my $data ($element->get_data) {
     my $meta = $data->get_meta('html_info');
1.10:
 foreach my $data ($element->get_field_types) {

The $data in 1.10 basically encompasses the old $data
plus the old $meta. We have these replacements (otherwise the same):

1.8                        ===  1.10
type => $meta->{type}      ===  ???
label => $meta->{disp}     ===  name => $data->get_name
default => $meta->{value}  ===  default_val => $data->get_default_val
options => $meta->{vals}   ===   => $data->get_vals
multiple => $meta->{multiple} ===  => $data->get_multiple
size => $meta->{length}    ===  length => $data->get_length
rows => $meta->{rows}      ===   => $data->get_rows
cols => $meta->{cols}      ===   => $data->get_rows

And for setters, it’s similar, 1.8 had some things
like $data→set_key_name, $data→set_required, $data→set_quantifier,
etc., but also the meta crap:


$data→set_attr(html_info => disp => $field→{label});

— Bric.ScottLanning – 26 Apr 2007

Integrating with third-party projects, libraries, etc.

Dawn was pointing out some formatting options (e.g, for character entities, encoding, etc.) and I wanted to note this project as one to look at integrating: http://code.google.com/p/typogrify/

Also, I’ve been finding this editor easier for simple markup than loading a WYSYWYG-style editor:
http://alexking.org/projects/js-quicktags

Chris Schultz mentioned NiceEdit (http://nicedit.com/) which looks like it could also be a simple, fast, WYSIWYG option for Bricolage. This example (http://nicedit.com/demos.php?demo=4) of having “inline” editing of span elements, with an AJAX save option is very cool.

— Bric.PhillipSmith – 10 Jan 2008

See also Bric.MakeUp for “Makeup”, a port of John Grubers excellent “Markdown”. The port is finished, and has been in production for some time at http://www.newint.org.

— Bric.BradHarder – 02 Jan 2008

How to work with Media Elements in Bricolage

References: Bric::Biz::Asset::Business::Media, Bric::Util::MediaType

Uploading and Adding Metadata for Media Elements in Bricolage


$media = $media->upload_file($file_handle, $file_name)
$media = $media->upload_file($file_handle, $file_name, $media_type)
$media = $media->upload_file($file_handle, $file_name, $media_type, $size)

Reads a file from the passed $file_handle and stores it in the media object under $file_name. If $media_type is passed, it will be used to set the media type of the file. Otherwise, upload_file() will use Bric::Util::MediaType to determine the media type. If $size is passed, its value will be used for the size of the file; otherwise, upload_file() will figure out the file size itself.

Side Effects: Closes the $file_handle after reading. Updates the media document’s URI.

Also of interest:


# Returns the uri of the media object for the Bricolage application server.
$uri = $media->get_local_uri();

# Returns the path of the media object on the Bricolage file system.
$uri = $media->get_path();

# Returns the media type object associated with this object.
$mt_obj = $media->get_media_type();

# This is the size of the media file in bytes
$size = $media->get_size();

Accessing Metadata for Media Elements in Bricolage

Although not all media elements yet have all their metadata stored in the Bricolage database (see wishlist below) you can still use the appropriate CPAN module within your Bricolage templates to access the metadata of a media file on the fly. This is what Scott is doing with this excellent Perl PodcastGeneration script which relies on the MP3::Info module.

Bricolage Media Handling Wishlist

Images that are uploaded as Media Elements in Bricolage automatically have some of their metadata (compression, interlaced ect) automatically added to the Media Element definition in the database. Apparently the Perl Image::Info module is used to gather this information while uploading.

For example the “Illustration” and “Photograph” elements which are including in each default Bricolage installation, are of the media element type ‘Image’. Their element definition comes with the following test input fields predefined: Height, Width, Resolution, Compression, Color Type.
(You can of course add your own later too.)

The interesting thing is the Perl module Image::Info is used to prepopulate these fields. I now have to figure out how to use other modules for other media type to pre-populate audio and video feilds.

David Wheeler suggests “Take a look at Bric::App::MediaFunc. It would need to be updated to support audio file formats (probably using Audio::Info, IIRC). You would also need to add values to the database a la sql/Pg/Bric/Biz/Asset/Business/Media.val (and for mysql, too).”

Clone this wiki locally