aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMatias Linares <matiaslina@openmailbox.org>2016-04-17 01:42:47 -0300
committerMatias Linares <matiaslina@openmailbox.org>2016-04-17 01:42:47 -0300
commit464c6a83333f644b896785378b70cec578493dbb (patch)
treef603ed4f244e15e1de68a4d12f5b0fe0f3e376c8
parent1db32da3e531b9b07ec78eba10f63d4e95ce97a8 (diff)
downloadssg-464c6a83333f644b896785378b70cec578493dbb.tar.gz
Add support for excluded files
-rwxr-xr-xssg53
1 files 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<<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 {