From e8ccd4beeccdc54695648c8a88f0612de529d5e8 Mon Sep 17 00:00:00 2001 From: dequis Date: Wed, 6 Aug 2014 21:15:25 -0300 Subject: Use for loops over attributes to generate scripts.dmp output It's shorter and also reduces redundant whitespace in output. This liquid templating engine is dumb. Writing it this way is the only way to avoid whitespace between tags. --- scripts.dmp | 31 +++++++------------------------ 1 file changed, 7 insertions(+), 24 deletions(-) (limited to 'scripts.dmp') diff --git a/scripts.dmp b/scripts.dmp index fc396fe..d80b6b4 100644 --- a/scripts.dmp +++ b/scripts.dmp @@ -2,33 +2,16 @@ layout: nil --- +{% assign required_attributes = "filename modified version authors contact name description license" | split: ' ' %} +{% assign optional_attributes = "url changed commands note modules" | split: ' ' %} + $scripts = { {% for script in site.data.scripts %} '{{ script.filename }}' => { - 'filename' => '{{ script.filename }}', - 'last_modified' => '{{ script.modified }}', - 'version' => '{{ script.version }}', - 'authors' => '{{ script.authors }}', - 'contact' => '{{ script.contact }}', - 'name' => '{{ script.name }}', - 'description' => '{{ script.description }}', - 'license' => '{{ script.license }}', -{% if script.url %} - 'url' => '{{ script.url }}', -{% endif %} -{% if script.changed %} - 'changed' => '{{ script.changed }}', -{% endif %} -{% if script.commands %} - 'commands' => '{{ script.commands }}', -{% endif %} -{% if script.note %} - 'note' => '{{ script.note }}', -{% endif %} -{% if script.modules %} - 'modules' => '{{ script.modules }}', -{% endif %} - +{% for attr in required_attributes %} + '{{ attr }}' => '{{ script[attr] }}',{% endfor %} +{% for attr in optional_attributes %}{% if script contains attr %} + '{{ attr }}' => '{{ script[attr] }}',{% endif %}{% endfor %} }, {% endfor %} }; -- cgit v1.2.3 From 67298f57c6706500865a627e3a6eb335a1f5ce9b Mon Sep 17 00:00:00 2001 From: dequis Date: Thu, 7 Aug 2014 01:28:38 -0300 Subject: Remove "changed" field from scripts.yaml and scripts.dmp output A few reasons: - It had an horribly inconsistent date format - Some of them were just "$VERSION" or "none" - It's redundant with the "modified" field - scriptassist.pl never actually used that field --- scripts.dmp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'scripts.dmp') diff --git a/scripts.dmp b/scripts.dmp index d80b6b4..3662285 100644 --- a/scripts.dmp +++ b/scripts.dmp @@ -3,7 +3,7 @@ layout: nil --- {% assign required_attributes = "filename modified version authors contact name description license" | split: ' ' %} -{% assign optional_attributes = "url changed commands note modules" | split: ' ' %} +{% assign optional_attributes = "url commands note modules" | split: ' ' %} $scripts = { {% for script in site.data.scripts %} -- cgit v1.2.3 From ddd1f4533eaa1a71082588349ff538ef4e5955bd Mon Sep 17 00:00:00 2001 From: dequis Date: Thu, 7 Aug 2014 07:16:13 -0300 Subject: The "modified" field in scripts.dmp should be called "last_modified" How annoying. --- scripts.dmp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'scripts.dmp') diff --git a/scripts.dmp b/scripts.dmp index 3662285..3dc122e 100644 --- a/scripts.dmp +++ b/scripts.dmp @@ -2,7 +2,7 @@ layout: nil --- -{% assign required_attributes = "filename modified version authors contact name description license" | split: ' ' %} +{% assign required_attributes = "filename version authors contact name description license" | split: ' ' %} {% assign optional_attributes = "url commands note modules" | split: ' ' %} $scripts = { @@ -10,6 +10,8 @@ $scripts = { '{{ script.filename }}' => { {% for attr in required_attributes %} '{{ attr }}' => '{{ script[attr] }}',{% endfor %} + + 'last_modified' => '{{ script.modified }}', {% for attr in optional_attributes %}{% if script contains attr %} '{{ attr }}' => '{{ script[attr] }}',{% endif %}{% endfor %} }, -- cgit v1.2.3