NAME

Tags::HTML::Message::Board::Blank - Tags helper for message board blank page.

SYNOPSIS

use Tags::HTML::Message::Board::Blank;

my $obj = Tags::HTML::Message::Board::Blank->new(%params);
$obj->cleanup;
$obj->init;
$obj->preapre;
$obj->process;
$obj->process_css;

DESCRIPTION

Tags helper to print HTML page of blank message board.

The page contains form to create message board and save button to save.

This helper is created for usage in Plack::App::Message::Board plack application which is full application for page.

METHODS

new

my $obj = Tags::HTML::Message::Board::Blank->new(%params);

Constructor.

  • css

    CSS::Struct::Output object for process_css processing.

    Default value is undef.

  • css_class

    CSS class for message board.

    Default value is 'message-board'.

  • lang

    Language in ISO 639-3 code.

    Default value is 'eng'.

  • tags

    Tags::Output object.

    Default value is undef.

  • text

    Hash reference with keys defined language in ISO 639-2 code and value with hash reference with texts.

    Required keys are 'add_comment', 'author', 'date' and 'save'.

    Default value is:

    {
    	'eng' => {
                   'add_message_board' => 'Add message board',
                   'save' => 'Save',
    	},
    }

Returns instance of object.

cleanup

$obj->cleanup;

Process cleanup after page run.

Do nothing in this class.

Returns undef.

init

$obj->init;

Initialize object.

Do nothing in this class.

Returns undef.

prepare

$obj->prepare;

Prepare object.

Do nothing in this class.

Returns undef.

process

$obj->process;

Process Tags structure for message board.

Returns undef.

process_css

$obj->process_css;

Process CSS::Struct structure for message board.

Returns undef.

ERRORS

new():
        From Class::Utils::set_params():
                Unknown parameter '%s'.
        From Mo::utils::Language::check_language_639_2():
                Parameter 'lang' doesn't contain valid ISO 639-2 code.
                        Codeset: %s
                        Value: %s
        From Tags::HTML::new():
                Parameter 'css' must be a 'CSS::Struct::Output::*' class.
                Parameter 'tags' must be a 'Tags::Output::*' class.
        Number of texts isn't same as expected.
        Parameter 'text' is required.
        Parameter 'text' must be a hash with language texts.
        Texts for language '%s' doesn't exist.
        Text for lang '%s' and key '%s' doesn't exist.

process():
        From Tags::HTML::process():
                Parameter 'tags' isn't defined.

process_css():
        From Tags::HTML::process_css():
                Parameter 'css' isn't defined.

EXAMPLE1

use strict;
use warnings;

use CSS::Struct::Output::Indent;
use Tags::HTML::Message::Board::Blank;
use Tags::Output::Indent;

# Object.
my $css = CSS::Struct::Output::Indent->new;
my $tags = Tags::Output::Indent->new(
        'no_simple' => ['textarea'],
        'preserved' => ['style', 'textarea'],
        'xml' => 1,
);
my $obj = Tags::HTML::Message::Board::Blank->new(
        'css' => $css,
        'tags' => $tags,
);

# Process message board.
$obj->process_css;
$obj->process;

# Print out.
print "CSS\n";
print $css->flush."\n\n";
print "HTML\n";
print $tags->flush."\n";

# Output:
# CSS
# textarea {
#         width: 100%;
#         padding: 12px 20px;
#         margin: 8px 0;
#         display: inline-block;
#         border: 1px solid #ccc;
#         border-radius: 4px;
#         box-sizing: border-box;
# }
# button {
#         width: 100%;
#         background-color: #4CAF50;
#         color: white;
#         padding: 14px 20px;
#         margin: 8px 0;
#         border: none;
#         border-radius: 4px;
#         cursor: pointer;
# }
# button:hover {
#         background-color: #45a049;
# }
# .message-board-blank {
#         max-width: 600px;
#         margin: auto;
# }
# .message-board-blank .title {
#         margin-top: 20px;
#         font-weight: bold;
#         font-size: 1.2em;
# }
# button {
#         margin: 0;
# }
# 
# HTML
# <div class="message-board-blank">
#   <div class="title">
#     Add message board
#   </div>
#   <form method="post">
#     <textarea autofocus="autofocus" rows="6"></textarea>    <button type="button">
#       Save
#     </button>
#   </form>
# </div>

EXAMPLE2

use strict;
use warnings;

use CSS::Struct::Output::Indent;
use Plack::App::Tags::HTML;
use Plack::Runner;
use Tags::HTML::Message::Board::Blank;
use Tags::Output::Indent;

my $css = CSS::Struct::Output::Indent->new;
my $tags = Tags::Output::Indent->new(
        'no_simple' => ['textarea'],
        'preserved' => ['style', 'textarea'],
        'xml' => 1,
);
my $message_board_blank = Tags::HTML::Message::Board::Blank->new(
        'css' => $css,
        'tags' => $tags,
);
$message_board_blank->process_css;
my $app = Plack::App::Tags::HTML->new(
        'component' => 'Tags::HTML::Container',
        'data' => [sub {
                my $self = shift;
                $message_board_blank->process_css;
                $message_board_blank->process;
                return;
        }],
        'css' => $css,
        'tags' => $tags,
)->to_app;
Plack::Runner->new->run($app);

# Output screenshot is in images/ directory.
Web app example

DEPENDENCIES

Class::Utils, Data::HTML::Element::Button, Data::HTML::Element::Textarea, Error::Pure, Mo::utils, Mo::utils::CSS, Mo::utils::Language, Readonly, Tags::HTML, Tags::HTML::Element::Button, Tags::HTML::Element::Textarea.

REPOSITORY

https://github.com/michal-josef-spacek/Tags-HTML-Message-Board

AUTHOR

Michal Josef Špaček mailto:skim@cpan.org

http://skim.cz

LICENSE AND COPYRIGHT

© 2024 Michal Josef Špaček

BSD 2-Clause License

VERSION

0.05