mirror of https://github.com/freeCodeCamp/devdocs
parent
6b0390d7c7
commit
ece6ff80fd
Before Width: | Height: | Size: 14 KiB After Width: | Height: | Size: 15 KiB |
Before Width: | Height: | Size: 36 KiB After Width: | Height: | Size: 39 KiB |
@ -0,0 +1,8 @@
|
||||
#= require views/pages/base
|
||||
|
||||
class app.views.KnockoutPage extends app.views.BasePage
|
||||
afterRender: ->
|
||||
for el in @findAll('pre')
|
||||
language = if el.innerHTML.indexOf('data-bind="') > 0 then 'markup' else 'javascript'
|
||||
@highlightCode el, language
|
||||
return
|
@ -0,0 +1,6 @@
|
||||
._knockout {
|
||||
> h2 { @extend %block-heading; }
|
||||
> h3 { @extend %block-label, %label-blue; }
|
||||
p > code { @extend %label; }
|
||||
.liveExample { @extend %note; }
|
||||
}
|
@ -0,0 +1,30 @@
|
||||
module Docs
|
||||
class Knockout
|
||||
class CleanHtmlFilter < Filter
|
||||
def call
|
||||
root_page? ? root : other
|
||||
|
||||
css('pre > code').each do |node|
|
||||
node.before(node.children).remove
|
||||
end
|
||||
|
||||
doc
|
||||
end
|
||||
|
||||
def root
|
||||
@doc = at_css '.content'
|
||||
at_css('h1').content = 'Knockout.js'
|
||||
end
|
||||
|
||||
def other
|
||||
css('h1 ~ h1').each do |node|
|
||||
node.name = 'h2'
|
||||
end
|
||||
|
||||
css('.liveExample').each do |node|
|
||||
node.content = 'Live examples are not available on DevDocs, sorry.'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,38 @@
|
||||
module Docs
|
||||
class Knockout
|
||||
class EntriesFilter < Docs::EntriesFilter
|
||||
NAME_BY_SLUG = {
|
||||
'custom-bindings' => 'Custom bindings',
|
||||
'custom-bindings-controlling-descendant-bindings' => 'Descendant bindings',
|
||||
'custom-bindings-for-virtual-elements' => 'Virtual elements',
|
||||
'binding-preprocessing' => 'Binding preprocessing',
|
||||
'json-data' => 'JSON data',
|
||||
'extenders' => 'Extending observables',
|
||||
'unobtrusive-event-handling' => 'Event handling',
|
||||
'fn' => 'Custom functions' }
|
||||
|
||||
def get_name
|
||||
return NAME_BY_SLUG[slug] if NAME_BY_SLUG.has_key?(slug)
|
||||
name = at_css('h1').content.strip
|
||||
name.sub! 'The ', ''
|
||||
name.sub! %r{"(.+?)"}, '\1'
|
||||
name.gsub!(/ [A-Z]/) { |str| str.downcase! }
|
||||
name
|
||||
end
|
||||
|
||||
def get_type
|
||||
if name =~ /observable/i || slug =~ /extender/
|
||||
'Observables'
|
||||
elsif slug.include?('binding') && !name.end_with?('binding')
|
||||
'Binding'
|
||||
elsif slug.include? 'binding'
|
||||
'Bindings'
|
||||
elsif slug.include? 'plugin'
|
||||
'Plugins'
|
||||
else
|
||||
'Miscellaneous'
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
@ -0,0 +1,32 @@
|
||||
module Docs
|
||||
class Knockout < UrlScraper
|
||||
self.name = 'Knockout.js'
|
||||
self.slug = 'knockout'
|
||||
self.type = 'knockout'
|
||||
self.version = '3.0.0'
|
||||
self.base_url = 'http://knockoutjs.com/documentation/'
|
||||
self.root_path = 'introduction.html'
|
||||
|
||||
html_filters.push 'knockout/clean_html', 'knockout/entries'
|
||||
|
||||
options[:follow_links] = ->(filter) { filter.root_page? }
|
||||
options[:container] = ->(filter) { filter.root_page? ? '#wrapper' : '.content' }
|
||||
|
||||
options[:only] = %w(
|
||||
json-data.html
|
||||
extenders.html
|
||||
throttle-extender.html
|
||||
unobtrusive-event-handling.html
|
||||
fn.html)
|
||||
|
||||
options[:only_patterns] = [
|
||||
/observable/i,
|
||||
/binding/,
|
||||
/plugin/]
|
||||
|
||||
options[:attribution] = <<-HTML
|
||||
© Steven Sanderson, the Knockout.js team, and other contributors<br>
|
||||
Licensed under the MIT License.
|
||||
HTML
|
||||
end
|
||||
end
|
After Width: | Height: | Size: 902 B |
After Width: | Height: | Size: 2.3 KiB |
@ -0,0 +1 @@
|
||||
http://learn.knockoutjs.com/
|
Loading…
Reference in new issue