Krang::Publisher - Center of the Publishing Universe.


  use Krang::ClassLoader 'Publisher';
  my $publisher = new pkg('Publisher')();
  # Publish a list of stories to the preview path.
  # returns preview URL of first story in the list.
  my $url = $publisher->preview_story(story => \@stories);
  # Publish a list of stories to the publish path.
  $publisher->publish_story(story => \@stories);
  # unpublish a story, usually called from $story->delete
  $publisher->unpublish_story(story => $story);
  # Publish a media object to the preview path.
  # Returns the media URL if successful.
  $url = $publisher->preview_media(media => $media);
  # Publish a media object to the preview path.
  # Returns the media URL if successful.
  $url = $publisher->publish_media(media => $media);
  # unpublish a media object, usually called from $media->delete
  $publisher->unpublish_media(media => $media);
  # Get the list of related stories and media that will get published
  my $asset_list = $publisher->asset_list(story => [$story1, $story2]);
  # Place a Krang::Template template into the production path, to be
  # used when publishing.
  $publisher->deploy_template(template => $template);
  # Remove a template from the production path.
  $publisher->undeploy_template(template => $template);
  # Returns the mark used internally to break content into pages.
  my $break_txt = $publisher->PAGE_BREAK();
  # Return the Krang::Story object of the story currently being published.
  my $story = $publisher->story();
  # Return the Krang::Category object for the current category of the
  # story being published.
  my $category = $publisher->category();
  # Return the filename for a given page of the story being published.
  my $filename = $publisher->story_filename(page => $page_num);
  # determine if we're in preview mode or publish mode.
  $bool = $publisher->is_preview();
  $bool = $publisher->is_publish();
  # check to see if an object will be published, given its current state
  $bool = $publisher->test_publish_status(object => $story, mode => 'publish');


Krang::Publisher is responsible for coordinating the various components that make up a Story (Elements, Media, Categories), and putting them all together, out on the filesystem, for the world + dog to see. The publish process will result in either 'preview' or 'publish' output - content-wise, they are indistinguishable.

In both the preview and publish process, stories are checked for related media (see Krang::Story->linked_media()). Media objects will be copied into the proper output directory as part of the build process.

Unless version_check is turned off, all related assets will compare version() with preview_version() or published_version(), to see if the currently live version (in either preview or publish, depending on the mode) is the latest saved version. If so, the asset will not be published, though it will be checked for additional related assets to publish.

See Krang::ElementClass::TopLevel->force_republish() to bypass the version_check functionality.

In the publish (but not preview) process, stories will also be checked for linked stories (see Krang::Story->linked_stories()). Any linked-to stories will be checked for publish status, and will be published if they are marked as unpublished.



Access to fields for this object are provided by Krang::MethodMaker. All fields are accessible in a read-only fashion. The value of fields can be obtained in the following fashion:

  $value = $publisher->field_name();

The available fields for a publish object are:



Nothing at the moment.


Krang::ElementClass, Krang::Category, Krang::Media