{"action":"created","comment":{"url":"https://api.github.com/repos/SkygearIO/skygear-doc/pulls/comments/61203611","id":61203611,"diff_hunk":"@@ -16,6 +18,79 @@ export default function(source) {\n     source = source.replace('import \\'babel/polyfill\\';', ''); // eslint-disable-line no-param-reassign\n   }\n \n+  const routeGenerator = new Promise((resolve, reject) => {\n+    glob('**/*.json', { cwd: join(__dirname, '../../routes') }, (err, files) => {\n+      if (err) {\n+        reject(err);\n+      } else {\n+        resolve(files);\n+      }\n+    });\n+  })\n+  .then((files) => {\n+    if (files.length === 0) {\n+      return Promise.resolve([]);\n+    }\n+\n+    return Promise.all(\n+      map(files, perFile => new Promise((resolve, reject) => {\n+        const file = join(__dirname, '../../routes', perFile);\n+        fs.readFile(file, 'utf8', (err, data) => {\n+          if (err) {\n+            reject(err);\n+            return;\n+          }\n+\n+          try {\n+            resolve(JSON.parse(data));\n+          } catch(e) {\n+            reject(e);\n+          }\n+\n+        });\n+      }))\n+    );\n+  })\n+  .then((routeInfo) => {\n+    let factories = {};\n+    let lines = [];\n+    forEach(routeInfo, ({factory, routes}) => {\n+      factories[factory.name] = factory.path;\n+\n+      forEach(routes, (perRouteData, perRouteName) => {\n+        const contentParam = `content: require(\"${perRouteData['content_path']}\"),`;\n+        let menuParam = '';\n+        if (perRouteData['menu_path']) {\n+          menuParam = `menu: require(\"${perRouteData['menu_path']}\"),`;\n+        }\n+\n+        let line = '';\n+        if (target === 'node') {\n+          line += `'${perRouteName}': () => ${factory.name}({`;\n+          line += `  name: \"${perRouteData.name}\",`;\n+          line += `  title: \"${perRouteData.title}\",`;\n+          line += `  ${contentParam}`;\n+          line += `  ${menuParam}`;\n+          line += `}),`;\n+        } else {\n+          line += `'${perRouteName}': () => Promise.resolve(`;\n+          line += `  ${factory.name}({`;\n+          line += `    name: \"${perRouteData.name}\",`;\n+          line += `    title: \"${perRouteData.title}\",`;\n+          line += `    ${contentParam}`;\n+          line += `    ${menuParam}`;\n+          line += `  })`;\n+          line += `),`;","path":"tools/lib/routes-loader.js","position":92,"original_position":76,"commit_id":"38e78cd3284d17833af07719a182c9d09bc75627","original_commit_id":"008975b0c5637a3492ebe8093c31cf535001b3d4","user":{"login":"ben181231","id":3863953,"avatar_url":"https://avatars.githubusercontent.com/u/3863953?v=3","gravatar_id":"","url":"https://api.github.com/users/ben181231","html_url":"https://github.com/ben181231","followers_url":"https://api.github.com/users/ben181231/followers","following_url":"https://api.github.com/users/ben181231/following{/other_user}","gists_url":"https://api.github.com/users/ben181231/gists{/gist_id}","starred_url":"https://api.github.com/users/ben181231/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ben181231/subscriptions","organizations_url":"https://api.github.com/users/ben181231/orgs","repos_url":"https://api.github.com/users/ben181231/repos","events_url":"https://api.github.com/users/ben181231/events{/privacy}","received_events_url":"https://api.github.com/users/ben181231/received_events","type":"User","site_admin":false},"body":"@rickmak Okay.","created_at":"2016-04-27T04:49:43Z","updated_at":"2016-04-27T04:49:43Z","html_url":"https://github.com/SkygearIO/skygear-doc/pull/22#discussion_r61203611","pull_request_url":"https://api.github.com/repos/SkygearIO/skygear-doc/pulls/22","_links":{"self":{"href":"https://api.github.com/repos/SkygearIO/skygear-doc/pulls/comments/61203611"},"html":{"href":"https://github.com/SkygearIO/skygear-doc/pull/22#discussion_r61203611"},"pull_request":{"href":"https://api.github.com/repos/SkygearIO/skygear-doc/pulls/22"}}},"pull_request":{"url":"https://api.github.com/repos/SkygearIO/skygear-doc/pulls/22","id":67852542,"html_url":"https://github.com/SkygearIO/skygear-doc/pull/22","diff_url":"https://github.com/SkygearIO/skygear-doc/pull/22.diff","patch_url":"https://github.com/SkygearIO/skygear-doc/pull/22.patch","issue_url":"https://api.github.com/repos/SkygearIO/skygear-doc/issues/22","number":22,"state":"open","locked":false,"title":"Link current contents","user":{"login":"ben181231","id":3863953,"avatar_url":"https://avatars.githubusercontent.com/u/3863953?v=3","gravatar_id":"","url":"https://api.github.com/users/ben181231","html_url":"https://github.com/ben181231","followers_url":"https://api.github.com/users/ben181231/followers","following_url":"https://api.github.com/users/ben181231/following{/other_user}","gists_url":"https://api.github.com/users/ben181231/gists{/gist_id}","starred_url":"https://api.github.com/users/ben181231/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ben181231/subscriptions","organizations_url":"https://api.github.com/users/ben181231/orgs","repos_url":"https://api.github.com/users/ben181231/repos","events_url":"https://api.github.com/users/ben181231/events{/privacy}","received_events_url":"https://api.github.com/users/ben181231/received_events","type":"User","site_admin":false},"body":"connect #13","created_at":"2016-04-26T09:23:15Z","updated_at":"2016-04-27T04:49:43Z","closed_at":null,"merged_at":null,"merge_commit_sha":"8efd3d9749ede9bae135607ded4fdc6de63c5bc5","assignee":{"login":"rickmak","id":62677,"avatar_url":"https://avatars.githubusercontent.com/u/62677?v=3","gravatar_id":"","url":"https://api.github.com/users/rickmak","html_url":"https://github.com/rickmak","followers_url":"https://api.github.com/users/rickmak/followers","following_url":"https://api.github.com/users/rickmak/following{/other_user}","gists_url":"https://api.github.com/users/rickmak/gists{/gist_id}","starred_url":"https://api.github.com/users/rickmak/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rickmak/subscriptions","organizations_url":"https://api.github.com/users/rickmak/orgs","repos_url":"https://api.github.com/users/rickmak/repos","events_url":"https://api.github.com/users/rickmak/events{/privacy}","received_events_url":"https://api.github.com/users/rickmak/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/SkygearIO/skygear-doc/pulls/22/commits","review_comments_url":"https://api.github.com/repos/SkygearIO/skygear-doc/pulls/22/comments","review_comment_url":"https://api.github.com/repos/SkygearIO/skygear-doc/pulls/comments{/number}","comments_url":"https://api.github.com/repos/SkygearIO/skygear-doc/issues/22/comments","statuses_url":"https://api.github.com/repos/SkygearIO/skygear-doc/statuses/38e78cd3284d17833af07719a182c9d09bc75627","head":{"label":"ben181231:content-loader","ref":"content-loader","sha":"38e78cd3284d17833af07719a182c9d09bc75627","user":{"login":"ben181231","id":3863953,"avatar_url":"https://avatars.githubusercontent.com/u/3863953?v=3","gravatar_id":"","url":"https://api.github.com/users/ben181231","html_url":"https://github.com/ben181231","followers_url":"https://api.github.com/users/ben181231/followers","following_url":"https://api.github.com/users/ben181231/following{/other_user}","gists_url":"https://api.github.com/users/ben181231/gists{/gist_id}","starred_url":"https://api.github.com/users/ben181231/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ben181231/subscriptions","organizations_url":"https://api.github.com/users/ben181231/orgs","repos_url":"https://api.github.com/users/ben181231/repos","events_url":"https://api.github.com/users/ben181231/events{/privacy}","received_events_url":"https://api.github.com/users/ben181231/received_events","type":"User","site_admin":false},"repo":{"id":56218680,"name":"skygear-doc","full_name":"ben181231/skygear-doc","owner":{"login":"ben181231","id":3863953,"avatar_url":"https://avatars.githubusercontent.com/u/3863953?v=3","gravatar_id":"","url":"https://api.github.com/users/ben181231","html_url":"https://github.com/ben181231","followers_url":"https://api.github.com/users/ben181231/followers","following_url":"https://api.github.com/users/ben181231/following{/other_user}","gists_url":"https://api.github.com/users/ben181231/gists{/gist_id}","starred_url":"https://api.github.com/users/ben181231/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ben181231/subscriptions","organizations_url":"https://api.github.com/users/ben181231/orgs","repos_url":"https://api.github.com/users/ben181231/repos","events_url":"https://api.github.com/users/ben181231/events{/privacy}","received_events_url":"https://api.github.com/users/ben181231/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ben181231/skygear-doc","description":"","fork":true,"url":"https://api.github.com/repos/ben181231/skygear-doc","forks_url":"https://api.github.com/repos/ben181231/skygear-doc/forks","keys_url":"https://api.github.com/repos/ben181231/skygear-doc/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ben181231/skygear-doc/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ben181231/skygear-doc/teams","hooks_url":"https://api.github.com/repos/ben181231/skygear-doc/hooks","issue_events_url":"https://api.github.com/repos/ben181231/skygear-doc/issues/events{/number}","events_url":"https://api.github.com/repos/ben181231/skygear-doc/events","assignees_url":"https://api.github.com/repos/ben181231/skygear-doc/assignees{/user}","branches_url":"https://api.github.com/repos/ben181231/skygear-doc/branches{/branch}","tags_url":"https://api.github.com/repos/ben181231/skygear-doc/tags","blobs_url":"https://api.github.com/repos/ben181231/skygear-doc/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ben181231/skygear-doc/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ben181231/skygear-doc/git/refs{/sha}","trees_url":"https://api.github.com/repos/ben181231/skygear-doc/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ben181231/skygear-doc/statuses/{sha}","languages_url":"https://api.github.com/repos/ben181231/skygear-doc/languages","stargazers_url":"https://api.github.com/repos/ben181231/skygear-doc/stargazers","contributors_url":"https://api.github.com/repos/ben181231/skygear-doc/contributors","subscribers_url":"https://api.github.com/repos/ben181231/skygear-doc/subscribers","subscription_url":"https://api.github.com/repos/ben181231/skygear-doc/subscription","commits_url":"https://api.github.com/repos/ben181231/skygear-doc/commits{/sha}","git_commits_url":"https://api.github.com/repos/ben181231/skygear-doc/git/commits{/sha}","comments_url":"https://api.github.com/repos/ben181231/skygear-doc/comments{/number}","issue_comment_url":"https://api.github.com/repos/ben181231/skygear-doc/issues/comments{/number}","contents_url":"https://api.github.com/repos/ben181231/skygear-doc/contents/{+path}","compare_url":"https://api.github.com/repos/ben181231/skygear-doc/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ben181231/skygear-doc/merges","archive_url":"https://api.github.com/repos/ben181231/skygear-doc/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ben181231/skygear-doc/downloads","issues_url":"https://api.github.com/repos/ben181231/skygear-doc/issues{/number}","pulls_url":"https://api.github.com/repos/ben181231/skygear-doc/pulls{/number}","milestones_url":"https://api.github.com/repos/ben181231/skygear-doc/milestones{/number}","notifications_url":"https://api.github.com/repos/ben181231/skygear-doc/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ben181231/skygear-doc/labels{/name}","releases_url":"https://api.github.com/repos/ben181231/skygear-doc/releases{/id}","deployments_url":"https://api.github.com/repos/ben181231/skygear-doc/deployments","created_at":"2016-04-14T08:03:10Z","updated_at":"2016-04-19T06:46:20Z","pushed_at":"2016-04-26T10:30:45Z","git_url":"git://github.com/ben181231/skygear-doc.git","ssh_url":"git@github.com:ben181231/skygear-doc.git","clone_url":"https://github.com/ben181231/skygear-doc.git","svn_url":"https://github.com/ben181231/skygear-doc","homepage":null,"size":3633,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"SkygearIO:master","ref":"master","sha":"07c3741f88131ec85775ed551229be3c936b28cc","user":{"login":"SkygearIO","id":15025887,"avatar_url":"https://avatars.githubusercontent.com/u/15025887?v=3","gravatar_id":"","url":"https://api.github.com/users/SkygearIO","html_url":"https://github.com/SkygearIO","followers_url":"https://api.github.com/users/SkygearIO/followers","following_url":"https://api.github.com/users/SkygearIO/following{/other_user}","gists_url":"https://api.github.com/users/SkygearIO/gists{/gist_id}","starred_url":"https://api.github.com/users/SkygearIO/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SkygearIO/subscriptions","organizations_url":"https://api.github.com/users/SkygearIO/orgs","repos_url":"https://api.github.com/users/SkygearIO/repos","events_url":"https://api.github.com/users/SkygearIO/events{/privacy}","received_events_url":"https://api.github.com/users/SkygearIO/received_events","type":"Organization","site_admin":false},"repo":{"id":56206030,"name":"skygear-doc","full_name":"SkygearIO/skygear-doc","owner":{"login":"SkygearIO","id":15025887,"avatar_url":"https://avatars.githubusercontent.com/u/15025887?v=3","gravatar_id":"","url":"https://api.github.com/users/SkygearIO","html_url":"https://github.com/SkygearIO","followers_url":"https://api.github.com/users/SkygearIO/followers","following_url":"https://api.github.com/users/SkygearIO/following{/other_user}","gists_url":"https://api.github.com/users/SkygearIO/gists{/gist_id}","starred_url":"https://api.github.com/users/SkygearIO/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/SkygearIO/subscriptions","organizations_url":"https://api.github.com/users/SkygearIO/orgs","repos_url":"https://api.github.com/users/SkygearIO/repos","events_url":"https://api.github.com/users/SkygearIO/events{/privacy}","received_events_url":"https://api.github.com/users/SkygearIO/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/SkygearIO/skygear-doc","description":"","fork":false,"url":"https://api.github.com/repos/SkygearIO/skygear-doc","forks_url":"https://api.github.com/repos/SkygearIO/skygear-doc/forks","keys_url":"https://api.github.com/repos/SkygearIO/skygear-doc/keys{/key_id}","collaborators_url":"https://api.github.com/repos/SkygearIO/skygear-doc/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/SkygearIO/skygear-doc/teams","hooks_url":"https://api.github.com/repos/SkygearIO/skygear-doc/hooks","issue_events_url":"https://api.github.com/repos/SkygearIO/skygear-doc/issues/events{/number}","events_url":"https://api.github.com/repos/SkygearIO/skygear-doc/events","assignees_url":"https://api.github.com/repos/SkygearIO/skygear-doc/assignees{/user}","branches_url":"https://api.github.com/repos/SkygearIO/skygear-doc/branches{/branch}","tags_url":"https://api.github.com/repos/SkygearIO/skygear-doc/tags","blobs_url":"https://api.github.com/repos/SkygearIO/skygear-doc/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/SkygearIO/skygear-doc/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/SkygearIO/skygear-doc/git/refs{/sha}","trees_url":"https://api.github.com/repos/SkygearIO/skygear-doc/git/trees{/sha}","statuses_url":"https://api.github.com/repos/SkygearIO/skygear-doc/statuses/{sha}","languages_url":"https://api.github.com/repos/SkygearIO/skygear-doc/languages","stargazers_url":"https://api.github.com/repos/SkygearIO/skygear-doc/stargazers","contributors_url":"https://api.github.com/repos/SkygearIO/skygear-doc/contributors","subscribers_url":"https://api.github.com/repos/SkygearIO/skygear-doc/subscribers","subscription_url":"https://api.github.com/repos/SkygearIO/skygear-doc/subscription","commits_url":"https://api.github.com/repos/SkygearIO/skygear-doc/commits{/sha}","git_commits_url":"https://api.github.com/repos/SkygearIO/skygear-doc/git/commits{/sha}","comments_url":"https://api.github.com/repos/SkygearIO/skygear-doc/comments{/number}","issue_comment_url":"https://api.github.com/repos/SkygearIO/skygear-doc/issues/comments{/number}","contents_url":"https://api.github.com/repos/SkygearIO/skygear-doc/contents/{+path}","compare_url":"https://api.github.com/repos/SkygearIO/skygear-doc/compare/{base}...{head}","merges_url":"https://api.github.com/repos/SkygearIO/skygear-doc/merges","archive_url":"https://api.github.com/repos/SkygearIO/skygear-doc/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/SkygearIO/skygear-doc/downloads","issues_url":"https://api.github.com/repos/SkygearIO/skygear-doc/issues{/number}","pulls_url":"https://api.github.com/repos/SkygearIO/skygear-doc/pulls{/number}","milestones_url":"https://api.github.com/repos/SkygearIO/skygear-doc/milestones{/number}","notifications_url":"https://api.github.com/repos/SkygearIO/skygear-doc/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/SkygearIO/skygear-doc/labels{/name}","releases_url":"https://api.github.com/repos/SkygearIO/skygear-doc/releases{/id}","deployments_url":"https://api.github.com/repos/SkygearIO/skygear-doc/deployments","created_at":"2016-04-14T04:00:08Z","updated_at":"2016-04-19T04:41:40Z","pushed_at":"2016-04-27T04:43:16Z","git_url":"git://github.com/SkygearIO/skygear-doc.git","ssh_url":"git@github.com:SkygearIO/skygear-doc.git","clone_url":"https://github.com/SkygearIO/skygear-doc.git","svn_url":"https://github.com/SkygearIO/skygear-doc","homepage":null,"size":3634,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":8,"forks":2,"open_issues":8,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/SkygearIO/skygear-doc/pulls/22"},"html":{"href":"https://github.com/SkygearIO/skygear-doc/pull/22"},"issue":{"href":"https://api.github.com/repos/SkygearIO/skygear-doc/issues/22"},"comments":{"href":"https://api.github.com/repos/SkygearIO/skygear-doc/issues/22/comments"},"review_comments":{"href":"https://api.github.com/repos/SkygearIO/skygear-doc/pulls/22/comments"},"review_comment":{"href":"https://api.github.com/repos/SkygearIO/skygear-doc/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/SkygearIO/skygear-doc/pulls/22/commits"},"statuses":{"href":"https://api.github.com/repos/SkygearIO/skygear-doc/statuses/38e78cd3284d17833af07719a182c9d09bc75627"}}}}