annotate lib/Slideshow/Util.pm @ 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 79a79bbc5c01
children 2eac67c0d7da 74859abd87cc
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
4
03ab44e80533 add make script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
1 package Slideshow::Util;
03ab44e80533 add make script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
2 use strict;
03ab44e80533 add make script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
3 use warnings;
03ab44e80533 add make script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
4 use utf8;
03ab44e80533 add make script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
5
03ab44e80533 add make script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
6 use Carp qw/ croak /;
03ab44e80533 add make script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
7
03ab44e80533 add make script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
8 use base 'Exporter';
03ab44e80533 add make script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
9
03ab44e80533 add make script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
10 use Time::Piece;
03ab44e80533 add make script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
11 use feature 'say';
03ab44e80533 add make script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
12 use Path::Tiny;
6
e35e9779078a auto-Update generated slides by script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 5
diff changeset
13 use File::chdir;
e35e9779078a auto-Update generated slides by script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 5
diff changeset
14 use Capture::Tiny qw/capture/;
4
03ab44e80533 add make script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
15
03ab44e80533 add make script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
16 our @EXPORT = qw/
6
e35e9779078a auto-Update generated slides by script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 5
diff changeset
17 getopts
4
03ab44e80533 add make script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
18 new
03ab44e80533 add make script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
19 set_template
6
e35e9779078a auto-Update generated slides by script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 5
diff changeset
20 build_recently
e35e9779078a auto-Update generated slides by script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 5
diff changeset
21 build_pinpoint
13
967fe50f1ef4 add open and edit mode
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 8
diff changeset
22 open_slide
967fe50f1ef4 add open and edit mode
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 8
diff changeset
23 edit_slide
21
952136cc268f upgrade directory separate
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
24 edit_memo
4
03ab44e80533 add make script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
25 /;
03ab44e80533 add make script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
26
6
e35e9779078a auto-Update generated slides by script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 5
diff changeset
27 sub getopts {
e35e9779078a auto-Update generated slides by script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 5
diff changeset
28 my ($arg,$path) = @_;
e35e9779078a auto-Update generated slides by script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 5
diff changeset
29
e35e9779078a auto-Update generated slides by script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 5
diff changeset
30 unless (defined $arg){
e35e9779078a auto-Update generated slides by script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 5
diff changeset
31 return { help => 1};
e35e9779078a auto-Update generated slides by script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 5
diff changeset
32 }
e35e9779078a auto-Update generated slides by script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 5
diff changeset
33
e35e9779078a auto-Update generated slides by script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 5
diff changeset
34 if ($arg eq "new") {
e35e9779078a auto-Update generated slides by script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 5
diff changeset
35 return {new => 1};
13
967fe50f1ef4 add open and edit mode
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 8
diff changeset
36
6
e35e9779078a auto-Update generated slides by script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 5
diff changeset
37 } elsif ( $arg eq "upload") {
e35e9779078a auto-Update generated slides by script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 5
diff changeset
38 upload();
e35e9779078a auto-Update generated slides by script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 5
diff changeset
39 exit;
e35e9779078a auto-Update generated slides by script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 5
diff changeset
40
e35e9779078a auto-Update generated slides by script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 5
diff changeset
41 } elsif ( $arg eq "build") {
e35e9779078a auto-Update generated slides by script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 5
diff changeset
42
e35e9779078a auto-Update generated slides by script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 5
diff changeset
43 if(defined $path){
e35e9779078a auto-Update generated slides by script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 5
diff changeset
44 return { build_point=> $path};
e35e9779078a auto-Update generated slides by script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 5
diff changeset
45 } else {
e35e9779078a auto-Update generated slides by script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 5
diff changeset
46 return { build => "recent"};
e35e9779078a auto-Update generated slides by script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 5
diff changeset
47 }
e35e9779078a auto-Update generated slides by script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 5
diff changeset
48
13
967fe50f1ef4 add open and edit mode
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 8
diff changeset
49
15
80767afba59c auto-Update generated slides by script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 13
diff changeset
50 } elsif ( $arg eq "build-open"){
80767afba59c auto-Update generated slides by script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 13
diff changeset
51 return { build_open => 1};
80767afba59c auto-Update generated slides by script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 13
diff changeset
52
13
967fe50f1ef4 add open and edit mode
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 8
diff changeset
53 } elsif ( $arg eq "open"){
967fe50f1ef4 add open and edit mode
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 8
diff changeset
54 return { open => 1};
967fe50f1ef4 add open and edit mode
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 8
diff changeset
55
967fe50f1ef4 add open and edit mode
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 8
diff changeset
56 } elsif ( $arg eq "edit"){
967fe50f1ef4 add open and edit mode
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 8
diff changeset
57 return { edit=> 1};
21
952136cc268f upgrade directory separate
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
58 } elsif ( $arg eq "memo"){
952136cc268f upgrade directory separate
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
59 return { memo => 1};
6
e35e9779078a auto-Update generated slides by script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 5
diff changeset
60 } else {
e35e9779078a auto-Update generated slides by script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 5
diff changeset
61 return { help => 1};
e35e9779078a auto-Update generated slides by script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 5
diff changeset
62 }
e35e9779078a auto-Update generated slides by script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 5
diff changeset
63
e35e9779078a auto-Update generated slides by script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 5
diff changeset
64 }
e35e9779078a auto-Update generated slides by script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 5
diff changeset
65
4
03ab44e80533 add make script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
66 sub set_template {
03ab44e80533 add make script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
67 my $template = shift;
03ab44e80533 add make script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
68 my $file = path($template);
03ab44e80533 add make script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
69 return $file;
03ab44e80533 add make script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
70 }
03ab44e80533 add make script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
71
03ab44e80533 add make script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
72 sub new {
03ab44e80533 add make script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
73 my ($template,$root_directory_name) = @_;
03ab44e80533 add make script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
74 my $root_dir = path($root_directory_name);
03ab44e80533 add make script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
75 my $t = localtime;
03ab44e80533 add make script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
76
5
e762bb571a45 gather file and direcotory method
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 4
diff changeset
77 # ex... 2018/02/14
21
952136cc268f upgrade directory separate
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
78 my ($y,$m,$d) = ($t->strftime('%Y'), $t->strftime('%m'), $t->strftime('%d'));
952136cc268f upgrade directory separate
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
79 my $slide = $root_dir->child($y .'/'. $m .'/'. $d .'/'.'slide.md')->touchpath;
4
03ab44e80533 add make script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
80 $template->copy($slide);
03ab44e80533 add make script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
81 }
03ab44e80533 add make script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
82
13
967fe50f1ef4 add open and edit mode
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 8
diff changeset
83 sub _search_recently {
6
e35e9779078a auto-Update generated slides by script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 5
diff changeset
84 my ($root_directory_name) = @_;
e35e9779078a auto-Update generated slides by script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 5
diff changeset
85 my $t = localtime;
e35e9779078a auto-Update generated slides by script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 5
diff changeset
86
21
952136cc268f upgrade directory separate
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
87 # ex... 2018/02/14
952136cc268f upgrade directory separate
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
88 my ($y,$m,$d) = ($t->strftime('%Y'), $t->strftime('%m'), $t->strftime('%d'));
952136cc268f upgrade directory separate
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
89 my $root_dir = path($root_directory_name.'/'.$y.'/'.$m);
6
e35e9779078a auto-Update generated slides by script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 5
diff changeset
90
21
952136cc268f upgrade directory separate
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
91 my $date = shift @{ [sort { $b->stat->mtime <=> $a->stat->mtime } $root_dir->children]};
952136cc268f upgrade directory separate
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
92
952136cc268f upgrade directory separate
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
93 return $date;
13
967fe50f1ef4 add open and edit mode
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 8
diff changeset
94 }
967fe50f1ef4 add open and edit mode
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 8
diff changeset
95
967fe50f1ef4 add open and edit mode
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 8
diff changeset
96
967fe50f1ef4 add open and edit mode
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 8
diff changeset
97
967fe50f1ef4 add open and edit mode
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 8
diff changeset
98 sub build_recently {
967fe50f1ef4 add open and edit mode
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 8
diff changeset
99 my $recently = _search_recently(shift);
6
e35e9779078a auto-Update generated slides by script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 5
diff changeset
100 _build($recently);
4
03ab44e80533 add make script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
101 }
03ab44e80533 add make script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
102
6
e35e9779078a auto-Update generated slides by script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 5
diff changeset
103 sub build_pinpoint {
e35e9779078a auto-Update generated slides by script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 5
diff changeset
104 my $target = shift;
e35e9779078a auto-Update generated slides by script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 5
diff changeset
105
e35e9779078a auto-Update generated slides by script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 5
diff changeset
106 my $target_path = path($target);
e35e9779078a auto-Update generated slides by script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 5
diff changeset
107
e35e9779078a auto-Update generated slides by script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 5
diff changeset
108 my $dir = $target_path->dirname;
e35e9779078a auto-Update generated slides by script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 5
diff changeset
109 my $slide = $target_path->basename;
e35e9779078a auto-Update generated slides by script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 5
diff changeset
110
18
79a79bbc5c01 auto-Update generated slides by script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 15
diff changeset
111 _build($dir,$slide);
6
e35e9779078a auto-Update generated slides by script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 5
diff changeset
112 }
e35e9779078a auto-Update generated slides by script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 5
diff changeset
113
21
952136cc268f upgrade directory separate
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
114 sub edit_memo {
952136cc268f upgrade directory separate
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
115 my $root_dir = path(shift);
952136cc268f upgrade directory separate
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
116 my $t = localtime;
952136cc268f upgrade directory separate
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
117
952136cc268f upgrade directory separate
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
118 # ex... 2018/02/14
952136cc268f upgrade directory separate
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
119 my ($y,$m,$d) = ($t->strftime('%Y'), $t->strftime('%m'), $t->strftime('%d'));
952136cc268f upgrade directory separate
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
120 my $memo = $root_dir->child($y .'/'. $m .'/'. $d .'/'.'memo.txt')->touchpath;
952136cc268f upgrade directory separate
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
121 exec $ENV{EDITOR}, ($memo->realpath);
952136cc268f upgrade directory separate
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
122 }
952136cc268f upgrade directory separate
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
123
13
967fe50f1ef4 add open and edit mode
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 8
diff changeset
124 sub edit_slide {
967fe50f1ef4 add open and edit mode
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 8
diff changeset
125 my $recently = _search_recently(shift);
967fe50f1ef4 add open and edit mode
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 8
diff changeset
126 my $target = $recently->child('slide.md');
967fe50f1ef4 add open and edit mode
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 8
diff changeset
127 exec $ENV{EDITOR}, ($target->realpath);
967fe50f1ef4 add open and edit mode
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 8
diff changeset
128 }
967fe50f1ef4 add open and edit mode
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 8
diff changeset
129
967fe50f1ef4 add open and edit mode
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 8
diff changeset
130 sub open_slide {
967fe50f1ef4 add open and edit mode
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 8
diff changeset
131 my $recently = _search_recently(shift);
967fe50f1ef4 add open and edit mode
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 8
diff changeset
132 my $target = $recently->child('slide.html');
967fe50f1ef4 add open and edit mode
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 8
diff changeset
133
967fe50f1ef4 add open and edit mode
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 8
diff changeset
134 if ( $target->realpath){
967fe50f1ef4 add open and edit mode
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 8
diff changeset
135 system "open", ($target->realpath);
967fe50f1ef4 add open and edit mode
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 8
diff changeset
136 } else {
967fe50f1ef4 add open and edit mode
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 8
diff changeset
137 say "didn't slide.html";
967fe50f1ef4 add open and edit mode
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 8
diff changeset
138 }
967fe50f1ef4 add open and edit mode
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 8
diff changeset
139 }
4
03ab44e80533 add make script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
140
6
e35e9779078a auto-Update generated slides by script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 5
diff changeset
141 sub _build {
e35e9779078a auto-Update generated slides by script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 5
diff changeset
142 my ($dir,$target) = @_;
e35e9779078a auto-Update generated slides by script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 5
diff changeset
143 use Capture::Tiny;
e35e9779078a auto-Update generated slides by script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 5
diff changeset
144
e35e9779078a auto-Update generated slides by script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 5
diff changeset
145 $target //= 'slide.md';
e35e9779078a auto-Update generated slides by script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 5
diff changeset
146
8
0b502eb897cc add message
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 7
diff changeset
147 say "[AUTO] BUILD at $dir/$target";
6
e35e9779078a auto-Update generated slides by script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 5
diff changeset
148
e35e9779078a auto-Update generated slides by script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 5
diff changeset
149 local $CWD = $dir;
e35e9779078a auto-Update generated slides by script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 5
diff changeset
150
e35e9779078a auto-Update generated slides by script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 5
diff changeset
151 my ($stdout,$stderr,$exit) = capture {
21
952136cc268f upgrade directory separate
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 18
diff changeset
152 system("slideshow build ${target} -t s6cr");
6
e35e9779078a auto-Update generated slides by script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 5
diff changeset
153 };
e35e9779078a auto-Update generated slides by script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 5
diff changeset
154
e35e9779078a auto-Update generated slides by script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 5
diff changeset
155 if ($stderr){
e35e9779078a auto-Update generated slides by script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 5
diff changeset
156 croak "Perl can't build....";
e35e9779078a auto-Update generated slides by script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 5
diff changeset
157 }
4
03ab44e80533 add make script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
158 }
03ab44e80533 add make script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
159
03ab44e80533 add make script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
160
03ab44e80533 add make script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
161 sub upload {
03ab44e80533 add make script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
162
8
0b502eb897cc add message
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 7
diff changeset
163 say "[AUTO]hg addremove";
4
03ab44e80533 add make script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
164 my ($stdout,$stderr,$exit) = capture {
03ab44e80533 add make script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
165 system("hg addremove");
03ab44e80533 add make script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
166 system("hg add");
03ab44e80533 add make script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
167 };
03ab44e80533 add make script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
168
8
0b502eb897cc add message
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 7
diff changeset
169 if ($stderr) {
0b502eb897cc add message
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 7
diff changeset
170 croak "didn't add";
4
03ab44e80533 add make script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
171 }
03ab44e80533 add make script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
172
8
0b502eb897cc add message
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 7
diff changeset
173 say "[AUTO]hg commit -m auto-Update generated slides by script";
0b502eb897cc add message
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 7
diff changeset
174
4
03ab44e80533 add make script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
175 ($stdout,$stderr,$exit) = capture {
03ab44e80533 add make script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
176 system('hg commit -m "auto-Update generated slides by script"');
03ab44e80533 add make script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
177 };
03ab44e80533 add make script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
178
8
0b502eb897cc add message
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 7
diff changeset
179 if ($stderr) {
0b502eb897cc add message
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 7
diff changeset
180 say $stderr;
0b502eb897cc add message
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 7
diff changeset
181 croak "didn't commit";
0b502eb897cc add message
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 7
diff changeset
182 }
18
79a79bbc5c01 auto-Update generated slides by script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 15
diff changeset
183
8
0b502eb897cc add message
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 7
diff changeset
184 say "[AUTO]hg push";
0b502eb897cc add message
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 7
diff changeset
185
0b502eb897cc add message
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 7
diff changeset
186 ($stdout,$stderr,$exit) = capture {
7
7d3faa099bc6 auto-Update generated slides by script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 6
diff changeset
187 system('hg push');
8
0b502eb897cc add message
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 7
diff changeset
188 };
0b502eb897cc add message
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 7
diff changeset
189
0b502eb897cc add message
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 7
diff changeset
190 if ( $stderr ) {
4
03ab44e80533 add make script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
191 say $stderr;
8
0b502eb897cc add message
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 7
diff changeset
192 croak "didn't commit";
0b502eb897cc add message
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 7
diff changeset
193 } else {
0b502eb897cc add message
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents: 7
diff changeset
194 say $stdout;
4
03ab44e80533 add make script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
195 }
03ab44e80533 add make script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
196 }
03ab44e80533 add make script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
197
03ab44e80533 add make script
Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
parents:
diff changeset
198 1;