comparison lib/Slideshow/Util.pm @ 33:2eac67c0d7da fix

auto-Update generated slides by script
author Takahiro SHIMIZU <anatofuz@cr.ie.u-ryukyu.ac.jp>
date Tue, 01 May 2018 09:25:17 +0900
parents 952136cc268f
children 448db64959d0
comparison
equal deleted inserted replaced
32:2f99cb7078f2 33:2eac67c0d7da
20 build_recently 20 build_recently
21 build_pinpoint 21 build_pinpoint
22 open_slide 22 open_slide
23 edit_slide 23 edit_slide
24 edit_memo 24 edit_memo
25 upload
25 /; 26 /;
26 27
27 sub getopts { 28 sub getopts {
28 my ($arg,$path) = @_; 29 my ($arg,$path) = @_;
29 30
30 unless (defined $arg){ 31 unless (defined $arg){
31 return { help => 1}; 32 return { help => 1};
32 } 33 }
33 34
34 if ($arg eq "new") { 35 if ($arg eq "new") {
35 return {new => 1}; 36 return[\new(set_template('lib/template.md'),"slides")];
36
37 } elsif ( $arg eq "upload") { 37 } elsif ( $arg eq "upload") {
38 upload(); 38 return [\upload() ];
39 exit;
40
41 } elsif ( $arg eq "build") { 39 } elsif ( $arg eq "build") {
42 40 return [\build_recently()];
43 if(defined $path){
44 return { build_point=> $path};
45 } else {
46 return { build => "recent"};
47 }
48
49
50 } elsif ( $arg eq "build-open"){ 41 } elsif ( $arg eq "build-open"){
51 return { build_open => 1}; 42 return [\build_recently("slides"),\open_slide()];
52
53 } elsif ( $arg eq "open"){ 43 } elsif ( $arg eq "open"){
54 return { open => 1}; 44 return [\open_slide("slides")];
55
56 } elsif ( $arg eq "edit"){ 45 } elsif ( $arg eq "edit"){
57 return { edit=> 1}; 46 return [\edit_slide("slides")];
58 } elsif ( $arg eq "memo"){ 47 } elsif ( $arg eq "memo"){
59 return { memo => 1}; 48 return [\edit_memo("slides")];
60 } else { 49 } else {
61 return { help => 1}; 50 return { help => 1};
62 } 51 }
63 52
64 } 53 }
94 } 83 }
95 84
96 85
97 86
98 sub build_recently { 87 sub build_recently {
99 my $recently = _search_recently(shift); 88 my $target = shift // "slides";
89 my $recently = _search_recently($target);
100 _build($recently); 90 _build($recently);
101 } 91 }
102 92
103 sub build_pinpoint { 93 sub build_pinpoint {
104 my $target = shift; 94 my $target = shift;
110 100
111 _build($dir,$slide); 101 _build($dir,$slide);
112 } 102 }
113 103
114 sub edit_memo { 104 sub edit_memo {
115 my $root_dir = path(shift); 105 my $target = shift // "slides";
106 my $root_dir = path($target);
116 my $t = localtime; 107 my $t = localtime;
117 108
118 # ex... 2018/02/14 109 # ex... 2018/02/14
119 my ($y,$m,$d) = ($t->strftime('%Y'), $t->strftime('%m'), $t->strftime('%d')); 110 my ($y,$m,$d) = ($t->strftime('%Y'), $t->strftime('%m'), $t->strftime('%d'));
120 my $memo = $root_dir->child($y .'/'. $m .'/'. $d .'/'.'memo.txt')->touchpath; 111 my $memo = $root_dir->child($y .'/'. $m .'/'. $d .'/'.'memo.txt')->touchpath;
121 exec $ENV{EDITOR}, ($memo->realpath); 112 exec $ENV{EDITOR}, ($memo->realpath);
122 } 113 }
123 114
124 sub edit_slide { 115 sub edit_slide {
125 my $recently = _search_recently(shift); 116 my $arg = shift // "slides";
117 my $recently = _search_recently($arg);
126 my $target = $recently->child('slide.md'); 118 my $target = $recently->child('slide.md');
127 exec $ENV{EDITOR}, ($target->realpath); 119 exec $ENV{EDITOR}, ($target->realpath);
128 } 120 }
129 121
130 sub open_slide { 122 sub open_slide {