laravel.rb 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. module Docs
  2. class Laravel < UrlScraper
  3. self.type = 'laravel'
  4. self.base_url = 'https://laravel.com'
  5. self.links = {
  6. home: 'https://laravel.com/',
  7. code: 'https://github.com/laravel/laravel'
  8. }
  9. html_filters.push 'laravel/entries', 'laravel/clean_html'
  10. options[:container] = ->(filter) {
  11. filter.subpath.start_with?('/api') ? '#content' : '.docs-wrapper'
  12. }
  13. options[:skip_patterns] = [
  14. %r{\A/api/\d\.\d/\.html},
  15. %r{\A/api/\d\.\d/panel\.html},
  16. %r{\A/api/\d\.\d/namespaces\.html},
  17. %r{\A/api/\d\.\d/interfaces\.html},
  18. %r{\A/api/\d\.\d/traits\.html},
  19. %r{\A/api/\d\.\d/doc-index\.html},
  20. %r{\A/api/\d\.\d/Illuminate\.html},
  21. %r{\A/api/\d\.\d/search\.html} ]
  22. options[:attribution] = <<-HTML
  23. &copy; Taylor Otwell<br>
  24. Licensed under the MIT License.<br>
  25. Laravel is a trademark of Taylor Otwell.
  26. HTML
  27. version '5.7' do
  28. self.release = '5.7.7'
  29. self.root_path = '/api/5.7/index.html'
  30. self.initial_paths = %w(/docs/5.7/installation /api/5.7/classes.html)
  31. options[:only_patterns] = [%r{\A/api/5\.7/}, %r{\A/docs/5\.7/}]
  32. options[:fix_urls] = ->(url) do
  33. url.sub! %r{#{Regexp.escape(Laravel.base_url)}/docs\/(?!\d)}, "#{Laravel.base_url}/docs/5.7/"
  34. url
  35. end
  36. end
  37. version '5.6' do
  38. self.release = '5.6.33'
  39. self.root_path = '/api/5.6/index.html'
  40. self.initial_paths = %w(/docs/5.6/installation /api/5.6/classes.html)
  41. options[:only_patterns] = [%r{\A/api/5\.6/}, %r{\A/docs/5\.6/}]
  42. options[:fix_urls] = ->(url) do
  43. url.sub! %r{#{Regexp.escape(Laravel.base_url)}/docs\/(?!\d)}, "#{Laravel.base_url}/docs/5.6/"
  44. url
  45. end
  46. end
  47. version '5.5' do
  48. self.release = '5.5.28'
  49. self.root_path = '/api/5.5/index.html'
  50. self.initial_paths = %w(/docs/5.5/installation /api/5.5/classes.html)
  51. options[:only_patterns] = [%r{\A/api/5\.5/}, %r{\A/docs/5\.5/}]
  52. options[:fix_urls] = ->(url) do
  53. url.sub! %r{#{Regexp.escape(Laravel.base_url)}/docs\/(?!\d)}, "#{Laravel.base_url}/docs/5.5/"
  54. url
  55. end
  56. end
  57. version '5.4' do
  58. self.release = '5.4.30'
  59. self.root_path = '/api/5.4/index.html'
  60. self.initial_paths = %w(/docs/5.4/installation /api/5.4/classes.html)
  61. options[:only_patterns] = [%r{\A/api/5\.4/}, %r{\A/docs/5\.4/}]
  62. options[:fix_urls] = ->(url) do
  63. url.sub! %r{#{Regexp.escape(Laravel.base_url)}/docs\/(?!\d)}, "#{Laravel.base_url}/docs/5.4/"
  64. url
  65. end
  66. end
  67. version '5.3' do
  68. self.release = '5.3.30'
  69. self.root_path = '/api/5.3/index.html'
  70. self.initial_paths = %w(/docs/5.3/installation /api/5.3/classes.html)
  71. options[:only_patterns] = [%r{\A/api/5\.3/}, %r{\A/docs/5\.3/}]
  72. options[:fix_urls] = ->(url) do
  73. url.sub! %r{#{Regexp.escape(Laravel.base_url)}/docs\/(?!\d)}, "#{Laravel.base_url}/docs/5.3/"
  74. url
  75. end
  76. end
  77. version '5.2' do
  78. self.release = '5.2.31'
  79. self.root_path = '/api/5.2/index.html'
  80. self.initial_paths = %w(/docs/5.2/installation /api/5.2/classes.html)
  81. options[:only_patterns] = [%r{\A/api/5\.2/}, %r{\A/docs/5\.2/}]
  82. options[:fix_urls] = ->(url) do
  83. url.sub! %r{#{Regexp.escape(Laravel.base_url)}/docs\/(?!\d)}, "#{Laravel.base_url}/docs/5.2/"
  84. url
  85. end
  86. end
  87. version '5.1' do
  88. self.release = '5.1.33'
  89. self.root_path = '/api/5.1/index.html'
  90. self.initial_paths = %w(/docs/5.1/installation /api/5.1/classes.html)
  91. options[:only_patterns] = [%r{\A/api/5\.1/}, %r{\A/docs/5\.1/}]
  92. options[:fix_urls] = ->(url) do
  93. url.sub! %r{#{Regexp.escape(Laravel.base_url)}/docs\/(?!\d)}, "#{Laravel.base_url}/docs/5.1/"
  94. url
  95. end
  96. end
  97. version '4.2' do
  98. self.release = '4.2.11'
  99. self.root_path = '/api/4.2/index.html'
  100. self.initial_paths = %w(/docs/4.2/installation /api/4.2/classes.html)
  101. options[:only_patterns] = [%r{\A/api/4\.2/}, %r{\A/docs/4\.2/}]
  102. options[:fix_urls] = ->(url) do
  103. url.sub! %r{#{Regexp.escape(Laravel.base_url)}/docs\/(?!\d)}, "#{Laravel.base_url}/docs/4.2/"
  104. url
  105. end
  106. end
  107. def get_latest_version(opts)
  108. get_latest_github_release('laravel', 'laravel', opts)['tag_name'][1..-1]
  109. end
  110. end
  111. end