From cb4c0d3476f597626993edd9d8d947f0d496c8fd Mon Sep 17 00:00:00 2001 From: Philipp Schafft Date: Mon, 1 May 2017 12:33:17 +0000 Subject: Feature: Generate IDs based on content if none is set. --- webgenp-blog | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'webgenp-blog') diff --git a/webgenp-blog b/webgenp-blog index 46e5da1..11ffab6 100755 --- a/webgenp-blog +++ b/webgenp-blog @@ -26,8 +26,10 @@ use warnings; use DateTime::Format::ISO8601; use DateTime; +use UUID::Tiny qw(:std); my %conf = ( + 'uuid-ns' => 'd0a083bf-d36c-43ff-bcb8-a32a9ae4a030', # random UUID. 'tpl' => undef, 'mode' => 'generate', 'input' => '.', @@ -256,6 +258,16 @@ sub read_file_entry { } } close($in); + + $cur = entry_makelang($entry => '*'); + unless (defined $cur->{'id'}) { + my $data = $info->{'entryname'}; + foreach my $info (map{$cur->{$_}}(qw(subject from date tags body))) { + next unless defined $info; + $data .= ':'.$info; + } + $cur->{'id'} = create_uuid_as_string(UUID_SHA1, $conf{'uuid-ns'}, $data); + } } sub read_file_template { -- cgit v1.2.3