App-Zapzi

 view release on metacpan or  search on metacpan

lib/App/Zapzi/Articles.pm  view on Meta::CPAN

}


sub export_article
{
    my $id = shift;

    my $rs = get_article($id);
    return unless $rs;

    my $html = sprintf("<html><head><meta charset=\"utf-8\">\n" .
                       "<title>%s</title></head><body>%s</body></html>\n",
                       $rs->title, $rs->article_text->text);

    return $html;
}

# Convenience function to get the DBIx::Class::ResultSet object for
# this table.

sub _articles

lib/App/Zapzi/Publishers/HTML.pm  view on Meta::CPAN


sub start_publication
{
    my $self = shift;

    $self->_set_encoding('UTF-8') unless $self->encoding;

    open my $file, '>', $self->filename
            or croak "Can't open output HTML file: $!\n";

    my $html = sprintf("<html><head><meta charset=\"%s\">\n" .
                       "<title>%s</title></head><body>\n",
                       $self->encoding, $self->collection_title);
    print {$file} $html;

    $self->_set_file($file);
}


sub add_article
{

lib/App/Zapzi/Transformers/HTML.pm  view on Meta::CPAN

{
    my $self = shift;

    # Use the passed in text if explicity set, else get it from the
    # fetched article object. This is used by derived classes that
    # transform text into HTML then call this method.
    my ($input) = @_;
    $input //= $self->input->text;

    my $encoding = 'utf8';
    if ($self->input->content_type =~ m/charset=([\w-]+)/)
    {
        $encoding = $1;
    }
    my $raw_html = Encode::decode($encoding, $input);

    $self->_extract_title($raw_html);

    my $tree = $self->_extract_html($raw_html);
    return unless $tree;

t/10-app.t  view on Meta::CPAN

    $app = get_test_app();
    my $stdout = Test::Output::stdout_from(sub
                                           { $app->process_args(qw(publish)) });
    like( $stdout,
          qr/Published .*\.html$/,
          'publish as different encoding by config' );
    if ($stdout =~ /Published (.+)$/)
    {
        my $published_file = $1;
        my $contents = path($published_file)->slurp;
        like( $contents, qr/<meta charset="ISO-8859-1">/,
              'Contents encoded correctly for ISO-8859-1' );
    }
    else
    {
        fail('Could not read published file');
    }
    ok( ! $app->run, 'pub encoding by config run' );

    $app->process_args(qw(add t/testfiles/sample.txt));

t/testfiles/empty.html  view on Meta::CPAN

<!DOCTYPE html>

<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>Empty HTML Document</title>
    <meta name="description" content="A testing document for App::Zapzi">
    <meta name="author" content="Rupert Lane">
  </head>

  <body>
  </body>
</html>

t/testfiles/html-font.html  view on Meta::CPAN

<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>Font tests </title>
    <meta name="description" content="A testing document for App::Zapzi">
    <meta name="author" content="Rupert Lane">
  </head>

  <body>

    <h1>Lorem ipsum</h1>

    <p>

t/testfiles/html-links.html  view on Meta::CPAN

<!DOCTYPE html>

<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>Sample &ldquo;HTML&rdquo; Document</title>
    <meta name="description" content="A testing document for App::Zapzi">
    <meta name="author" content="Rupert Lane">
  </head>

  <body>

    <div id="header"><p>Header!</p></div>

    <div id="body">

t/testfiles/html-no-title.html  view on Meta::CPAN

<html>
<head>
  <meta charset="utf-8">
</head>
<body>
  <p>Here is some text.</p>
</body>
</html>

t/testfiles/html-two-titles.html  view on Meta::CPAN

<!DOCTYPE html>

<html lang="en">
  <head>
    <meta charset="utf-8">
    <title> Title 1 </title>
    <meta name="description" content="A testing document for App::Zapzi">
    <meta name="author" content="Rupert Lane">
  </head>

  <body>

    <h1>Lorem ipsum</h1>

    <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed

t/testfiles/sample.html  view on Meta::CPAN

<!DOCTYPE html>

<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>Sample &ldquo;HTML&rdquo; Document</title>
    <meta name="description" content="A testing document for App::Zapzi">
    <meta name="author" content="Rupert Lane">
  </head>

  <body>

    <div id="header"><p>Header!</p></div>

    <div id="body">



( run in 1.062 second using v1.01-cache-2.11-cpan-fd5d4e115d8 )