diff options
author | Sarah German <sgerman@gitlab.com> | 2022-11-09 00:22:59 +0300 |
---|---|---|
committer | Sarah German <sgerman@gitlab.com> | 2022-11-09 00:22:59 +0300 |
commit | 86e9c57c1b2c5b7946d0b2e44dcf489b7786228d (patch) | |
tree | b547772027aee106a393f7448f3c2675c5979189 | |
parent | 3482c8f44aa701e2b4ec68f38ff88207e17e183c (diff) | |
parent | 1ae27a79d2086275b5ca3a1f60c5d67103dbadcb (diff) |
Merge branch 'marshall_blueprints-index' into 'main'
Add layout and styling for blueprint index page
Closes #1301
See merge request https://gitlab.com/gitlab-org/gitlab-docs/-/merge_requests/3205
Merged-by: Sarah German <sgerman@gitlab.com>
Approved-by: Sarah German <sgerman@gitlab.com>
Co-authored-by: Achilleas Pipinellis <axil@gitlab.com>
Co-authored-by: Marshall Cottrell <mcottrell@gitlab.com>
-rw-r--r-- | Rules | 11 | ||||
-rw-r--r-- | content/assets/stylesheets/labels.scss | 26 | ||||
-rw-r--r-- | content/assets/stylesheets/stylesheet.scss | 1 | ||||
-rw-r--r-- | layouts/blueprints/index.erb | 15 | ||||
-rw-r--r-- | layouts/blueprints/table.erb | 53 | ||||
-rw-r--r-- | lib/helpers/blueprints.rb | 33 | ||||
-rw-r--r-- | lib/helpers_.rb | 2 |
7 files changed, 141 insertions, 0 deletions
@@ -6,6 +6,9 @@ TITLE_FILTER_REGEXP = /(#\s|#{BadgesFilter::BADGES_MARKDOWN_PATTERN})/.freeze preprocess do badges_filter = BadgesFilter.new + # Do not process Markdown files with an underscore prefix + @items.delete_if { |i| i.identifier.match?('/**/_*.md') } + @items.each do |item| if item.identifier.to_s.end_with?(".md") && !item.binary? # If there isn't already a 'redirect_to' defined in the yaml frontmatter, @@ -38,6 +41,14 @@ preprocess do # Run badges filter with title fragment item[:title_badge] = badges_filter.run_from_markdown(raw_title.match(BadgesFilter::BADGES_MARKDOWN_PATTERN).to_s) end + + if item.identifier.match?('/ee/architecture/**/*.md') + item[:layout] = 'blueprints/index' + item[:feedback] = false + item[:comments] = false + + item[:status] ||= 'proposed' + end end config[:algolia] = ENV['ALGOLIA_SEARCH'] || 'true' diff --git a/content/assets/stylesheets/labels.scss b/content/assets/stylesheets/labels.scss new file mode 100644 index 00000000..34b29e86 --- /dev/null +++ b/content/assets/stylesheets/labels.scss @@ -0,0 +1,26 @@ +.gl-label { + --label-inset-border: inset 0 0 0 2px var(--label-background-color); + color: var(--white); + font-size: .75rem; + line-height: 1rem; + + &.devops { + --label-background-color: var(--orange); + } + + &.proposed { + --label-background-color: var(--gray); + } + &.accepted { + --label-background-color: var(--cyan); + } + &.ready { + --label-background-color: var(--green); + } + &.implemented { + --label-background-color: var(--blue); + } + &.rejected { + --label-background-color: var(--red); + } +}
\ No newline at end of file diff --git a/content/assets/stylesheets/stylesheet.scss b/content/assets/stylesheets/stylesheet.scss index d6fa587f..421786b3 100644 --- a/content/assets/stylesheets/stylesheet.scss +++ b/content/assets/stylesheets/stylesheet.scss @@ -9,6 +9,7 @@ version: 130 @import 'mixins'; @import 'base'; @import 'tables'; +@import 'labels'; @import 'sidebar'; @import 'typography'; @import 'docsearch'; diff --git a/layouts/blueprints/index.erb b/layouts/blueprints/index.erb new file mode 100644 index 00000000..a8542be6 --- /dev/null +++ b/layouts/blueprints/index.erb @@ -0,0 +1,15 @@ +<% render '/default.*' do %> + <% if @item.identifier.match?('/ee/architecture/blueprints/**/*.md') %> + <%= render '/blueprints/table.*', { :blueprints => [ @item ], :summary => true } %> + <%= yield %> + <% else %> + <%= yield %> + + <div class="gl-display-flex gl-justify-content-space-around"> + <% all_blueprints.group_by{ |b| b[:status] }.each do |k,c| %> + <gl-label title="<%= "#{k}::#{c.size.to_s}" %>" /> + <% end %> + </div> + <%= render '/blueprints/table.*', :blueprints => all_blueprints %> + <% end %> +<% end %> diff --git a/layouts/blueprints/table.erb b/layouts/blueprints/table.erb new file mode 100644 index 00000000..fef13030 --- /dev/null +++ b/layouts/blueprints/table.erb @@ -0,0 +1,53 @@ +<% @summary ||= false %> + +<table> + <caption>List of GitLab Architecture Blueprints</caption> + <thead> + <tr> + <th>Status</th> + <% unless @summary %> + <th>Title</th> + <% end %> + <th>Author(s)</th> + <th>Coach</th> + <% if @summary %> + <th>Approver(s)</th> + <% end %> + <th>Owning Stage</th> + <th>Created</th> + </tr> + </thead> + <tbody> + <% @blueprints.each do |b| %> + <tr> + <td> + <%= gl_label(b[:status])%> + </td> + <% unless @summary %> + <td> + <%= link_to(b[:title], b.path) %> + </td> + <% end %> + <td> + <% b[:authors]&.each do |a| %> + <code><%= author_link(a) %></code> + <% end %> + </td> + <td> + <% if b[:coach] %> + <code><%= author_link(b[:coach]) %></code> + <% end %> + </td> + <% if @summary %> + <td> + <% b[:approvers]&.each do |a| %> + <code><%= author_link(a) %></code> + <% end %> + </td> + <% end %> + <td><%= gl_label(b[:'owning-stage']) %></td> + <td><%= blueprint_creation_date(b) %></td> + </tr> + <% end %> + </tbody> +</table> diff --git a/lib/helpers/blueprints.rb b/lib/helpers/blueprints.rb new file mode 100644 index 00000000..2e889732 --- /dev/null +++ b/lib/helpers/blueprints.rb @@ -0,0 +1,33 @@ +# frozen_string_literal: true + +module Nanoc::Helpers + module Blueprints + def all_blueprints + @items.find_all('/ee/architecture/blueprints/**/*.md').sort_by { |i| blueprint_creation_date(i) }.reverse + end + + def author_link(author) + username = author.tr('@', '') + link_to("@#{username}", "https://gitlab.com/#{username}") + end + + def blueprint_creation_date(blueprint) + blueprint[:'creation-date'].nil? ? '-' : Time.parse(blueprint[:'creation-date']).strftime('%Y-%m-%d') + end + + # TODO: this is generic, should live elsewhere + def gl_label(label) + return if label.nil? + + scope, text = label.tr('~', '').split('::') + is_scoped = !text.nil? + + %( + <span class="gl-label #{is_scoped ? 'gl-label-scoped' : ''} #{scope}"> + <span class="gl-label-text">#{scope}</span> + #{%(<span class="gl-label-text-scoped">#{text}</span>) if is_scoped} + </span> + ) + end + end +end diff --git a/lib/helpers_.rb b/lib/helpers_.rb index ed7eaeda..cb831720 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::Blueprints use_helper Nanoc::Helpers::EditOnGitLab use_helper Nanoc::Helpers::Generic use_helper Nanoc::Helpers::GitLabKramdown @@ -9,3 +10,4 @@ use_helper Nanoc::Helpers::ReadingTimeHelper use_helper Nanoc::Helpers::Rendering use_helper Nanoc::Helpers::VersionsDropdown use_helper Nanoc::Helpers::XMLSitemap +use_helper Nanoc::Helpers::LinkTo |