Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-docs.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAchilleas Pipinellis <axil@gitlab.com>2018-03-19 19:25:37 +0300
committerAchilleas Pipinellis <axil@gitlab.com>2018-03-19 19:25:37 +0300
commit9ccc6234db3aad99e96845033b1544862fca642e (patch)
treebabf57b61bc2a6f056fc702eb77764b2efa6f445
parentc45d65f0210bc74b8691cd942c69b84a5fba8ef7 (diff)
Fix head and move canonical URLs to own layout
-rw-r--r--layouts/canonical_urls.html35
-rw-r--r--layouts/default.html110
-rw-r--r--layouts/head.html34
3 files changed, 91 insertions, 88 deletions
diff --git a/layouts/canonical_urls.html b/layouts/canonical_urls.html
new file mode 100644
index 00000000..8a3af5d8
--- /dev/null
+++ b/layouts/canonical_urls.html
@@ -0,0 +1,35 @@
+<% if false %>
+This is a comment!
+Implement canonical links https://gitlab.com/gitlab-com/gitlab-docs/issues/167
+We want to:
+- All index.html and README.html files stripped
+- Replace ce/ with ee/
+------------------
+if the link ends with README.md or index.md
+ if the link starts with ce
+ replace it with ee and strip README.md or index.md
+ if the link doesn't start with ce
+ strip README.md or index.md
+if the link doesn't end with README.md or index.md
+ if the link starts with ce
+ replace it with ee
+ if the link doesn't start with ce
+ use its initial path
+<% end %>
+<% if ENV['NANOC_ENV'] == 'production' %>
+ <% if (@item.identifier =~ /(index|README)\.md$/) == 0 %>
+ <% if @item.identifier.to_s.split('/')[1] == 'ce' %>
+ <link rel="canonical" href="<%= @config[:base_url] %>/ee/<%= @item.identifier.to_s.split('/')[2..-2].join('/') %><% unless @item.identifier.to_s.split('/')[2..-2].join('/').length == 0 %>/<% end %>" />
+ <% else %>
+ <link rel="canonical" href="<%= @config[:base_url] %><%= @item.identifier.to_s.split('/')[0..-2].join('/') %>/" />
+ <% end %>
+ <% else %>
+ <% if @item.identifier.to_s.split('/')[1] == 'ce' %>
+ <link rel="canonical" href="<%= @config[:base_url] %>/ee/<%= @item.identifier.without_ext.to_s.split('/')[2..-1].join('/') + '.html' %>" />
+ <% elsif @item.identifier.to_s == '/index.erb' %>
+ <link rel="canonical" href="<%= @config[:base_url] %>/" />
+ <% else %>
+ <link rel="canonical" href="<%= @config[:base_url] %><%= @item.identifier.without_ext + '.html' %>" />
+ <% end %>
+ <% end %>
+<% end %>
diff --git a/layouts/default.html b/layouts/default.html
index 37ce5690..bca75f9a 100644
--- a/layouts/default.html
+++ b/layouts/default.html
@@ -1,64 +1,64 @@
<!DOCTYPE HTML>
<html lang="en">
- <body>
- <head>
- <%= render '/head.*' %>
- </head>
- <%= render '/header.*' %>
- <div class="wrapper">
- <div class="main class js-main-wrapper">
- <% if @config[:breadcrumbs] %>
- <% ancestor_array = ancestor_path_array(@item) unless ancestor_path_array(@item).empty? %>
- <% if ancestor_array %>
- <ul class="breadcrumbs">
- <% ancestor_array.reverse_each do |item| %>
- <li class="breadcrumb"><%= link_to item.key?(:title) ? "#{item[:title]}" : "Breadcrumb", item %></li>
- <% end %>
- <li class="breadcrumb"><%= @item.key?(:title) ? "#{@item[:title]}" : "Current page" %></li>
- </ul>
- <% end %>
- <% end %>
- <div id="doc-nav" class="doc-nav">
- </div>
- <% if @item[:title] %>
- <h1 class="article-title">
- <%= @item[:title] %>
- </h1>
- <% end %>
- <% if @item[:author] %>
- <div class="article-metadata">
- Article written by <a href="https://gitlab.com/<%= @item[:author_gitlab] %>" target="_blank"><%= @item[:author] %></a>
- on <%= @item[:date] %>
- &#8226;
- <% if @item[:last_updated] %>
- Last updated: <%= @item[:last_updated] %>
- &#8226;
+<head>
+<%= render '/head.*' %>
+</head>
+<body>
+ <%= render '/header.*' %>
+ <div class="wrapper">
+ <div class="main class js-main-wrapper">
+ <% if @config[:breadcrumbs] %>
+ <% ancestor_array = ancestor_path_array(@item) unless ancestor_path_array(@item).empty? %>
+ <% if ancestor_array %>
+ <ul class="breadcrumbs">
+ <% ancestor_array.reverse_each do |item| %>
+ <li class="breadcrumb"><%= link_to item.key?(:title) ? "#{item[:title]}" : "Breadcrumb", item %></li>
<% end %>
- Type: <%= @item[:article_type] %>
- &#8226;
- Level: <%= @item[:level] %>
- </div>
+ <li class="breadcrumb"><%= @item.key?(:title) ? "#{@item[:title]}" : "Current page" %></li>
+ </ul>
<% end %>
- <div class="article-content js-article-content">
- <%= yield %>
- </div>
- <div class="edit-on">
- <%= edit_on_gitlab(@item) %>
+ <% end %>
+ <div id="doc-nav" class="doc-nav">
+ </div>
+ <% if @item[:title] %>
+ <h1 class="article-title">
+ <%= @item[:title] %>
+ </h1>
+ <% end %>
+ <% if @item[:author] %>
+ <div class="article-metadata">
+ Article written by <a href="https://gitlab.com/<%= @item[:author_gitlab] %>" target="_blank"><%= @item[:author] %></a>
+ on <%= @item[:date] %>
+ &#8226;
+ <% if @item[:last_updated] %>
+ Last updated: <%= @item[:last_updated] %>
+ &#8226;
+ <% end %>
+ Type: <%= @item[:article_type] %>
+ &#8226;
+ Level: <%= @item[:level] %>
</div>
- <% if @item[:last_updated] %>
- <hr>
- <p class="last-updated">
- <em>Last updated <%= @item[:last_updated] %></em>
- </p>
- <% end %>
- <%= render '/disqus.*' %>
+ <% end %>
+ <div class="article-content js-article-content">
+ <%= yield %>
+ </div>
+ <div class="edit-on">
+ <%= edit_on_gitlab(@item) %>
</div>
- <div class="clear"></div>
+ <% if @item[:last_updated] %>
+ <hr>
+ <p class="last-updated">
+ <em>Last updated <%= @item[:last_updated] %></em>
+ </p>
+ <% end %>
+ <%= render '/disqus.*' %>
</div>
+ <div class="clear"></div>
+ </div>
- <%= render '/footer.*' %>
- <%= render '/docsearch.*' %>
- <%= render '/analytics.*' %>
- <%= render '/https_redirect.*' %>
- </body>
+ <%= render '/footer.*' %>
+ <%= render '/docsearch.*' %>
+ <%= render '/analytics.*' %>
+ <%= render '/https_redirect.*' %>
+</body>
</html>
diff --git a/layouts/head.html b/layouts/head.html
index 6211623a..c94993da 100644
--- a/layouts/head.html
+++ b/layouts/head.html
@@ -5,39 +5,7 @@
<% else %>
<meta name="description" content="Documentation for GitLab Community Edition, GitLab Enterprise Edition, Omnibus GitLab, and GitLab Runner.">
<% end %>
-<% if false %>
-This is a comment!
-Implement canonical links https://gitlab.com/gitlab-com/gitlab-docs/issues/167
-We want to:
-- All index.html and README.html files stripped
-- Replace ce/ with ee/
-------------------
-if the link ends with README.md or index.md
- if the link starts with ce
- replace it with ee and strip README.md or index.md
- if the link doesn't start with ce
- strip README.md or index.md
-if the link doesn't end with README.md or index.md
- if the link starts with ce
- replace it with ee
- if the link doesn't start with ce
- use its initial path
-<% end %>
-<% if ENV['NANOC_ENV'] == 'production' %>
- <% if (@item.identifier =~ /(index|README)\.md$/) == 0 %>
- <% if @item.identifier.to_s.split('/')[1] == 'ce' %>
- <link rel="canonical" href="<%= @config[:base_url] %>/ee/<%= @item.identifier.to_s.split('/')[2..-2].join('/') %><% unless @item.identifier.to_s.split('/')[2..-2].join('/').length == 0 %>/<% end %>" />
- <% else %>
- <link rel="canonical" href="<%= @config[:base_url] %><%= @item.identifier.to_s.split('/')[0..-2].join('/') %>/" />
- <% end %>
- <% else %>
- <% if @item.identifier.to_s.split('/')[1] == 'ce' %>
- <link rel="canonical" href="<%= @config[:base_url] %>/ee/<%= @item.identifier.without_ext.to_s.split('/')[2..-1].join('/') + '.html' %>" />
- <% else %>
- <link rel="canonical" href="<%= @config[:base_url] %><%= @item.identifier.without_ext + '.html' %>" />
- <% end %>
- <% end %>
-<% end %>
+<%= render '/canonical_urls.*' %>
<link rel="stylesheet" href="<%= @items['/assets/stylesheets/bootstrap.min.*'].path %>">
<link rel="stylesheet" href="<%= @items['/assets/stylesheets/font-awesome.min.*'].path %>">
<link rel="stylesheet" href="<%= @items['/assets/stylesheets/stylesheet.*'].path %>">