XAO-Content

 view release on metacpan or  search on metacpan

Content.pm  view on Meta::CPAN

configuration. Its URI is '/content' and parameters are:

 list_uri    => uri of content storage in the XAO FS, defaults
                to '/Content'

 cache_time  => for how long to keep retrieved content in memory cache,
                default is 5 minutes

 cache_size  => the size of memory cache in KB, default is 1024

 flag_cb_uri => location of a flag in clipboard that indicates whether
                or not the preview mode is on

=head1 INSTALLATION AND USE

The easiest way to install XAO Content is to use CPAN. Usually you would
need to do something like this:

 sudo perl -MCPAN -e'install XAO::DO::Web::Content'

If you downloaded archive and want to install it manually then usual

Content.pm  view on Meta::CPAN

Content is based in Web::Action object and such depends on 'mode'
argument, with the default mode being 'show'.

All methods if not stated otherwise support the following set of
arguments that defines which content object to use:

 name       => Name of content
 data_id    => ID of a specific version (optional, rarely used)
 preview    => if non-zero then unpublished version of content will
               be used. If that argument is not present then the
               clipboard preview flag is used (see flag_cb_uri above)

The following list of methods also shows 'mode' as the first element
(order alphabetically).

=over

=cut

###############################################################################
package XAO::DO::Web::Content;

Content.pm  view on Meta::CPAN


    my $form_args=merge_refs($args);
    delete @{$form_args}{qw(mode update)};
    $form->display($form_args);
}

###############################################################################

=item 'content-data' => content_data (%)

Displays data text by name according to preview argument or clipboard
flag.

By default it just outputs the content literally without any
processing. If 'parse' argument is true then the content will be parsed
as if it were a template. Arguments given to 'content-data' will be
available to that template in this case.

If there is a 'default.path' or 'default.template' arguments then they
will be displayed in case where there is no content object by that name
exists in the database. If default is not given and there is no content

Content.pm  view on Meta::CPAN


=cut

