Skip to content

Instantly share code, notes, and snippets.

@bergie
Created July 13, 2012 16:35
Show Gist options
  • Save bergie/3105838 to your computer and use it in GitHub Desktop.
Save bergie/3105838 to your computer and use it in GitHub Desktop.
JSON-LD to Jekyll converter with NoFlo
# We need to process the date into suitable for filename
'dc:date' -> KEY GetDate(GetObjectKey)
'10' -> LIMIT CleanDate(SubStr)
Split(Split) OUT -> IN GetDate() OUT -> IN CleanDate()
# We also need the URL name for the filename
'dc:name' -> KEY GetName(GetObjectKey)
Split() OUT -> IN GetName()
# And finally we need the format
'dc:contentType' -> KEY GetType(GetObjectKey)
Split() OUT -> IN GetType()
# Merge date and name into the filename
CleanDate() OUT -> IN ConcatName(Concat)
GetName() OUT -> IN ConcatName()
# Build name
'-' -> DELIMITER BuildName(CompileString)
ConcatName() OUT -> IN BuildName() OUT -> IN ConcatNameSuffix(Concat)
# Add file type to name
GetType() OUT -> IN ConcatNameSuffix()
# Create (so far fake) filename
'.' -> DELIMITER BuildFile(CompileString)
ConcatNameSuffix() OUT -> IN BuildFile()
# Start by parsing the blogdump JSON and separating entries
'blogdump.json' -> IN Read(ReadFile) OUT -> IN Parse(ParseJson)
Parse() OUT -> IN SplitPosts(SplitArray) OUT -> IN GroupPost(GroupByPacket) OUT -> IN Split(Split) OUT -> IN Count(Counter) COUNT -> IN Display(Output)
# Build the filename out of date, name, and suffix
'buildfilename.fbp' -> GRAPH BuildFileName(Graph)
Split() OUT -> SPLIT.IN BuildFileName()
BuildFileName() BUILDFILE.OUT -> FILENAME Save(WriteFile)
# Transform metadata
'dc:title=title' -> MAP MapMetadata(MapProperty)
'dc:categories=categories' -> MAP MapMetadata()
'title' -> ACCEPT FilterMetadata(FilterProperty)
'categories' -> ACCEPT FilterMetadata()
'layout=post' -> PROPERTY SetLayout(SetProperty)
Split() OUT -> IN MapMetadata()
MapMetadata() OUT -> IN FilterMetadata()
FilterMetadata() OUT -> IN SetLayout() OUT -> IN GetMetadata(ToYaml)
# Extract contents
'atom:content' -> KEY GetContent(GetObjectKey)
Split() OUT -> IN GetContent()
# Merge metadata and contents to a file
GetMetadata() OUT -> IN BuildContents(Concat)
'---' -> STRING Separator(SendString)
Split() OUT -> IN Separator() OUT -> IN BuildContents()
GetContent() OUT -> IN BuildContents()
BuildContents() OUT -> IN CombineContents(CompileString)
# Save
CombineContents() OUT -> IN Save() OUT -> IN Display()
Save() ERROR -> IN Display()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment