Daizu::Publish - functions for publishing output
This module contains various functions used for publishing content. A lot of the code in here is for implementing the daizu publish command, which means working out what changes have been made to content since the last time it was run.
The following functions are available for export from this module. None of them are exported by default.
Returns a reference to a hash describing what changes where made between revision $start_rev and revision $end_rev in the content repository.
The keys to the hash are the GUID IDs for the files changed (not paths, because one of the the changes might have been the file getting renamed). Each of the values is another hash, in the same format as for the $changes value of the url_updates_for_file_change() method.
This is all run in a transaction.
Updates the URLs for any changed files described by $changes, which should be the value returned from the file_changes_between_revisions() function.
This starts by using the url_updates_for_file_change() method to figure out if any other files need their URLs updating. Then, for any such files and for all the ones given in $changes, it calls the update_urls_in_db() method to do the updates.
This returns a reference to a hash containing the following keys, each of which is itself a reference to a hash:
Keys are actual URLs. They are included if the URL update process has caused them to become newly active (which means they need to be published), or have been deactivated, or the URL itself has changed but the new one still points to basically the same content. The values in all cases are URL info hashes.
Keys are filenames of rewrite maps named in the Daizu configuration file. Only ones which need to be updated to reflect the URL changes are included in these hashes. The values are the hashes of output configuration information Daizu uses internally to reflect the output XML element.
All of this is done within a database transaction.
Figures out which URLs need to be published or deleted on the live websites to reflect changes in the content repository. $start_rev should be the revision just before the changes began (the end revision has to be the current one of the live working copy). $changes is the value returned from the file_changes_between_revisions() function.
The last three arguments should be the corresponding values returned by the do_publishing_url_updates() function.
Returns a list of two values, each of which is a reference to a hash. The first contains information about URLs which need to be published to bring the live websites up to date, and the second URLs which have to be deleted. The keys are the actual URLs, and the values are URL info hashes.
It is this function which calls the methods publishing_for_file_change() and publishing_for_url_change() on generators, so it includes URLs which need to be pubilshed because of their say-so.
This actually does the publication work required to bring live sites up to date with changes made in the content repository, given enough information about what to do. It doesn't return anything.
$publish_url and $delete_url should be the two values returned from the urls_which_need_publishing() function. $update_redirect_maps and $update_gone_maps should be the corresponding values returned by the do_publishing_url_updates() function.
This first does publication for all the specified URLs, writing them in to the appropriate files in the appropriate document roots. See the publish_urls() function for full details of how the output is written.
After that, the redirect and 'gone' maps are published. Finally the files associated with any deleted URLs are removed.
TODO - should this do rsyncing afterwards?
Publishes the output for the URLs whose info hashes are supplied (in an array reference) in $urls. If there is more than one URL they are all published using the same generator with a single method call.
$file should be a Daizu::File object suitable for passing to the generator method with the name $method on class $generator.
This writes the new content into temporary files alongside the intended output file first and then moves them into place (possibly over the top of an older version of the file) when complete, so if publication fails part way through it won't leave output half written. It should clear away the temporary files if something goes wrong. Note that it doesn't overwrite an older file if it is identical to the new one, so that the modification time of the file will be unaffected if the publication wasn't really necessary.
TODO - redirect and gone maps should be published in the same way as URL content, with the file first written to a different filename, then compared with the old version, then moved into place if necessary.
This software is copyright 2006 Geoff Richards <email@example.com>. For licensing information see this page:
To install Daizu, copy and paste the appropriate command in to your terminal.
perl -MCPAN -e shell
For more information on module installation, please visit the detailed CPAN module installation guide.