Aozora2Epub

 view release on metacpan or  search on metacpan

lib/Aozora2Epub/CachedGet.pm  view on Meta::CPAN

    my $r = HTTP::Tiny->new->get($url);
    croak "$url: $r->{status} $r->{reason}" unless $r->{success};
    $content = $r->{content};

    my $encoding = 'utf-8';
    my $content_type = $r->{headers}{'content-type'};
    unless ($content_type =~ m{text/}) {
        $CACHE->set($url, $content);
        return $content; # binary
    }
    if ($content_type =~ /charset=([^;]+)/) {
        $encoding = $1;
    } elsif ($content =~ m{<meta http-equiv="content-type" content="[^"]+;charset=(\w+)"}i) {
        $encoding = $1;
    }
    $content = Encode::decode($encoding, $content);
    $CACHE->set($url, $content);
    return $content;
}

1;

__END__

share/basic/EPUB/nav.xhtml  view on Meta::CPAN

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" lang="ja-JP" xml:lang="ja-JP">
<head>
  <meta charset="utf-8" />
  <meta name="generator" content="aozora2epub" />
  <title><: $title :></title>
  <style>
  </style>
</head>
<body epub:type="frontmatter">
  <nav epub:type="toc" role="doc-toc" id="toc">
    <h1 id="toc-title"><: $title :></h1>
      <ol class="toc">
        : if $has_sections {

share/basic/EPUB/text/cover_page.xhtml  view on Meta::CPAN

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" lang="ja-JP" xml:lang="ja-JP">
<head>
  <meta charset="utf-8" />
  <meta name="generator" content="aozora2epub" />
  <title><: $title :></title>
  <style>
    #cover {
	width: 100%;
	height: 100%;
	text-align: center;
    }
  </style>
</head>

share/basic/EPUB/text/file.xhtml  view on Meta::CPAN

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" lang="ja-JP" xml:lang="ja-JP">
<head>
  <meta charset="utf-8" />
  <meta name="generator" content="aozora2epub" />
  <title><: $name :></title>
  <style>
  </style>
  <link rel="stylesheet" type="text/css" href="../styles/style.css" />
</head>
<body epub:type="bodymatter">
<section id="start" class="level1 unnumbered">
<: $content :>
</section>

share/basic/EPUB/text/okuzuke.xhtml  view on Meta::CPAN

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" lang="ja-JP" xml:lang="ja-JP">
<head>
  <meta charset="utf-8" />
  <meta name="generator" content="aozora2epub" />
  <title><: $name :></title>
  <style>
    div.okuzuke { font-size: 0.7em; }
    h5 { font-size: 1em; margin:1.75em 0 0.5em 0; padding:0; }
  </style>
</head>
<body epub:type="bodymatter">
<section id="start" class="level1 unnumbered">
<div class="okuzuke">

share/basic/EPUB/text/title_page.xhtml  view on Meta::CPAN

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" lang="ja-JP" xml:lang="ja-JP">
<head>
  <meta charset="utf-8" />
  <meta name="generator" content="aozora2epub" />
  <title><: $title :></title>
  <style>
    .title { margin-top: 3em; text-align: center; }
    .author { margin-top: 4em; text-align: center; }
    #aozora {
	margin-bottom: 5em;
	width: 100%;
	text-align: center;
	font-size: 0.8em;

share/basic/EPUB/toc.xhtml  view on Meta::CPAN

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:epub="http://www.idpf.org/2007/ops" lang="ja-JP" xml:lang="ja-JP">
<head>
  <meta charset="utf-8" />
  <meta name="generator" content="aozora2epub" />
  <title><: $title :></title>
  <style>
    h1 { font-size: 1.25em; }
    div.level1 { margin-top: 2em; }
    div.level2 { margin-top: 4em; }
  </style>
  <link rel="stylesheet" type="text/css" href="styles/style.css" />
</head>
<body epub:type="bodymatter">

xt/input/01/files/01_000.html  view on Meta::CPAN

<html><head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<title>テスト1</title>
</head>
<body>
<div class="metadata">
<h1 class="title">テスト1</h1>
<h2 class="author">酔狂亭不出来</h2>
<br />
<br />
</div>
<div class="main_text"><br />

xt/input/02/files/02_000.html  view on Meta::CPAN

<html><head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<title>テスト2</title>
</head>
<body>
<div class="metadata">
<h1 class="title">テスト-no-toc</h1>
<h2 class="author">酔狂亭不出来</h2>
<br />
<br />
</div>
<div class="main_text"><br />

xt/input/03/files/03_000.html  view on Meta::CPAN

<html><head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<title>テスト2</title>
</head>
<body>
<div class="metadata">
<h1 class="title">テスト-sub-title</h1>
<h2 class="subtitle">サブタイトル3</h2>
<h2 class="author">酔狂亭不出来</h2>
<br />
<br />
</div>

xt/input/04/files/04_000.html  view on Meta::CPAN

<html><head>
<meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
<title>テスト4</title>
</head>
<body>
<div class="metadata">
<h1 class="title">テスト4</h1>
<h2 class="subtitle">サブタイトル3</h2>
<h2 class="author">酔狂亭不出来</h2>
<br />
<br />
</div>



( run in 0.282 second using v1.01-cache-2.11-cpan-4d50c553e7e )