sub content_data ($%) {
    my $self=shift;
    my $args=get_args(\@_);

    my $config=$self->siteconfig('/content');
    my $flag_cb_uri=$config->{flag_cb_uri} || '/content/preview_flag';
    my $preview=$args->{preview} ||
                $self->clipboard->get($flag_cb_uri) ||
                '';

    my $text;
    if($preview) {
        if($args->{'default.path'} || defined($args->{'default.template'})) {
            use XAO::Errors qw(XAO::E::DO::FS::List);

            try {
                my ($content,$data)=$self->get_content($args);
                $text=$data->get('text');

Content.pm  view on Meta::CPAN


=cut

sub content_if_preview ($%) {
    my $self=shift;
    my $args=get_args(\@_);

    my $config=$self->siteconfig('/content');
    my $flag_cb_uri=$config->{flag_cb_uri} || '/content/preview_flag';

    if($self->clipboard->get($flag_cb_uri)) {
        $self->object->display(template => $args->{template},
                               path     => $args->{path});
    }
    elsif($args->{'default.path'} || defined($args->{'default.template'})) {
        $self->object->display(template => $args->{'default.template'},
                               path     => $args->{'default.path'});
    }
}

###############################################################################

Content.pm  view on Meta::CPAN

            path        => $args->{path},
            template    => $args->{template},
        );
    }
}

###############################################################################

=item 'content-set-preview' => content_set_preview (%)

Sets or drop preview flag in the clipboard indicating whether all
subsequent calls to the Content should return current or preview
content.

Usually this is used somewhere in the page header on all pages to check
for a specific cookie or a CGI parameter to turn on site 'preview' mode.

Example:

 <%Content
   mode="content-set-preview"

Content.pm  view on Meta::CPAN


=cut

sub content_set_preview ($%) {
    my $self=shift;
    my $args=get_args(\@_);

    my $config=$self->siteconfig('/content');
    my $flag_cb_uri=$config->{flag_cb_uri} || '/content/preview_flag';

    $self->clipboard->put($flag_cb_uri => $args->{value} ? 1 : 0);
}

###############################################################################

=item 'content-show' => content_show (%)

Displays the content by a given name and optionally an ID of a specific
release of that content.

Passes the following parameters to the given template:

Content.pm  view on Meta::CPAN


If called in scalar context then returns only content object, without
data.

Arguments it accepts are (as stated above):

 name       => Name of content (required)
 data_id    => ID of a specific version (optional, rarely used)
 preview    => if non-zero then unpublished version of content will
               be used. If that argument is not present then the
               clipboard preview flag is used (see flag_cb_uri above)

=cut

sub get_content ($%) {
    my $self=shift;
    my $args=get_args(\@_);

    my $config=$self->siteconfig('/content');
    my $list_uri=$config->{list_uri} || '/Content';
    my $flag_cb_uri=$config->{flag_cb_uri} || '/content/preview_flag';

    my $name=$args->{name};
    my $data_id=$args->{data_id} || '';
    my $preview=$args->{preview} ||
                $self->clipboard->get($flag_cb_uri) ||
                '';

    my $content=$self->odb->fetch("$list_uri/$name");

    return $content unless wantarray;

    if($data_id) {
        # Nothing
    }
    elsif($preview) {

README  view on Meta::CPAN

    configuration. Its URI is '/content' and parameters are:

     list_uri    => uri of content storage in the XAO FS, defaults
                    to '/Content'

     cache_time  => for how long to keep retrieved content in memory cache,
                    default is 5 minutes

     cache_size  => the size of memory cache in KB, default is 1024

     flag_cb_uri => location of a flag in clipboard that indicates whether
                    or not the preview mode is on

INSTALLATION AND USE
    The easiest way to install XAO Content is to use CPAN. Usually you would
    need to do something like this:

     sudo perl -MCPAN -e'install XAO::DO::Web::Content'

    If you downloaded archive and want to install it manually then usual
    four commands will do:

README  view on Meta::CPAN

    Content is based in Web::Action object and such depends on 'mode'
    argument, with the default mode being 'show'.

    All methods if not stated otherwise support the following set of
    arguments that defines which content object to use:

     name       => Name of content
     data_id    => ID of a specific version (optional, rarely used)
     preview    => if non-zero then unpublished version of content will
                   be used. If that argument is not present then the
                   clipboard preview flag is used (see flag_cb_uri above)

    The following list of methods also shows 'mode' as the first element
    (order alphabetically).

    'content-add' => content_add (%)
        Displays a form for creating new content and when the form is filled
        -- creates that content accordingly.

        Arguments are:

         form.path      => path to form template
         success.path   => path to success template

    'content-data' => content_data (%)
        Displays data text by name according to preview argument or
        clipboard flag.

        By default it just outputs the content literally without any
        processing. If 'parse' argument is true then the content will be
        parsed as if it were a template. Arguments given to 'content-data'
        will be available to that template in this case.

        If there is a 'default.path' or 'default.template' arguments then
        they will be displayed in case where there is no content object by
        that name exists in the database. If default is not given and there
        is no content found in the database then an error will be thrown.

README  view on Meta::CPAN


        Arguments are:

         name       => content name
         time       => time to revert to

    'content_revert_all' => content_revert_all (%)
        Loads older date content for all content elements at once.

    'content-set-preview' => content_set_preview (%)
        Sets or drop preview flag in the clipboard indicating whether all
        subsequent calls to the Content should return current or preview
        content.

        Usually this is used somewhere in the page header on all pages to
        check for a specific cookie or a CGI parameter to turn on site
        'preview' mode.

        Example:

         <%Content

README  view on Meta::CPAN


        If called in scalar context then returns only content object,
        without data.

        Arguments it accepts are (as stated above):

         name       => Name of content (required)
         data_id    => ID of a specific version (optional, rarely used)
         preview    => if non-zero then unpublished version of content will
                       be used. If that argument is not present then the
                       clipboard preview flag is used (see flag_cb_uri above)

AUTHORS
    Copyright (c) 2000-2002 XAO Inc.

    Andrew Maltsev <am@xao.com>

SEE ALSO
    Recommended reading: XAO::DO::Web::Content, XAO::FS, XAO::Web.



( run in 1.273 second using v1.01-cache-2.11-cpan-81fc1098f69 )