############################################################
#
# 書籍執筆用のプラグインを提供します。
#
############################################################
package plugin::book::Install;
use strict;
use plugin::book::TocParser;

sub install {
	my $wiki  = shift;
	$wiki->add_paragraph_plugin("chapter", "plugin::book::Chapter", "HTML");
	$wiki->add_inline_plugin("title1", "plugin::book::Title1", "HTML");
	$wiki->add_inline_plugin("title2", "plugin::book::Title2", "HTML");
	$wiki->add_inline_plugin("title3", "plugin::book::Title3", "HTML");
	$wiki->add_paragraph_plugin("caption" ,"plugin::book::Caption" ,"HTML");
	$wiki->add_paragraph_plugin("toc" ,"plugin::book::Toc" ,"HTML");
	$wiki->add_inline_plugin("link" ,"plugin::book::Link" ,"HTML");
	
	$wiki->add_block_plugin("list" ,"plugin::book::List" ,"HTML");
	$wiki->add_inline_plugin("code" ,"plugin::book::Code" ,"HTML");
	
	$wiki->add_block_plugin("column" ,"plugin::book::Column" ,"HTML");
	
	$wiki->add_inline_plugin("memo", "plugin::book::Memo", "HTML");
	$wiki->add_paragraph_plugin("memolist", "plugin::book::Memolist", "HTML");
	
	$wiki->add_inline_plugin("wordcount", "plugin::book::Wordcount", "HTML");
	$wiki->add_inline_plugin("pagecount", "plugin::book::Pagecount", "HTML");
	
	$wiki->add_hook("chapter", "plugin::book::Title1");
	$wiki->add_hook("chapter", "plugin::book::Title2");
	$wiki->add_hook("chapter", "plugin::book::Title3");
	$wiki->add_hook("chapter", "plugin::book::Caption");
	
	$wiki->add_hook("title1", "plugin::book::Title2");
	$wiki->add_hook("title1", "plugin::book::Title3");
	$wiki->add_hook("title3", "plugin::book::Title3");
	
	$wiki->add_inline_plugin("br", "plugin::book::Br");
	
	my @paths = split(/\//, $wiki->get_CGI()->path_info());
	my $path_prefix = '';
	for(my $i = 0; $i < $#paths; $i++){
		$path_prefix .= '../';
	}
	
	my $head_info = <<"END_OF_HEAD";
<link href="${path_prefix}plugin/book/google-code-prettify/sunburst.css" type="text/css" rel="stylesheet" />
<script type="text/javascript" src="${path_prefix}plugin/book/google-code-prettify/prettify.js"></script>
<script type="text/javascript">window.onload = function(){ prettyPrint(); }</script>
<style type="text/css">
div.chapter {
  text-align: right;
  padding: 20px;
  font-size: 200%;
  font-style: italic;
}

a.xref {
  background-color: silver;
}

a.xref:link {
  color: black;
}

a.xref:hover {
  color: black;
}

a.xref:visited {
  color: black;
}

span.xref-error {
  background-color: silver;
  font-weight: bold;
}

span.memo {
  background-color: yellow;
  border: 1px solid #888800;
  margin-left: 2px;
  margin-right: 2x;
}

div.caption {
  font-size: 80%;
  font-weight: bold;
}

code {
 font-weight: bold;
/* font-style: italic; */
 font-family: monospace;
}

img {
  border: 1px solid silver;
}

div.column-title {
  border-top: 1px solid gray;
  border-left: 1px solid gray;
  border-right: 1px solid gray;
  padding: 4px;
  background-color: silver;
  font-weight: bold;
  margin-left: 20px;
  margin-right: 20px;
}

div.column-body {
  border-bottom: 1px solid gray;
  border-left: 1px solid gray;
  border-right: 1px solid gray;
  padding: 4px;
  margin-left: 20px;
  margin-right: 20px;
  margin-bottom: 20px;
}
</style>
END_OF_HEAD
	
	$wiki->add_head_info($head_info);
}

1;
