Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion _data/external_links.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ oi-patents:

oi-trademark:
id: oi-trademark
url: www.OneIdentity.com/legal/trademark-information.aspx
url: https://www.OneIdentity.com/legal/trademark-information.aspx
title: [ "One Identity Trademark" ]

sn-ccanndw-license:
Expand Down
61 changes: 32 additions & 29 deletions _plugins/generate_tooltips.rb
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,10 @@ class << self

def add_matching_files(file_names, folder_path, pattern)
fullPattern = File.join(folder_path, '*') #pattern

# NOTE: This is not a real reg-exp https://docs.ruby-lang.org/en/master/Dir.html#method-c-glob
# and actually, how it works is a mess
# Trying to use a manual solution instead, filtering * with useable regex
# Trying to use a manual solution instead, filtering * with useable regex
Dir.glob(fullPattern, File::FNM_EXTGLOB).each do |file|
if file.match?(pattern)
#puts "match: " + file
Expand All @@ -33,15 +33,15 @@ def save_from_markdownify(text)
text = text.gsub(/\|/, "&#124;") # |
end

def is_external_url?(url)
def is_prefixed_url?(url)
if url =~ %r{^\w+://}
return true
end
return false
end

def prefixed_url(url, base_url)
if false == is_external_url?(url)
if false == is_prefixed_url?(url)
url = base_url + url
end
return url
Expand All @@ -58,12 +58,15 @@ def make_tooltip(page, page_links, id, url, needs_tooltip, match)
url = page_links[id]["url"]
url = prefixed_url(url, page.site.config["baseurl"])
end

external_url = is_external_url?(url)

# NOTE: Now we treat every link that has protocol prefix part as an external one
# that allows usage of direct links anywhere if needed (not recommended, plz use external_links.yml instead)
# but, at the same time requires e.g. all the really external links to be fully qualified (even in external_links.yml as well)
external_url = is_prefixed_url?(url)
match = save_from_markdownify(match)
replacement_text = '<a href="' + url + '" class="nav-link' + (needs_tooltip ? ' content-tooltip' : '') + '"' + (external_url ? ' target="_blank"' : '') + '>' + match + '</a>'
puts "replacement_text: " + replacement_text

return replacement_text
end

Expand Down Expand Up @@ -97,14 +100,14 @@ def process_markdown_parts(page, markdown)
# Split the content by special Markdown blocks
markdown_parts = markdown.split(special_markdown_blocks_pattern)
#puts markdown_parts
markdown_parts.each_with_index do |markdown_part, markdown_index|
markdown_parts.each_with_index do |markdown_part, markdown_index|
#puts "---------------\nmarkdown_index: " + markdown_index.to_s + "\n" + (markdown_index.even? ? "NONE " : "") + "markdown_part: " + markdown_part

page.data["page_links_ids_sorted_by_title"].each do |page_titles_data|
#puts "page_titles_data: #{page_titles_data}"

id = page_titles_data["id"]

link_data = page_links[id]
# id = link_data["id"] these must match too
title = page_titles_data["title"] # link_data["title"] is an array of titles that all must be already in the page_links_ids_sorted_by_title array
Expand All @@ -118,14 +121,14 @@ def process_markdown_parts(page, markdown)
pattern = pattern.gsub('\ ', '[\s]+')
#puts "searching for #{pattern}"

if markdown_index.even?
if markdown_index.even?
# Content outside of special Markdown blocks, aka. pure text (NOTE: Also excludes the reqursively self added <a ...>title</a> tooltips/links)

# Search for known link titles
# NOTE: Using multi line matching here will not help either if the pattern itself is in the middle broken/spaned to multiple lines, so using whitespace replacements now inside the patter to handle this, see above!
full_pattern = /(^|[\s.,;:&'(])(#{pattern})([\s.,;:&')]|\z)(?![^<]*?<\/a>)/
markdown_part = process_markdown_part(page, markdown_part, page_links, full_pattern, id, url, needs_tooltip, true)
else
else
# Content inside of special Markdown blocks

