BrainFeeder Coppermine Plugin

Introduction

Have you spent a lot of time building up your Coppermine Gallery and are looking for new ways to distribute your content? RSS feeds let you create feeds that your visitors can subscribe to, so that they receive new pictures automatically when you publish them. In order to receive your feed, the users need to use an aggregator. Most web browsers have built-in aggregators (Google Chrome does not) so most users can receive and subscribe to feeds without installing any new applications or plugins.

BrainFeeder provides a simple user interface that lets you configure your feeds without any knowledge of PHP or the technical aspects of RSS feeds or Coppermine. BrainFeeder for Coppermine lets you easily set up different feeds for different users or different purposes. BrainFeeder can also display RSS icons on your front page and/or on the thumbnail views that have their own feed.

BrainFeeder was designed with flexibility and ease of use in mind. By answering simple questions, you can set up feeds such as:

If you want, you can also make BrainFeeder publish pictures from restricted albums. This is a handy feature if you need to protect most pictures in an album, but still want to publish some of them.
Brainfeeder handles BB-code in picture captions and descriptions.
BrainFeeder can be run in either "realtime mode" or "batch mode." The difference is that in batch mode you need to set up a cron job that generates the RSS file, whereas in realtime mode, the feed is generated each time a user downloads or refreshes the feed. If you are concerned with response time or other performance issues of your site, the batch mode will make sure that BrainFeeder doesn't consume a lot of resources. However batch mode requires you to set up a cron job or finding another way of refreshing the RSS file.

Requirements for using BrainFeeder

BrainFeeder is closely integrated with Coppermine, and uses Coppermine's database access layer and various core functions and variables.

The only technical requirement is PHP5. There is no need to test it with PHP4 - it just won't work.

To have the script work smoothly, the following Coppermine configuration is recommended:

If you are going to run your feeds in batch mode to save server load, you need a crontab (or a similar mechanism) for refreshing the file containing the feed.

Installing or upgrading BrainFeeder for Coppermine

Before you start, make sure you understand the Brainfeeder license.

You install or upgrade BrainFeeder like this:

  1. Download the plugin unzip it and and then upload it to your plugins directory ([coppermine root]/plugins/brainfeeder).
  2. Copy the file rss.php to your Coppermine root directory.
  3. Copy the file rss.gif to your Coppermine images directory ([coppermine root]/images).
  4. Login as a Coppermine administrator
  5. If it's a new install: Go to the configuration page and install BrainFeeder from the Manage Plugins screen.
  6. Go to the BrainFeeder Configuration screen by clicking the button on the administrator's button bar (essential for upgrades as this upgrades your database)
Always make sure that you go into the BrainFeeder Configuration screen after an upgrade. The configurations screen automatically checks your database and carries out any necessary upgrades or data conversions.

Getting fed by BrainFeeder...

There are three options for running BrainFeeder:
Realtime feed: [Your Coppermine Root Directory]/rss.php?fid=n Where n is the id number of the feed (see Fid below).
Realtime feed: [Your Coppermine Root Directory]/rss.php?feed=[name] Where [name] is the name of the feed (see below).
Batch feeds: [Your Coppermine Root Directory]/rss.php Will generate all batch feeds and generate RSS files. No output when running.

By calling a batch mode feed with one of the realtime syntaxes, you can also run a batch feed in realtime.

Setting up a new feed

To setup a new feed, go to the BrainFeed configuration screen and click the "new feed" button in the lower left part of the screen.

General settings

Added in version 0.9

The general settings are used to set common parameters for all feeds.

Show RSS icon on thumbnail pages?

Added in version 0.9

If you select Yes, a RSS-icon will be shown on all thumbnail pages that has a corresponding RSS feed. For example, if you look at the thumbnail view of album number 5 and there is a RSS feed for this album, a feed icon will be shown right beneath the breadcrumb menu. If there isn't a corresponding feed, and you are logged on as an administrator, a button will appear instead that lets you create a feed with the right settings preselected.

Id for main feed

Added in version 0.9

This parameter defines a main feed for your gallery. You enter a number into the field that matches the id number (fid) of the feed you want to use as the main feed. A RSS icon will appear in the gallery header except on thumb nail views that have their own feed (see above).

Mouseover text RSS icon

Added in version 0.9

Here you can enter the text that you want to be shown when the mouse hovers over a RSS icon (tooltip). For example, you can use this text to explain to the user how they can subscribe to a feed.

Feed settings

These settings define how each individual feed should work. Click the "Add Feed" button in the lower right corner of the screen to start defining a new feed.
Click the name of an existing feed to edit it or click the Title to test it if your browser supports RSS feeds (Google Chrome does not!!)

Description

This group of parameters contains the main parameters for the feed.

Fid

The id of the feed. It is automatically generated by BrainFeeder and can't be changed. Use this number for n in the rss.php?fid=n syntax
Top

Feed name

The (technical) name of the feed. It is recommended to avoid using space character and only use standard ascii characters for the name (A->z, 0->9, _-) Use this name in the rss.php?fed=[feed name] syntax.
Top

Feed title

This is the name or title of the feed that the user will see in their RSS reader software or aggregator. Use a short but descriptive name.
Top

Keyword for logo picture

BrainFeeder uses one of your picture as a logo for the feed. It uses a unique keyword for identifying the correct picture. Make sure that the keyword is truly unique in order to get the right logo. For example, if you use the keyword "feedlogo" for feed A "logo" for feed B, feed B might very well pick the logo of feed A because it also contains "logo." In this case you should use something like "logoA" and "logoB" as they are truly unique.
Top

Feed main link

This is the URL that the user should end up at when they click the title or logo of the feed.
Top

Description

Here you can add a description of your site and your feed. Not all aggregators show the descripton while some show when you select "feed properties." Some show it at the top of the feed. As the use of this is so inconsistent, you should not put important information into this field.
Top

Copyright message

The copyright message you would like to include in your feed. Normally not visible to the user.
Top

Feed categories

You can add one or more categories to your feed which some aggregators use for sorting feeds. Separate categories by space and use a slash to denote hierarchical relations.
Top


Select content

In this section you define how Brainfeeder should select pictures for your feed.

Number of items to include

This also complements the type parameter and applies to all types. It decides how many pictures will be included in the feed. For all types except hits and rating, it is the most recet additions that will be included.
Top

Type

Changend in version 0.6

This parameter decides how pictures are selected for inclusion into the feed. This is how the various feed types work:
ParameterDescription
AnySelects any pictures in the gallery. Use this to display the most recent additions across the entire gallery.
KeywordSelects pictures with the given keyword
AlbumSelects pictures in the given album (given by album number, not name)
CategorySelects recent pictures in the given category(given by cat number, not name). Child categories are included
HitsSelects the pictures that have been viewed the highest number of times
RatingSelects the pictures with the highest rating

Top

Which keyword(s)...

This information complements the Type parameter above. If you have selected "keyword" this is where you enter the specific keyword. Similarly if you have selected album or category, this is where you enter the number of the album or category. You find this number by opening the album or category in Coppermine and looking at the URL. The album number looks like this: "....?album=3" and in this case it is the number 3 that should be put into this field. For category the URL parameter is "cat". Any, Hits and Rating do not use this field.


Top

Media types

Added in version 0.7

This parameter decides whether the feed will contain only pictures (jpg, png etc), pictures and videos (mpeg, mov etc) or any media type allowed in Coppermine (such as powerpoint, word etc). For other media than pictures, Brainfeeder will use a fixed icon in the feed. For example for a quicktime movie (.MOV) the feed will include the quicktime icon, and not a thumbnail from the movie itself.

Last pictures or Random

Added in version 0.6

Set this parameter to have the feed made up of a random selection of pictures that matches the other criteria defined for the feed. In order to limit server load the feed will only pick pictures from the most recent 1000 pictures that matches the selection criteria. As a random feed changes each time it is called, you may consider setting it up as a batch feed in order to control how quickly aggregators cycle through your gallery.
Top

Include protected pictures?

Protected pictures are pictures that belong to albums that are restricted to certain user groups, or albums that have an album password. If you answer "Yes" BrainFeeder will not take Coppermine's restriction settings into account.
Please make sure that you understand the implication of this setting. Here is an example:

You have an album with pictures from the birthday party of your daughter. Being concerned about displaying pictures of your daughter's friends freely on the internet, you set the album properties to only show this album to members of the "friends and family" user group. You give the keywords "great fun" to a few of the pictures. Later you setup a RSS feed for your site and use the keyword type and enter "fun" in the "Which keyword(s)..." field so that the feed will show all the fun stuff you've got. You answer "Yes" to "Include protected pictures." This feed will include the pictures from your daughters birthday party that you gave the keywords "greate fun" if they are among the number of most recent pictures given in the "Number of items to include" (below) because the word "fun" is part of the picture keywords "great fun".

