Speed up re-rendering pages from cache

pull/281/head
Thibaut 9 years ago
parent a37e9d87cf
commit dbc628cebd

@ -24,18 +24,18 @@ class app.views.EntryPage extends app.View
@trigger 'loading'
return
render: (content = '') ->
render: (content = '', fromCache = false) ->
return unless @activated
@empty()
@subview = new (@subViewClass()) @el, @entry
@subview.render(content)
@subview.render(content, fromCache)
if app.disabledDocs.findBy 'slug', @entry.doc.slug
@hiddenView = new app.views.HiddenPage @el, @entry
@trigger 'loaded'
@delay @addClipboardLinks
@delay @addClipboardLinks unless fromCache
return
CLIPBOARD_LINK = '<a class="_pre-clip" title="Copy to clipboard"></a>'
@ -122,7 +122,7 @@ class app.views.EntryPage extends app.View
restore: ->
if @cacheMap[path = @entry.filePath()]
@render @cacheMap[path]
@render @cacheMap[path], true
true
onClick: (event) =>

@ -1,7 +1,7 @@
#= require views/pages/base
class app.views.AngularPage extends app.views.BasePage
afterRender: ->
prepare: ->
for el in @findAllByTag('pre')
lang = if el.classList.contains('lang-html') or el.textContent[0] is '<'
'markup'

@ -1,9 +1,10 @@
class app.views.BasePage extends app.View
constructor: (@el, @entry) -> super
render: (content) ->
render: (content, fromCache = false) ->
@addClass "_#{@entry.doc.type}" unless @constructor.className
@html content
@prepare?() unless fromCache
@activate()
@delay @afterRender if @afterRender
return

@ -1,6 +1,6 @@
#= require views/pages/base
class app.views.BowerPage extends app.views.BasePage
afterRender: ->
prepare: ->
@highlightCode @findAll('pre[data-lang="js"], pre[data-lang="javascript"], pre[data-lang="json"]'), 'javascript'
return

@ -1,7 +1,7 @@
#= require views/pages/base
class app.views.CPage extends app.views.BasePage
afterRender: ->
prepare: ->
@highlightCode @findAll('pre.source-c, .source-c > pre'), 'c'
@highlightCode @findAll('pre.source-cpp, .source-cpp > pre'), 'cpp'
return

@ -1,7 +1,7 @@
#= require views/pages/base
class app.views.CoffeescriptPage extends app.views.BasePage
afterRender: ->
prepare: ->
@highlightCode @findAll('.code > pre:first-child'), 'coffeescript'
@highlightCode @findAll('.code > pre:last-child'), 'javascript'
return

@ -1,6 +1,6 @@
#= require views/pages/base
class app.views.D3Page extends app.views.BasePage
afterRender: ->
prepare: ->
@highlightCode @findAll('.highlight > pre'), 'javascript'
return

@ -1,6 +1,6 @@
#= require views/pages/base
class app.views.DrupalPage extends app.views.BasePage
afterRender: ->
prepare: ->
@highlightCode @findAll('pre.php'), 'php'
return

@ -1,7 +1,7 @@
#= require views/pages/base
class app.views.EmberPage extends app.views.BasePage
afterRender: ->
prepare: ->
for el in @findAllByTag 'pre'
language = if el.classList.contains 'javascript'
'javascript'

@ -1,6 +1,6 @@
#= require views/pages/base
class app.views.GoPage extends app.views.BasePage
afterRender: ->
prepare: ->
@highlightCode @findAll('pre'), 'go'
return

@ -1,12 +1,12 @@
#= require views/pages/base
class app.views.JavascriptPage extends app.views.BasePage
afterRender: ->
prepare: ->
@highlightCode @findAllByTag('pre'), 'javascript'
return
class app.views.JavascriptWithMarkupCheckPage extends app.views.BasePage
afterRender: ->
prepare: ->
for el in @findAllByTag('pre')
language = if el.textContent.match(/^\s*</)
'markup'

