mirror of
https://github.com/freeCodeCamp/devdocs
synced 2024-11-16 19:48:10 +01:00
Merge pull request #1879 from vallabhtiwari/wagtail
Added doc support for Wagtail a Content Management System based on Django
This commit is contained in:
commit
5ac1a4d9c8
8 changed files with 142 additions and 1 deletions
|
@ -970,7 +970,12 @@ credits = [
|
|||
'2014-2017 Khronos Group Inc.<br>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',
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
67
lib/docs/filters/wagtail/clean_html.rb
Normal file
67
lib/docs/filters/wagtail/clean_html.rb
Normal file
|
@ -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
|
15
lib/docs/filters/wagtail/entries.rb
Normal file
15
lib/docs/filters/wagtail/entries.rb
Normal file
|
@ -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
|
48
lib/docs/scrapers/wagtail.rb
Normal file
48
lib/docs/scrapers/wagtail.rb
Normal file
|
@ -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.<br>
|
||||
All rights are reserved.<br>
|
||||
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
|
BIN
public/icons/docs/wagtail/16.png
Normal file
BIN
public/icons/docs/wagtail/16.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 553 B |
BIN
public/icons/docs/wagtail/16@2x.png
Normal file
BIN
public/icons/docs/wagtail/16@2x.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.2 KiB |
1
public/icons/docs/wagtail/SOURCE
Normal file
1
public/icons/docs/wagtail/SOURCE
Normal file
|
@ -0,0 +1 @@
|
|||
https://github.com/wagtail/wagtail/blob/main/docs/logo.png
|
Loading…
Reference in a new issue