{"action":"created","issue":{"url":"https://api.github.com/repos/punkave/best-practices/issues/12","repository_url":"https://api.github.com/repos/punkave/best-practices","labels_url":"https://api.github.com/repos/punkave/best-practices/issues/12/labels{/name}","comments_url":"https://api.github.com/repos/punkave/best-practices/issues/12/comments","events_url":"https://api.github.com/repos/punkave/best-practices/issues/12/events","html_url":"https://github.com/punkave/best-practices/issues/12","id":184314925,"number":12,"title":"Improving practices around importing spreadsheet data into apostrophe-pieces based content types","user":{"login":"colpanik","id":1735569,"avatar_url":"https://avatars.githubusercontent.com/u/1735569?v=3","gravatar_id":"","url":"https://api.github.com/users/colpanik","html_url":"https://github.com/colpanik","followers_url":"https://api.github.com/users/colpanik/followers","following_url":"https://api.github.com/users/colpanik/following{/other_user}","gists_url":"https://api.github.com/users/colpanik/gists{/gist_id}","starred_url":"https://api.github.com/users/colpanik/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/colpanik/subscriptions","organizations_url":"https://api.github.com/users/colpanik/orgs","repos_url":"https://api.github.com/users/colpanik/repos","events_url":"https://api.github.com/users/colpanik/events{/privacy}","received_events_url":"https://api.github.com/users/colpanik/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/punkave/best-practices/labels/to%20document","name":"to document","color":"0052cc"},{"url":"https://api.github.com/repos/punkave/best-practices/labels/to%20implement","name":"to implement","color":"d93f0b"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2016-10-20T19:09:27Z","updated_at":"2016-10-20T19:45:14Z","closed_at":null,"body":"@agilbert talked us though some examples of importing spreadsheet data into as `apostrophe-piece` content. We looked at NDRI, CCD and Plat Labs (linked below). All examples used Google Sheets as a content source and we all agreed that this is the most practical approach for sharing and maintaining spreadsheets with clients.\r\n\r\nThe code itself is fairly straightforward, so next steps are to port what's already been written to a simple module that takes project-level configuration for each content type to be made importable.\r\n\r\nConfiguration options would be the Google spreadsheet ID to be imported, module/content type to attach the task to, and maybe which fields to include in the import.\r\n\r\nThis module would be named something like `apostrophe-pieces-google-import` or `apostrophe-pieces-google-sheets`.\r\n\r\nIn `app.js`, configuration might look like this:\r\n\r\n```javascript\r\n  'apostrophe-pieces-google-import': {\r\n    tasks: [\r\n      {\r\n        piecesModuleName: 'apostrophe-places'\r\n        spreadsheetId: 'xxx',\r\n        fields: ['name', 'address', 'hours', 'tags']\r\n      },\r\n      {\r\n        piecesModuleName: 'my-people'\r\n        spreadsheetId: 'yyy',\r\n        fields: ['firstName', 'lastName', 'age', 'sex', 'favoriteColor']      \r\n      }\r\n    ]\r\n  }\r\n```\r\n\r\nAlternatively, we could follow this kind of pattern, where the import for piece-type is a subclass of the `apostrophe-pieces-google-import` module like so:\r\n\r\n```javascript\r\n  'apostophe-places-import': {\r\n    extend: 'apostrophe-pieces-google-import',\r\n    piecesModuleName: 'apostrophe-places'\r\n    spreadsheetId: 'xxx',\r\n    fields: ['name', 'address', 'hours', 'tags']    \r\n  }\r\n```\r\n\r\n#### Other Questions\r\nThere are features that could potentially be added to the pieces UI to give site editors the ability to run the imports on their end, but we didn't reach consensus on whether or not this was practical. In the future, we should create enhancement issues in the apostrophe repo if we decide we want to move forward.\r\n\r\nWe also discussed supporting the ability to export pieces content to a csv file, but I'm not certain how that falls into the big picture here.\r\n\r\n#### Examples\r\n---\r\n*NDRI Example*\r\nhttps://github.com/punkave/ndri/blob/development/lib/modules/nd-publications/index.js\r\n\r\n*CCD Example*\r\nhttps://github.com/punkave/ccd/blob/develop/lib/modules/ccd-places/index.js\r\n\r\n*Platt Labs Example*\r\nhttps://github.com/punkave/plattlabs/blob/master/lib/modules/pl-piece-publication/index.js"},"comment":{"url":"https://api.github.com/repos/punkave/best-practices/issues/comments/255208283","html_url":"https://github.com/punkave/best-practices/issues/12#issuecomment-255208283","issue_url":"https://api.github.com/repos/punkave/best-practices/issues/12","id":255208283,"user":{"login":"boutell","id":32125,"avatar_url":"https://avatars.githubusercontent.com/u/32125?v=3","gravatar_id":"","url":"https://api.github.com/users/boutell","html_url":"https://github.com/boutell","followers_url":"https://api.github.com/users/boutell/followers","following_url":"https://api.github.com/users/boutell/following{/other_user}","gists_url":"https://api.github.com/users/boutell/gists{/gist_id}","starred_url":"https://api.github.com/users/boutell/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/boutell/subscriptions","organizations_url":"https://api.github.com/users/boutell/orgs","repos_url":"https://api.github.com/users/boutell/repos","events_url":"https://api.github.com/users/boutell/events{/privacy}","received_events_url":"https://api.github.com/users/boutell/received_events","type":"User","site_admin":false},"created_at":"2016-10-20T19:45:14Z","updated_at":"2016-10-20T19:45:14Z","body":"Based on experiences in 0.5 and previous, I am tempted to bake CSV import into core, because clients love that feature and because apostrophe-schemas already contains half the implementation. But I'm not married to that idea. In fact, an apostrophe-pieces-csv module might be a better idea, with both import and export features present over time.\r\n\r\nIt would make sense for pieces to have a clean API for registering importers and exporters by file extension so it can just be \"import file / export file\". That much should probably be in the core, which argues for apostrophe-pieces-csv being in the core too (so there's an example that is also the most commonly used)... but as a well-factored, separate module in the core.\r\n\r\napostrophe-pieces-google-sheets would be a good name for the module that provides an analogous feature for google sheets. It's a separate module because the model is so different.\r\n\r\nI think the UI should certainly support it, clients use this stuff. We should come up with a noncrappy progress display this time.\r\n"}}
{"actor":{"display_login":"boutell"}}