Skip to content

Commit

Permalink
Improved documentation versioning (#3569)
Browse files Browse the repository at this point in the history
* add navbar-version-selector.html

* update site/build_docs.py

* update site/build_docs.py

* update _index.html and fix mistakes in config.toml

* fix _index.html

* replace all tabs with spaces

* update navbar-version-selector.html

* fix link in the site/readme.md

* replace tabs with spaces in custom.scss and 404.html

* fix linter errors
  • Loading branch information
TOsmanov authored Aug 30, 2021
1 parent 3800a91 commit 35f5be2
Show file tree
Hide file tree
Showing 8 changed files with 58 additions and 44 deletions.
2 changes: 1 addition & 1 deletion site/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ To build and preview your site locally, use:
cd <your local directory>/cvat/site/
hugo server

By default, your site will be available at <http://localhost:1313/>.
By default, your site will be available at <http://localhost:1313/docs/>.

Instead of a "hugo server" command, you can use the "hugo" command that generates the site into a "public" folder.

Expand Down
3 changes: 2 additions & 1 deletion site/build_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,8 @@ def run_hugo(content_loc, destination_dir):

generate_versioning_config(os.path.join(cwd, 'site', 'versioning.toml'), (t.name for t in tags), '/..')
for tag in tags:
repo.git.checkout(tag.name)
repo.git.checkout(tag.name, '--', 'site/content/en/docs')
repo.git.checkout(tag.name, '--', 'site/content/en/images')
destination_dir = os.path.join(output_dir, tag.name)
os.makedirs(destination_dir)
run_hugo(content_loc, destination_dir)
Expand Down
2 changes: 1 addition & 1 deletion site/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ anchor = "smart"
[services]
[services.googleAnalytics]
# Comment out the next line to disable GA tracking. Also disables the feature described in [params.ui.feedback].
id = "UA-00000000-0"
# id = "UA-00000000-0"

# Language configuration

Expand Down
2 changes: 2 additions & 0 deletions site/content/en/_index.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
linkTitle = "Home"
+++

<meta http-equiv="refresh" content="0; URL=/cvat/about">

{{< blocks/section height="full" color="docs" >}}

<section id="temporary-page" class="mx-auto text-center py-5">
Expand Down
14 changes: 7 additions & 7 deletions site/layouts/404.html
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
{{ define "main"}}
<main id="main">
<div class="text-center">
<h1>404</h1>
<p>Not found</p>
<p>Oops! This page doesn't exist. Try going back to our <a href="./about">about page</a> or <a href="./docs">documentation page</a>.</p>
</div>
</main>
<main id="main">
<div class="text-center">
<h1>404</h1>
<p>Not found</p>
<p>Oops! This page doesn't exist. Try going back to our <a href="./about">about page</a> or <a href="./docs">documentation page</a>.</p>
</div>
</main>
{{ end }}
6 changes: 3 additions & 3 deletions site/layouts/partials/footer.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,9 @@
<div class="footer-disclaimer text-white ">
<small>Intel technologies may require enabled hardware, software or service activation. // No product or component can be absolutely secure. // Your costs and results may vary. // Performance varies by use, configuration and other factors. // See our complete legal <u><a href="https://edc.intel.com/content/www/us/en/products/performance/benchmarks/overview/?r=219444055">Notices and Disclaimers</a></u>. // Intel is committed to respecting human rights and avoiding complicity in human rights abuses. See Intel’s <a href="https://www.intel.com/content/www/us/en/policy/policy-human-rights.html"><u>Global Human Rights Principles</u></a>. Intel’s products and software are intended only to be used in applications that do not cause or contribute to a violation of an internationally recognized human right.</small>
</div>
{{ if not .Site.Params.ui.footer_about_disable }}
{{ with .Site.GetPage "about" }}<p class="mt-2"><a href="{{ .RelPermalink }}">{{ .Title }}</a></p>{{ end }}
{{ end }}
{{ if not .Site.Params.ui.footer_about_disable }}
{{ with .Site.GetPage "about" }}<p class="mt-2"><a href="{{ .RelPermalink }}">{{ .Title }}</a></p>{{ end }}
{{ end }}
</div>
</div>
</div>
Expand Down
11 changes: 11 additions & 0 deletions site/layouts/partials/navbar-version-selector.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{{ $page_rel := .Page.RelPermalink | safeURL }}
{{ $page_rel_trim := strings.TrimLeft "/" $page_rel | safeURL }}
<a class="nav-link dropdown-toggle" href="#" id="navbarDropdown" role="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
{{ .Site.Params.version_menu }}
</a>
<div class="dropdown-menu" aria-labelledby="navbarDropdownMenuLink">
{{ range .Site.Params.versions }}
{{ $ver := .version }}
<a class="dropdown-item" href="{{ .url }}{{ if eq $ver "develop" }}{{ $page_rel_trim }}{{ else }}{{ $page_rel }}{{ end }}">{{ $ver }}</a>
{{ end }}
</div>
62 changes: 31 additions & 31 deletions site/layouts/partials/navbar.html
Original file line number Diff line number Diff line change
@@ -1,35 +1,35 @@
{{ $cover := .HasShortcode "blocks/cover" }}
<nav class="js-navbar-scroll navbar navbar-expand navbar-dark {{ if $cover}} td-navbar-cover {{ end }}flex-column flex-md-row td-navbar">
<a class="navbar-brand" href="{{ .Site.Home.RelPermalink }}about/">
<span class="navbar-logo">{{ if .Site.Params.ui.navbar_logo }}{{ with resources.Get "icons/logo.svg" }}{{ ( . | minify).Content | safeHTML }}{{ end }}{{ end }}</span>
</a>
<div class="td-navbar-nav-scroll ml-md-auto" id="main_navbar">
<ul class="navbar-nav mt-2 mt-lg-0">
{{ $p := . }}
{{ range .Site.Menus.main }}
<li class="nav-item mr-4 mb-2 mb-lg-0">
{{ $active := or ($p.IsMenuCurrent "main" .) ($p.HasMenuCurrent "main" .) }}
{{ with .Page }}
{{ $active = or $active ( $.IsDescendant .) }}
{{ end }}
{{ $pre := .Pre }}
{{ $post := .Post }}
{{ $url := urls.Parse .URL }}
{{ $baseurl := urls.Parse $.Site.Params.Baseurl }}
<a class="nav-link{{if $active }} active{{end}}" href="{{ with .Page }}{{ .RelPermalink }}{{ else }}{{ .URL | relLangURL }}{{ end }}" {{ if ne $url.Host $baseurl.Host }}target="_blank" {{ end }}>{{ with .Pre}}{{ $pre }}{{ end }}<span{{if $active }} class="active"{{end}}>{{ .Name }}</span>{{ with .Post}}{{ $post }}{{ end }}</a>
</li>
{{ end }}
{{ if .Site.Params.versions }}
<li class="nav-item dropdown d-none d-lg-block">
{{ partial "navbar-version-selector.html" . }}
</li>
{{ end }}
{{ if (gt (len .Site.Home.Translations) 0) }}
<li class="nav-item dropdown d-none d-lg-block">
{{ partial "navbar-lang-selector.html" . }}
</li>
{{ end }}
</ul>
</div>
<div class="navbar-nav d-none d-lg-block">{{ partial "search-input.html" . }}</div>
<span class="navbar-logo">{{ if .Site.Params.ui.navbar_logo }}{{ with resources.Get "icons/logo.svg" }}{{ ( . | minify).Content | safeHTML }}{{ end }}{{ end }}</span>
</a>
<div class="td-navbar-nav-scroll ml-md-auto" id="main_navbar">
<ul class="navbar-nav mt-2 mt-lg-0">
{{ $p := . }}
{{ range .Site.Menus.main }}
<li class="nav-item mr-4 mb-2 mb-lg-0">
{{ $active := or ($p.IsMenuCurrent "main" .) ($p.HasMenuCurrent "main" .) }}
{{ with .Page }}
{{ $active = or $active ( $.IsDescendant .) }}
{{ end }}
{{ $pre := .Pre }}
{{ $post := .Post }}
{{ $url := urls.Parse .URL }}
{{ $baseurl := urls.Parse $.Site.Params.Baseurl }}
<a class="nav-link{{if $active }} active{{end}}" href="{{ with .Page }}{{ .RelPermalink }}{{ else }}{{ .URL | relLangURL }}{{ end }}" {{ if ne $url.Host $baseurl.Host }}target="_blank" {{ end }}>{{ with .Pre}}{{ $pre }}{{ end }}<span{{if $active }} class="active"{{end}}>{{ .Name }}</span>{{ with .Post}}{{ $post }}{{ end }}</a>
</li>
{{ end }}
{{ if .Site.Params.versions }}
<li class="nav-item dropdown d-none d-lg-block">
{{ partial "navbar-version-selector.html" . }}
</li>
{{ end }}
{{ if (gt (len .Site.Home.Translations) 0) }}
<li class="nav-item dropdown d-none d-lg-block">
{{ partial "navbar-lang-selector.html" . }}
</li>
{{ end }}
</ul>
</div>
<div class="navbar-nav d-none d-lg-block">{{ partial "search-input.html" . }}</div>
</nav>

0 comments on commit 35f5be2

Please sign in to comment.