From 2d6c1be335d64dd32bcbfdacd295019f5fd2b621 Mon Sep 17 00:00:00 2001 From: Nicolas Ettlin Date: Wed, 3 Oct 2018 21:50:22 +0200 Subject: [PATCH] Add Vue Router reference --- .../templates/pages/about_tmpl.coffee | 5 ++ lib/docs/filters/vue_router/clean_html.rb | 14 ++++ lib/docs/filters/vue_router/entries.rb | 73 ++++++++++++++++++ lib/docs/scrapers/vue_router.rb | 27 +++++++ public/icons/docs/vue_router/16.png | Bin 0 -> 1211 bytes public/icons/docs/vue_router/16@2x.png | Bin 0 -> 2020 bytes public/icons/docs/vue_router/SOURCE | 2 + 7 files changed, 121 insertions(+) create mode 100644 lib/docs/filters/vue_router/clean_html.rb create mode 100644 lib/docs/filters/vue_router/entries.rb create mode 100644 lib/docs/scrapers/vue_router.rb create mode 100644 public/icons/docs/vue_router/16.png create mode 100644 public/icons/docs/vue_router/16@2x.png create mode 100644 public/icons/docs/vue_router/SOURCE diff --git a/assets/javascripts/templates/pages/about_tmpl.coffee b/assets/javascripts/templates/pages/about_tmpl.coffee index fef9a024..56dfadd1 100644 --- a/assets/javascripts/templates/pages/about_tmpl.coffee +++ b/assets/javascripts/templates/pages/about_tmpl.coffee @@ -680,6 +680,11 @@ credits = [ '2013-2018 Evan You, Vue.js contributors', 'MIT', 'https://raw.githubusercontent.com/vuejs/vue/master/LICENSE' + ], [ + 'Vue Router', + '2013-2018 Evan You, Vue.js contributors', + 'MIT', + 'https://github.com/vuejs/vue-router/blob/dev/LICENSE' ], [ 'Vulkan', '2014-2017 Khronos Group Inc.
Vulkan and the Vulkan logo are registered trademarks of the Khronos Group Inc.', diff --git a/lib/docs/filters/vue_router/clean_html.rb b/lib/docs/filters/vue_router/clean_html.rb new file mode 100644 index 00000000..6377b0d4 --- /dev/null +++ b/lib/docs/filters/vue_router/clean_html.rb @@ -0,0 +1,14 @@ +module Docs + class VueRouter + class CleanHtmlFilter < Filter + def call + @doc = at_css('.content') + + # Remove unneeded elements + css('.bit-sponsor, .header-anchor').remove + + doc + end + end + end +end \ No newline at end of file diff --git a/lib/docs/filters/vue_router/entries.rb b/lib/docs/filters/vue_router/entries.rb new file mode 100644 index 00000000..c00c99f2 --- /dev/null +++ b/lib/docs/filters/vue_router/entries.rb @@ -0,0 +1,73 @@ +module Docs + class VueRouter + class EntriesFilter < Docs::EntriesFilter + def get_name + name = at_css('h1').content + + name.remove! '# ' + + name + end + + def get_type + return 'Other Guides' if subpath.start_with?('guide/advanced') + return 'Basic Guides' if subpath.start_with?('guide') || subpath.start_with?('installation') + + 'API Reference' + end + + def include_default_entry? + name != 'API Reference' + end + + def additional_entries + return [] unless subpath.start_with?('api') + + entries = [ + ['', 'router-link', 'API Reference'], + ['', 'router-view', 'API Reference'], + ['$route', 'the-route-object', 'API Reference'], + ['Component Injections', 'component-injections', 'API Reference'] + ] + + css('h3').each do |node| + entryName = node.content.strip + + # Get the previous h2 title + title = node + title = title.previous_element until title.name == 'h2' + title = title.content.strip + title.remove! '# ' + + entryName.remove! '# ' + + unless entryName.start_with?('router.') + if title == "Router Construction Options" + entryName = "RouterOptions.#{entryName}" + elsif title == " Props" + entryName = " `#{entryName}` prop" + elsif title == " Props" + entryName = " `#{entryName}` prop" + else + entryName = "> #{entryName} (in: #{title})" + end + end + + unless title == "Component Injections" || node['id'] == 'applying-active-class-to-outer-element' || node['id'] == 'route-object-properties' + entries << [entryName, node['id'], 'API Reference'] + end + end + + css('#route-object-properties + ul > li > p:first-child > strong').each do |node| + entryName = node.content.strip + id = "route-object-#{entryName.remove('$route.')}" + + node['id'] = id + entries << [entryName, node['id'], 'API Reference'] + end + + entries + end + end + end +end \ No newline at end of file diff --git a/lib/docs/scrapers/vue_router.rb b/lib/docs/scrapers/vue_router.rb new file mode 100644 index 00000000..e19efa11 --- /dev/null +++ b/lib/docs/scrapers/vue_router.rb @@ -0,0 +1,27 @@ +module Docs + class VueRouter < UrlScraper + self.slug = 'vue_router' + self.name = 'Vue Router' + self.type = 'simple' + + self.links = { + home: 'https://router.vuejs.org', + code: 'https://github.com/vuejs/vue-router' + } + + html_filters.push 'vue_router/entries', 'vue_router/clean_html' + + self.release = '3.0.1' + self.base_url = 'https://router.vuejs.org/' + + options[:skip_patterns] = [ + # Other languages + /^(zh|ja|ru|kr)\//, + ] + + options[:attribution] = <<-HTML + © 2013–2018 Evan You, Vue.js contributors
+ Licensed under the MIT License. + HTML + end +end diff --git a/public/icons/docs/vue_router/16.png b/public/icons/docs/vue_router/16.png new file mode 100644 index 0000000000000000000000000000000000000000..64eb9b345a929493b14931f7a58b07abd91835b8 GIT binary patch literal 1211 zcmeAS@N?(olHy`uVBq!ia0vp^0wB!61|;P_|4#%`Ea{HEjtmSN`?>!lvI6-E$sR$z z3=CCj3=9n|3=F@3LJcn%7)lKo7+xhXFj&oCU=S~uvn$XBD8X6a5m^l63xP0W`us~k z8yK%Q&?x097+E*i={nnYpPYi3%0DIeEoa6}C!X6;?nt zNLXJ<0j#7X+g2&UH$cHTzbI9~RL?}uK*^3vK|#T$C?(A*$i)q+9mum)$|xx*u+rBr zFE7_CH`dE9O4m2Ew6xSWFw!?N(gmu}Ew0QfNvzP#D^`XW0yD=YwK%ybv!En1KTiQ< zZemh?X^E|p638MrfVeXy8E#KOX;BW?mXu`u)ST4Z)Vz{neM3D%eQf$lGSd()%qxZl z2QXmtK{7yX2KsO}0j;!2Nwz93P0C75E&+QN?h3HKof6aak%VpZv8uKKnQY}>lnHcL zBFJxchBjc^P{g2qw9yB794R0mp$rxU2D2TPjXpfe?6?Gv@0iTMz!c!=;uvBfSQ}{D zEfpwIo1Z2V{-;S-r)jE=W{awlSeJJ8Ouf0S8(NRuh;;Fo?ECPLQo znWB}NQ@!SkhB!#T!Qzj*~`1HEjPxZPfVJY$5)bz@#8>^1`L|hSHfBiShX4?a~33;g| zQjw>hPO5ivTO7zdgIo5F&+^OZ7bLF~v8=xSdgY02j?aqq*tho_O*-`av!_(;v9cSM zJFf&}zgL)kT9QNSY0*#RTYnd1&XVF`+kT^U!Nv3*3Ck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^GCz%cpP!$HdnXOA2YXQrdqj#28ugt${nnzdH!e2I_C?Bkfg+=mxn2j& zLcyT`otM2Ou83q?&lMlxn?#?zYw;LFJ-6?Yd&|d^2)EV+4f^qq=39bjje{SeoDbyO zFYb9i+12_eL(Z$iI$@y0z?~`j7ryv~Ma+urnx|aJ8mG#J4H~g*U3fNV$OZ>37vPdp zg&9WW^=Fa;1%i=hSGU6Xg^e;xzbBq%0S?>zu67H9c`uh;gp1GdzX5dAmn^^Bwd literal 0 HcmV?d00001 diff --git a/public/icons/docs/vue_router/SOURCE b/public/icons/docs/vue_router/SOURCE new file mode 100644 index 00000000..474e2fca --- /dev/null +++ b/public/icons/docs/vue_router/SOURCE @@ -0,0 +1,2 @@ +http://vuejs.org/ +(Edited from the original logo to distinguish Vue Router from Vue)