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.991'; |
7
|
4
|
|
|
4
|
|
2670
|
use Moose; |
|
4
|
|
|
|
|
13
|
|
|
4
|
|
|
|
|
129
|
|
8
|
|
|
|
|
|
|
extends 'HiD::App::Command'; |
9
|
4
|
|
|
4
|
|
24989
|
use namespace::autoclean; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
39
|
|
10
|
|
|
|
|
|
|
|
11
|
4
|
|
|
4
|
|
387
|
use 5.014; # strict, unicode_strings |
|
4
|
|
|
|
|
17
|
|
12
|
4
|
|
|
4
|
|
21
|
use utf8; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
28
|
|
13
|
4
|
|
|
4
|
|
85
|
use autodie; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
31
|
|
14
|
4
|
|
|
4
|
|
19520
|
use warnings qw/ FATAL utf8 /; |
|
4
|
|
|
|
|
12
|
|
|
4
|
|
|
|
|
209
|
|
15
|
4
|
|
|
4
|
|
23
|
use open qw/ :std :utf8 /; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
32
|
|
16
|
4
|
|
|
4
|
|
637
|
use charnames qw/ :full /; |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
35
|
|
17
|
|
|
|
|
|
|
|
18
|
4
|
|
|
4
|
|
910
|
use YAML::Tiny; |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
1972
|
|
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
|
|
11
|
my( $self , $opts , $args ) = @_; |
50
|
|
|
|
|
|
|
|
51
|
3
|
50
|
|
|
|
73
|
die "TODO: github support" if $self->github; |
52
|
|
|
|
|
|
|
|
53
|
3
|
|
|
|
|
10
|
for ( qw/ includes layouts site / ) { |
54
|
9
|
50
|
|
|
|
1744
|
mkdir "_$_" unless -e "_$_" |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
3
|
|
|
|
|
195
|
open( my $fh , '>' , '_layouts/default.html' ); |
58
|
3
|
|
|
|
|
1929
|
print $fh <<EOF; |
59
|
|
|
|
|
|
|
[% content %] |
60
|
|
|
|
|
|
|
EOF |
61
|
3
|
|
|
|
|
19
|
close $fh; |
62
|
|
|
|
|
|
|
|
63
|
3
|
100
|
|
|
|
1095
|
$self->_init_blog if $self->blog; |
64
|
|
|
|
|
|
|
|
65
|
3
|
|
|
|
|
128
|
my $yaml = YAML::Tiny->new({ title => $self->title }); |
66
|
3
|
|
|
|
|
33
|
$yaml->write( '_config.yml' ); |
67
|
|
|
|
|
|
|
|
68
|
3
|
|
|
|
|
9313
|
say "Enjoy your new site!"; |
69
|
|
|
|
|
|
|
} |
70
|
|
|
|
|
|
|
|
71
|
|
|
|
|
|
|
sub _init_blog { |
72
|
|
|
|
|
|
|
{ |
73
|
1
|
|
|
|
|
7
|
open( my $fh , '>' , '_layouts/post.html' ); |
74
|
1
|
|
|
|
|
93
|
print $fh <<EOF; |
75
|
|
|
|
|
|
|
--- |
76
|
|
|
|
|
|
|
layout: default |
77
|
|
|
|
|
|
|
--- |
78
|
|
|
|
|
|
|
[% page.title %] |
79
|
|
|
|
|
|
|
[% content %] |
80
|
|
|
|
|
|
|
EOF |
81
|
1
|
|
|
|
|
5
|
close( $fh ); |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
{ |
84
|
1
|
|
|
1
|
|
3
|
mkdir "_posts"; |
|
1
|
|
|
|
|
56
|
|
|
1
|
|
|
|
|
5
|
|
85
|
1
|
|
|
|
|
63
|
open( my $fh , '>' , '_posts/1999-09-09-first-post.markdown' ); |
86
|
1
|
|
|
|
|
86
|
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
|
|
|
|
|
4
|
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.991 |
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 |