diff options
author | Marshall Cottrell <mcottrell@gitlab.com> | 2022-11-15 22:01:51 +0300 |
---|---|---|
committer | Suzanne Selhorn <sselhorn@gitlab.com> | 2022-11-15 22:01:51 +0300 |
commit | 663bbcf184fa94aa9e0e6af5b3fd4f77504ea0fb (patch) | |
tree | 6a8e70facfea59b93a9e8ce6985dee6d6dd39584 /lib | |
parent | 6888659a51e362d289198694cfb6d58c33deadb7 (diff) |
Automatically add legal disclaimer to architecture blueprints
Diffstat (limited to 'lib')
-rw-r--r-- | lib/filters/admonition.rb | 24 | ||||
-rw-r--r-- | lib/helpers/admonition.rb | 39 | ||||
-rw-r--r-- | lib/helpers_.rb | 1 |
3 files changed, 41 insertions, 23 deletions
diff --git a/lib/filters/admonition.rb b/lib/filters/admonition.rb index e88267bd..703e553c 100644 --- a/lib/filters/admonition.rb +++ b/lib/filters/admonition.rb @@ -4,22 +4,6 @@ class AdmonitionFilter < Nanoc::Filter identifier :admonition - BOOTSTRAP_MAPPING = { - 'note' => 'note', - 'warning' => 'warning', - 'flag' => 'flag', - 'info' => 'info', - 'disclaimer' => 'disclaimer' - }.freeze - - GITLAB_SVGS_MAPPING = { - 'note' => 'information-o', - 'warning' => 'warning', - 'flag' => 'flag', - 'info' => 'tanuki', - 'disclaimer' => 'review-warning' - }.freeze - def run(content, params = {}) # `#dup` is necessary because `.fragment` modifies the incoming string. Ew! # See https://github.com/sparklemotion/nokogiri/issues/1077 @@ -29,15 +13,9 @@ class AdmonitionFilter < Nanoc::Filter match = content.match(%r{\A(?<type>NOTE|WARNING|FLAG|INFO|DISCLAIMER):\s?(?<content>.*)\Z}m) next unless match - new_content = generate(match[:type].downcase, match[:content]) + new_content = admonition(match[:type].downcase, match[:content]) para.replace(new_content) end doc.to_s end - - def generate(kind, content) - %(<div class="mt-3 admonition-wrapper #{kind}">) + - %(<div class="admonition admonition-non-dismissable alert alert-#{BOOTSTRAP_MAPPING[kind]}">) + - %(<div>#{icon(GITLAB_SVGS_MAPPING[kind], 16, 'alert-icon')}<div role="alert"><div class="alert-body">#{content}</div></div></div></div></div>) - end end diff --git a/lib/helpers/admonition.rb b/lib/helpers/admonition.rb new file mode 100644 index 00000000..e6df0eca --- /dev/null +++ b/lib/helpers/admonition.rb @@ -0,0 +1,39 @@ +# frozen_string_literal: true + +module Nanoc::Helpers + module Admonition + BOOTSTRAP_MAPPING = { + 'note' => 'note', + 'warning' => 'warning', + 'flag' => 'flag', + 'info' => 'info', + 'disclaimer' => 'disclaimer' + }.freeze + + GITLAB_SVGS_MAPPING = { + 'note' => 'information-o', + 'warning' => 'warning', + 'flag' => 'flag', + 'info' => 'tanuki', + 'disclaimer' => 'review-warning' + }.freeze + + def admonition(kind, content) + kind = kind.downcase + %(<div class="mt-3 admonition-wrapper #{kind}">) + + %(<div class="admonition admonition-non-dismissable alert alert-#{BOOTSTRAP_MAPPING[kind]}">) + + %(<div>#{icon(GITLAB_SVGS_MAPPING[kind], 16, 'alert-icon')}<div role="alert"><div class="alert-body">#{content}</div></div></div></div></div>) + end + + def legal_disclaimer + admonition('DISCLAIMER', " +This page contains information related to upcoming products, features, and functionality. +It is important to note that the information presented is for informational purposes only. +Please do not rely on this information for purchasing or planning purposes. +As with all projects, the items mentioned on this page are subject to change or delay. +The development, release, and timing of any products, features, or functionality remain at the +sole discretion of GitLab Inc. + ") + end + end +end diff --git a/lib/helpers_.rb b/lib/helpers_.rb index cb831720..0af3ec3f 100644 --- a/lib/helpers_.rb +++ b/lib/helpers_.rb @@ -1,6 +1,7 @@ # frozen_string_literal: true use_helper Nanoc::Helpers::AlgoliaRank +use_helper Nanoc::Helpers::Admonition use_helper Nanoc::Helpers::Blueprints use_helper Nanoc::Helpers::EditOnGitLab use_helper Nanoc::Helpers::Generic |