diff --git a/src/nat/ArchiveController.kiss b/src/nat/ArchiveController.kiss index b6bd1d2..f4be82b 100644 --- a/src/nat/ArchiveController.kiss +++ b/src/nat/ArchiveController.kiss @@ -152,6 +152,9 @@ // Add systems! (archive.addSystem nameSystem) (archive.addSystem (new WikipediaImageSystem)) + // Just for testing: + (archive.addSystem (new AttachmentSystem ["jpg" "jpeg" "png"] ->[archive e files] ~files)) + (archive.processSystems) (defCommand Help [] diff --git a/src/nat/systems/AttachmentSystem.hx b/src/nat/systems/AttachmentSystem.hx new file mode 100644 index 0000000..6eb6511 --- /dev/null +++ b/src/nat/systems/AttachmentSystem.hx @@ -0,0 +1,17 @@ +package nat.systems; + +import kiss.Prelude; +import kiss.List; +import nat.System; +import haxe.Json; + +using haxe.io.Path; + +typedef AttachmentProcessor = (Archive, Entry, Array) -> Dynamic; + +/** + * Base System that processes Entries based on whether they have file attachments + * which match a given set of extensions + */ +@:build(kiss.Kiss.build()) +class AttachmentSystem extends System {} diff --git a/src/nat/systems/AttachmentSystem.kiss b/src/nat/systems/AttachmentSystem.kiss new file mode 100644 index 0000000..6dcc387 --- /dev/null +++ b/src/nat/systems/AttachmentSystem.kiss @@ -0,0 +1,14 @@ +(load "../Lib.kiss") + +(defNew [&prop :Array extensions + :AttachmentProcessor processor] + (super + ->[archive e] + { + (doFor file e.files + (when !(= -1 (extensions.indexOf (file.extension))) + (return true))) + false + } + ->[archive e] + (processor archive e (filter e.files ->file !(= -1 (extensions.indexOf (file.extension))))))) \ No newline at end of file