diff --git a/assets/javascripts/templates/pages/about_tmpl.coffee b/assets/javascripts/templates/pages/about_tmpl.coffee index 30c4c479..fc5279eb 100644 --- a/assets/javascripts/templates/pages/about_tmpl.coffee +++ b/assets/javascripts/templates/pages/about_tmpl.coffee @@ -970,7 +970,12 @@ credits = [ '2014-2017 Khronos Group Inc.
Vulkan and the Vulkan logo are registered trademarks of the Khronos Group Inc.', 'CC BY', 'https://creativecommons.org/licenses/by/4.0/' - ], [ + ],[ + 'wagtail', + '2014-present Torchbox Ltd and individual contributors', + 'BSD', + 'https://github.com/wagtail/wagtail/blob/main/LICENSE' + ],[ 'webpack', 'JS Foundation and other contributors', 'CC BY', diff --git a/assets/stylesheets/pages/_sphinx.scss b/assets/stylesheets/pages/_sphinx.scss index 64a4df6b..cb23ef69 100644 --- a/assets/stylesheets/pages/_sphinx.scss +++ b/assets/stylesheets/pages/_sphinx.scss @@ -47,6 +47,11 @@ span.descclassname, span.descname { font-family: var(--monoFont) } } +nav[aria-label="Page navigation"]{ + display: flex !important; + justify-content: space-between !important; +} + ._sphinx { @extend %sphinx; } diff --git a/lib/docs/filters/wagtail/clean_html.rb b/lib/docs/filters/wagtail/clean_html.rb new file mode 100644 index 00000000..050388d5 --- /dev/null +++ b/lib/docs/filters/wagtail/clean_html.rb @@ -0,0 +1,67 @@ +module Docs + class Wagtail + class CleanHtmlFilter < Filter + def call + @doc = at_css('main > section', 'main') + + # footer contains links like about,contact us etc which + # are not needed in documentation so removed + doc.search('footer').each do |footer| + footer.remove + end + + # aside bar contains the search bar and navigation links + # which are not needed + doc.search('aside').each do |aside| + aside.remove + end + + # header contains links which are not needed(see sourch code of Wagtail docs) + doc.search('header').each do |head| + head.remove + end + + # nav bar contains the search bar and navigation links(older versions) + # which are not needed + doc.search('nav.wy-nav-side').each do |nav| + nav.remove + end + + # removing unimportant links(older versions) + doc.search('nav.wy-nav-top').each do |nav| + nav.remove + end + + # removing unimportant links from header of very old versions + doc.search('ul.wy-breadcrumbs').each do |ul| + ul.remove + end + + # removing release notes + doc.search('li.toctree-l1').each do |li| + li.remove if li.to_s.include? 'Release notes' + end + + # removing release notes(older versions) + doc.search('dl').each do |dl| + dl.remove + end + + # removing scripts and style + css('script', 'style', 'link').remove + css('hr').remove + # Make proper table headers + css('td.header').each do |node| + node.name = 'th' + end + + # Remove code highlighting + css('pre').each do |node| + node.content = node.content + end + + doc + end + end + end +end diff --git a/lib/docs/filters/wagtail/entries.rb b/lib/docs/filters/wagtail/entries.rb new file mode 100644 index 00000000..8af4c4c7 --- /dev/null +++ b/lib/docs/filters/wagtail/entries.rb @@ -0,0 +1,15 @@ +module Docs + class Wagtail + class EntriesFilter < Docs::EntriesFilter + def get_name + # removing the pilcrow sign and returning the heading + at_css('h1').content.strip.remove("\u{00b6}") + end + + def get_type + object, method = *slug.split('/') + method ? object : 'Miscellaneous' + end + end + end +end diff --git a/lib/docs/scrapers/wagtail.rb b/lib/docs/scrapers/wagtail.rb new file mode 100644 index 00000000..bc9d626d --- /dev/null +++ b/lib/docs/scrapers/wagtail.rb @@ -0,0 +1,48 @@ +module Docs + class Wagtail < UrlScraper + self.name = 'Wagtail' + self.type = 'sphinx' + self.root_path = 'index.html' + self.links = { + home: 'https://wagtail.org/', + code: 'https://github.com/wagtail/wagtail' + } + + # adding filters from lib/docs/filters/wagtail + html_filters.push 'wagtail/entries', 'sphinx/clean_html', 'wagtail/clean_html' + + # attributions are seen at the bottom of every page(copyright and license etc. details) + options[:attribution] = <<-HTML + © 2014-present Torchbox Ltd and individual contributors.
+ All rights are reserved.
+ Licensed under the BSD License. + HTML + + # no one wants to see docs about search or release notes + options[:skip] = %w[search.html] + options[:skip_patterns] = [ + %r{\Areleases/} + ] + + # updating release and base_url for different versions + version do + self.release = '4.1.1' + self.base_url = 'https://docs.wagtail.org/en/stable/' + end + + version '3' do + self.release = '3.0.3' + self.base_url = "https://docs.wagtail.org/en/v#{release}/" + end + + version '2' do + self.release = '2.16.3' + self.base_url = "https://docs.wagtail.org/en/v#{release}/" + end + + # this method will fetch the latest version of wagtail + def get_latest_version(opts) + get_latest_github_release('wagtail', 'wagtail', opts) + end + end +end diff --git a/public/icons/docs/wagtail/16.png b/public/icons/docs/wagtail/16.png new file mode 100644 index 00000000..73a98e39 Binary files /dev/null and b/public/icons/docs/wagtail/16.png differ diff --git a/public/icons/docs/wagtail/16@2x.png b/public/icons/docs/wagtail/16@2x.png new file mode 100644 index 00000000..965b30f5 Binary files /dev/null and b/public/icons/docs/wagtail/16@2x.png differ diff --git a/public/icons/docs/wagtail/SOURCE b/public/icons/docs/wagtail/SOURCE new file mode 100644 index 00000000..76f5d4b1 --- /dev/null +++ b/public/icons/docs/wagtail/SOURCE @@ -0,0 +1 @@ +https://github.com/wagtail/wagtail/blob/main/docs/logo.png