GitHub PullRequestEvent at 2014-06-28 22:15:42
Repository: middleman
Actor: tdreyno
Payload: {"action":"opened","number":1307,"pull_request":{"url":"https://api.github.com/repos/middleman/middleman/pulls/1307","id":17742085,"html_url":"https://github.com/middleman/middleman/pull/1307","diff_url":"https://github.com/middleman/middleman/pull/1307.diff","patch_url":"https://github.com/middleman/middleman/pull/1307.patch","issue_url":"https://api.github.com/repos/middleman/middleman/issues/1307","number":1307,"state":"open","title":"Collections","user":{"login":"tdreyno","id":233,"avatar_url":"https://avatars.githubusercontent.com/u/233?","gravatar_id":"291394b477c2824bf5d75b831f125304","url":"https://api.github.com/users/tdreyno","html_url":"https://github.com/tdreyno","followers_url":"https://api.github.com/users/tdreyno/followers","following_url":"https://api.github.com/users/tdreyno/following{/other_user}","gists_url":"https://api.github.com/users/tdreyno/gists{/gist_id}","starred_url":"https://api.github.com/users/tdreyno/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tdreyno/subscriptions","organizations_url":"https://api.github.com/users/tdreyno/orgs","repos_url":"https://api.github.com/users/tdreyno/repos","events_url":"https://api.github.com/users/tdreyno/events{/privacy}","received_events_url":"https://api.github.com/users/tdreyno/received_events","type":"User","site_admin":false},"body":"This is a WIP feature/PR for tracking the concept of \"Collections\" which is being extracted from Middleman Blog and brought into core. Some code may be shared, but it's more likely this will be a rewrite.\r\n\r\nThe API in this PR currently looks like this:\r\n\r\n```\r\ncollect :articles,\r\n  where: proc { |resource|\r\n    uri_match resource.url, 'blog/{year}-{month}-{day}-{title}.html'\r\n  }\r\n\r\ncollect :tags,\r\n  where: proc { |resource|\r\n    resource.data.tags\r\n  },\r\n  group_by: proc { |resource|\r\n    if resource.data.tags.is_a? String\r\n      resource.data.tags.split(',').map(&:strip)\r\n    else\r\n      resource.data.tags\r\n    end\r\n  }\r\n```\r\n\r\nThe first example allows the user to create a named collection and simply `filter` the sitemap. Collections are kept up-to-date with Sitemap changes. Eventually, we will move the collection-specific helpers from Blog over to build things like automatic paging and sorting into collections.\r\n\r\nFrom a template, the first collection would be used like so:\r\n\r\n```\r\n<% collected.articles.each do |article| %>\r\n  <li>\r\n    <a href=\"<%= article.url %>\"><%= article.data.title %></a>\r\n    <time><%= article.data.date.strftime('%b %e') %></time>\r\n  </li>\r\n<% end %>\r\n```\r\n\r\nThe second example adds another key to create a collection of collections. In this case, it looks at articles it thinks are blog posts, pulls out the tags and makes an array for each unique match. From the template:\r\n\r\n```\r\n<% collected[:tags].each do |k, items| %>\r\n  <li>\r\n    <%= k %>\r\n    <% items.each do |article| %>\r\n      <%= article.data.title %>\r\n    <% end %>\r\n  </li>\r\n<% end %>\r\n```\r\n\r\nRight now this is the only API. The next step will be to provide some sugar over directly using `Proc`s.\r\n\r\nI'd love some feedback, not really on the code yet, but on the flexibility of the approach. I spoke with @pulletsforever the other day and realized the API had originally imagines wouldn't be nearly powerful enough for his needs. Starting from the bottom like this will let power users be very specific, but we can add nicer looking APIs on top later.\r\n\r\nThoughts? @bhollis @karlfreeman ","created_at":"2014-06-28T22:15:41Z","updated_at":"2014-06-28T22:15:41Z","closed_at":null,"merged_at":null,"merge_commit_sha":null,"assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/middleman/middleman/pulls/1307/commits","review_comments_url":"https://api.github.com/repos/middleman/middleman/pulls/1307/comments","review_comment_url":"https://api.github.com/repos/middleman/middleman/pulls/comments/{number}","comments_url":"https://api.github.com/repos/middleman/middleman/issues/1307/comments","statuses_url":"https://api.github.com/repos/middleman/middleman/statuses/3af92560d579500d4eb69128845eef2bed52b2ad","head":{"label":"middleman:collections","ref":"collections","sha":"3af92560d579500d4eb69128845eef2bed52b2ad","user":{"login":"middleman","id":1280820,"avatar_url":"https://avatars.githubusercontent.com/u/1280820?","gravatar_id":"2fd3a9ecba62fd547bb1a58dea245a9c","url":"https://api.github.com/users/middleman","html_url":"https://github.com/middleman","followers_url":"https://api.github.com/users/middleman/followers","following_url":"https://api.github.com/users/middleman/following{/other_user}","gists_url":"https://api.github.com/users/middleman/gists{/gist_id}","starred_url":"https://api.github.com/users/middleman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/middleman/subscriptions","organizations_url":"https://api.github.com/users/middleman/orgs","repos_url":"https://api.github.com/users/middleman/repos","events_url":"https://api.github.com/users/middleman/events{/privacy}","received_events_url":"https://api.github.com/users/middleman/received_events","type":"Organization","site_admin":false},"repo":{"id":261943,"name":"middleman","full_name":"middleman/middleman","owner":{"login":"middleman","id":1280820,"avatar_url":"https://avatars.githubusercontent.com/u/1280820?","gravatar_id":"2fd3a9ecba62fd547bb1a58dea245a9c","url":"https://api.github.com/users/middleman","html_url":"https://github.com/middleman","followers_url":"https://api.github.com/users/middleman/followers","following_url":"https://api.github.com/users/middleman/following{/other_user}","gists_url":"https://api.github.com/users/middleman/gists{/gist_id}","starred_url":"https://api.github.com/users/middleman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/middleman/subscriptions","organizations_url":"https://api.github.com/users/middleman/orgs","repos_url":"https://api.github.com/users/middleman/repos","events_url":"https://api.github.com/users/middleman/events{/privacy}","received_events_url":"https://api.github.com/users/middleman/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/middleman/middleman","description":"Hand-crafted frontend development","fork":false,"url":"https://api.github.com/repos/middleman/middleman","forks_url":"https://api.github.com/repos/middleman/middleman/forks","keys_url":"https://api.github.com/repos/middleman/middleman/keys{/key_id}","collaborators_url":"https://api.github.com/repos/middleman/middleman/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/middleman/middleman/teams","hooks_url":"https://api.github.com/repos/middleman/middleman/hooks","issue_events_url":"https://api.github.com/repos/middleman/middleman/issues/events{/number}","events_url":"https://api.github.com/repos/middleman/middleman/events","assignees_url":"https://api.github.com/repos/middleman/middleman/assignees{/user}","branches_url":"https://api.github.com/repos/middleman/middleman/branches{/branch}","tags_url":"https://api.github.com/repos/middleman/middleman/tags","blobs_url":"https://api.github.com/repos/middleman/middleman/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/middleman/middleman/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/middleman/middleman/git/refs{/sha}","trees_url":"https://api.github.com/repos/middleman/middleman/git/trees{/sha}","statuses_url":"https://api.github.com/repos/middleman/middleman/statuses/{sha}","languages_url":"https://api.github.com/repos/middleman/middleman/languages","stargazers_url":"https://api.github.com/repos/middleman/middleman/stargazers","contributors_url":"https://api.github.com/repos/middleman/middleman/contributors","subscribers_url":"https://api.github.com/repos/middleman/middleman/subscribers","subscription_url":"https://api.github.com/repos/middleman/middleman/subscription","commits_url":"https://api.github.com/repos/middleman/middleman/commits{/sha}","git_commits_url":"https://api.github.com/repos/middleman/middleman/git/commits{/sha}","comments_url":"https://api.github.com/repos/middleman/middleman/comments{/number}","issue_comment_url":"https://api.github.com/repos/middleman/middleman/issues/comments/{number}","contents_url":"https://api.github.com/repos/middleman/middleman/contents/{+path}","compare_url":"https://api.github.com/repos/middleman/middleman/compare/{base}...{head}","merges_url":"https://api.github.com/repos/middleman/middleman/merges","archive_url":"https://api.github.com/repos/middleman/middleman/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/middleman/middleman/downloads","issues_url":"https://api.github.com/repos/middleman/middleman/issues{/number}","pulls_url":"https://api.github.com/repos/middleman/middleman/pulls{/number}","milestones_url":"https://api.github.com/repos/middleman/middleman/milestones{/number}","notifications_url":"https://api.github.com/repos/middleman/middleman/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/middleman/middleman/labels{/name}","releases_url":"https://api.github.com/repos/middleman/middleman/releases{/id}","created_at":"2009-07-27T21:41:11Z","updated_at":"2014-06-28T13:32:58Z","pushed_at":"2014-06-28T22:07:53Z","git_url":"git://github.com/middleman/middleman.git","ssh_url":"git@github.com:middleman/middleman.git","clone_url":"https://github.com/middleman/middleman.git","svn_url":"https://github.com/middleman/middleman","homepage":"http://middlemanapp.com","size":43077,"stargazers_count":3271,"watchers_count":3271,"language":"Ruby","has_issues":true,"has_downloads":false,"has_wiki":false,"forks_count":318,"mirror_url":null,"open_issues_count":62,"forks":318,"open_issues":62,"watchers":3271,"default_branch":"v3-stable"}},"base":{"label":"middleman:master","ref":"master","sha":"c4dac7803f69e5ebdf2f4c090c9f5aadf96fc5f3","user":{"login":"middleman","id":1280820,"avatar_url":"https://avatars.githubusercontent.com/u/1280820?","gravatar_id":"2fd3a9ecba62fd547bb1a58dea245a9c","url":"https://api.github.com/users/middleman","html_url":"https://github.com/middleman","followers_url":"https://api.github.com/users/middleman/followers","following_url":"https://api.github.com/users/middleman/following{/other_user}","gists_url":"https://api.github.com/users/middleman/gists{/gist_id}","starred_url":"https://api.github.com/users/middleman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/middleman/subscriptions","organizations_url":"https://api.github.com/users/middleman/orgs","repos_url":"https://api.github.com/users/middleman/repos","events_url":"https://api.github.com/users/middleman/events{/privacy}","received_events_url":"https://api.github.com/users/middleman/received_events","type":"Organization","site_admin":false},"repo":{"id":261943,"name":"middleman","full_name":"middleman/middleman","owner":{"login":"middleman","id":1280820,"avatar_url":"https://avatars.githubusercontent.com/u/1280820?","gravatar_id":"2fd3a9ecba62fd547bb1a58dea245a9c","url":"https://api.github.com/users/middleman","html_url":"https://github.com/middleman","followers_url":"https://api.github.com/users/middleman/followers","following_url":"https://api.github.com/users/middleman/following{/other_user}","gists_url":"https://api.github.com/users/middleman/gists{/gist_id}","starred_url":"https://api.github.com/users/middleman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/middleman/subscriptions","organizations_url":"https://api.github.com/users/middleman/orgs","repos_url":"https://api.github.com/users/middleman/repos","events_url":"https://api.github.com/users/middleman/events{/privacy}","received_events_url":"https://api.github.com/users/middleman/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/middleman/middleman","description":"Hand-crafted frontend development","fork":false,"url":"https://api.github.com/repos/middleman/middleman","forks_url":"https://api.github.com/repos/middleman/middleman/forks","keys_url":"https://api.github.com/repos/middleman/middleman/keys{/key_id}","collaborators_url":"https://api.github.com/repos/middleman/middleman/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/middleman/middleman/teams","hooks_url":"https://api.github.com/repos/middleman/middleman/hooks","issue_events_url":"https://api.github.com/repos/middleman/middleman/issues/events{/number}","events_url":"https://api.github.com/repos/middleman/middleman/events","assignees_url":"https://api.github.com/repos/middleman/middleman/assignees{/user}","branches_url":"https://api.github.com/repos/middleman/middleman/branches{/branch}","tags_url":"https://api.github.com/repos/middleman/middleman/tags","blobs_url":"https://api.github.com/repos/middleman/middleman/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/middleman/middleman/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/middleman/middleman/git/refs{/sha}","trees_url":"https://api.github.com/repos/middleman/middleman/git/trees{/sha}","statuses_url":"https://api.github.com/repos/middleman/middleman/statuses/{sha}","languages_url":"https://api.github.com/repos/middleman/middleman/languages","stargazers_url":"https://api.github.com/repos/middleman/middleman/stargazers","contributors_url":"https://api.github.com/repos/middleman/middleman/contributors","subscribers_url":"https://api.github.com/repos/middleman/middleman/subscribers","subscription_url":"https://api.github.com/repos/middleman/middleman/subscription","commits_url":"https://api.github.com/repos/middleman/middleman/commits{/sha}","git_commits_url":"https://api.github.com/repos/middleman/middleman/git/commits{/sha}","comments_url":"https://api.github.com/repos/middleman/middleman/comments{/number}","issue_comment_url":"https://api.github.com/repos/middleman/middleman/issues/comments/{number}","contents_url":"https://api.github.com/repos/middleman/middleman/contents/{+path}","compare_url":"https://api.github.com/repos/middleman/middleman/compare/{base}...{head}","merges_url":"https://api.github.com/repos/middleman/middleman/merges","archive_url":"https://api.github.com/repos/middleman/middleman/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/middleman/middleman/downloads","issues_url":"https://api.github.com/repos/middleman/middleman/issues{/number}","pulls_url":"https://api.github.com/repos/middleman/middleman/pulls{/number}","milestones_url":"https://api.github.com/repos/middleman/middleman/milestones{/number}","notifications_url":"https://api.github.com/repos/middleman/middleman/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/middleman/middleman/labels{/name}","releases_url":"https://api.github.com/repos/middleman/middleman/releases{/id}","created_at":"2009-07-27T21:41:11Z","updated_at":"2014-06-28T13:32:58Z","pushed_at":"2014-06-28T22:07:53Z","git_url":"git://github.com/middleman/middleman.git","ssh_url":"git@github.com:middleman/middleman.git","clone_url":"https://github.com/middleman/middleman.git","svn_url":"https://github.com/middleman/middleman","homepage":"http://middlemanapp.com","size":43077,"stargazers_count":3271,"watchers_count":3271,"language":"Ruby","has_issues":true,"has_downloads":false,"has_wiki":false,"forks_count":318,"mirror_url":null,"open_issues_count":62,"forks":318,"open_issues":62,"watchers":3271,"default_branch":"v3-stable"}},"_links":{"self":{"href":"https://api.github.com/repos/middleman/middleman/pulls/1307"},"html":{"href":"https://github.com/middleman/middleman/pull/1307"},"issue":{"href":"https://api.github.com/repos/middleman/middleman/issues/1307"},"comments":{"href":"https://api.github.com/repos/middleman/middleman/issues/1307/comments"},"review_comments":{"href":"https://api.github.com/repos/middleman/middleman/pulls/1307/comments"},"review_comment":{"href":"https://api.github.com/repos/middleman/middleman/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/middleman/middleman/pulls/1307/commits"},"statuses":{"href":"https://api.github.com/repos/middleman/middleman/statuses/3af92560d579500d4eb69128845eef2bed52b2ad"}},"merged":false,"mergeable":null,"mergeable_state":"unknown","merged_by":null,"comments":0,"review_comments":0,"commits":1,"additions":349,"deletions":1,"changed_files":10}}