class GovukTechDocs::SourceUrls
Attributes
config[R]
current_page[R]
Public Class Methods
new(current_page, config)
click to toggle source
# File lib/govuk_tech_docs/contribution_banner.rb, line 12 def initialize(current_page, config) @current_page = current_page @config = config end
Public Instance Methods
repo_branch()
click to toggle source
# File lib/govuk_tech_docs/contribution_banner.rb, line 35 def repo_branch config[:tech_docs][:github_branch] || "master" end
repo_url()
click to toggle source
# File lib/govuk_tech_docs/contribution_banner.rb, line 31 def repo_url "https://github.com/#{config[:tech_docs][:github_repo]}" end
report_issue_url()
click to toggle source
# File lib/govuk_tech_docs/contribution_banner.rb, line 21 def report_issue_url url = config[:source_urls]&.[](:report_issue_url) if url.nil? "#{repo_url}/issues/new?labels=bug&title=Re: '#{current_page.data.title}'&body=Problem with '#{current_page.data.title}' (#{config[:tech_docs][:host]}#{current_page.url})" else "#{url}?subject=Re: '#{current_page.data.title}'&body=Problem with '#{current_page.data.title}' (#{config[:tech_docs][:host]}#{current_page.url})" end end
view_source_url()
click to toggle source
# File lib/govuk_tech_docs/contribution_banner.rb, line 17 def view_source_url override_from_page || source_from_yaml_file || source_from_file end
Private Instance Methods
locals()
click to toggle source
# File lib/govuk_tech_docs/contribution_banner.rb, line 58 def locals current_page.metadata[:locals] end
override_from_page()
click to toggle source
If a `page` local exists, see if it has a `source_url`. This is used by the pages that are created by the proxy system because they can't use frontmatter
# File lib/govuk_tech_docs/contribution_banner.rb, line 43 def override_from_page locals.key?(:page) ? locals[:page].try(:source_url) : false end
source_from_file()
click to toggle source
As the last fallback link to the source file in this repository.
# File lib/govuk_tech_docs/contribution_banner.rb, line 54 def source_from_file "#{repo_url}/blob/#{repo_branch}/source/#{current_page.file_descriptor[:relative_path]}" end
source_from_yaml_file()
click to toggle source
In the frontmatter we can specify a `source_url`. Use this if the actual source of the page is in another GitHub repo.
# File lib/govuk_tech_docs/contribution_banner.rb, line 49 def source_from_yaml_file current_page.data.source_url end