Mercurial > hg > Members > anatofuz > slides
changeset 21:952136cc268f
upgrade directory separate
author | Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp> |
---|---|
date | Thu, 05 Apr 2018 11:27:39 +0900 |
parents | 31a78619d6eb |
children | 7143a82401fa |
files | lib/Slideshow/Util.pm slide-cr slides/20180306/slide.md |
diffstat | 3 files changed, 26 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/lib/Slideshow/Util.pm Tue Mar 06 19:19:37 2018 +0900 +++ b/lib/Slideshow/Util.pm Thu Apr 05 11:27:39 2018 +0900 @@ -21,6 +21,7 @@ build_pinpoint open_slide edit_slide + edit_memo /; sub getopts { @@ -54,7 +55,8 @@ } elsif ( $arg eq "edit"){ return { edit=> 1}; - + } elsif ( $arg eq "memo"){ + return { memo => 1}; } else { return { help => 1}; } @@ -73,18 +75,22 @@ my $t = localtime; # ex... 2018/02/14 - my $slide = $root_dir->child($t->strftime('%Y%m%d'). '/'.'slide.md')->touchpath; + my ($y,$m,$d) = ($t->strftime('%Y'), $t->strftime('%m'), $t->strftime('%d')); + my $slide = $root_dir->child($y .'/'. $m .'/'. $d .'/'.'slide.md')->touchpath; $template->copy($slide); } sub _search_recently { my ($root_directory_name) = @_; - my $root_dir = path($root_directory_name); my $t = localtime; - my $recently = shift @{[sort { $b->stat->mtime <=> $a->stat->mtime } $root_dir->children]}; + # ex... 2018/02/14 + my ($y,$m,$d) = ($t->strftime('%Y'), $t->strftime('%m'), $t->strftime('%d')); + my $root_dir = path($root_directory_name.'/'.$y.'/'.$m); - return $recently; + my $date = shift @{ [sort { $b->stat->mtime <=> $a->stat->mtime } $root_dir->children]}; + + return $date; } @@ -105,6 +111,16 @@ _build($dir,$slide); } +sub edit_memo { + my $root_dir = path(shift); + my $t = localtime; + + # ex... 2018/02/14 + my ($y,$m,$d) = ($t->strftime('%Y'), $t->strftime('%m'), $t->strftime('%d')); + my $memo = $root_dir->child($y .'/'. $m .'/'. $d .'/'.'memo.txt')->touchpath; + exec $ENV{EDITOR}, ($memo->realpath); +} + sub edit_slide { my $recently = _search_recently(shift); my $target = $recently->child('slide.md'); @@ -133,7 +149,7 @@ local $CWD = $dir; my ($stdout,$stderr,$exit) = capture { - system(" slideshow build ${target} -t s6cr"); + system("slideshow build ${target} -t s6cr"); }; if ($stderr){