Browse Source

Update jQuery docs

Closes #204.
Thibaut Courouble 9 năm trước cách đây
mục cha
commit
9098ff5275

+ 3 - 3
assets/javascripts/templates/pages/about_tmpl.coffee

@@ -191,17 +191,17 @@ credits = [
     'https://raw.githubusercontent.com/iojs/io.js/v1.x/LICENSE'
   ], [
     'jQuery',
-    '2009 Packt Publishing<br>&copy; 2014 jQuery Foundation',
+    'Packt Publishing<br>&copy; jQuery Foundation and other contributors',
     'MIT',
     'https://raw.githubusercontent.com/jquery/api.jquery.com/master/LICENSE.txt'
   ], [
     'jQuery Mobile',
-    '2014 jQuery Foundation',
+    'jQuery Foundation and other contributors',
     'MIT',
     'https://raw.githubusercontent.com/jquery/api.jquerymobile.com/master/LICENSE.txt'
   ], [
     'jQuery UI',
-    '2014 jQuery Foundation',
+    'jQuery Foundation and other contributors',
     'MIT',
     'https://raw.githubusercontent.com/jquery/api.jqueryui.com/master/LICENSE.txt'
   ], [

+ 0 - 10
lib/docs/filters/jquery/clean_urls.rb

@@ -1,10 +0,0 @@
-module Docs
-  class Jquery
-    class CleanUrlsFilter < Filter
-      def call
-        html.gsub! 'local.api.jquery', 'api.jquery'
-        html
-      end
-    end
-  end
-end

+ 1 - 0
lib/docs/filters/jquery_core/entries.rb

@@ -9,6 +9,7 @@ module Docs
       def get_name
         name = at_css('h1').content.strip
         name.gsub!(/ [A-Z]/) { |str| str.downcase! }
+        name.gsub! %r{[“”]}, '"'
         name
       end
 

+ 1 - 2
lib/docs/scrapers/jquery/jquery.rb

@@ -4,7 +4,6 @@ module Docs
     self.type = 'jquery'
 
     html_filters.push 'jquery/clean_html', 'title'
-    text_filters.push 'jquery/clean_urls'
 
     options[:title] = false
     options[:container] = '#content'
@@ -12,7 +11,7 @@ module Docs
     options[:skip_patterns] = [/category/]
 
     options[:attribution] = <<-HTML
-      &copy; 2014 The jQuery Foundation<br>
+      &copy; The jQuery Foundation and other contributors<br>
       Licensed under the MIT License.
     HTML
   end

+ 11 - 8
lib/docs/scrapers/jquery/jquery_core.rb

@@ -1,19 +1,22 @@
 module Docs
   class JqueryCore < Jquery
     self.name = 'jQuery'
-    self.release = 'up to 2.1.0'
-    self.base_url = 'http://local.api.jquery.com'
+    self.release = 'up to 2.2.0'
+    self.base_url = 'https://api.jquery.com/'
+    self.initial_paths = %w(/index/index)
 
     html_filters.insert_before 'jquery/clean_html', 'jquery_core/entries'
 
     options[:root_title] = 'jQuery'
 
-    # Duplicates
-    options[:skip] = %w(/selectors/odd /selectors/even /selectors/event
-      /selected /checked)
+    options[:fix_urls] = ->(url) do
+      url.sub! 'http://api.jquery.com/', 'https://api.jquery.com/'
+    end
 
-    options[:replace_paths] = {
-      '/index/'             => '/index/index',
-      '/h/deferred.reject/' => '/deferred.reject' }
+    options[:skip_patterns] += [
+      /h\/deferred\.reject/i,
+      /Selectors\/odd/i,
+      /index/i
+    ]
   end
 end

+ 7 - 3
lib/docs/scrapers/jquery/jquery_mobile.rb

@@ -2,15 +2,19 @@ module Docs
   class JqueryMobile < Jquery
     self.name = 'jQuery Mobile'
     self.slug = 'jquerymobile'
-    self.release = '1.4.0'
-    self.base_url = 'http://local.api.jquerymobile.com'
+    self.release = '1.4.5'
+    self.base_url = 'https://api.jquerymobile.com'
     self.root_path = '/category/all'
 
     html_filters.insert_before 'jquery/clean_html', 'jquery_mobile/entries'
 
     options[:root_title] = 'jQuery Mobile'
     options[:skip] = %w(/tabs /theme)
-    options[:skip_patterns].concat [/\A\/icons/]
+    options[:skip_patterns].concat [/\A\/icons/, /cdn-cgi/i]
     options[:replace_paths] = { '/select/' => '/selectmenu' }
+
+    options[:fix_urls] = ->(url) do
+      url.sub! 'http://api.jquerymobile.com/', 'https://api.jquerymobile.com/'
+    end
   end
 end

+ 7 - 3
lib/docs/scrapers/jquery/jquery_ui.rb

@@ -2,14 +2,18 @@ module Docs
   class JqueryUi < Jquery
     self.name = 'jQuery UI'
     self.slug = 'jqueryui'
-    self.release = '1.10.4'
-    self.base_url = 'http://local.api.jqueryui.com'
+    self.release = '1.11.4'
+    self.base_url = 'https://api.jqueryui.com'
     self.root_path = '/category/all'
 
     html_filters.insert_before 'jquery/clean_html', 'jquery_ui/entries'
 
     options[:root_title] = 'jQuery UI'
     options[:skip] = %w(/theming)
-    options[:skip_patterns].concat [/\A\/1\./]
+    options[:skip_patterns] += [/\A\/1\./]
+
+    options[:fix_urls] = ->(url) do
+      url.sub! 'http://api.jqueryui.com/', 'https://api.jqueryui.com/'
+    end
   end
 end