The Original Article Cache (OAC) processor for feedapi retrieves the html of the page that the options->original_url tag points to and saves it to the database. It does this for every feed-item.

In addition, it implements a method for displaying the cached original article.

CommentFileSizeAuthor
#4 feedapi_oac.zip6.23 KBbuzink
#1 feedapi_oac.zip4.46 KBbuzink

Comments

buzink’s picture

Status: Active » Needs review
StatusFileSize
new4.46 KB

Hereby my first attempt. It seems to work rather well. You'll probably have to look into the code and change/remove some vocabulary-term checks to adjust it to your liking.

Unzip feedapi_oac.zip and put the folder "feedapi_oac" in the "modules/feedapi" folder.

aron novak’s picture

Really nice idea!

I have one suggestion for you:
You wrote a feedapi processor. This is really good. It means that your processor can be enabled on a per-content-type basis. The module should respect this. You use nodeapi, it will be called all the time.
At code level:

/**
 * Implementation of hook_nodeapi().
 */
function feedapi_oac_nodeapi(&$node, $op) {
  switch ($op) {
    case 'insert':
      if ($node->feedapi_node->feed_item && feedapi_enabled($node->type, 'feedapi_oac')) {
         _feedapi_oac_do_cache($node);
      }
      break;
  }
}
buzink’s picture

Thanks Aron, you are absolutely right, only your code does not work. It checks the content type of the produced feed-item nodes, not of the producing feedapi node. Do you know how to get the content-type of the producing feedapi-node? It's nowhere to be found in the node object.

buzink’s picture

StatusFileSize
new6.23 KB

AjK pointed out to me that my processor was insecure, because it doesn't filter out the javascript of cached html-pages. I now filter the html after retrieving it from the database and before displaying it as a cache page. The filter is very secure, but not very subtitle.

Because the filter operates after retrieving and not before storing the html, the full html is stored in the database. That means the filter can be easily adjusted without breaking things, even after you have used OAC to cache pages for a while. Also, placing the filter after and not before storing, saves processing power when refreshing feeds.

aron novak’s picture

buzink: Sorry, I suggested you nonsense.
In fact it's totally enough if you check the $node->feedapi_node->feed_item as the feedapi_node processor does. So your module is done right :)