# Handle own auto tooltip links [[ ]], [[ | ]], [[ |id ]]
Expand Down Expand Up @@ -168,7 +171,7 @@ def write_to_file(file_path, content)
file.write(content)
end
end

def process_nav_link_items(items, ndx, nav_links_dictionary)
items.each do |item|
item['nav_ndx'] = ndx
Expand All @@ -182,14 +185,14 @@ def process_nav_link_items(items, ndx, nav_links_dictionary)
return ndx
end

def is_excluded_title?(excluded_titles, page_title)
def is_excluded_title?(excluded_titles, page_title)
if excluded_titles and false == excluded_titles.empty?
# exluded list items can be a regex patters here
excluded_titles.each do |title|
title = title.gsub(/\A'|'\z/, '')
pattern = /^#{title}$/
#pattern = Regexp.escape(title)
if page_title.match?(pattern)
if page_title.match?(pattern)
return true
end
end
Expand Down Expand Up @@ -239,7 +242,7 @@ def gen_page_link_data(links_dir, link_files_pattern)
#page_links_dictionary = {}
link_file_names = []
add_matching_files(link_file_names, links_dir, link_files_pattern)

link_file_names.each do |file_name|
#puts file_name
yaml_content = YAML.load_file(file_name)
Expand Down Expand Up @@ -271,7 +274,7 @@ def gen_page_link_data(links_dir, link_files_pattern)
}

