{"action":"created","comment":{"url":"https://api.github.com/repos/cfpb/cfgov-refresh/pulls/comments/31361340","id":31361340,"diff_hunk":"@@ -24,51 +24,82 @@ def documents(name, url, **kwargs):\n         yield process_office(post)\n \n \n-def process_office(item):\n+def process_office(post):\n \n-    item['_id'] = item['slug']\n-    custom_fields = item['custom_fields']\n+    post[\"_id\"] = post[\"slug\"]\n+    custom_fields = post[\"custom_fields\"]\n \n     # get intro text & subscribe form data from custom fields\n-    for attr in ['intro_text', 'intro_subscribe_form', 'intro_govdelivery_code', 'related_contact']:\n+    intro = {}\n+    for attr in [\"intro_text\", \"intro_subscribe_form\", \"intro_govdelivery_code\"]:\n         if attr in custom_fields:\n-            item[attr] = custom_fields[attr][0]\n+            new_attr = attr.replace(\"intro_\", \"\")\n+            intro[new_attr] = custom_fields[attr]\n+    if intro:\n+        post[\"intro\"] = intro\n \n     # build top story dict\n     top_story = {}\n-    for attr in ['top_story_head', 'top_story_desc']:\n+    for attr in [\"top_story_head\", \"top_story_desc\"]:\n         if attr in custom_fields:\n-            top_story[attr] = custom_fields[attr][0]\n+            new_attr = attr.replace(\"top_story_\", \"\")\n+            top_story[new_attr] = custom_fields[attr]\n \n     # convert top story links into a proper list\n-    top_story_links = []\n-    for x in xrange(0, 5):\n-        key = 'top_story_links_%s_link' % x\n-        if key in custom_fields:\n-            top_story_links.append(custom_fields[key])\n-\n-    if top_story_links:\n-        top_story['top_story_links'] = top_story_links\n+    if \"top_story_links\" in custom_fields:\n+        top_story[\"links\"] = custom_fields[\"top_story_links\"]\n+    else:\n+        top_story_links = []\n+        for x in xrange(0, 5):\n+            key = \"top_story_links_%s\" % x\n+            if key in custom_fields:\n+                top_story_links.append({\"url\": custom_fields[key][0],\n+                                        \"label\": custom_fields[key][1]})\n+\n+        if top_story_links:\n+            top_story[\"links\"] = top_story_links\n \n     if top_story:\n-        item['top_story'] = top_story\n+        post[\"top_story\"] = top_story\n \n     # create list of office resource dicts\n-    item['resources'] = []\n-    for x in xrange(0, 4):\n-        resource = {}\n-        fields = ['title', 'desc', 'icon', 'link']\n-        for field in fields:\n-            field_name = 'resource_%s_%s' % (str(x), field)\n-            if field_name in custom_fields and custom_fields[field_name][0] != '':\n-                if field == 'link':\n-                    resource[field] = custom_fields[field_name]\n-                else:\n-                    resource[field] = custom_fields[field_name][0]\n-\n-        if resource:\n-            item['resources'].append(resource)\n-\n-    del item['custom_fields']\n-\n-    return item\n+    if \"resources\" in custom_fields:\n+        post[\"resources\"] = custom_fields[\"resources\"]\n+    else:\n+        post[\"resources\"] = []\n+        for x in xrange(0, 4):\n+            resource = {}\n+            fields = [\"title\", \"desc\", \"icon\", \"link\"]\n+            for field in fields:\n+                field_name = \"resource_%s_%s\" % (str(x), field)\n+                if field_name in custom_fields and custom_fields[field_name]:\n+                    if field == \"link\":\n+                        resource[field] = \\\n+                        {\"url\": custom_fields[field_name][0],\n+                         \"label\": custom_fields[field_name][1]}\n+                    else:\n+                        resource[field] = custom_fields[field_name]\n+\n+            if resource:\n+                post[\"resources\"].append(resource)\n+\n+    # add other custom fields\n+    names = [\"og_title\", \"og_image\", \"og_desc\", \"twtr_text\", \"twtr_lang\",\n+             \"twtr_rel\", \"twtr_hash\", \"utm_campaign\", \"utm_term\",\n+             \"utm_content\", \"short_title\"]\n+    for name in names:\n+        if name in custom_fields:\n+            post[name] = custom_fields[name]\n+\n+    for related in [\"related_hero\", \"related_contact\"]:\n+        if related in custom_fields:\n+            if \"str\" in str(type(custom_fields[related])):","path":"_lib/wordpress_office_processor.py","position":130,"original_position":130,"commit_id":"f2b40986d63dee8bb4aaa973a356e544dd0eb0b5","original_commit_id":"f2b40986d63dee8bb4aaa973a356e544dd0eb0b5","user":{"login":"dpford","id":2790776,"avatar_url":"https://avatars.githubusercontent.com/u/2790776?v=3","gravatar_id":"","url":"https://api.github.com/users/dpford","html_url":"https://github.com/dpford","followers_url":"https://api.github.com/users/dpford/followers","following_url":"https://api.github.com/users/dpford/following{/other_user}","gists_url":"https://api.github.com/users/dpford/gists{/gist_id}","starred_url":"https://api.github.com/users/dpford/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dpford/subscriptions","organizations_url":"https://api.github.com/users/dpford/orgs","repos_url":"https://api.github.com/users/dpford/repos","events_url":"https://api.github.com/users/dpford/events{/privacy}","received_events_url":"https://api.github.com/users/dpford/received_events","type":"User","site_admin":false},"body":"Could also be `if type(custom_fields[related]) is str:`","created_at":"2015-05-29T20:23:49Z","updated_at":"2015-05-29T20:23:49Z","html_url":"https://github.com/cfpb/cfgov-refresh/pull/604#discussion_r31361340","pull_request_url":"https://api.github.com/repos/cfpb/cfgov-refresh/pulls/604","_links":{"self":{"href":"https://api.github.com/repos/cfpb/cfgov-refresh/pulls/comments/31361340"},"html":{"href":"https://github.com/cfpb/cfgov-refresh/pull/604#discussion_r31361340"},"pull_request":{"href":"https://api.github.com/repos/cfpb/cfgov-refresh/pulls/604"}}},"pull_request":{"url":"https://api.github.com/repos/cfpb/cfgov-refresh/pulls/604","id":36522980,"html_url":"https://github.com/cfpb/cfgov-refresh/pull/604","diff_url":"https://github.com/cfpb/cfgov-refresh/pull/604.diff","patch_url":"https://github.com/cfpb/cfgov-refresh/pull/604.patch","issue_url":"https://api.github.com/repos/cfpb/cfgov-refresh/issues/604","number":604,"state":"open","locked":false,"title":"Refactor sheer processors and templates for cms-toolkit/wp-flapjack upgrade","user":{"login":"kurtw","id":1412978,"avatar_url":"https://avatars.githubusercontent.com/u/1412978?v=3","gravatar_id":"","url":"https://api.github.com/users/kurtw","html_url":"https://github.com/kurtw","followers_url":"https://api.github.com/users/kurtw/followers","following_url":"https://api.github.com/users/kurtw/following{/other_user}","gists_url":"https://api.github.com/users/kurtw/gists{/gist_id}","starred_url":"https://api.github.com/users/kurtw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kurtw/subscriptions","organizations_url":"https://api.github.com/users/kurtw/orgs","repos_url":"https://api.github.com/users/kurtw/repos","events_url":"https://api.github.com/users/kurtw/events{/privacy}","received_events_url":"https://api.github.com/users/kurtw/received_events","type":"User","site_admin":false},"body":"This is mostly a refactor with some formatting kicked in as well. New [cms-toolkit](https://github.com/cfpb/cms-toolkit/pull/60) and [wp-flapjack](https://github.cfpb.gov/flapjack/wp-flapjack/pull/49) code is waiting to be merged. Once it is merged, sheer processors will have to accommodate the new format the meta-data is saved in, while maintaining the ability of indexing the older format. **Note**: Event has not been modified.\r\n\r\n### Additions\r\n- Broke out some types that were handled in a single processor into multiple\r\n\r\n### Changes\r\n- Name of Initiatives is now Sub-pages so the folders and files reflect that as well as the code\r\n\r\n### Testing\r\nComplete testing means indexing older content and also indexing newer content. Newer content should be created locally by pulling down the two repo's linked above, ([and this one](https://github.com/cfpb/wp-json-api/pull/5)) and creating posts on your Unitybox's Wordpress, then indexing from that. \r\n\r\nAfter properly indexing, you could also serve the site and double check the content is there.\r\n\r\n### Review\r\n@dpford\r\n\r\n ","created_at":"2015-05-29T16:38:41Z","updated_at":"2015-05-29T20:23:49Z","closed_at":null,"merged_at":null,"merge_commit_sha":"73f22fd232b01091880d2f01df0b92d854b2ad38","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/cfpb/cfgov-refresh/pulls/604/commits","review_comments_url":"https://api.github.com/repos/cfpb/cfgov-refresh/pulls/604/comments","review_comment_url":"https://api.github.com/repos/cfpb/cfgov-refresh/pulls/comments{/number}","comments_url":"https://api.github.com/repos/cfpb/cfgov-refresh/issues/604/comments","statuses_url":"https://api.github.com/repos/cfpb/cfgov-refresh/statuses/f2b40986d63dee8bb4aaa973a356e544dd0eb0b5","head":{"label":"kurtw:DF-1850","ref":"DF-1850","sha":"f2b40986d63dee8bb4aaa973a356e544dd0eb0b5","user":{"login":"kurtw","id":1412978,"avatar_url":"https://avatars.githubusercontent.com/u/1412978?v=3","gravatar_id":"","url":"https://api.github.com/users/kurtw","html_url":"https://github.com/kurtw","followers_url":"https://api.github.com/users/kurtw/followers","following_url":"https://api.github.com/users/kurtw/following{/other_user}","gists_url":"https://api.github.com/users/kurtw/gists{/gist_id}","starred_url":"https://api.github.com/users/kurtw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kurtw/subscriptions","organizations_url":"https://api.github.com/users/kurtw/orgs","repos_url":"https://api.github.com/users/kurtw/repos","events_url":"https://api.github.com/users/kurtw/events{/privacy}","received_events_url":"https://api.github.com/users/kurtw/received_events","type":"User","site_admin":false},"repo":{"id":26283151,"name":"cfgov-refresh","full_name":"kurtw/cfgov-refresh","owner":{"login":"kurtw","id":1412978,"avatar_url":"https://avatars.githubusercontent.com/u/1412978?v=3","gravatar_id":"","url":"https://api.github.com/users/kurtw","html_url":"https://github.com/kurtw","followers_url":"https://api.github.com/users/kurtw/followers","following_url":"https://api.github.com/users/kurtw/following{/other_user}","gists_url":"https://api.github.com/users/kurtw/gists{/gist_id}","starred_url":"https://api.github.com/users/kurtw/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kurtw/subscriptions","organizations_url":"https://api.github.com/users/kurtw/orgs","repos_url":"https://api.github.com/users/kurtw/repos","events_url":"https://api.github.com/users/kurtw/events{/privacy}","received_events_url":"https://api.github.com/users/kurtw/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/kurtw/cfgov-refresh","description":"","fork":true,"url":"https://api.github.com/repos/kurtw/cfgov-refresh","forks_url":"https://api.github.com/repos/kurtw/cfgov-refresh/forks","keys_url":"https://api.github.com/repos/kurtw/cfgov-refresh/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kurtw/cfgov-refresh/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kurtw/cfgov-refresh/teams","hooks_url":"https://api.github.com/repos/kurtw/cfgov-refresh/hooks","issue_events_url":"https://api.github.com/repos/kurtw/cfgov-refresh/issues/events{/number}","events_url":"https://api.github.com/repos/kurtw/cfgov-refresh/events","assignees_url":"https://api.github.com/repos/kurtw/cfgov-refresh/assignees{/user}","branches_url":"https://api.github.com/repos/kurtw/cfgov-refresh/branches{/branch}","tags_url":"https://api.github.com/repos/kurtw/cfgov-refresh/tags","blobs_url":"https://api.github.com/repos/kurtw/cfgov-refresh/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kurtw/cfgov-refresh/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kurtw/cfgov-refresh/git/refs{/sha}","trees_url":"https://api.github.com/repos/kurtw/cfgov-refresh/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kurtw/cfgov-refresh/statuses/{sha}","languages_url":"https://api.github.com/repos/kurtw/cfgov-refresh/languages","stargazers_url":"https://api.github.com/repos/kurtw/cfgov-refresh/stargazers","contributors_url":"https://api.github.com/repos/kurtw/cfgov-refresh/contributors","subscribers_url":"https://api.github.com/repos/kurtw/cfgov-refresh/subscribers","subscription_url":"https://api.github.com/repos/kurtw/cfgov-refresh/subscription","commits_url":"https://api.github.com/repos/kurtw/cfgov-refresh/commits{/sha}","git_commits_url":"https://api.github.com/repos/kurtw/cfgov-refresh/git/commits{/sha}","comments_url":"https://api.github.com/repos/kurtw/cfgov-refresh/comments{/number}","issue_comment_url":"https://api.github.com/repos/kurtw/cfgov-refresh/issues/comments{/number}","contents_url":"https://api.github.com/repos/kurtw/cfgov-refresh/contents/{+path}","compare_url":"https://api.github.com/repos/kurtw/cfgov-refresh/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kurtw/cfgov-refresh/merges","archive_url":"https://api.github.com/repos/kurtw/cfgov-refresh/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kurtw/cfgov-refresh/downloads","issues_url":"https://api.github.com/repos/kurtw/cfgov-refresh/issues{/number}","pulls_url":"https://api.github.com/repos/kurtw/cfgov-refresh/pulls{/number}","milestones_url":"https://api.github.com/repos/kurtw/cfgov-refresh/milestones{/number}","notifications_url":"https://api.github.com/repos/kurtw/cfgov-refresh/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kurtw/cfgov-refresh/labels{/name}","releases_url":"https://api.github.com/repos/kurtw/cfgov-refresh/releases{/id}","created_at":"2014-11-06T18:13:46Z","updated_at":"2015-03-27T19:56:38Z","pushed_at":"2015-05-29T19:45:48Z","git_url":"git://github.com/kurtw/cfgov-refresh.git","ssh_url":"git@github.com:kurtw/cfgov-refresh.git","clone_url":"https://github.com/kurtw/cfgov-refresh.git","svn_url":"https://github.com/kurtw/cfgov-refresh","homepage":"http://cfpb.github.io/cfgov-refresh/","size":18137,"stargazers_count":0,"watchers_count":0,"language":"CSS","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":1,"forks":0,"open_issues":1,"watchers":0,"default_branch":"gh-pages"}},"base":{"label":"cfpb:flapjack","ref":"flapjack","sha":"19c72d25048491eb98a4fcee0fdae70829de4ef8","user":{"login":"cfpb","id":1071563,"avatar_url":"https://avatars.githubusercontent.com/u/1071563?v=3","gravatar_id":"","url":"https://api.github.com/users/cfpb","html_url":"https://github.com/cfpb","followers_url":"https://api.github.com/users/cfpb/followers","following_url":"https://api.github.com/users/cfpb/following{/other_user}","gists_url":"https://api.github.com/users/cfpb/gists{/gist_id}","starred_url":"https://api.github.com/users/cfpb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cfpb/subscriptions","organizations_url":"https://api.github.com/users/cfpb/orgs","repos_url":"https://api.github.com/users/cfpb/repos","events_url":"https://api.github.com/users/cfpb/events{/privacy}","received_events_url":"https://api.github.com/users/cfpb/received_events","type":"Organization","site_admin":false},"repo":{"id":18852566,"name":"cfgov-refresh","full_name":"cfpb/cfgov-refresh","owner":{"login":"cfpb","id":1071563,"avatar_url":"https://avatars.githubusercontent.com/u/1071563?v=3","gravatar_id":"","url":"https://api.github.com/users/cfpb","html_url":"https://github.com/cfpb","followers_url":"https://api.github.com/users/cfpb/followers","following_url":"https://api.github.com/users/cfpb/following{/other_user}","gists_url":"https://api.github.com/users/cfpb/gists{/gist_id}","starred_url":"https://api.github.com/users/cfpb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cfpb/subscriptions","organizations_url":"https://api.github.com/users/cfpb/orgs","repos_url":"https://api.github.com/users/cfpb/repos","events_url":"https://api.github.com/users/cfpb/events{/privacy}","received_events_url":"https://api.github.com/users/cfpb/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/cfpb/cfgov-refresh","description":"In-progress redesign of the consumerfinance.gov website.","fork":false,"url":"https://api.github.com/repos/cfpb/cfgov-refresh","forks_url":"https://api.github.com/repos/cfpb/cfgov-refresh/forks","keys_url":"https://api.github.com/repos/cfpb/cfgov-refresh/keys{/key_id}","collaborators_url":"https://api.github.com/repos/cfpb/cfgov-refresh/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/cfpb/cfgov-refresh/teams","hooks_url":"https://api.github.com/repos/cfpb/cfgov-refresh/hooks","issue_events_url":"https://api.github.com/repos/cfpb/cfgov-refresh/issues/events{/number}","events_url":"https://api.github.com/repos/cfpb/cfgov-refresh/events","assignees_url":"https://api.github.com/repos/cfpb/cfgov-refresh/assignees{/user}","branches_url":"https://api.github.com/repos/cfpb/cfgov-refresh/branches{/branch}","tags_url":"https://api.github.com/repos/cfpb/cfgov-refresh/tags","blobs_url":"https://api.github.com/repos/cfpb/cfgov-refresh/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/cfpb/cfgov-refresh/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/cfpb/cfgov-refresh/git/refs{/sha}","trees_url":"https://api.github.com/repos/cfpb/cfgov-refresh/git/trees{/sha}","statuses_url":"https://api.github.com/repos/cfpb/cfgov-refresh/statuses/{sha}","languages_url":"https://api.github.com/repos/cfpb/cfgov-refresh/languages","stargazers_url":"https://api.github.com/repos/cfpb/cfgov-refresh/stargazers","contributors_url":"https://api.github.com/repos/cfpb/cfgov-refresh/contributors","subscribers_url":"https://api.github.com/repos/cfpb/cfgov-refresh/subscribers","subscription_url":"https://api.github.com/repos/cfpb/cfgov-refresh/subscription","commits_url":"https://api.github.com/repos/cfpb/cfgov-refresh/commits{/sha}","git_commits_url":"https://api.github.com/repos/cfpb/cfgov-refresh/git/commits{/sha}","comments_url":"https://api.github.com/repos/cfpb/cfgov-refresh/comments{/number}","issue_comment_url":"https://api.github.com/repos/cfpb/cfgov-refresh/issues/comments{/number}","contents_url":"https://api.github.com/repos/cfpb/cfgov-refresh/contents/{+path}","compare_url":"https://api.github.com/repos/cfpb/cfgov-refresh/compare/{base}...{head}","merges_url":"https://api.github.com/repos/cfpb/cfgov-refresh/merges","archive_url":"https://api.github.com/repos/cfpb/cfgov-refresh/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/cfpb/cfgov-refresh/downloads","issues_url":"https://api.github.com/repos/cfpb/cfgov-refresh/issues{/number}","pulls_url":"https://api.github.com/repos/cfpb/cfgov-refresh/pulls{/number}","milestones_url":"https://api.github.com/repos/cfpb/cfgov-refresh/milestones{/number}","notifications_url":"https://api.github.com/repos/cfpb/cfgov-refresh/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/cfpb/cfgov-refresh/labels{/name}","releases_url":"https://api.github.com/repos/cfpb/cfgov-refresh/releases{/id}","created_at":"2014-04-16T19:22:03Z","updated_at":"2015-05-22T16:51:06Z","pushed_at":"2015-05-29T19:53:50Z","git_url":"git://github.com/cfpb/cfgov-refresh.git","ssh_url":"git@github.com:cfpb/cfgov-refresh.git","clone_url":"https://github.com/cfpb/cfgov-refresh.git","svn_url":"https://github.com/cfpb/cfgov-refresh","homepage":"","size":94401,"stargazers_count":8,"watchers_count":8,"language":"CSS","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":14,"mirror_url":null,"open_issues_count":81,"forks":14,"open_issues":81,"watchers":8,"default_branch":"flapjack"}},"_links":{"self":{"href":"https://api.github.com/repos/cfpb/cfgov-refresh/pulls/604"},"html":{"href":"https://github.com/cfpb/cfgov-refresh/pull/604"},"issue":{"href":"https://api.github.com/repos/cfpb/cfgov-refresh/issues/604"},"comments":{"href":"https://api.github.com/repos/cfpb/cfgov-refresh/issues/604/comments"},"review_comments":{"href":"https://api.github.com/repos/cfpb/cfgov-refresh/pulls/604/comments"},"review_comment":{"href":"https://api.github.com/repos/cfpb/cfgov-refresh/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/cfpb/cfgov-refresh/pulls/604/commits"},"statuses":{"href":"https://api.github.com/repos/cfpb/cfgov-refresh/statuses/f2b40986d63dee8bb4aaa973a356e544dd0eb0b5"}}}}