diff options
| author | Philipp Schafft <lion@lion.leolix.org> | 2017-05-01 12:33:17 +0000 |
|---|---|---|
| committer | Philipp Schafft <lion@lion.leolix.org> | 2017-05-01 16:15:00 +0000 |
| commit | cb4c0d3476f597626993edd9d8d947f0d496c8fd (patch) | |
| tree | 7a9fa6ab2525ac2e04b69b6c8a749b4a55281115 /webgenp-blog | |
| parent | 59f50a9764f722f25dc0b5c2ede583559327f5cd (diff) | |
Feature: Generate IDs based on content if none is set.
Diffstat (limited to 'webgenp-blog')
| -rwxr-xr-x | webgenp-blog | 12 |
1 files changed, 12 insertions, 0 deletions
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 { |