# Add the page_link_data object to the ID dictionary
# NOTE: Title duplications are allowed now [[title|id]] format must be used
# NOTE: Title duplications are allowed now [[title|id]] format must be used
# to get the propwer matching tooltip for duplicated title items
page_links_dictionary[page_id] = page_link_data
end
Expand Down Expand Up @@ -341,8 +344,8 @@ def JekyllTooltipGen_debug_page_info(page, details = true)
def JekyllTooltipGen_debug_filter_pages?(page)
debug_pages = {
# "doc/README.md" => true,
}
debug_ok = true
}
debug_ok = true
# Comment this line out if not debugging!!!
# debug_ok = (debug_pages[page.relative_path] != nil && debug_pages[page.relative_path])
return debug_ok
Expand All @@ -362,15 +365,15 @@ def JekyllTooltipGen_hack_description_in(page_has_subtitle, page_has_description
if page_has_description || page_has_subtitle
# NOTE: Additional line breaks are essential here otherwise special constructs like tables, liquid notice or code block, etc. might break
# Added double \n\n just to be prepared for the case if there's no \n at all at the file ending
page.content = page.content + "\n\n" + desc_hack_separator + description
page.content = page.content + "\n\n" + desc_hack_separator + description
end
end

def JekyllTooltipGen_hack_description_out(page_has_subtitle, page_has_description, page, desc_hack_separator)
description = nil

content_parts = page.content.split(desc_hack_separator)
content_parts.each_with_index do |content_part, content_part_index|
content_parts.each_with_index do |content_part, content_part_index|
#puts "---------------\ncontent_part_index: " + content_part_index.to_s + "\ncontent_part: " + content_part
if content_part_index.even?
page.content = content_part
Expand Down Expand Up @@ -412,7 +415,7 @@ def JekyllTooltipGen_hack_description_out(page_has_subtitle, page_has_descriptio

# 1st pass
#
# This is used now to
# This is used now to
# - set the page nav_ndx correctly to support our custom bottom collection elements navigator
# - set additional page data elements that will be used during all the passes
#
Expand All @@ -424,7 +427,7 @@ def JekyllTooltipGen_hack_description_out(page_has_subtitle, page_has_descriptio
$JekyllTooltipGen_should_build_tooltips = (ENV['JEKYLL_BUILD_TOOLTIPS'] == 'yes')
$JekyllTooltipGen_should_build_persistent_tooltips = (ENV['JEKYLL_BUILD_PERSISTENT_TOOLTIPS'] == 'yes')
end
next if false == $JekyllTooltipGen_should_build_tooltips
next if false == $JekyllTooltipGen_should_build_tooltips

if $JekyllTooltipGen_markdown_extensions == nil
$JekyllTooltipGen_markdown_extensions = site.config['markdown_ext'].split(',').map { |ext| ".#{ext.strip}" }
Expand All @@ -443,25 +446,25 @@ def JekyllTooltipGen_hack_description_out(page_has_subtitle, page_has_descriptio

next if false == $JekyllTooltipGen_markdown_extensions.include?(File.extname(page.relative_path)) && File.extname(page.relative_path) != ".html"

page_url = page.url.gsub(/\.[^.]+$/, '')
page_url = page.url.gsub(/\.[^.]+$/, '')
if (link_data = $JekyllTooltipGen_nav_links[page_url]) != nil
page.data['nav_ndx'] = link_data['nav_ndx'] # page_pagination.html will use this as sort value for navigation ordering
end
page.data["page_links"] = $JekyllTooltipGen_page_links
page.data["page_links_ids_sorted_by_title"] = $JekyllTooltipGen_page_links_ids_sorted_by_title
# puts "collection: " + (page.respond_to?(:collection) ? page.collection.label : "") + ", nav_ndx: " + (link_data != nil ? link_data['nav_ndx'].to_s : "") + ", page_url: #{page_url}, page: #{page.relative_path}"
# puts "collection: " + (page.respond_to?(:collection) ? page.collection.label : "") + ", nav_ndx: " + (link_data != nil ? link_data['nav_ndx'].to_s : "") + ", page_url: #{page_url}, page: #{page.relative_path}"
end
end
end

# 2nd pass
#
# This is used now to
# This is used now to
# - add the description to the page end to get it rendred correclty the same way, together with the page content (will be removed/handled in the 3rd pass)
# - render the page content manually and create the autolinks and tooltips
#
Jekyll::Hooks.register [:pages, :documents], :pre_render do |page, payload|
next if false == $JekyllTooltipGen_should_build_tooltips
next if false == $JekyllTooltipGen_should_build_tooltips
next if false == $JekyllTooltipGen_markdown_extensions.include?(File.extname(page.relative_path)) && File.extname(page.relative_path) != ".html"
next if false == JekyllTooltipGen_debug_filter_pages?(page)

Expand All @@ -487,14 +490,14 @@ def JekyllTooltipGen_hack_description_out(page_has_subtitle, page_has_descriptio

# 3rd pass
#
# This is used now to
# This is used now to
# - remove the added hackish description block from the page end and replace the description with the now correctly rendered one
#
Jekyll::Hooks.register [:pages, :documents], :post_convert do |page|
next if false == $JekyllTooltipGen_should_build_tooltips
next if false == $JekyllTooltipGen_markdown_extensions.include?(File.extname(page.relative_path)) && File.extname(page.relative_path) != ".html"
next if false == JekyllTooltipGen_debug_filter_pages?(page)

page_has_subtitle = (page.data["subtitle"] && false == page.data["subtitle"].empty?)
page_has_description = (page.data["description"] && false == page.data["description"].empty?)
JekyllTooltipGen_hack_description_out(page_has_subtitle, page_has_description, page, JekyllTooltipGen_desc_hack_separator)
Expand Down
8 changes: 4 additions & 4 deletions doc/404.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
---
title: 404 - Page Not Found
description: >-
Uh oh!</br>
Houston, we have a problem... This page seems to be lost in space.
id: 404
permalink: /404
layout: single
toc: false
search: false
---

Uh oh!\
Houston, we have a problem... This page seems to be lost in space.

![404 - Lost In Space]({{img_folder}}/lost_in_space.png){: .align-center}

Fear not, intrepid traveler!
Fear not, intrepid traveler!\
Here are a few ways to escape this digital abyss:

> * Check the URL again. Typos happen to the best of us!
Expand Down