mirror of
https://github.com/freeCodeCamp/devdocs
synced 2024-11-16 19:48:10 +01:00
Improve jQuery scraper
This commit is contained in:
parent
bffabec8a6
commit
bd7aec1311
4 changed files with 5 additions and 10 deletions
|
@ -1,14 +1,8 @@
|
||||||
#= require views/pages/base
|
#= require views/pages/simple
|
||||||
|
|
||||||
class app.views.JqueryPage extends app.views.BasePage
|
class app.views.JqueryPage extends app.views.SimplePage
|
||||||
@demoClassName: '_jquery-demo'
|
@demoClassName: '_jquery-demo'
|
||||||
|
|
||||||
prepare: ->
|
|
||||||
for el in @findAllByClass 'syntaxhighlighter'
|
|
||||||
language = if el.classList.contains('javascript') then 'javascript' else 'markup'
|
|
||||||
@highlightCode el, language
|
|
||||||
return
|
|
||||||
|
|
||||||
afterRender: ->
|
afterRender: ->
|
||||||
# Prevent jQuery Mobile's demo iframes from scrolling the page
|
# Prevent jQuery Mobile's demo iframes from scrolling the page
|
||||||
for iframe in @findAllByTag 'iframe'
|
for iframe in @findAllByTag 'iframe'
|
||||||
|
|
|
@ -31,6 +31,7 @@ module Docs
|
||||||
css('div.syntaxhighlighter').each do |node|
|
css('div.syntaxhighlighter').each do |node|
|
||||||
node.name = 'pre'
|
node.name = 'pre'
|
||||||
node.content = node.at_css('td.code').css('div.line').map(&:content).join("\n")
|
node.content = node.at_css('td.code').css('div.line').map(&:content).join("\n")
|
||||||
|
node['data-language'] = node['class'].include?('javascript') ? 'javascript' : 'markup'
|
||||||
end
|
end
|
||||||
|
|
||||||
# jQueryMobile/jqmData, etc.
|
# jQueryMobile/jqmData, etc.
|
||||||
|
|
|
@ -6,7 +6,7 @@ module Docs
|
||||||
|
|
||||||
def get_name
|
def get_name
|
||||||
name = at_css('h1').content.strip
|
name = at_css('h1').content.strip
|
||||||
name.remove! ' Widget'
|
name.remove! ' Widget' unless name.start_with?('Category')
|
||||||
name.prepend '.' if name.start_with? 'jqm'
|
name.prepend '.' if name.start_with? 'jqm'
|
||||||
name << ' event' if type == 'Events' && !name.end_with?(' event')
|
name << ' event' if type == 'Events' && !name.end_with?(' event')
|
||||||
name
|
name
|
||||||
|
|
|
@ -6,7 +6,7 @@ module Docs
|
||||||
|
|
||||||
def get_name
|
def get_name
|
||||||
name = at_css('h1').content.strip
|
name = at_css('h1').content.strip
|
||||||
name.remove! ' Widget'
|
name.remove! ' Widget' unless name.start_with?('Category')
|
||||||
name.gsub!(/ [A-Z]/) { |str| str.downcase! }
|
name.gsub!(/ [A-Z]/) { |str| str.downcase! }
|
||||||
name
|
name
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue