Permalink
Browse files

rename as share.

  • Loading branch information...
1 parent 0dae062 commit 367a5caa59b7fc011750864ba2eb9707710746aa @yusukebe committed Feb 6, 2012
View
1 Makefile.PL
@@ -8,6 +8,7 @@ requires 'Text::Xslate';
requires 'Path::Class';
install_script 'yomico';
+install_share 'share';
tests 't/*.t';
author_tests 'xt';
View
11 lib/Yomico/Web.pm
@@ -7,6 +7,7 @@ use File::Spec;
use Text::Markdown qw/markdown/;
use Yomico;
use Text::Xslate qw/mark_raw/;
+use File::ShareDir qw/dist_file/;
sub new {
my ( $class, %opt ) = @_;
@@ -33,8 +34,8 @@ sub app {
sub render_content {
my ( $self, $content_html ) = @_;
- my $header = file(Yomico->base_dir, 'templates/header.tt')->slurp;
- my $footer = file(Yomico->base_dir, 'templates/footer.tt')->slurp;
+ my $header = file( $self->local_or_share_file('header.tt') )->slurp;
+ my $footer = file( $self->local_or_share_file('footer.tt') )->slurp;
my $tx = Text::Xslate->new(
syntax => 'TTerse',
);
@@ -50,6 +51,12 @@ sub render_content {
[$html] ];
}
+sub local_or_share_file {
+ my ( $self, $name ) = @_;
+ return $name if -f $name;
+ return dist_file( 'Yomico', $name );
+}
+
sub make_path {
my ( $self, $path_info ) = @_;
return $self->{root} if $path_info =~ m!^/$!;
View
0 templates/footer.tt → share/footer.tt
File renamed without changes.
View
0 templates/header.tt → share/header.tt
File renamed without changes.

0 comments on commit 367a5ca

Please sign in to comment.