However, this wasn't designed like this by accident. Please look into the examples to see how you can take advantage of this feature to create good feeds without comprimising security.
Top

Heading for pictures without a title in Coppermine

Titles are required for RSS feeds but not for coppermine pictures. If some of your pictures lack a title, the text that you enter here will be used instead. If you don't know what to put here - just put the word "picture."
Top

Select size of picture in feed

Changed in version 0.9

You can select whether the feed should contain the thumbnail pictures or the normal size picture (also called the intermediate picture).

Include picture story from miniCMS

Removed in version 1.0

This parameter was prior to version 1.0 used for retrieving a picture story from miniCMS. Please use the {miniCMS} anchor in the picture story field to achieve this from version 1.0
Top

Picture caption

Added in version 1.0

The picture caption is the text that accompanies each picture in the feed. Each feed item includes a title, a picture and a picture caption. By entering text and small commands called "anchors" in this field, you can customize the picture story to suit your requirements.
The anchors are used for retrieving data from the database, such as date of the picture, keywords, owner etc. The anchors are small commands included in curly braces - e.g. {keyw}, which is the anchor for the picture keywords. Text that is not contained in {curly braces} will appear in the feed just as you have typed it.
Here is an example of how you may build your picture story:

{descr}{br}
Date: {date}{br}
Category: {bread}{br}

This will create a text that is made up of the description, a line with the date the picture was shot, and a line with the breadcrumb path to the picture (category and album).



You will find a list of valid anchors here.

Include comments?

If you answer "Yes" the comments that your users have written in Coppermine will be included along with the picture itself. A maximum of 5 comments are included.
Top

Enclose picture

If you enclose the picture, the feed item will include a link to the picture file on your site. Some aggregators will download the enclosed picture automatically. If you want this, you need to decide whether the normal (intermediate) or original picture file should be included. If you choose "Normal" your Coppermine configuration must be so that Coppermine have generated intermediate picture when you uploaded your picture. Remember that you cannot change that parameter in Coppermine after-the-fact without using the admin tools to regenarate your picture library.
Top

Include Source?

If your feed get forwarded into a new feed from somebody else's site, they (should) include your site as the original source of the content. If you answer "Yes", the main URL to your site will be included as the source.
Top

Include picture keywords?

Most aggregators provide a way for users to sort or search items by category. BrainFeeder uses Coppermine keywords as feed item category if you answer "Yes" here.
Top

Publishing options

These parameters control how your feed is published.

Batch or realtime?

If you select "Realtime" the BrainFeeder script is run each time a subscriber refreshes the feed. This may cause a heavy load on your server. If you have many subscribers it is recommended that you use Batch mode. In this case, a RSS XML file is generated each time you run rss.php and your subscribers download this file rather than running the BrainFeeder script. See more information here.
Top

Filename for batchmode

Here you enter the directory and filename for the RSS XML file that should be generated if you run batch mode. If you don't give a directory name, the RSS file will be stored in you coppermine root directory. If you want to store a feed called "new pictures" in a subdirectory called "rss" which sits below the coppermine root directory, you should enter something like this: ./rss/newpictures.xml

Remember that you should only use standard ascii characters and keep "xml" as the file extension. BrainFeeder suggests a random name by default.
For the batch mode feed to be refreshed you need to run a crontab that calls rss.php (without any parameters) in your Coppermine root directory. If you don't have access to crontabs (or cronjobs or just crons) you can run rss.php manually in your browser - just know that it doesn't produce any output, just a blank screen.

Minutes between each refresh

Aggregators that refresh their feeds automatically, use this parameter to decide how often they should do a refresh. The default is once per day.
Top

Examples of how you can make the best use of BrainFeeder

The features of BrainFeeder are designed so that you can easily create interesting feeds without any knowledge of PHP or the techical details of Coppermine. There are three types of feeds that are pretty self-explanatory and doesn't really offer any more than what has been explained in the documentation above: "Hits" show the ones with the most hits (views), "Rating" the ones with the highest ratings, and "Last public" the latest public pictures. However, using the other types gives you some interesting possibilities:

Album:

Using the Album-type enable you to offer a feed that shows all the latest additions to a certain album. For example, if your hobby is to keep aquariums, you can make an album for each family of fish that you keep - let's say Cichlids. Using the Album type of feed would enable your users to subscribe to your cichlid pictures.

Category:

Category-type feeds work in a similar way to album feeds. The important difference is that a category may consist of several albums and several sub-categories which again have several albums. In the aquarist example above, you might want to create a separate feed for the fish category, so that people can subscribe to all your fish pictures no matter what species.

Keyword:

Keyword-feeds are the most flexible ones. You can create your own structure of keywords ("ontology") that lets you create feeds that show certain types of picture nomatter what album or category they belong to. Make sure that you understand how you can use unique and non-unique keywords to get the effect you want. Drawing on the aquarist example again, you could create a keyword feed using the keyword "breeding" to publish pictures of your breeding fish across all albums and categories. You can also use this feature to make exeptions to the Coppermine security model, so that certain pictures in protected albums becomes available to subscribers. You can also use a keyword feed to publish a "best of" feed. Especially if you don't have ratings for your pictures, or you want a different "best of" feed that what other users have created through rating. Just give your favorite pictures a truly unique keyword and use it in a keyword feed.

Top

Making exceptions to album security

Coppermine's security model is not very flexible. An album is either public or restricted to one or more user groups. Sometimes you have taken series of pictures that belong naturally together and where you need to restrict access to some of the pictures, but not all. This could be the case if you go trekking in the mountains and take some fantastic shots of landscape and of yourself and your friends. You may want to publish the pictures of the landscape whereas you need to restrict access to pictures showing people as not everybody likes to have their pictures on the internet. In Coppermine you would need to sort the pictures into two different albums, which requires extra work and takes the pictures out of their logical sequence.
With BrainFeeder you can achieve this by restricting access to the album, but then give all the pictures that can be published a certain keyword. You can then set up a keyword feed for that keyword that lets your subscribers see those pictures as well. Beware that when they click on the title of one of the protected pictures, they will not be able to see the picture in Coppermine without logging in with a user that has the required permissions. One way to reduce this problem is to enclose the intermediate or originial picture in the feed, so that the subscriber can actually get it. I hope to find a way to let subscribers see single pictures in restricted albums without comprimising security in a future release of BrainFeeder. Suggestions on how to achieve that are welcome :-)


Top

Change log

0.5 First publicly available alpha release

0.6 Beta release, April 6, 2009

  1. Version handling of database table - BF_db_ver in config table
  2. Implemented Random feeds
  3. Changed first feed type from "Last public" to "Any
  4. Implemented conversion logic to upgrade smoothly from 0.5 to 0.6

0.61 Beta release, April 10, 2009

  1. Updated installation script to install ver 2 of the brainfeeder table
  2. Corrected the version number shown in "manage plugins" in Coppermine

0.7 Beta release, June 14, 2009

  1. Improved handling of non-picture files
  2. Made pictures in feeds clickable
  3. Introduced a parameter that decides what media types (pictures, video etc) that will be included in the feed

0.9 Beta release, July 14, 2009

  1. Optionally, add RSS icons to thumbnail views (context sensitive)
  2. Select what size of picture to show in the feed
  3. One click feed setup from thumbnail views

1.0 RC November, 2009

  1. Structured the configuration screen to make it easier to understand
  2. You can retrieve data elements from Coppermine and Exif-info in the pictures into the captions
  3. Minor bugfixes
  4. Improved installation and upgrading process

About BrainFeeder - The licence or the lack thereof

BrainFeeder was created by Hallvard Natvik (hallvard (at) natvik (dot) com) as a pet project in order to create feeds from his family gallery at natvik.com The BrainFeeder script does not come with any particular licence because that would require me (and you, really) to read a long document of boring legal babble in order to understand what we are venturing into. However, the moment you use it, you accept software as it is and you are responsible for all consequences of using it. I give you the opportunity to do whatever you want with this software as long as you don't blame me for any bad things that happen when somebody uses it. I don't even require you to tell anybody that you got this from me (it would probably only give me trouble anyway).
However, if you do use this software, I would very much appreciate it if you sent me a short message saying where you use it and how it works. The email address is hallvard (at) natvik (dot)com. Enjoy! Top