From 464c6a83333f644b896785378b70cec578493dbb Mon Sep 17 00:00:00 2001 From: Matias Linares Date: Sun, 17 Apr 2016 01:42:47 -0300 Subject: Add support for excluded files --- ssg | 53 ++++++++++++++++++++++++++++++++++------------------- 1 file changed, 34 insertions(+), 19 deletions(-) diff --git a/ssg b/ssg index f502040..d2faa90 100755 --- a/ssg +++ b/ssg @@ -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<{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 "
  • $str
  • "; + return "
  • $str
  • "; + } + } } sub transverse { -- cgit v1.2.3-70-g09d2