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.
- file_changes_between_revisions($cms, $start_rev, $end_rev)
Returns a reference to a hash describing what changes where made between revision
$end_revin 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
$changesvalue of the url_updates_for_file_change() method.
This is all run in a transaction.
- do_publishing_url_updates($cms, $changes)
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:
- url_activated, url_deactivated, url_changed
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.
- update_redirect_maps, update_gone_maps
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
All of this is done within a database transaction.
- urls_which_need_publishing($cms, $start_rev, $changes, $url_activated, $url_deactivated, $url_changed)
Figures out which URLs need to be published or deleted on the live websites to reflect changes in the content repository.
$start_revshould be the revision just before the changes began (the end revision has to be the current one of the live working copy).
$changesis 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.
- do_publication_work($cms, $publish_url, $delete_url, $update_redirect_maps, $update_gone_maps)
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.
$delete_urlshould be the two values returned from the urls_which_need_publishing() function.
$update_gone_mapsshould 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?
- publish_urls($cms, $file, $generator, $method, $urls)
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.
$fileshould be a Daizu::File object suitable for passing to the generator method with the name
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.
- publish_redirect_map($cms, $wc_id, $config)
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.
- publish_gone_map($cms, $wc_id, $config)
- update_live_sites($cms, $start_rev)
This software is copyright 2006 Geoff Richards <firstname.lastname@example.org>. For licensing information see this page: