diff options
author | Matias Linares <matiaslina@openmailbox.org> | 2016-04-17 01:42:47 -0300 |
---|---|---|
committer | Matias Linares <matiaslina@openmailbox.org> | 2016-04-17 01:42:47 -0300 |
commit | 464c6a83333f644b896785378b70cec578493dbb (patch) | |
tree | f603ed4f244e15e1de68a4d12f5b0fe0f3e376c8 /ssg | |
parent | 1db32da3e531b9b07ec78eba10f63d4e95ce97a8 (diff) | |
download | ssg-464c6a83333f644b896785378b70cec578493dbb.tar.gz |
Add support for excluded files
Diffstat (limited to 'ssg')
-rwxr-xr-x | ssg | 53 |
1 files changed, 34 insertions, 19 deletions
@@ -1,6 +1,9 @@ #!/usr/bin/perl use strict; use warnings; +use v5.22; +# Disable experimental warnings. +no warnings 'experimental'; use File::Path qw(make_path remove_tree); use Path::Class; @@ -11,6 +14,10 @@ my $indir; my $outdir; my $VERSION = "v0.1"; +my @exlude_files = ( + qr/TIL\/\w+\/*/ +); + sub help { print<<EOF $0 [switches] input-directory @@ -90,29 +97,37 @@ sub generate_link { my ($file, $options) = @_; $options->{hl} = 0 if !exists($options->{hl}); - my $path = $file->stringify; - my $str = $file->basename; + # Exclude links + given($file) { + when(@exlude_files) { + return ""; + } + default { + my $path = $file->stringify; + my $str = $file->basename; - if($path =~ /index\.md$/) { - return ""; - } + if($path =~ /index\.md$/) { + return ""; + } - # remove the input directory. - $path =~ s/^$indir//g; - if($file->is_dir()) { - $str = "$str/" if $file->is_dir(); - } else { - $path =~ s/\.md$/.html/g; - $str =~ s/\.md$//g; - } + # remove the input directory. + $path =~ s/^$indir//g; + if($file->is_dir()) { + $str = "$str/" if $file->is_dir(); + } else { + $path =~ s/\.md$/.html/g; + $str =~ s/\.md$//g; + } - # Higlight? - my $hl = ""; - if($options->{hl} eq 1) { - $hl = "class='hl'"; - } + # Higlight? + my $hl = ""; + if($options->{hl} eq 1) { + $hl = "class='hl'"; + } - return "<li><a $hl href='$path'>$str</a></li>"; + return "<li><a $hl href='$path'>$str</a></li>"; + } + } } sub transverse { |