Note that there are some explanatory texts on larger screens.

plurals
  1. POJavascript: Convert string path to a formatted array
    primarykey
    data
    text
    <p>So I am trying to use the github api and convert it to use for dynatree.</p> <p>I am looking to use javascript. But if it's easier done in Ruby, ClojureScript etc that could work as well. </p> <p>So Github api returns something that looks like:</p> <pre><code> { "sha": "a1f28431d5ee1a00361ff7e1e2dc91172d5bbabd", "url": "https://api.github.com/repos/Jonovono/c/git/trees/a1f28431d5ee1a00361ff7e1e2dc91172d5bbabd", "tree": [ { "mode": "100644", "type": "blob", "sha": "b81f704ee24f08f5f3e00675a9912da79274c3bc", "path": ".gitignore", "size": 114, "url": "https://api.github.com/repos/Jonovono/c/git/blobs/b81f704ee24f08f5f3e00675a9912da79274c3bc" }, { "mode": "100644", "type": "blob", "sha": "c6231c2f161f50bededaaac624a7a96db6179e9a", "path": "Makefile.am", "size": 40, "url": "https://api.github.com/repos/Jonovono/c/git/blobs/c6231c2f161f50bededaaac624a7a96db6179e9a" }, { "mode": "100644", "type": "blob", "sha": "ca41e5b8fb710b4ae7a2cdb35cdbafb143382dc2", "path": "README.md", "size": 2194, "url": "https://api.github.com/repos/Jonovono/c/git/blobs/ca41e5b8fb710b4ae7a2cdb35cdbafb143382dc2" }, { "mode": "100644", "type": "blob", "sha": "dd3b02c5fcf3312ef7a83f4b6370a8b546739bc1", "path": "config.h.in", "size": 625, "url": "https://api.github.com/repos/Jonovono/c/git/blobs/dd3b02c5fcf3312ef7a83f4b6370a8b546739bc1" }, { "mode": "100644", "type": "blob", "sha": "e242df0dc8be1fec7b2da2091ab8161aaee1b7a2", "path": "configure.ac", "size": 156, "url": "https://api.github.com/repos/Jonovono/c/git/blobs/e242df0dc8be1fec7b2da2091ab8161aaee1b7a2" }, { "mode": "100755", "type": "blob", "sha": "df8eea7e4ce8862105fcd7929b20bdb45488048b", "path": "depcomp", "size": 18615, "url": "https://api.github.com/repos/Jonovono/c/git/blobs/df8eea7e4ce8862105fcd7929b20bdb45488048b" }, { "mode": "100755", "type": "blob", "sha": "6781b987bdbcbc23efe6bbe1654a1e3637b9af07", "path": "install-sh", "size": 13663, "url": "https://api.github.com/repos/Jonovono/c/git/blobs/6781b987bdbcbc23efe6bbe1654a1e3637b9af07" }, { "mode": "100755", "type": "blob", "sha": "28055d2ae6f2a2c584afcd769d7881e11f62ecd9", "path": "missing", "size": 11419, "url": "https://api.github.com/repos/Jonovono/c/git/blobs/28055d2ae6f2a2c584afcd769d7881e11f62ecd9" }, { "mode": "040000", "type": "tree", "sha": "57bb4a62d2de582c74b2e6de71e3024db7905cac", "path": "src", "url": "https://api.github.com/repos/Jonovono/c/git/trees/57bb4a62d2de582c74b2e6de71e3024db7905cac" }, { "mode": "100644", "type": "blob", "sha": "daaed524883bd510502834d472e9be6cff4e3a69", "path": "src/Makefile.am", "size": 59, "url": "https://api.github.com/repos/Jonovono/c/git/blobs/daaed524883bd510502834d472e9be6cff4e3a69" }, { "mode": "100644", "type": "blob", "sha": "cf3f8f549fe870315eb4417c9f84dec587c8286b", "path": "src/c.c", "size": 9480, "url": "https://api.github.com/repos/Jonovono/c/git/blobs/cf3f8f549fe870315eb4417c9f84dec587c8286b" } ] } </code></pre> <p>So basically I want to get all of the paths that are in the array like "Makefile.am", "src" (recognize that is a folder), "src/c.c". This would work for recursive folders as well.</p> <p>The format that dynatree looks like:</p> <pre><code> var obj = [ { title: 'Lazy node 1', isLazy: true }, { title: 'Lazy node 2', isLazy: true }, { title: 'Folder node 3', isFolder: true, children: [ { title: 'node 3.1' }, { title: 'node 3.2', children: [ { title: 'node 3.2.1' }, { title: 'node 3.2.2', children: [ { title: 'node 3.2.2.1' } ] } ] } ] } ]; </code></pre> <p>OR</p> <pre><code> var rootNode = $("#tree").dynatree("getRoot"); var childNode = rootNode.addChild({ title: "Programatically addded nodes", tooltip: "This folder and all child nodes were added programmatically.", isFolder: true }); childNode.addChild({ title: "Document using a custom icon", icon: "customdoc1.gif" }); </code></pre> <p>I am not sure which one would be easier to get to. I am thinking I could use some type of hash table with but I am just not sure how to get it working recursively for files like: "src/a/b/c/index.text"</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload