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 20:29:11 +0300
committerAchilleas Pipinellis <axil@gitlab.com>2018-03-19 20:29:11 +0300
commit33de5dcb765083fe38656c7298b30c7a400546ce (patch)
treeee1617461dbc0b8912f1bd55adb0ae952668da0a
parentc45d65f0210bc74b8691cd942c69b84a5fba8ef7 (diff)
parent8fb03cce3565c3454eacabbbdfbf0478bdcbaf18 (diff)
Merge branch 'head-fix' into 'master'
Fix head and move canonical URLs to own layout See merge request gitlab-com/gitlab-docs!216
-rw-r--r--layouts/404.html2
-rw-r--r--layouts/archives.html1
-rw-r--r--layouts/canonical_urls.html35
-rw-r--r--layouts/default.html111
-rw-r--r--layouts/head.html33
-rw-r--r--layouts/home.html1
-rw-r--r--layouts/instantsearch.html1
7 files changed, 96 insertions, 88 deletions
diff --git a/layouts/404.html b/layouts/404.html
index a211920b..89b7ba1f 100644
--- a/layouts/404.html
+++ b/layouts/404.html
@@ -2,6 +2,8 @@
<html lang="en">
<head>
<%= render '/head.*' %>
+ <meta name="robots" content="noindex">
+ <link rel="canonical" href="<%= @config[:base_url] %>/404.html">
<link rel="stylesheet" href="<%= @items['/assets/stylesheets/404.*'].path %>">
</head>
<body>
diff --git a/layouts/archives.html b/layouts/archives.html
index 7ffb8cca..a77bf497 100644
--- a/layouts/archives.html
+++ b/layouts/archives.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<%= render '/head.*' %>
+ <link rel="canonical" href="<%= @config[:base_url] %>/archives.html">
</head>
<body>
<%= render '/header.*' %>
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..d09455d9 100644
--- a/layouts/default.html
+++ b/layouts/default.html
@@ -1,64 +1,65 @@
<!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.*' %>
+<%= render '/canonical_urls.*' %>
+</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..09c8b5c9 100644
--- a/layouts/head.html
+++ b/layouts/head.html
@@ -5,39 +5,6 @@
<% 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 %>
<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 %>">
diff --git a/layouts/home.html b/layouts/home.html
index 3c33a9f9..6d1f1472 100644
--- a/layouts/home.html
+++ b/layouts/home.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<%= render '/head.*' %>
+ <link rel="canonical" href="<%= @config[:base_url] %>/">
</head>
<body class="landing">
<div class="landing-header">
diff --git a/layouts/instantsearch.html b/layouts/instantsearch.html
index 17566a96..58da4541 100644
--- a/layouts/instantsearch.html
+++ b/layouts/instantsearch.html
@@ -2,6 +2,7 @@
<html lang="en">
<head>
<%= render '/head.*' %>
+ <link rel="canonical" href="<%= @config[:base_url] %>/search/">
<!-- instantsearch -->
<link rel="stylesheet" href="<%= @items['/assets/stylesheets/instantsearch.*'].path %>">
<link rel="stylesheet" type="text/css" href="https://cdn.jsdelivr.net/npm/instantsearch.js@2.5.0/dist/instantsearch-theme-algolia.min.css">