Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
Add support for replacing tags in <head> #165
Add ability to mark head tags with data-turbolinks-replace.
This will remove the tag on page:change and replace it with the new version from the freshly fetched page.
Example use cases:
This is an interesting idea, but there are couple bugs in your implementation.
I think you can fix these bugs by doing this:
fetchReplacement = (url) -> # ... else changePage extractTitleAndBody(doc)... replaceHeadNodes extractReplaceableNodes(doc.head), true reflectRedirectedUrl xhr # ... fetchHistory = (state) -> # ... changePage page.title, page.body replaceHeadNodes page.replaceableHeadNodes recallScrollPosition page # ... cacheCurrentPage = -> # ... pageCache[currentState.position] = url: document.location.href, # ... replaceableHeadNodes: extractReplaceableNodes document.head # ... replaceHeadNodes = (nodes, execute) -> document.head.removeChild node for node in extractReplaceableNodes(document.head) for node in nodes if execute copy = document.createElement node.nodeName copy.setAttribute attr.name, attr.value for attr in node.attributes copy.appendChild document.createTextNode node.innerHTML document.head.appendChild copy else document.head.appendChild node
referenced this pull request
Jan 25, 2013
I think the submitter should defend his idea, but I'll throw this out there:
There are plenty of third-party API's that use page-specific meta tags, like Facebook's Open Graph or Twitter Cards (both of which you'd find in the source of this page). I think this would make compatibility easier to achieve.
Our current method of handling asset changes just falls back to a normal page load if there are any changes. Using this solution would allow assets to change without abandoning the turbolinks session.
You can still have per-page meta tags, though, that work with first-hit requests. Doesn't that satisfy Twitter cards etc?
Thing is, if you constantly need to reload, then what is turbo links doing for you?
On Feb 27, 2013, at 6:24 PM, Nick Reed firstname.lastname@example.org wrote:
My use case for this was when the csrf token changes because the session has been reseted on the server.
Eg.: using a memcache session store w/ 2 hours expiry
Now csrf token in meta tag is invalid and will stay invalid until a full page refresh is triggered by the user or some other code.
However this is no longer an issue for me, we've since gone back to the cookie store. And of course could be solved by increasing expiry too.
I think this solution has value, but I don't feel strongly enough about it to continue advocating for it if Marc-Andre doesn't need it anymore.