Hello community, here is the log from the commit of package rubygem-turbolinks for openSUSE:Factory checked in at 2014-10-19 19:28:34 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/rubygem-turbolinks (Old) and /work/SRC/openSUSE:Factory/.rubygem-turbolinks.new (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "rubygem-turbolinks" Changes: -------- --- /work/SRC/openSUSE:Factory/rubygem-turbolinks/rubygem-turbolinks.changes 2014-10-14 13:25:22.000000000 +0200 +++ /work/SRC/openSUSE:Factory/.rubygem-turbolinks.new/rubygem-turbolinks.changes 2014-10-19 19:29:18.000000000 +0200 @@ -1,0 +2,5 @@ +Fri Oct 17 04:42:20 UTC 2014 - co...@suse.com + +- updated to version 2.4.0, no changelog + +------------------------------------------------------------------- Old: ---- turbolinks-2.2.2.gem New: ---- turbolinks-2.4.0.gem ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ rubygem-turbolinks.spec ++++++ --- /var/tmp/diff_new_pack.YhdKe7/_old 2014-10-19 19:29:19.000000000 +0200 +++ /var/tmp/diff_new_pack.YhdKe7/_new 2014-10-19 19:29:19.000000000 +0200 @@ -16,8 +16,15 @@ # +# +# This file was generated with a gem2rpm.yml and not just plain gem2rpm. +# All sections marked as MANUAL, license headers, summaries and descriptions +# can be maintained in that file. Please consult this file before editing any +# of those fields +# + Name: rubygem-turbolinks -Version: 2.2.2 +Version: 2.4.0 Release: 0 %define mod_name turbolinks %define mod_full_name %{mod_name}-%{version} ++++++ turbolinks-2.2.2.gem -> turbolinks-2.4.0.gem ++++++ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/README.md new/README.md --- old/README.md 1970-01-01 01:00:00.000000000 +0100 +++ new/README.md 1970-01-01 01:00:00.000000000 +0100 @@ -33,8 +33,9 @@ * `page:before-change` a Turbolinks-enabled link has been clicked *(see below for more details)* * `page:fetch` starting to fetch a new target page * `page:receive` the page has been fetched from the server, but not yet parsed -* `page:change` the page has been parsed and changed to the new version and on DOMContentLoaded -* `page:update` is triggered whenever page:change is PLUS on jQuery's ajaxSucess, if jQuery is available (otherwise you can manually trigger it when calling XMLHttpRequest in your own code) +* `page:before-unload` the page has been parsed and is about to be changed +* `page:change` the page has been changed to the new version (and on DOMContentLoaded) +* `page:update` is triggered alongside both page:change and jQuery's ajaxSuccess (if jQuery is available - otherwise you can manually trigger it when calling XMLHttpRequest in your own code) * `page:load` is fired at the end of the loading process. Handlers bound to the `page:before-change` event may return `false`, which will cancel the Turbolinks process. @@ -42,6 +43,7 @@ By default, Turbolinks caches 10 of these page loads. It listens to the [popstate](https://developer.mozilla.org/en-US/docs/DOM/Manipulating_the_browser_history#The_popstate_event) event and attempts to restore page state from the cache when it's triggered. When `popstate` is fired the following process happens: ***Restore* a cached page from the client-side cache:** +* `page:before-unload` page has been fetched from the cache and is about to be changed * `page:change` page has changed to the cached page. * `page:restore` is fired at the end of restore process. @@ -59,8 +61,12 @@ To implement a client-side spinner, you could listen for `page:fetch` to start it and `page:receive` to stop it. - document.addEventListener("page:fetch", startSpinner); - document.addEventListener("page:receive", stopSpinner); +```javascript +// using jQuery for simplicity + +$(document).on("page:fetch", startSpinner); +$(document).on("page:receive", stopSpinner); +``` DOM transformations that are idempotent are best. If you have transformations that are not, hook them to happen only on `page:load` instead of `page:change` (as that would run them again on the cached pages). @@ -195,6 +201,7 @@ *These projects are not affiliated with or endorsed by the Rails Turbolinks team.* * [Flask Turbolinks](https://github.com/lepture/flask-turbolinks) (Python Flask) +* [Django Turbolinks](https://github.com/dgladkov/django-turbolinks) (Python Django) * [ASP.NET MVC Turbolinks](https://github.com/kazimanzurrashid/aspnetmvcturbolinks) * [PHP Turbolinks Component](https://github.com/helthe/Turbolinks) (Symfony Component) * [PHP Turbolinks Package](https://github.com/frenzyapp/turbolinks) (Laravel Package) Files old/checksums.yaml.gz and new/checksums.yaml.gz differ diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/assets/javascripts/turbolinks.js.coffee new/lib/assets/javascripts/turbolinks.js.coffee --- old/lib/assets/javascripts/turbolinks.js.coffee 1970-01-01 01:00:00.000000000 +0100 +++ new/lib/assets/javascripts/turbolinks.js.coffee 1970-01-01 01:00:00.000000000 +0100 @@ -10,13 +10,22 @@ createDocument = null xhr = null +EVENTS = + BEFORE_CHANGE: 'page:before-change' + FETCH: 'page:fetch' + RECEIVE: 'page:receive' + CHANGE: 'page:change' + UPDATE: 'page:update' + LOAD: 'page:load' + RESTORE: 'page:restore' + BEFORE_UNLOAD: 'page:before-unload' + EXPIRE: 'page:expire' fetch = (url) -> url = new ComponentUrl url rememberReferer() cacheCurrentPage() - reflectNewUrl url if transitionCacheEnabled and cachedPage = transitionCacheFor(url.absolute) fetchHistory cachedPage @@ -31,8 +40,8 @@ enableTransitionCache = (enable = true) -> transitionCacheEnabled = enable -fetchReplacement = (url, onLoadFunction = =>) -> - triggerEvent 'page:fetch', url: url.absolute +fetchReplacement = (url, onLoadFunction = =>) -> + triggerEvent EVENTS.FETCH, url: url.absolute xhr?.abort() xhr = new XMLHttpRequest @@ -41,13 +50,15 @@ xhr.setRequestHeader 'X-XHR-Referer', referer xhr.onload = -> - triggerEvent 'page:receive' + triggerEvent EVENTS.RECEIVE, url: url.absolute if doc = processResponse() + reflectNewUrl url changePage extractTitleAndBody(doc)... + manuallyTriggerHashChangeForFirefox() reflectRedirectedUrl() onLoadFunction() - triggerEvent 'page:load' + triggerEvent EVENTS.LOAD else document.location.href = url.absolute @@ -60,7 +71,7 @@ xhr?.abort() changePage cachedPage.title, cachedPage.body recallScrollPosition cachedPage - triggerEvent 'page:restore' + triggerEvent EVENTS.RESTORE cacheCurrentPage = -> @@ -88,23 +99,26 @@ .sort (a, b) -> b - a for key in pageCacheKeys when pageCache[key].cachedAt <= cacheTimesRecentFirst[limit] - triggerEvent 'page:expire', pageCache[key] + triggerEvent EVENTS.EXPIRE, pageCache[key] delete pageCache[key] changePage = (title, body, csrfToken, runScripts) -> + triggerEvent EVENTS.BEFORE_UNLOAD document.title = title document.documentElement.replaceChild body, document.body CSRFToken.update csrfToken if csrfToken? + setAutofocusElement() executeScriptTags() if runScripts currentState = window.history.state - triggerEvent 'page:change' - triggerEvent 'page:update' + triggerEvent EVENTS.CHANGE + triggerEvent EVENTS.UPDATE executeScriptTags = -> scripts = Array::slice.call document.body.querySelectorAll 'script:not([data-turbolinks-eval="false"])' for script in scripts when script.type in ['', 'text/javascript'] copy = document.createElement 'script' copy.setAttribute attr.name, attr.value for attr in script.attributes + copy.async = false unless script.hasAttribute 'async' copy.appendChild document.createTextNode script.innerHTML { parentNode, nextSibling } = script parentNode.removeChild script @@ -115,6 +129,12 @@ node.innerHTML = node.innerHTML.replace /<noscript[\S\s]*?<\/noscript>/ig, '' node +# Firefox bug: Doesn't autofocus fields that are inserted via JavaScript +setAutofocusElement = -> + autofocusElement = (list = document.querySelectorAll 'input[autofocus], textarea[autofocus]')[list.length - 1] + if autofocusElement and document.activeElement isnt autofocusElement + autofocusElement.focus() + reflectNewUrl = (url) -> if (url = new ComponentUrl url).absolute isnt referer window.history.pushState { turbolinks: true, url: url.absolute }, '', url.absolute @@ -134,6 +154,18 @@ rememberCurrentState = -> currentState = window.history.state +# Unlike other browsers, Firefox doesn't trigger hashchange after changing the +# location (via pushState) to an anchor on a different page. For example: +# +# /pages/one => /pages/two#with-hash +# +# By forcing Firefox to trigger hashchange, the rest of the code can rely on more +# consistent behavior across browsers. +manuallyTriggerHashChangeForFirefox = -> + if navigator.userAgent.match(/Firefox/) and !(url = (new ComponentUrl)).hasNoHash() + window.history.replaceState currentState, '', url.withoutHash() + document.location.hash = url.hash + recallScrollPosition = (page) -> window.scrollTo page.positionX, page.positionY @@ -144,29 +176,39 @@ window.scrollTo 0, 0 +clone = (original) -> + return original if not original? or typeof original isnt 'object' + copy = new original.constructor() + copy[key] = clone value for key, value of original + copy + popCookie = (name) -> value = document.cookie.match(new RegExp(name+"=(\\w+)"))?[1].toUpperCase() or '' document.cookie = name + '=; expires=Thu, 01-Jan-70 00:00:01 GMT; path=/' value triggerEvent = (name, data) -> + if typeof Prototype isnt 'undefined' + Event.fire document, name, data, true + event = document.createEvent 'Events' event.data = data if data event.initEvent name, true, true document.dispatchEvent event -pageChangePrevented = -> - !triggerEvent 'page:before-change' +pageChangePrevented = (url) -> + !triggerEvent EVENTS.BEFORE_CHANGE, url: url processResponse = -> clientOrServerError = -> 400 <= xhr.status < 600 validContent = -> - xhr.getResponseHeader('Content-Type').match /^(?:text\/html|application\/xhtml\+xml|application\/xml)(?:;|$)/ + (contentType = xhr.getResponseHeader('Content-Type'))? and + contentType.match /^(?:text\/html|application\/xhtml\+xml|application\/xml)(?:;|$)/ extractTrackAssets = (doc) -> - for node in doc.head.childNodes when node.getAttribute?('data-turbolinks-track')? + for node in doc.querySelector('head').childNodes when node.getAttribute?('data-turbolinks-track')? node.getAttribute('src') or node.getAttribute('href') assetsChanged = (doc) -> @@ -185,7 +227,7 @@ extractTitleAndBody = (doc) -> title = doc.querySelector 'title' - [ title?.textContent, removeNoscriptTags(doc.body), CSRFToken.get(doc).token, 'runScripts' ] + [ title?.textContent, removeNoscriptTags(doc.querySelector('body')), CSRFToken.get(doc).token, 'runScripts' ] CSRFToken = get: (doc = document) -> @@ -213,6 +255,15 @@ doc.close() doc + createDocumentUsingFragment = (html) -> + head = html.match(/<head[^>]*>([\s\S.]*)<\/head>/i)?[0] or '<head></head>' + body = html.match(/<body[^>]*>([\s\S.]*)<\/body>/i)?[0] or '<body></body>' + htmlWrapper = document.createElement 'html' + htmlWrapper.innerHTML = head + body + doc = document.createDocumentFragment() + doc.appendChild htmlWrapper + doc + # Use createDocumentUsingParser if DOMParser is defined and natively # supports 'text/html' parsing (Firefox 12+, IE 10) # @@ -223,16 +274,32 @@ # - DOMParser isn't defined # - createDocumentUsingParser returns null due to unsupported type 'text/html' (Chrome, Safari) # - createDocumentUsingDOM doesn't create a valid HTML document (safeguarding against potential edge cases) + # + # Use createDocumentUsingFragment if the previously selected parser does not + # correctly parse <form> tags. (Safari 7.1+ - see github.com/rails/turbolinks/issues/408) + buildTestsUsing = (createMethod) -> + buildTest = (fallback, passes) -> + passes: passes() + fallback: fallback + + structureTest = buildTest createDocumentUsingWrite, => + (createMethod '<html><body><p>test')?.body?.childNodes.length is 1 + + formNestingTest = buildTest createDocumentUsingFragment, => + (createMethod '<html><body><form></form><div></div></body></html>')?.body?.childNodes.length is 2 + + [structureTest, formNestingTest] + try if window.DOMParser - testDoc = createDocumentUsingParser '<html><body><p>test' + docTests = buildTestsUsing createDocumentUsingParser createDocumentUsingParser catch e - testDoc = createDocumentUsingDOM '<html><body><p>test' + docTests = buildTestsUsing createDocumentUsingDOM createDocumentUsingDOM finally - unless testDoc?.body?.childNodes.length is 1 - return createDocumentUsingWrite + for docTest in docTests + return docTest.fallback unless docTest.passes # The ComponentUrl class converts a basic URL string into an object @@ -245,7 +312,7 @@ return @original if @original.constructor is ComponentUrl @_parse() - withoutHash: -> @href.replace @hash, '' + withoutHash: -> @href.replace(@hash, '').replace('#', '') # Intention revealing function alias withoutHashForIE10compatibility: -> @withoutHash() @@ -273,6 +340,8 @@ constructor: (@link) -> return @link if @link.constructor is Link @original = @link.href + @originalElement = @link + @link = @link.cloneNode false super shouldIgnore: -> @@ -286,14 +355,14 @@ @origin isnt (new ComponentUrl).origin _anchored: -> - ((@hash and @withoutHash()) is (current = new ComponentUrl).withoutHash()) or - (@href is current.href + '#') + (@hash.length > 0 or @href.charAt(@href.length - 1) is '#') and + (@withoutHash() is (new ComponentUrl).withoutHash()) _nonHtml: -> @pathname.match(/\.[a-z]+$/g) and not @pathname.match(new RegExp("\\.(?:#{Link.HTML_EXTENSIONS.join('|')})?$", 'g')) _optOut: -> - link = @link + link = @originalElement until ignore or link is document ignore = link.getAttribute('data-no-turbolink')? link = link.parentNode @@ -320,7 +389,7 @@ return if @event.defaultPrevented @_extractLink() if @_validForTurbolinks() - visit @link.href unless pageChangePrevented() + visit @link.href unless pageChangePrevented(@link.absolute) @event.preventDefault() _extractLink: -> @@ -346,15 +415,15 @@ installDocumentReadyPageEventTriggers = -> document.addEventListener 'DOMContentLoaded', ( -> - triggerEvent 'page:change' - triggerEvent 'page:update' + triggerEvent EVENTS.CHANGE + triggerEvent EVENTS.UPDATE ), true installJqueryAjaxSuccessPageUpdateTrigger = -> if typeof jQuery isnt 'undefined' jQuery(document).on 'ajaxSuccess', (event, xhr, settings) -> return unless jQuery.trim xhr.responseText - triggerEvent 'page:update' + triggerEvent EVENTS.UPDATE installHistoryChangeHandler = (event) -> if event.state?.turbolinks @@ -371,6 +440,10 @@ document.addEventListener 'click', Click.installHandlerLast, true + window.addEventListener 'hashchange', (event) -> + rememberCurrentUrl() + rememberCurrentState() + , false bypassOnLoadPopstate -> window.addEventListener 'popstate', installHistoryChangeHandler, false @@ -409,4 +482,12 @@ # Turbolinks.enableTransitionCache() # Turbolinks.allowLinkExtensions('md') # Turbolinks.supported -@Turbolinks = { visit, pagesCached, enableTransitionCache, allowLinkExtensions: Link.allowExtensions, supported: browserSupportsTurbolinks } +# Turbolinks.EVENTS +@Turbolinks = { + visit, + pagesCached, + enableTransitionCache, + allowLinkExtensions: Link.allowExtensions, + supported: browserSupportsTurbolinks, + EVENTS: clone(EVENTS) +} \ No newline at end of file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/turbolinks/cookies.rb new/lib/turbolinks/cookies.rb --- old/lib/turbolinks/cookies.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/lib/turbolinks/cookies.rb 1970-01-01 01:00:00.000000000 +0100 @@ -1,10 +1,15 @@ module Turbolinks - # Sets a request_method cookie containing the request method of the current request. - # The Turbolinks script will not initialize if this cookie is set to anything other than GET. + # For non-GET requests, sets a request_method cookie containing + # the request method of the current request. The Turbolinks script + # will not initialize if this cookie is set. module Cookies private def set_request_method_cookie - cookies[:request_method] = request.request_method + if request.get? + cookies.delete(:request_method) + else + cookies[:request_method] = request.request_method + end end end -end \ No newline at end of file +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/turbolinks/version.rb new/lib/turbolinks/version.rb --- old/lib/turbolinks/version.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/lib/turbolinks/version.rb 1970-01-01 01:00:00.000000000 +0100 @@ -1,3 +1,3 @@ module Turbolinks - VERSION = '2.2.2' + VERSION = '2.4.0' end \ No newline at end of file diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/turbolinks/xhr_headers.rb new/lib/turbolinks/xhr_headers.rb --- old/lib/turbolinks/xhr_headers.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/lib/turbolinks/xhr_headers.rb 1970-01-01 01:00:00.000000000 +0100 @@ -11,30 +11,36 @@ module XHRHeaders extend ActiveSupport::Concern - included do - alias_method_chain :_compute_redirect_to_location, :xhr_referer - end + def _compute_redirect_to_location(*args) + options, request = _normalize_redirect_params(args) - private - def _compute_redirect_to_location_with_xhr_referer(options) - store_for_turbolinks begin - if options == :back && request.headers["X-XHR-Referer"] - _compute_redirect_to_location_without_xhr_referer(request.headers["X-XHR-Referer"]) - else - _compute_redirect_to_location_without_xhr_referer(options) - end + store_for_turbolinks begin + if options == :back && request.headers["X-XHR-Referer"] + super(*[(request if args.length == 2), request.headers["X-XHR-Referer"]].compact) + else + super(*args) end end + end + private def store_for_turbolinks(url) - session[:_turbolinks_redirect_to] = url if request.headers["X-XHR-Referer"] + session[:_turbolinks_redirect_to] = url if session && request.headers["X-XHR-Referer"] url end def set_xhr_redirected_to - if session[:_turbolinks_redirect_to] + if session && session[:_turbolinks_redirect_to] response.headers['X-XHR-Redirected-To'] = session.delete :_turbolinks_redirect_to end end + + # Ensure backwards compatibility + # Rails < 4.2: _compute_redirect_to_location(options) + # Rails >= 4.2: _compute_redirect_to_location(request, options) + def _normalize_redirect_params(args) + options, req = args.reverse + [options, req || request] + end end -end \ No newline at end of file +end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/lib/turbolinks.rb new/lib/turbolinks.rb --- old/lib/turbolinks.rb 1970-01-01 01:00:00.000000000 +0100 +++ new/lib/turbolinks.rb 1970-01-01 01:00:00.000000000 +0100 @@ -27,7 +27,7 @@ (ActionView::RoutingUrlFor rescue ActionView::Helpers::UrlHelper).module_eval do include XHRUrlFor end - end + end unless RUBY_VERSION =~ /^1\.8/ end end end diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' old/metadata new/metadata --- old/metadata 1970-01-01 01:00:00.000000000 +0100 +++ new/metadata 1970-01-01 01:00:00.000000000 +0100 @@ -1,14 +1,14 @@ --- !ruby/object:Gem::Specification name: turbolinks version: !ruby/object:Gem::Version - version: 2.2.2 + version: 2.4.0 platform: ruby authors: - David Heinemeier Hansson autorequire: bindir: bin cert_chain: [] -date: 2014-04-06 00:00:00.000000000 Z +date: 2014-10-03 00:00:00.000000000 Z dependencies: - !ruby/object:Gem::Dependency name: coffee-rails -- To unsubscribe, e-mail: opensuse-commit+unsubscr...@opensuse.org For additional commands, e-mail: opensuse-commit+h...@opensuse.org