{"action":"created","issue":{"url":"https://api.github.com/repos/hapijs/university/issues/136","labels_url":"https://api.github.com/repos/hapijs/university/issues/136/labels{/name}","comments_url":"https://api.github.com/repos/hapijs/university/issues/136/comments","events_url":"https://api.github.com/repos/hapijs/university/issues/136/events","html_url":"https://github.com/hapijs/university/issues/136","id":79631788,"number":136,"title":" Glue and HTML views","user":{"login":"zoe-1","id":1852507,"avatar_url":"https://avatars.githubusercontent.com/u/1852507?v=3","gravatar_id":"","url":"https://api.github.com/users/zoe-1","html_url":"https://github.com/zoe-1","followers_url":"https://api.github.com/users/zoe-1/followers","following_url":"https://api.github.com/users/zoe-1/following{/other_user}","gists_url":"https://api.github.com/users/zoe-1/gists{/gist_id}","starred_url":"https://api.github.com/users/zoe-1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zoe-1/subscriptions","organizations_url":"https://api.github.com/users/zoe-1/orgs","repos_url":"https://api.github.com/users/zoe-1/repos","events_url":"https://api.github.com/users/zoe-1/events{/privacy}","received_events_url":"https://api.github.com/users/zoe-1/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/hapijs/university/labels/assignment","name":"assignment","color":"5319e7"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/hapijs/university/milestones/5","html_url":"https://github.com/hapijs/university/milestones/0.0.5","labels_url":"https://api.github.com/repos/hapijs/university/milestones/5/labels","id":1126522,"number":5,"title":"0.0.5","description":null,"creator":{"login":"zoe-1","id":1852507,"avatar_url":"https://avatars.githubusercontent.com/u/1852507?v=3","gravatar_id":"","url":"https://api.github.com/users/zoe-1","html_url":"https://github.com/zoe-1","followers_url":"https://api.github.com/users/zoe-1/followers","following_url":"https://api.github.com/users/zoe-1/following{/other_user}","gists_url":"https://api.github.com/users/zoe-1/gists{/gist_id}","starred_url":"https://api.github.com/users/zoe-1/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zoe-1/subscriptions","organizations_url":"https://api.github.com/users/zoe-1/orgs","repos_url":"https://api.github.com/users/zoe-1/repos","events_url":"https://api.github.com/users/zoe-1/events{/privacy}","received_events_url":"https://api.github.com/users/zoe-1/received_events","type":"User","site_admin":false},"open_issues":1,"closed_issues":0,"state":"open","created_at":"2015-05-22T21:31:53Z","updated_at":"2015-05-22T22:15:42Z","due_on":null,"closed_at":null},"comments":6,"created_at":"2015-05-22T22:15:42Z","updated_at":"2015-05-24T17:08:35Z","closed_at":null,"body":"#### We transitioned to hapijs university.\r\n\r\nFor details about this change see: <br/>\r\n* New [README](https://github.com/hapijs/university) for explanation of changes.\r\n* [This Discussion] (https://github.com/hapijs/university/issues/132). To see current thoughts about project direction.\r\n* And this [Documentation](https://github.com/hapijs/university/issues/133)\r\n\r\nLet's keep our project going! This is community learning which means much of the learning will be \r\nhorizontal and not just vertical! Make your contribution, ask questions, give advice (review others code) , share your thoughts about our projects direction and let's push each other to keep growing :-) \r\n\r\n## The Assignment\r\n\r\n*  Refactor the application to use the hapijs server composer  [hapijs / glue](https://github.com/hapijs/glue).  <br/>Glue should be used to load \"version\" and \"private\" plugins.\r\nHere is a helpful resource from the Glue project: [Sample Manifest JSON object](https://github.com/hapijs/glue/blob/master/lib/index.js) . \r\n\r\n*  Create a plugin called \"home\":\r\n   * This plugin should contain one endpoint called \"home\".\r\n   * Configure the plugin to use handlebars template rendering engine to render html templates.\r\n   * Configure this plugin to serve html view files and make the home endpoint render an html page/template named home.\r\n   *  Configure the home plugin to find view files in a directory named \"views\" located in\r\n   the root path of the application. For now, just make html pages for view files (no .hbs files).\r\n * The view directory should contain one html template named home.html. <br/>\r\n    When viewed in a browser, the home.html template should display the path to this view file from the root of our project. \r\n*  In the end, the application should have thee endpoints. One called: \"home\", \r\n   the other called \"version\", and one called \"private\". Each point is located in it's own plugin \r\n   which glue composes when the server starts up. \r\n*  Ensure 100% test coverage.\r\n   Note, testing if a plugin loads is not practical with Glue. \r\n   If a plugin described in the manifest file does not load, glue will throw errors and shut down the application nothing else will get executed.  So, you cannot make tests like we did in earlier assignments to see if a plugin loads or not when using glue. \r\n*  Refactor project to meet new requirements https://github.com/hapijs/contrib/issues/31.  \r\n   - Remove Makefile and switch to using npm scripts (see hapi package.json)\r\n   - Remove root index.js (point package.json to lib/index.js)\r\n   - Replace package.json licenses array with single license key and `\"BSD-3-Clause\"` value\r\n   - Update code style to stop putting functions on single line (new lab will error on that lint warning)\r\n* An extra challenge, after doing the above, refactor hapi-auth-basic registration code: \r\n   * Refactor the application to load hapi-auth-basic plugin using glue's manifest file.  \r\n   * Remove hapi-auth-basic plugin registration code from the private.js file.\r\n   * private.js plugins' functionality will not change.  We are just moving where the \r\n     hapi-auth-basic plugin is registered.  \r\n   * Configure Glue to load hapi-auth-basic plugin and make a file dedicated to register the hapi-auth-basic strategy.\r\n   Glue will reference this file in the manifest file to load the plugin. \r\n   * While making the assignment, there was discussion about why not to make this change. See: [The Discussion](https://github.com/hapijs/university/issues/132) for details. \r\n   But, I encourage everyone to try it.  Doing this exercise will help you get to know Glue and hapijs' auth plugin design better ;-)\r\n   If you get stuck here, we will work together to make it work! \r\n\r\n#### What is coming next?\r\n* adding static assets like css, images, js files.\r\n* validation with joi\r\n* sessions and authentication with hapi-auth-cookie\r\n* See \"What we are going to build?\" section in the README https://github.com/hapijs/university  for the big picture plan.\r\n* If you have suggestions for issues to study please make them!\r\nCheers!"},"comment":{"url":"https://api.github.com/repos/hapijs/university/issues/comments/105039832","html_url":"https://github.com/hapijs/university/issues/136#issuecomment-105039832","issue_url":"https://api.github.com/repos/hapijs/university/issues/136","id":105039832,"user":{"login":"FennNaten","id":5120098,"avatar_url":"https://avatars.githubusercontent.com/u/5120098?v=3","gravatar_id":"","url":"https://api.github.com/users/FennNaten","html_url":"https://github.com/FennNaten","followers_url":"https://api.github.com/users/FennNaten/followers","following_url":"https://api.github.com/users/FennNaten/following{/other_user}","gists_url":"https://api.github.com/users/FennNaten/gists{/gist_id}","starred_url":"https://api.github.com/users/FennNaten/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/FennNaten/subscriptions","organizations_url":"https://api.github.com/users/FennNaten/orgs","repos_url":"https://api.github.com/users/FennNaten/repos","events_url":"https://api.github.com/users/FennNaten/events{/privacy}","received_events_url":"https://api.github.com/users/FennNaten/received_events","type":"User","site_admin":false},"created_at":"2015-05-24T17:08:35Z","updated_at":"2015-05-24T17:08:35Z","body":"@roelof1967 For the test examples, you'd better go to a repo utilizing glue rather than the Glue repo itself. See e.g. [aqua](https://github.com/jedireza/aqua)\r\n\r\nIn the plugins object of the manifest, each key should be the name of the target module if it's a npm module, or the relative path to it if the module is internal to the app. That's how Glue requires them before calling register.\r\ne.g. \r\n```javascript\r\nvar manifest = {\r\n    connections: [\r\n        {\r\n            port: 5000\r\n        }\r\n    ],\r\n    plugins: {\r\n        \"./version\": {} //the actual key depends on where you put your plugin and which folder you decide to use as relative root. Relative root is given as an option to the compose function.\r\n    }\r\n}\r\n```\r\nTo be able to start the server and aim for minimal refactoring, you can keep a structure very similar to what we already have, e.g. just changing the init function in index.js to take manifest and glueOptions as params, replacing the `server.register` part by `glue.compose`, then changing start.js to pass in a manifest instead of a port."}}