{"action":"created","comment":{"url":"https://api.github.com/repos/wikimedia/wikipedia-ios/pulls/comments/38569227","id":38569227,"diff_hunk":"@@ -6,12 +6,15 @@\n \n #import \"NSAttributedString+WMFModify.h\"\n #import \"UIImageView+MWKImage.h\"\n+#import \"NSAttributedString+WMFHTMLForSite.h\"\n+#import \"UIFont+WMFStyle.h\"\n #import \"UIButton+WMFButton.h\"\n #import \"WMFSaveButtonController.h\"\n #import \"SessionSingleton.h\"\n+#import \"NSParagraphStyle+WMFParagraphStyles.h\"\n \n-static CGFloat const WMFTextPadding = 8.0;\n-static CGFloat const WMFImageHeight = 160;\n+CGFloat const WMFArticlePreviewCellTextPadding = 8.0;","path":"Wikipedia/UI-V5/WMFArticlePreviewCell.m","position":13,"original_position":13,"commit_id":"1b8ca785584dc260b8fe1a5d0e3aa741d61570ac","original_commit_id":"e2fdd705fab62b176e5e4450d35cb81c1eb1f5c0","user":{"login":"coreyfloyd","id":64771,"avatar_url":"https://avatars.githubusercontent.com/u/64771?v=3","gravatar_id":"","url":"https://api.github.com/users/coreyfloyd","html_url":"https://github.com/coreyfloyd","followers_url":"https://api.github.com/users/coreyfloyd/followers","following_url":"https://api.github.com/users/coreyfloyd/following{/other_user}","gists_url":"https://api.github.com/users/coreyfloyd/gists{/gist_id}","starred_url":"https://api.github.com/users/coreyfloyd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/coreyfloyd/subscriptions","organizations_url":"https://api.github.com/users/coreyfloyd/orgs","repos_url":"https://api.github.com/users/coreyfloyd/repos","events_url":"https://api.github.com/users/coreyfloyd/events{/privacy}","received_events_url":"https://api.github.com/users/coreyfloyd/received_events","type":"User","site_admin":false},"body":"Do you have a reference to demonstrate why removing `static` from file scoped constants is the preferred pattern? \r\n\r\nI ask because this goes against our style guide and we should update it if there is a technical reason to do this: https://www.mediawiki.org/wiki/Wikimedia_Apps/Team/iOS/ObjectiveCStyleGuide#Constants","created_at":"2015-09-02T18:47:18Z","updated_at":"2015-09-02T18:47:18Z","html_url":"https://github.com/wikimedia/wikipedia-ios/pull/98#discussion_r38569227","pull_request_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/pulls/98","_links":{"self":{"href":"https://api.github.com/repos/wikimedia/wikipedia-ios/pulls/comments/38569227"},"html":{"href":"https://github.com/wikimedia/wikipedia-ios/pull/98#discussion_r38569227"},"pull_request":{"href":"https://api.github.com/repos/wikimedia/wikipedia-ios/pulls/98"}}},"pull_request":{"url":"https://api.github.com/repos/wikimedia/wikipedia-ios/pulls/98","id":43641033,"html_url":"https://github.com/wikimedia/wikipedia-ios/pull/98","diff_url":"https://github.com/wikimedia/wikipedia-ios/pull/98.diff","patch_url":"https://github.com/wikimedia/wikipedia-ios/pull/98.patch","issue_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/issues/98","number":98,"state":"open","locked":false,"title":"Add extracts to related article feed items","user":{"login":"bgerstle","id":444217,"avatar_url":"https://avatars.githubusercontent.com/u/444217?v=3","gravatar_id":"","url":"https://api.github.com/users/bgerstle","html_url":"https://github.com/bgerstle","followers_url":"https://api.github.com/users/bgerstle/followers","following_url":"https://api.github.com/users/bgerstle/following{/other_user}","gists_url":"https://api.github.com/users/bgerstle/gists{/gist_id}","starred_url":"https://api.github.com/users/bgerstle/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bgerstle/subscriptions","organizations_url":"https://api.github.com/users/bgerstle/orgs","repos_url":"https://api.github.com/users/bgerstle/repos","events_url":"https://api.github.com/users/bgerstle/events{/privacy}","received_events_url":"https://api.github.com/users/bgerstle/received_events","type":"User","site_admin":false},"body":"Phab: [T110578](https://phabricator.wikimedia.org/T110578)\r\n\r\n- [x] fetch 4 lines of text\r\n- [x] prevent TextExtracts ellipsis from showing up (by fetching 4.5 lines of text)\r\n\r\n#### Review amendments\r\n- [x] 1b8ca78 Move image-less stylesheet factory method into a category on the stylesheet class\r\n\r\n---\r\n\r\n## Approach\r\nAdd `extracts` as part of the related search API call, which returns a \"subset of HTML\", allowing us to show an attributed string in the preview cell.  When fetching related titles, `WMFRelatedSectionController` calculates the number of characters to fetch based on the maximum width of preview cells, approximate chars per line, and number of lines—adding in an extra half a line to force overflow and UILabel truncation.  See `-[WMFRelatedSectionController numberOfCharactersToFetch]` for details.\r\n\r\n## Easter eggs\r\nFix some autolayout contraints that weren't satisfiable because we set `collectionView.estimatedItemSize = 150` even though the preview cell's image height was `160` :tired_face: \r\n\r\n### Networking architecture preview?!\r\nInstead of copy/pasting/subclassing the `MWKSearchResponseSerializer`, I made a more dynamic version of it which can serialize any `MTLModel` subclass which is JSON serializable.  This provides a working proof of concept for how we might build the foundation of our fetching hierarchy.  Check out `WMFMantleJSONResponseSerializer` for details.\r\n\r\n## Known issues\r\nThere are some cases where paragraphs are needlessly truncated.  After playing with this over the weekend, I've determined it's something weird with the attributed string returned by DTCoreText, since using the built-in `NSHTMLDocumentType` to generate the attributed string produces correct-looking output.  I'm going to file a bug to investigate this further.\r\n\r\n---\r\n\r\n## Screenshots\r\n\r\n![image](https://cloud.githubusercontent.com/assets/444217/9550377/e021e32c-4d78-11e5-9a72-dc6270c582b4.png)","created_at":"2015-08-28T15:36:51Z","updated_at":"2015-09-02T18:47:18Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5e60eea4b7525fb008b1892fb4acb3d01694cdef","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/pulls/98/commits","review_comments_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/pulls/98/comments","review_comment_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/pulls/comments{/number}","comments_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/issues/98/comments","statuses_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/statuses/1b8ca785584dc260b8fe1a5d0e3aa741d61570ac","head":{"label":"wikimedia:feature/T110578/extracts-in-related-cells","ref":"feature/T110578/extracts-in-related-cells","sha":"1b8ca785584dc260b8fe1a5d0e3aa741d61570ac","user":{"login":"wikimedia","id":56668,"avatar_url":"https://avatars.githubusercontent.com/u/56668?v=3","gravatar_id":"","url":"https://api.github.com/users/wikimedia","html_url":"https://github.com/wikimedia","followers_url":"https://api.github.com/users/wikimedia/followers","following_url":"https://api.github.com/users/wikimedia/following{/other_user}","gists_url":"https://api.github.com/users/wikimedia/gists{/gist_id}","starred_url":"https://api.github.com/users/wikimedia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wikimedia/subscriptions","organizations_url":"https://api.github.com/users/wikimedia/orgs","repos_url":"https://api.github.com/users/wikimedia/repos","events_url":"https://api.github.com/users/wikimedia/events{/privacy}","received_events_url":"https://api.github.com/users/wikimedia/received_events","type":"Organization","site_admin":false},"repo":{"id":13863130,"name":"wikipedia-ios","full_name":"wikimedia/wikipedia-ios","owner":{"login":"wikimedia","id":56668,"avatar_url":"https://avatars.githubusercontent.com/u/56668?v=3","gravatar_id":"","url":"https://api.github.com/users/wikimedia","html_url":"https://github.com/wikimedia","followers_url":"https://api.github.com/users/wikimedia/followers","following_url":"https://api.github.com/users/wikimedia/following{/other_user}","gists_url":"https://api.github.com/users/wikimedia/gists{/gist_id}","starred_url":"https://api.github.com/users/wikimedia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wikimedia/subscriptions","organizations_url":"https://api.github.com/users/wikimedia/orgs","repos_url":"https://api.github.com/users/wikimedia/repos","events_url":"https://api.github.com/users/wikimedia/events{/privacy}","received_events_url":"https://api.github.com/users/wikimedia/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/wikimedia/wikipedia-ios","description":"The official Wikipedia iOS client.","fork":false,"url":"https://api.github.com/repos/wikimedia/wikipedia-ios","forks_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/forks","keys_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/keys{/key_id}","collaborators_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/teams","hooks_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/hooks","issue_events_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/issues/events{/number}","events_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/events","assignees_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/assignees{/user}","branches_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/branches{/branch}","tags_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/tags","blobs_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/git/refs{/sha}","trees_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/git/trees{/sha}","statuses_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/statuses/{sha}","languages_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/languages","stargazers_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/stargazers","contributors_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/contributors","subscribers_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/subscribers","subscription_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/subscription","commits_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/commits{/sha}","git_commits_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/git/commits{/sha}","comments_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/comments{/number}","issue_comment_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/issues/comments{/number}","contents_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/contents/{+path}","compare_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/compare/{base}...{head}","merges_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/merges","archive_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/downloads","issues_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/issues{/number}","pulls_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/pulls{/number}","milestones_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/milestones{/number}","notifications_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/labels{/name}","releases_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/releases{/id}","created_at":"2013-10-25T14:36:56Z","updated_at":"2015-09-02T13:51:26Z","pushed_at":"2015-09-02T18:31:25Z","git_url":"git://github.com/wikimedia/wikipedia-ios.git","ssh_url":"git@github.com:wikimedia/wikipedia-ios.git","clone_url":"https://github.com/wikimedia/wikipedia-ios.git","svn_url":"https://github.com/wikimedia/wikipedia-ios","homepage":"https://www.mediawiki.org/wiki/Wikimedia_Apps","size":77927,"stargazers_count":377,"watchers_count":377,"language":"Objective-C","has_issues":false,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":98,"mirror_url":null,"open_issues_count":3,"forks":98,"open_issues":3,"watchers":377,"default_branch":"master"}},"base":{"label":"wikimedia:master","ref":"master","sha":"e6282d9b917b2886f00da799bd0322cf90e0745a","user":{"login":"wikimedia","id":56668,"avatar_url":"https://avatars.githubusercontent.com/u/56668?v=3","gravatar_id":"","url":"https://api.github.com/users/wikimedia","html_url":"https://github.com/wikimedia","followers_url":"https://api.github.com/users/wikimedia/followers","following_url":"https://api.github.com/users/wikimedia/following{/other_user}","gists_url":"https://api.github.com/users/wikimedia/gists{/gist_id}","starred_url":"https://api.github.com/users/wikimedia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wikimedia/subscriptions","organizations_url":"https://api.github.com/users/wikimedia/orgs","repos_url":"https://api.github.com/users/wikimedia/repos","events_url":"https://api.github.com/users/wikimedia/events{/privacy}","received_events_url":"https://api.github.com/users/wikimedia/received_events","type":"Organization","site_admin":false},"repo":{"id":13863130,"name":"wikipedia-ios","full_name":"wikimedia/wikipedia-ios","owner":{"login":"wikimedia","id":56668,"avatar_url":"https://avatars.githubusercontent.com/u/56668?v=3","gravatar_id":"","url":"https://api.github.com/users/wikimedia","html_url":"https://github.com/wikimedia","followers_url":"https://api.github.com/users/wikimedia/followers","following_url":"https://api.github.com/users/wikimedia/following{/other_user}","gists_url":"https://api.github.com/users/wikimedia/gists{/gist_id}","starred_url":"https://api.github.com/users/wikimedia/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wikimedia/subscriptions","organizations_url":"https://api.github.com/users/wikimedia/orgs","repos_url":"https://api.github.com/users/wikimedia/repos","events_url":"https://api.github.com/users/wikimedia/events{/privacy}","received_events_url":"https://api.github.com/users/wikimedia/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/wikimedia/wikipedia-ios","description":"The official Wikipedia iOS client.","fork":false,"url":"https://api.github.com/repos/wikimedia/wikipedia-ios","forks_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/forks","keys_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/keys{/key_id}","collaborators_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/teams","hooks_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/hooks","issue_events_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/issues/events{/number}","events_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/events","assignees_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/assignees{/user}","branches_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/branches{/branch}","tags_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/tags","blobs_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/git/refs{/sha}","trees_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/git/trees{/sha}","statuses_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/statuses/{sha}","languages_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/languages","stargazers_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/stargazers","contributors_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/contributors","subscribers_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/subscribers","subscription_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/subscription","commits_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/commits{/sha}","git_commits_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/git/commits{/sha}","comments_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/comments{/number}","issue_comment_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/issues/comments{/number}","contents_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/contents/{+path}","compare_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/compare/{base}...{head}","merges_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/merges","archive_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/downloads","issues_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/issues{/number}","pulls_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/pulls{/number}","milestones_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/milestones{/number}","notifications_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/labels{/name}","releases_url":"https://api.github.com/repos/wikimedia/wikipedia-ios/releases{/id}","created_at":"2013-10-25T14:36:56Z","updated_at":"2015-09-02T13:51:26Z","pushed_at":"2015-09-02T18:31:25Z","git_url":"git://github.com/wikimedia/wikipedia-ios.git","ssh_url":"git@github.com:wikimedia/wikipedia-ios.git","clone_url":"https://github.com/wikimedia/wikipedia-ios.git","svn_url":"https://github.com/wikimedia/wikipedia-ios","homepage":"https://www.mediawiki.org/wiki/Wikimedia_Apps","size":77927,"stargazers_count":377,"watchers_count":377,"language":"Objective-C","has_issues":false,"has_downloads":false,"has_wiki":false,"has_pages":false,"forks_count":98,"mirror_url":null,"open_issues_count":3,"forks":98,"open_issues":3,"watchers":377,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/wikimedia/wikipedia-ios/pulls/98"},"html":{"href":"https://github.com/wikimedia/wikipedia-ios/pull/98"},"issue":{"href":"https://api.github.com/repos/wikimedia/wikipedia-ios/issues/98"},"comments":{"href":"https://api.github.com/repos/wikimedia/wikipedia-ios/issues/98/comments"},"review_comments":{"href":"https://api.github.com/repos/wikimedia/wikipedia-ios/pulls/98/comments"},"review_comment":{"href":"https://api.github.com/repos/wikimedia/wikipedia-ios/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/wikimedia/wikipedia-ios/pulls/98/commits"},"statuses":{"href":"https://api.github.com/repos/wikimedia/wikipedia-ios/statuses/1b8ca785584dc260b8fe1a5d0e3aa741d61570ac"}}}}