{"action":"created","comment":{"url":"https://api.github.com/repos/pattern-library/patternlab-wrapper/pulls/comments/29771139","id":29771139,"diff_hunk":"@@ -0,0 +1,85 @@\n+/**\n+ * Compiles basic twig templates for patternlab iframe wrapper\n+ *\n+ * USAGE:\n+ * var patternlabWrapper = require('patternlab-wrapper');\n+ *\n+ * patternlabWrapper({\n+ *   dest: './app/public',\n+ *   patternPaths: {\"atoms\":{\"colors\":\"00-atoms-01-global-00-colors\",\"redirect\":\"00-atoms-01-global-01-redirect\",...}}\n+ *   patternNavHTML: '<ul class=\"patterns-menu sg-nav\">\n+    <li class=\"sg-nav-\"><a class=\"sg-acc-handle\">base</a>\n+        <ul class=\"sg-acc-panel\">\n+\n+            <li class=\"sg-nav-\"><a class=\"sg-pop\" href=\"app/bower_components/pattern-library/patterns/base/blockquote\">Blockquote</a></li>\n+            <li class=\"sg-nav-\"><a class=\"sg-pop\" href=\"app/bower_components/pattern-library/patterns/base/body\">Body</a></li>\n+        </ul>\n+    </li>\n+    </ul>'\n+ * });\n+ *\n+ */\n+\n+/**\n+ *\n+ * @type {Twig.exports|exports}\n+ */\n+\n+var Twig = require('twig');\n+var fs = require('fs');\n+var fsextra = require('fs-extra');\n+\n+var patternlabFiles = [\n+  'styleguide', 'js', 'images', 'fonts', 'data'\n+];\n+\n+/**\n+ *\n+ * @type {{dest: string, patternNav: string, patternNavTemplate: string, ishControls: string, ishControlsTemplate: string, patternPaths: {base: Array}, src: string}}\n+ */\n+var optionsDefault = {\n+  dest: './public',\n+  patternNavHTML: '',\n+  patternNavTemplate: './_patternlab-files/partials/patternNav.twig',\n+  ishControlsHTML: '',\n+  ishControlsTemplate: './_patternlab-files/partials/ishControls.twig',\n+  patternPaths: {base: []},\n+  src: './_patternlab-files'\n+};\n+\n+function patternlabWrapper(options) {\n+  options = options || {};\n+  options.patternNavHTML = options.patternNavHTML || Twig.twig({data: fs.readFileSync(optionsDefault.patternNavTemplate, 'utf8')}).render();\n+  options.ishControlsHTML = options.ishControlsHTML || Twig.twig({data: fs.readFileSync(optionsDefault.ishControlsTemplate, 'utf8')}).render();\n+  options.patternPaths = options.patternPaths || optionsDefault.patternPaths;\n+  options.dest = options.dest || optionsDefault.dest;\n+  options.src = options.src || optionsDefault.src;\n+\n+  var indexTemplate = Twig.twig({data: fs.readFileSync('./_patternlab-files/index.twig', 'utf8')});\n+\n+  fs.writeFile(options.dest + '/index.html', indexTemplate.render({","path":"index.js","position":60,"original_position":60,"commit_id":"6a5895b237347fbb097aeafc07c5a4d0bc00d6a9","original_commit_id":"6a5895b237347fbb097aeafc07c5a4d0bc00d6a9","user":{"login":"sergesemashko","id":1267571,"avatar_url":"https://avatars.githubusercontent.com/u/1267571?v=3","gravatar_id":"","url":"https://api.github.com/users/sergesemashko","html_url":"https://github.com/sergesemashko","followers_url":"https://api.github.com/users/sergesemashko/followers","following_url":"https://api.github.com/users/sergesemashko/following{/other_user}","gists_url":"https://api.github.com/users/sergesemashko/gists{/gist_id}","starred_url":"https://api.github.com/users/sergesemashko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sergesemashko/subscriptions","organizations_url":"https://api.github.com/users/sergesemashko/orgs","repos_url":"https://api.github.com/users/sergesemashko/repos","events_url":"https://api.github.com/users/sergesemashko/events{/privacy}","received_events_url":"https://api.github.com/users/sergesemashko/received_events","type":"User","site_admin":false},"body":"in long term - promises would be great, I'll add fs helpers in this repo for now.\r\ncc/ @beynya ","created_at":"2015-05-06T15:45:16Z","updated_at":"2015-05-06T15:45:16Z","html_url":"https://github.com/pattern-library/patternlab-wrapper/pull/1#discussion_r29771139","pull_request_url":"https://api.github.com/repos/pattern-library/patternlab-wrapper/pulls/1","_links":{"self":{"href":"https://api.github.com/repos/pattern-library/patternlab-wrapper/pulls/comments/29771139"},"html":{"href":"https://github.com/pattern-library/patternlab-wrapper/pull/1#discussion_r29771139"},"pull_request":{"href":"https://api.github.com/repos/pattern-library/patternlab-wrapper/pulls/1"}}},"pull_request":{"url":"https://api.github.com/repos/pattern-library/patternlab-wrapper/pulls/1","id":34775627,"html_url":"https://github.com/pattern-library/patternlab-wrapper/pull/1","diff_url":"https://github.com/pattern-library/patternlab-wrapper/pull/1.diff","patch_url":"https://github.com/pattern-library/patternlab-wrapper/pull/1.patch","issue_url":"https://api.github.com/repos/pattern-library/patternlab-wrapper/issues/1","number":1,"state":"open","locked":false,"title":"POC for patternlab viewer: initial commit","user":{"login":"sergesemashko","id":1267571,"avatar_url":"https://avatars.githubusercontent.com/u/1267571?v=3","gravatar_id":"","url":"https://api.github.com/users/sergesemashko","html_url":"https://github.com/sergesemashko","followers_url":"https://api.github.com/users/sergesemashko/followers","following_url":"https://api.github.com/users/sergesemashko/following{/other_user}","gists_url":"https://api.github.com/users/sergesemashko/gists{/gist_id}","starred_url":"https://api.github.com/users/sergesemashko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sergesemashko/subscriptions","organizations_url":"https://api.github.com/users/sergesemashko/orgs","repos_url":"https://api.github.com/users/sergesemashko/repos","events_url":"https://api.github.com/users/sergesemashko/events{/privacy}","received_events_url":"https://api.github.com/users/sergesemashko/received_events","type":"User","site_admin":false},"body":"@beynya @scottnath please review","created_at":"2015-05-05T22:54:22Z","updated_at":"2015-05-06T15:45:16Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6cd1d72c7dda9fc17b9445c1b34471894f992d45","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/pattern-library/patternlab-wrapper/pulls/1/commits","review_comments_url":"https://api.github.com/repos/pattern-library/patternlab-wrapper/pulls/1/comments","review_comment_url":"https://api.github.com/repos/pattern-library/patternlab-wrapper/pulls/comments{/number}","comments_url":"https://api.github.com/repos/pattern-library/patternlab-wrapper/issues/1/comments","statuses_url":"https://api.github.com/repos/pattern-library/patternlab-wrapper/statuses/6a5895b237347fbb097aeafc07c5a4d0bc00d6a9","head":{"label":"sergesemashko:master","ref":"master","sha":"6a5895b237347fbb097aeafc07c5a4d0bc00d6a9","user":{"login":"sergesemashko","id":1267571,"avatar_url":"https://avatars.githubusercontent.com/u/1267571?v=3","gravatar_id":"","url":"https://api.github.com/users/sergesemashko","html_url":"https://github.com/sergesemashko","followers_url":"https://api.github.com/users/sergesemashko/followers","following_url":"https://api.github.com/users/sergesemashko/following{/other_user}","gists_url":"https://api.github.com/users/sergesemashko/gists{/gist_id}","starred_url":"https://api.github.com/users/sergesemashko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sergesemashko/subscriptions","organizations_url":"https://api.github.com/users/sergesemashko/orgs","repos_url":"https://api.github.com/users/sergesemashko/repos","events_url":"https://api.github.com/users/sergesemashko/events{/privacy}","received_events_url":"https://api.github.com/users/sergesemashko/received_events","type":"User","site_admin":false},"repo":{"id":35127354,"name":"patternlab-wrapper","full_name":"sergesemashko/patternlab-wrapper","owner":{"login":"sergesemashko","id":1267571,"avatar_url":"https://avatars.githubusercontent.com/u/1267571?v=3","gravatar_id":"","url":"https://api.github.com/users/sergesemashko","html_url":"https://github.com/sergesemashko","followers_url":"https://api.github.com/users/sergesemashko/followers","following_url":"https://api.github.com/users/sergesemashko/following{/other_user}","gists_url":"https://api.github.com/users/sergesemashko/gists{/gist_id}","starred_url":"https://api.github.com/users/sergesemashko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sergesemashko/subscriptions","organizations_url":"https://api.github.com/users/sergesemashko/orgs","repos_url":"https://api.github.com/users/sergesemashko/repos","events_url":"https://api.github.com/users/sergesemashko/events{/privacy}","received_events_url":"https://api.github.com/users/sergesemashko/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sergesemashko/patternlab-wrapper","description":"Generate general patternlab wrapper with iframe","fork":true,"url":"https://api.github.com/repos/sergesemashko/patternlab-wrapper","forks_url":"https://api.github.com/repos/sergesemashko/patternlab-wrapper/forks","keys_url":"https://api.github.com/repos/sergesemashko/patternlab-wrapper/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sergesemashko/patternlab-wrapper/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sergesemashko/patternlab-wrapper/teams","hooks_url":"https://api.github.com/repos/sergesemashko/patternlab-wrapper/hooks","issue_events_url":"https://api.github.com/repos/sergesemashko/patternlab-wrapper/issues/events{/number}","events_url":"https://api.github.com/repos/sergesemashko/patternlab-wrapper/events","assignees_url":"https://api.github.com/repos/sergesemashko/patternlab-wrapper/assignees{/user}","branches_url":"https://api.github.com/repos/sergesemashko/patternlab-wrapper/branches{/branch}","tags_url":"https://api.github.com/repos/sergesemashko/patternlab-wrapper/tags","blobs_url":"https://api.github.com/repos/sergesemashko/patternlab-wrapper/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sergesemashko/patternlab-wrapper/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sergesemashko/patternlab-wrapper/git/refs{/sha}","trees_url":"https://api.github.com/repos/sergesemashko/patternlab-wrapper/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sergesemashko/patternlab-wrapper/statuses/{sha}","languages_url":"https://api.github.com/repos/sergesemashko/patternlab-wrapper/languages","stargazers_url":"https://api.github.com/repos/sergesemashko/patternlab-wrapper/stargazers","contributors_url":"https://api.github.com/repos/sergesemashko/patternlab-wrapper/contributors","subscribers_url":"https://api.github.com/repos/sergesemashko/patternlab-wrapper/subscribers","subscription_url":"https://api.github.com/repos/sergesemashko/patternlab-wrapper/subscription","commits_url":"https://api.github.com/repos/sergesemashko/patternlab-wrapper/commits{/sha}","git_commits_url":"https://api.github.com/repos/sergesemashko/patternlab-wrapper/git/commits{/sha}","comments_url":"https://api.github.com/repos/sergesemashko/patternlab-wrapper/comments{/number}","issue_comment_url":"https://api.github.com/repos/sergesemashko/patternlab-wrapper/issues/comments{/number}","contents_url":"https://api.github.com/repos/sergesemashko/patternlab-wrapper/contents/{+path}","compare_url":"https://api.github.com/repos/sergesemashko/patternlab-wrapper/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sergesemashko/patternlab-wrapper/merges","archive_url":"https://api.github.com/repos/sergesemashko/patternlab-wrapper/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sergesemashko/patternlab-wrapper/downloads","issues_url":"https://api.github.com/repos/sergesemashko/patternlab-wrapper/issues{/number}","pulls_url":"https://api.github.com/repos/sergesemashko/patternlab-wrapper/pulls{/number}","milestones_url":"https://api.github.com/repos/sergesemashko/patternlab-wrapper/milestones{/number}","notifications_url":"https://api.github.com/repos/sergesemashko/patternlab-wrapper/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sergesemashko/patternlab-wrapper/labels{/name}","releases_url":"https://api.github.com/repos/sergesemashko/patternlab-wrapper/releases{/id}","created_at":"2015-05-05T22:37:15Z","updated_at":"2015-05-05T22:53:30Z","pushed_at":"2015-05-05T22:53:29Z","git_url":"git://github.com/sergesemashko/patternlab-wrapper.git","ssh_url":"git@github.com:sergesemashko/patternlab-wrapper.git","clone_url":"https://github.com/sergesemashko/patternlab-wrapper.git","svn_url":"https://github.com/sergesemashko/patternlab-wrapper","homepage":null,"size":0,"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":"pattern-library:master","ref":"master","sha":"0841c4201cb072c14dea2b613cd35e175f4da5dd","user":{"login":"pattern-library","id":11633856,"avatar_url":"https://avatars.githubusercontent.com/u/11633856?v=3","gravatar_id":"","url":"https://api.github.com/users/pattern-library","html_url":"https://github.com/pattern-library","followers_url":"https://api.github.com/users/pattern-library/followers","following_url":"https://api.github.com/users/pattern-library/following{/other_user}","gists_url":"https://api.github.com/users/pattern-library/gists{/gist_id}","starred_url":"https://api.github.com/users/pattern-library/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pattern-library/subscriptions","organizations_url":"https://api.github.com/users/pattern-library/orgs","repos_url":"https://api.github.com/users/pattern-library/repos","events_url":"https://api.github.com/users/pattern-library/events{/privacy}","received_events_url":"https://api.github.com/users/pattern-library/received_events","type":"Organization","site_admin":false},"repo":{"id":35127348,"name":"patternlab-wrapper","full_name":"pattern-library/patternlab-wrapper","owner":{"login":"pattern-library","id":11633856,"avatar_url":"https://avatars.githubusercontent.com/u/11633856?v=3","gravatar_id":"","url":"https://api.github.com/users/pattern-library","html_url":"https://github.com/pattern-library","followers_url":"https://api.github.com/users/pattern-library/followers","following_url":"https://api.github.com/users/pattern-library/following{/other_user}","gists_url":"https://api.github.com/users/pattern-library/gists{/gist_id}","starred_url":"https://api.github.com/users/pattern-library/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/pattern-library/subscriptions","organizations_url":"https://api.github.com/users/pattern-library/orgs","repos_url":"https://api.github.com/users/pattern-library/repos","events_url":"https://api.github.com/users/pattern-library/events{/privacy}","received_events_url":"https://api.github.com/users/pattern-library/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/pattern-library/patternlab-wrapper","description":"Generate general patternlab wrapper with iframe","fork":false,"url":"https://api.github.com/repos/pattern-library/patternlab-wrapper","forks_url":"https://api.github.com/repos/pattern-library/patternlab-wrapper/forks","keys_url":"https://api.github.com/repos/pattern-library/patternlab-wrapper/keys{/key_id}","collaborators_url":"https://api.github.com/repos/pattern-library/patternlab-wrapper/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/pattern-library/patternlab-wrapper/teams","hooks_url":"https://api.github.com/repos/pattern-library/patternlab-wrapper/hooks","issue_events_url":"https://api.github.com/repos/pattern-library/patternlab-wrapper/issues/events{/number}","events_url":"https://api.github.com/repos/pattern-library/patternlab-wrapper/events","assignees_url":"https://api.github.com/repos/pattern-library/patternlab-wrapper/assignees{/user}","branches_url":"https://api.github.com/repos/pattern-library/patternlab-wrapper/branches{/branch}","tags_url":"https://api.github.com/repos/pattern-library/patternlab-wrapper/tags","blobs_url":"https://api.github.com/repos/pattern-library/patternlab-wrapper/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/pattern-library/patternlab-wrapper/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/pattern-library/patternlab-wrapper/git/refs{/sha}","trees_url":"https://api.github.com/repos/pattern-library/patternlab-wrapper/git/trees{/sha}","statuses_url":"https://api.github.com/repos/pattern-library/patternlab-wrapper/statuses/{sha}","languages_url":"https://api.github.com/repos/pattern-library/patternlab-wrapper/languages","stargazers_url":"https://api.github.com/repos/pattern-library/patternlab-wrapper/stargazers","contributors_url":"https://api.github.com/repos/pattern-library/patternlab-wrapper/contributors","subscribers_url":"https://api.github.com/repos/pattern-library/patternlab-wrapper/subscribers","subscription_url":"https://api.github.com/repos/pattern-library/patternlab-wrapper/subscription","commits_url":"https://api.github.com/repos/pattern-library/patternlab-wrapper/commits{/sha}","git_commits_url":"https://api.github.com/repos/pattern-library/patternlab-wrapper/git/commits{/sha}","comments_url":"https://api.github.com/repos/pattern-library/patternlab-wrapper/comments{/number}","issue_comment_url":"https://api.github.com/repos/pattern-library/patternlab-wrapper/issues/comments{/number}","contents_url":"https://api.github.com/repos/pattern-library/patternlab-wrapper/contents/{+path}","compare_url":"https://api.github.com/repos/pattern-library/patternlab-wrapper/compare/{base}...{head}","merges_url":"https://api.github.com/repos/pattern-library/patternlab-wrapper/merges","archive_url":"https://api.github.com/repos/pattern-library/patternlab-wrapper/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/pattern-library/patternlab-wrapper/downloads","issues_url":"https://api.github.com/repos/pattern-library/patternlab-wrapper/issues{/number}","pulls_url":"https://api.github.com/repos/pattern-library/patternlab-wrapper/pulls{/number}","milestones_url":"https://api.github.com/repos/pattern-library/patternlab-wrapper/milestones{/number}","notifications_url":"https://api.github.com/repos/pattern-library/patternlab-wrapper/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/pattern-library/patternlab-wrapper/labels{/name}","releases_url":"https://api.github.com/repos/pattern-library/patternlab-wrapper/releases{/id}","created_at":"2015-05-05T22:37:08Z","updated_at":"2015-05-05T22:37:08Z","pushed_at":"2015-05-05T22:54:22Z","git_url":"git://github.com/pattern-library/patternlab-wrapper.git","ssh_url":"git@github.com:pattern-library/patternlab-wrapper.git","clone_url":"https://github.com/pattern-library/patternlab-wrapper.git","svn_url":"https://github.com/pattern-library/patternlab-wrapper","homepage":null,"size":0,"stargazers_count":0,"watchers_count":0,"language":null,"has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":1,"forks":1,"open_issues":1,"watchers":0,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/pattern-library/patternlab-wrapper/pulls/1"},"html":{"href":"https://github.com/pattern-library/patternlab-wrapper/pull/1"},"issue":{"href":"https://api.github.com/repos/pattern-library/patternlab-wrapper/issues/1"},"comments":{"href":"https://api.github.com/repos/pattern-library/patternlab-wrapper/issues/1/comments"},"review_comments":{"href":"https://api.github.com/repos/pattern-library/patternlab-wrapper/pulls/1/comments"},"review_comment":{"href":"https://api.github.com/repos/pattern-library/patternlab-wrapper/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/pattern-library/patternlab-wrapper/pulls/1/commits"},"statuses":{"href":"https://api.github.com/repos/pattern-library/patternlab-wrapper/statuses/6a5895b237347fbb097aeafc07c5a4d0bc00d6a9"}}}}