# This graph loads a list of documents from a directory and sends it out 
# for processing.
#
# The directory inport accepts a path for a folder where to start loading
EXPORT=DIRECTORY.IN:DIRECTORY
# The subdirectory outport is where the path each subfolder is sent
EXPORT=SUBDIRECTORY.OUT:SUBDIRECTORY
# The document outport is where the path of each regular file is sent
EXPORT=FILENAME.OUT:DOCUMENT

'10' -> MAX ThrottleDir(Throttle)
Directory(Split) OUT -> IN ThrottleDir() OUT -> SOURCE Dir(ReadDir)
Dir() LOAD -> IN CountOpen(CountSum) OUT -> LOAD ThrottleDir()

'10' -> MAX ThrottleStat(Throttle)
Dir() OUT -> IN ThrottleStat(Throttle) OUT -> IN Stat(Stat)
Stat() LOAD -> IN CountOpen() OUT -> LOAD ThrottleStat()

# Routing rules
'isDirectory' -> ROUTES FileRouter(GroupRouter)
'isDirectory' -> KEY Group(GroupByObjectKey)
Stat() OUT -> IN DropGroups(RemoveGroups)
DropGroups() OUT -> IN Group() OUT -> IN FileRouter()

# First route: subfolder
'path=^(?:(?!\.git|_(?!(includes|layouts|posts))|node_modules).)*$' -> REGEXP FilterDirs(FilterPropertyValue)
'path' -> KEY SubDirectory(GetObjectKey)
FileRouter() OUT -> IN FilterDirs() OUT -> IN SubDirectory()

# Missed routing: regular file
'path' -> KEY FileName(GetObjectKey)
FileRouter() MISSED -> IN FileName()

# Error handling
Dir() ERROR -> IN Display(Output)
Stat() ERROR -> IN Display(Output)
