mirror of
https://github.com/NixOS/mobile-nixos.git
synced 2024-12-15 02:43:24 +03:00
doc: Add <head> link to RSS feed
This commit is contained in:
parent
810e18a758
commit
fa0a2a5734
@ -3,6 +3,7 @@ module Processor; end
|
||||
require_relative "processor/base"
|
||||
require_relative "processor/article"
|
||||
require_relative "processor/footer"
|
||||
require_relative "processor/head"
|
||||
require_relative "processor/header"
|
||||
require_relative "processor/page"
|
||||
require_relative "processor/rss"
|
||||
|
28
doc/_support/converter/lib/processor/head.rb
Normal file
28
doc/_support/converter/lib/processor/head.rb
Normal file
@ -0,0 +1,28 @@
|
||||
module Processor
|
||||
class Head
|
||||
attr_reader :page
|
||||
attr_reader :root_relative
|
||||
|
||||
def initialize(page, root_relative)
|
||||
@page = page
|
||||
@root_relative = root_relative
|
||||
end
|
||||
|
||||
def head()
|
||||
[
|
||||
'<link lang="en" rel="alternate" type="application/rss+xml" title="RSS feed (EN)" href="',
|
||||
"#{root_relative}index.xml",
|
||||
'" />',
|
||||
].join("")
|
||||
end
|
||||
|
||||
def append_to_head(document)
|
||||
output = document.split("\n")
|
||||
idx = output.find_index do |line|
|
||||
line.match(/<\/head>/)
|
||||
end
|
||||
output.insert(idx, head)
|
||||
output.join("\n")
|
||||
end
|
||||
end
|
||||
end
|
@ -16,12 +16,13 @@ module Processor
|
||||
].join("")
|
||||
end
|
||||
|
||||
def append_header(document)
|
||||
def header()
|
||||
header = ERB.new(File.read(File.join($options["root"], "_support/header.erb")))
|
||||
rootrel = root_relative
|
||||
header.result(binding)
|
||||
end
|
||||
|
||||
header = header.result(binding)
|
||||
|
||||
def append_header(document)
|
||||
output = document.split("\n")
|
||||
idx = output.find_index do |line|
|
||||
line.match(/<body /)
|
||||
|
@ -68,6 +68,9 @@ module Processor
|
||||
# Prepare output, to make next steps more readable.
|
||||
@output = @doc.convert
|
||||
|
||||
# Adds necessary stuff in <head />
|
||||
@output = Processor::Head.new(@page, @root_relative).append_to_head(@output)
|
||||
|
||||
# Force the site header on the generated page.
|
||||
@output = Processor::Header.new(@page, @root_relative).append_header(@output)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user