@ -3,6 +3,12 @@
class app.views.JqueryPage extends app.views.BasePage
@demoClassName: '_jquery-demo'
prepare: ->
for el in @findAllByClass 'syntaxhighlighter'
language = if el.classList.contains('javascript') then 'javascript' else 'markup'
@highlightCode el, language
return
afterRender: ->
# Prevent jQuery Mobile's demo iframes from scrolling the page
for iframe in @findAllByTag 'iframe'
@ -11,11 +17,6 @@ class app.views.JqueryPage extends app.views.BasePage
@runExamples()
for el in @findAllByClass 'syntaxhighlighter'
language = if el.classList.contains('javascript') then 'javascript' else 'markup'
@highlightCode el, language
return
onIframeLoaded: (event) =>
event.target.style.display = ''
$.off event.target, 'load', @onIframeLoaded

@ -1,7 +1,7 @@
#= require views/pages/base
class app.views.KnockoutPage extends app.views.BasePage
afterRender: ->
prepare: ->
for el in @findAll('pre')
language = if el.innerHTML.indexOf('data-bind="') > 0 then 'markup' else 'javascript'
@highlightCode el, language

@ -1,6 +1,6 @@
#= require views/pages/base
class app.views.LaravelPage extends app.views.BasePage
afterRender: ->
prepare: ->
@highlightCode @findAllByTag('pre'), 'php'
return

@ -5,7 +5,7 @@ class app.views.MdnPage extends app.views.BasePage
LANGUAGE_REGEXP = /brush: ?(\w+)/
afterRender: ->
prepare: ->
for el in @findAll 'pre[class^="brush"]'
language = el.className.match(LANGUAGE_REGEXP)[1]
.replace('html', 'markup')

@ -1,7 +1,7 @@
#= require views/pages/base
class app.views.MeteorPage extends app.views.BasePage
afterRender: ->
prepare: ->
@highlightCode @findAll('pre.js, pre.javascript'), 'javascript'
@highlightCode @findAll('pre.html'), 'markup'
return

@ -1,7 +1,7 @@
#= require views/pages/base
class app.views.PhalconPage extends app.views.BasePage
afterRender: ->
prepare: ->
@highlightCode @findAll('pre[class*="php"]'), 'php'
@highlightCode @findAll('pre.highlight-html'), 'markup'
return

@ -1,6 +1,6 @@
#= require views/pages/base
class app.views.PhpPage extends app.views.BasePage
afterRender: ->
prepare: ->
@highlightCode @findAllByClass('phpcode'), 'php'
return

@ -1,6 +1,6 @@
#= require views/pages/base
class app.views.PhpunitPage extends app.views.BasePage
afterRender: ->
prepare: ->
@highlightCode @findAll('pre.programlisting'), 'php'
return

@ -4,7 +4,7 @@ class app.views.RdocPage extends app.views.BasePage
@events:
click: 'onClick'
afterRender: ->
prepare: ->
@highlightCode @findAll('pre.ruby'), 'ruby'
@highlightCode @findAll('pre.c'), 'clike'
return

@ -1,7 +1,7 @@
#= require views/pages/base
class app.views.ReactPage extends app.views.BasePage
afterRender: ->
prepare: ->
for el in @findAllByTag 'pre'
switch el.getAttribute('data-lang')
when 'html' then @highlightCode el, 'markup'

@ -1,6 +1,6 @@
#= require views/pages/base
class app.views.RustPage extends app.views.BasePage
afterRender: ->
prepare: ->
@highlightCode @findAll('pre.rust'), 'rust'
return

@ -1,7 +1,7 @@
#= require views/pages/base
class app.views.SphinxPage extends app.views.BasePage
afterRender: ->
prepare: ->
@highlightCode @findAll('pre.python'), 'python'
@highlightCode @findAll('pre.markup'), 'markup'
return

Loading…
Cancel
Save