-
Notifications
You must be signed in to change notification settings - Fork 161
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow Populating Head Content #66
Conversation
This assumes we're able to merge ember-fastboot/simple-dom#12
- just serialize the head tag from the document directly - leave population of the tag to application code
Here is the ember-fastboot-server PR companion to this PR. 2 of the failing tests on this PR are fixed when using the version of ember-fastboot-server provided with the other PR. The other two failures appear to be present on master. Please let me know how I can help finish this off. I know there are a lot of moving parts now that the project has split. |
Looks good to me. |
@ronco thanks for taking over this and making it happen. |
@jpadilla No problem. I'm giving a talk at our local meetup next week on searchable ember apps (ie meta tags and pre-rendering). Seemed like a good opportunity to demo fastboot. |
@rwjblue <!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Dummy</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<base href="/" />
<head><title>Application Route -- Title</title><meta name="description" content="something here"><meta property="og:image" content="http://placehold.it/500x5
00"></head>
<link rel="stylesheet" href="assets/vendor.css">
<link rel="stylesheet" href="assets/dummy.css">
</head>
<body>
<body><div id="ember332" class="ember-view"><h2 id="title">Welcome to Ember.js</h2>
<!---->
</div></body>
<script src="assets/vendor.js"></script>
<script src="assets/dummy.js"></script>
</body>
</html> Note the I think the best way to address it would be for |
Seems like a reasonable solution off the cuff, mind digging in and seeing if there is already a way to do this in SimpleDOM (and submit a PR if not)? |
Will do. Probably won't get to it till tomorrow night. I'm giving a meetup talk on
|
@ronco has submitted a PR to SimpleDOM (ember-fastboot/simple-dom#18) to fix that issue. @ronco - Can you update this PR to point at your fork/branch of SimpleDOM so we can play around with things here a bit easier? |
@rwjblue updated this PR to point to my simple-dom fork and my fastboot-server fork. Note fastboot is throwing an error on the latest ember canary:
I think it's this line causing the issue in the node environment. I was able to test out this whole stack with an older canary checkout (2.2.0-canary+1a2cd166). |
@chancancode - I believe that this change was introduced in emberjs/ember.js#12394, and given that you are familiar with fastboot (and that PR was submitted to make the visit api much better) I am hoping that you might have a few pointers on how we need to update fastboot.... |
eh, that's one of my TODOs. I'll send a PR to update fastboot. |
@rwjblue @tomdale I'm about to start rebasing this for the new visit api updates (and make any necessary implementation updates). However on master currently tests are failing in the under-test smoke apps when run against canary. Updating the acceptance helper to run beta instead seems to fix. |
@rwjblue @tomdale Thanks for the info. I'll see if I can get that fixed before tackling this rebase. Looking at the work @chancancode did for the visit api here & on the server I think this feature will be much easier to implement than the original attempt. |
My thinking about how to implement this:
ExampleI want to support Open Graph in my application that shows rendered articles. // app/routes/article.js
export default Route.extend({
model(params) {
return fetch(`http://api.example.com/articles/${params.article_id}.json`)
.then(response => response.json());
},
afterModel(article) {
let headMetadata = this.get('headMetadata');
headMetadata.set('title', article.title);
headMetadata.set('image', {
url: article.thumbnailURL,
width: article.thumbnailWidth,
height: article.thumbnailHeight
});
}
}); {{!-- app/templates/head.hbs --}}
<title>{{model.title}}</title>
<meta property="og:site_name" content="Hubbub">
<meta property="og:title" content={{model.title}}>
<meta property="og:image" content={{model.image.url}}>
<meta property="og:image:width" content={{model.image.width}}>
<meta property="og:image:height" content={{model.image.height}}> |
That's a real interesting approach. I really like the idea of giving users access to that template for expressively building their head content. Would you be able to make full use of components and helpers in that template? In my addon I've created a component with a template to accomplish this which is appended to the head. It then has sub components for rendering the individual head tags. I think it makes a good example for this implementation. Do we need any changes to ember or ember-cli-fastboot for this? Would an addon with this service accomplish this combined with my fastboot-server PR to insert the whole head rather than just title? |
Hey @tomdale, I'm getting this error when trying to run the fastboot test suite against ember canary:
The error is raising here and it looks like |
@ronco Ah, the problem is that the sandboxed Ember app does not have access to |
@ronco The Ember tests didn't catch this because they are not running sandboxed like FastBoot apps are. |
cc @chancancode |
@tomdale Yeah, I thought it might be a sandboxing issue. Let me know if there's anything I can do to help. |
@ronco Can you patch https://github.com/tildeio/htmlbars/blob/master/packages/dom-helper/lib/main.js#L571-L598 to use the global |
@tomdale On it. |
@tomdale I started putting together an addon for However, when I try to integrate it with fastboot I'm running into some issues. I have a demo app I was testing it with here (using npm link to pull in the unpublished addon). Running fastboot with the addon results in:
The issue arises when looking up the head component from the container in my instance-initializer. This ends up triggering this code path in CoreView. I was trying to come up with a way to hack it in there within the addon, but I'm wondering if I'm shaving the wrong yak there. I'd appreciate any thoughts suggestions on how to get this working. |
Closed in favor of #114 |
najax@0.6.0 for gzip support
…mocha-4.0.0 Update mocha to the latest version 🚀
This strips down the great work done by @jpadilla in #49 to just serialize the (newly exposed) simple dom head element. This allows apps and addons to populate the head element as they see fit while running under fastboot.
I'll also open up a PR against ember-fastboot-server with the necessary changes for replacing the head content.