line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ABSTRACT: initialize a new site |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
package HiD::App::Command::init; |
5
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:GENEHACK'; |
6
|
|
|
|
|
|
|
$HiD::App::Command::init::VERSION = '1.99'; |
7
|
4
|
|
|
4
|
|
2828
|
use Moose; |
|
4
|
|
|
|
|
12
|
|
|
4
|
|
|
|
|
147
|
|
8
|
|
|
|
|
|
|
extends 'HiD::App::Command'; |
9
|
4
|
|
|
4
|
|
32122
|
use namespace::autoclean; |
|
4
|
|
|
|
|
38
|
|
|
4
|
|
|
|
|
53
|
|
10
|
|
|
|
|
|
|
|
11
|
4
|
|
|
4
|
|
505
|
use 5.014; # strict, unicode_strings |
|
4
|
|
|
|
|
20
|
|
12
|
4
|
|
|
4
|
|
32
|
use utf8; |
|
4
|
|
|
|
|
13
|
|
|
4
|
|
|
|
|
50
|
|
13
|
4
|
|
|
4
|
|
179
|
use autodie; |
|
4
|
|
|
|
|
13
|
|
|
4
|
|
|
|
|
41
|
|
14
|
4
|
|
|
4
|
|
25147
|
use warnings qw/ FATAL utf8 /; |
|
4
|
|
|
|
|
14
|
|
|
4
|
|
|
|
|
241
|
|
15
|
4
|
|
|
4
|
|
34
|
use open qw/ :std :utf8 /; |
|
4
|
|
|
|
|
16
|
|
|
4
|
|
|
|
|
37
|
|
16
|
4
|
|
|
4
|
|
738
|
use charnames qw/ :full /; |
|
4
|
|
|
|
|
17
|
|
|
4
|
|
|
|
|
39
|
|
17
|
|
|
|
|
|
|
|
18
|
4
|
|
|
4
|
|
1075
|
use YAML::Tiny; |
|
4
|
|
|
|
|
12
|
|
|
4
|
|
|
|
|
2388
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
has blog => ( |
22
|
|
|
|
|
|
|
is => 'ro' , |
23
|
|
|
|
|
|
|
isa => 'Bool' , |
24
|
|
|
|
|
|
|
traits => [ 'Getopt' ] , |
25
|
|
|
|
|
|
|
cmd_aliases => 'b' , |
26
|
|
|
|
|
|
|
documentation => 'include blog-specific features when creating site' , |
27
|
|
|
|
|
|
|
); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
has github => ( |
31
|
|
|
|
|
|
|
is => 'ro' , |
32
|
|
|
|
|
|
|
isa => 'Bool' , |
33
|
|
|
|
|
|
|
traits => [ 'Getopt' ] , |
34
|
|
|
|
|
|
|
cmd_aliases => 'g' , |
35
|
|
|
|
|
|
|
documentation => 'create site ready for publishing on GitHub' , |
36
|
|
|
|
|
|
|
); |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
has title => ( |
40
|
|
|
|
|
|
|
is => 'ro' , |
41
|
|
|
|
|
|
|
isa => 'Str' , |
42
|
|
|
|
|
|
|
traits => [ 'Getopt' ] , |
43
|
|
|
|
|
|
|
cmd_aliases => 't' , |
44
|
|
|
|
|
|
|
documentation => 'title for your new site' , |
45
|
|
|
|
|
|
|
default => 'My Great New Site' , |
46
|
|
|
|
|
|
|
); |
47
|
|
|
|
|
|
|
|
48
|
|
|
|
|
|
|
sub _run { |
49
|
3
|
|
|
3
|
|
9
|
my( $self , $opts , $args ) = @_; |
50
|
|
|
|
|
|
|
|
51
|
3
|
50
|
|
|
|
75
|
die "TODO: github support" if $self->github; |
52
|
|
|
|
|
|
|
|
53
|
3
|
|
|
|
|
19
|
for ( qw/ includes layouts site / ) { |
54
|
9
|
50
|
|
|
|
5111
|
mkdir "_$_" unless -e "_$_" |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
3
|
|
|
|
|
240
|
open( my $fh , '>' , '_layouts/default.html' ); |
58
|
3
|
|
|
|
|
2269
|
print $fh <<EOF; |
59
|
|
|
|
|
|
|
[% content %] |
60
|
|
|
|
|
|
|
EOF |
61
|
3
|
|
|
|
|
28
|
close $fh; |
62
|
|
|
|
|
|
|
|
63
|
3
|
100
|
|
|
|
1117
|
$self->_init_blog if $self->blog; |
64
|
|
|
|
|
|
|
|
65
|
3
|
|
|
|
|
211
|
my $yaml = YAML::Tiny->new({ title => $self->title }); |
66
|
3
|
|
|
|
|
46
|
$yaml->write( '_config.yml' ); |
67
|
|
|
|
|
|
|
|
68
|
3
|
|
|
|
|
13797
|
say "Enjoy your new site!"; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub _init_blog { |
72
|
|
|
|
|
|
|
{ |
73
|
1
|
|
|
|
|
7
|
open( my $fh , '>' , '_layouts/post.html' ); |
74
|
1
|
|
|
|
|
155
|
print $fh <<EOF; |
75
|
|
|
|
|
|
|
--- |
76
|
|
|
|
|
|
|
layout: default |
77
|
|
|
|
|
|
|
--- |
78
|
|
|
|
|
|
|
[% page.title %] |
79
|
|
|
|
|
|
|
[% content %] |
80
|
|
|
|
|
|
|
EOF |
81
|
1
|
|
|
|
|
7
|
close( $fh ); |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
{ |
84
|
1
|
|
|
1
|
|
4
|
mkdir "_posts"; |
|
1
|
|
|
|
|
180
|
|
|
1
|
|
|
|
|
7
|
|
85
|
1
|
|
|
|
|
117
|
open( my $fh , '>' , '_posts/1999-09-09-first-post.markdown' ); |
86
|
1
|
|
|
|
|
227
|
print $fh <<EOF; |
87
|
|
|
|
|
|
|
--- |
88
|
|
|
|
|
|
|
layout: post |
89
|
|
|
|
|
|
|
title: My First Post |
90
|
|
|
|
|
|
|
--- |
91
|
|
|
|
|
|
|
this is the first post in my new blog! |
92
|
|
|
|
|
|
|
EOF |
93
|
1
|
|
|
|
|
8
|
close( $fh ); |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
} |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
__PACKAGE__->meta->make_immutable; |
98
|
|
|
|
|
|
|
1; |
99
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
__END__ |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
=pod |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
=encoding UTF-8 |
105
|
|
|
|
|
|
|
|
106
|
|
|
|
|
|
|
=head1 NAME |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
HiD::App::Command::init - initialize a new site |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=head1 SYNOPSIS |
111
|
|
|
|
|
|
|
|
112
|
|
|
|
|
|
|
$ ../bin/hid init |
113
|
|
|
|
|
|
|
Enjoy your new site! |
114
|
|
|
|
|
|
|
|
115
|
|
|
|
|
|
|
$ ls |
116
|
|
|
|
|
|
|
_config.yml _includes/ _layouts/ _site/ |
117
|
|
|
|
|
|
|
|
118
|
|
|
|
|
|
|
$ cat _config.yml |
119
|
|
|
|
|
|
|
--- |
120
|
|
|
|
|
|
|
title: My Great New Site |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
=head1 DESCRIPTION |
123
|
|
|
|
|
|
|
|
124
|
|
|
|
|
|
|
Generates a directory structure and basic config for a Hid site. |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
=head1 ATTRIBUTES |
127
|
|
|
|
|
|
|
|
128
|
|
|
|
|
|
|
=head2 blog |
129
|
|
|
|
|
|
|
|
130
|
|
|
|
|
|
|
If enabled, this will add in additional site features useful for bloggers. |
131
|
|
|
|
|
|
|
|
132
|
|
|
|
|
|
|
# FIXME doesn't actually do anything currently. |
133
|
|
|
|
|
|
|
|
134
|
|
|
|
|
|
|
=head2 github |
135
|
|
|
|
|
|
|
|
136
|
|
|
|
|
|
|
If enabled, will set the site up to be hosted on and published through GitHub. |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
# FIXME doesn't actually do anything currently. |
139
|
|
|
|
|
|
|
|
140
|
|
|
|
|
|
|
=head2 title |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
Provide a title for the site being created. |
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
=head1 SEE ALSO |
145
|
|
|
|
|
|
|
|
146
|
|
|
|
|
|
|
See L<HiD::App::Command> for additional command line options supported by all |
147
|
|
|
|
|
|
|
sub commands. |
148
|
|
|
|
|
|
|
|
149
|
|
|
|
|
|
|
=head1 VERSION |
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
version 1.99 |
152
|
|
|
|
|
|
|
|
153
|
|
|
|
|
|
|
=head1 AUTHOR |
154
|
|
|
|
|
|
|
|
155
|
|
|
|
|
|
|
John SJ Anderson <genehack@genehack.org> |
156
|
|
|
|
|
|
|
|
157
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
158
|
|
|
|
|
|
|
|
159
|
|
|
|
|
|
|
This software is copyright (c) 2015 by John SJ Anderson. |
160
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
162
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
163
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
=cut |