Skip to content

Commit

Permalink
bouton
Browse files Browse the repository at this point in the history
  • Loading branch information
ThibaultGuillaumont committed Dec 19, 2024
1 parent 4bde499 commit 9116d0f
Show file tree
Hide file tree
Showing 5 changed files with 360 additions and 122 deletions.
227 changes: 120 additions & 107 deletions _layouts/default.html
Original file line number Diff line number Diff line change
@@ -1,113 +1,126 @@
<!DOCTYPE html>
{%- assign lang = page.lang | default: "fr" -%}
<html lang="{{lang}}">
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="utf-8">
<title>{{ page.title }} - {{ site.title }}</title>

<link rel="icon" type="image/png" href="/assets/img/logo-ecorpus.png" sizes="64x64">
<link rel="icon" type="image/svg+xml" href="/assets/img/logo-eCorpus.svg" />


{%- if page.description -%}
<meta name="description" content="{{ page.description | strip_html | truncatewords:155|escape }}" />
<meta property="og:description" content="{{page.description | strip_html | truncatewords:297|escape}}"/>
{%- endif -%}

{%- if page.image -%}
<meta property="og:image" content="{{page.image| absolute_url}}"/>
{% elsif page.scene %}
<meta property="og:image" content="https://ecorpus.holusion.com/scenes/{{page.scene}}/scene-image-thumb.jpg"/>
{%- else -%}
<meta property="og:image" content="{{ '/assets/img/og_header.jpg' | absolute_url}}"/>
<meta property="og:image:width" content="1200"/>
<meta property="og:image:height" content="630"/>
{%- endif -%}

{%- if page.lang -%}
{%- if page.lang == "fr" -%}
{%- assign alt_lang = "en" -%}
{%- assign alt_url = page.url | replace_first: "/fr/", "/en/" -%}
{%- else -%}
{%- assign alt_lang = "fr" -%}
{%- assign alt_url = page.url | replace_first: "/en/", "/fr/" -%}
{%- endif -%}
{%- assign alt = site.pages | where:"url", alt_url | first -%}
<meta property="og:locale" content="{{page.lang}}"/>
{%- if alt -%}
<meta rel="alternate" hreflang="{{ page.lang }}" href="{{ page.url | absolute_url }}"/>
<meta rel="alternate" hreflang="{{ alt_lang }}" href="{{ alt_url | absolute_url }}"/>
{%- endif -%}
{%- endif -%}


<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>

<link rel="stylesheet" href="{{ 'assets/css/main.css' | relative_url }}">

<link href="https://fonts.googleapis.com/css2?family=Noto+Serif&display=swap" rel="stylesheet">

<script src="/assets/js/index.js" async></script>
</head>
<body>
<!-- Header -->
<div class="navbar-header">
<button type="button" class="hidden">
<span>Toggle navigation</span>
</button>
<a href="/{{ lang }}/" class="header-brand" aria-label="ecorpus logo">
eCorpus

<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="utf-8">
<title>{{ page.title }} - {{ site.title }}</title>

<link rel="icon" type="image/png" href="/assets/img/logo-ecorpus.png" sizes="64x64">
<link rel="icon" type="image/svg+xml" href="/assets/img/logo-eCorpus.svg" />


{%- if page.description -%}
<meta name="description" content="{{ page.description | strip_html | truncatewords:155|escape }}" />
<meta property="og:description" content="{{page.description | strip_html | truncatewords:297|escape}}" />
{%- endif -%}

{%- if page.image -%}
<meta property="og:image" content="{{page.image| absolute_url}}" />
{% elsif page.scene %}
<meta property="og:image" content="https://ecorpus.holusion.com/scenes/{{page.scene}}/scene-image-thumb.jpg" />
{%- else -%}
<meta property="og:image" content="{{ '/assets/img/og_header.jpg' | absolute_url}}" />
<meta property="og:image:width" content="1200" />
<meta property="og:image:height" content="630" />
{%- endif -%}

{%- if page.lang -%}
{%- if page.lang == "fr" -%}
{%- assign alt_lang = "en" -%}
{%- assign alt_url = page.url | replace_first: "/fr/", "/en/" -%}
{%- else -%}
{%- assign alt_lang = "fr" -%}
{%- assign alt_url = page.url | replace_first: "/en/", "/fr/" -%}
{%- endif -%}
{%- assign alt = site.pages | where:"url", alt_url | first -%}
<meta property="og:locale" content="{{page.lang}}" />
{%- if alt -%}
<meta rel="alternate" hreflang="{{ page.lang }}" href="{{ page.url | absolute_url }}" />
<meta rel="alternate" hreflang="{{ alt_lang }}" href="{{ alt_url | absolute_url }}" />
{%- endif -%}
{%- endif -%}


<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>

<link rel="stylesheet" href="{{ 'assets/css/main.css' | relative_url }}">

<link href="https://fonts.googleapis.com/css2?family=Noto+Serif&display=swap" rel="stylesheet">

<script src="/assets/js/index.js" async></script>
</head>

<body>
<!-- Header -->
<div class="navbar-header">
<button type="button" class="hidden">
<span>Toggle navigation</span>
</button>
<a href="/{{ lang }}/" class="header-brand" aria-label="ecorpus logo">
eCorpus
</a>
<img class="img-header" src="/assets/img/img-bandeau-ecorpus_600.webp"
srcset="/assets/img/img-bandeau-ecorpus_1800.webp 1800w, /assets/img/img-bandeau-ecorpus_1200.webp 1200w, /assets/img/img-bandeau-ecorpus_600.webp 600w"
sizes="70vw" alt="plaque de Gédéon et la toison">
</div>

<nav id="navbar-top" class="navbar navbar-sticky" role="navigation">

<div class="navbar-nav">
<button type="button" class="navbar-toggle menu-btn hidden-large" data-target="#top-nav-content"></button>
<ul role="menu" id="top-nav-content" class="nav-group">
{%- for item in site.data.nav -%}
<li class="nav-item">
<a href="/{{ lang }}/{{ item[0] }}">{{ item[1][page.lang] }}</a>
</li>
{%- endfor -%}
</ul>
</div>
<div class="navbar-nav">
<div class="nav-tuto">
<a href="/{{ lang }}/howto">Tutoriel <br /> eCorpus</a>
</div>
{% include language_picker.html type="nav-item dropdown" classes="nav-link" %}

</div>
</ul>
</nav>
<!-- Page Content -->
{{ content }}
<!-- Footer -->
<footer>
<nav id="navbar-bottom" role="navigation">
<div class="alignement-footer">
<a style="text-decoration: none;" xmlns:dct="http://purl.org/dc/terms/"
href="https://github.com/Holusion/eCorpus" rel="dct:source">
<svg xmlns="http://www.w3.org/2000/svg" style="fill:currentColor" width="24" height="24" viewBox="0 0 24 24">
<path
d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z" />
</svg>
&nbspon&nbsp
<svg xmlns="http://www.w3.org/2000/svg" style="fill:currentColor" width="45" height="16" viewBox="0 0 45 16">
<path
d="M8.81 7.35v5.74c0 .04-.01.11-.06.13 0 0-1.25.89-3.31.89-2.49 0-5.44-.78-5.44-5.92S2.58 1.99 5.1 2c2.18 0 3.06.49 3.2.58.04.05.06.09.06.14L7.94 4.5c0 .09-.09.2-.2.17-.36-.11-.9-.33-2.17-.33-1.47 0-3.05.42-3.05 3.73s1.5 3.7 2.58 3.7c.92 0 1.25-.11 1.25-.11v-2.3H4.88c-.11 0-.19-.08-.19-.17V7.35c0-.09.08-.17.19-.17h3.74c.11 0 .19.08.19.17Zm35.85 2.33c0 3.43-1.11 4.41-3.05 4.41-1.64 0-2.52-.83-2.52-.83s-.04.46-.09.52c-.03.06-.08.08-.14.08h-1.48c-.1 0-.19-.08-.19-.17l.02-11.11c0-.09.08-.17.17-.17h2.13c.09 0 .17.08.17.17v3.77s.82-.53 2.02-.53l-.01-.02c1.2 0 2.97.45 2.97 3.88ZM27.68 2.43c.09 0 .17.08.17.17v11.11c0 .09-.08.17-.17.17h-2.13c-.09 0-.17-.08-.17-.17l.02-4.75h-3.31v4.75c0 .09-.08.17-.17.17h-2.13c-.08 0-.17-.08-.17-.17V2.6c0-.09.08-.17.17-.17h2.13c.09 0 .17.08.17.17v4.09h3.31V2.6c0-.09.08-.17.17-.17Zm8.26 3.64c.11 0 .19.08.19.17l-.02 7.47c0 .09-.06.17-.17.17H34.6c-.07 0-.14-.04-.16-.09-.03-.06-.08-.45-.08-.45s-1.13.77-2.52.77c-1.69 0-2.92-.55-2.92-2.75V6.25c0-.09.08-.17.17-.17h2.14c.09 0 .17.08.17.17V11c0 .75.22 1.09.97 1.09s1.3-.39 1.3-.39V6.26c0-.11.06-.19.17-.19Zm-17.406 5.971h.005a.177.177 0 0 1 .141.179v1.5c0 .07-.03.14-.09.16-.1.05-.74.22-1.27.22-1.16 0-2.86-.25-2.86-2.69V8.13h-1.11c-.09 0-.17-.08-.17-.19V6.58c0-.08.05-.15.13-.17.07-.01 1.16-.28 1.16-.28V3.96c0-.08.05-.13.14-.13h2.16c.09 0 .14.05.14.13v2.11h1.59c.08 0 .16.08.16.17v1.7c0 .11-.07.19-.16.19h-1.59v3.131c0 .47.27.83 1.05.83.247 0 .481-.049.574-.05ZM12.24 6.06c.09 0 .17.08.17.17v7.37c0 .18-.05.27-.25.27h-1.92c-.17 0-.3-.07-.3-.27V6.26c0-.11.08-.2.17-.2Zm29.99 3.78c0-1.81-.73-2.05-1.5-1.97-.6.04-1.08.34-1.08.34v3.52s.49.34 1.22.36c1.03.03 1.36-.34 1.36-2.25ZM11.19 2.68c.75 0 1.36.61 1.36 1.38 0 .77-.61 1.38-1.36 1.38-.77 0-1.38-.61-1.38-1.38 0-.77.61-1.38 1.38-1.38Zm7.34 9.35v.001l.01.01h-.001l-.005-.001v.001c-.009-.001-.015-.011-.024-.011Z" />
</svg>
</a>
<img class="img-header" src="/assets/img/img-bandeau-ecorpus_600.webp"
srcset="/assets/img/img-bandeau-ecorpus_1800.webp 1800w, /assets/img/img-bandeau-ecorpus_1200.webp 1200w, /assets/img/img-bandeau-ecorpus_600.webp 600w"
sizes="70vw"
alt="plaque de Gédéon et la toison">
<span>
<span>&nbspLicensed under</span>
<a rel="license" style="text-decoration:none;" href="http://creativecommons.org/licenses/by-sa/4.0/">
(CC)BY-SA 4.0
</a>
@ <a xmlns:cc="http://creativecommons.org/ns#" href="https://holusion.com" property="cc:attributionName"
rel="cc:attributionURL">holusion SAS</a>
</span>
</div>
</nav>
</footer>

{%- for script in page.scripts -%}
<script src="{{script}}" async></script>
{%- endfor -%}
</body>

<nav id="navbar-top" class="navbar navbar-sticky" role="navigation">

<div class="navbar-nav">
<button type="button" class="navbar-toggle menu-btn hidden-large" data-target="#top-nav-content"></button>
<ul role="menu" id="top-nav-content" class="nav-group">
{%- for item in site.data.nav -%}
<li class="nav-item">
<a href="/{{ lang }}/{{ item[0] }}">{{ item[1][page.lang] }}</a>
</li>
{%- endfor -%}
</ul>
</div>
<li class="nav-tuto">
<a href="/howto">Tutoriel <br/> eCorpus</a>
</li>
{% include language_picker.html type="nav-item dropdown" classes="nav-link" %}
</ul>
</nav>
<!-- Page Content -->
{{ content }}
<!-- Footer -->
<footer>
<nav id="navbar-bottom" role="navigation">
<div class="alignement-footer">
<a style="text-decoration: none;" xmlns:dct="http://purl.org/dc/terms/" href="https://github.com/Holusion/eCorpus" rel="dct:source">
<svg xmlns="http://www.w3.org/2000/svg" style="fill:currentColor" width="24" height="24" viewBox="0 0 24 24"><path d="M15.22 4.97a.75.75 0 0 1 1.06 0l6.5 6.5a.75.75 0 0 1 0 1.06l-6.5 6.5a.749.749 0 0 1-1.275-.326.749.749 0 0 1 .215-.734L21.19 12l-5.97-5.97a.75.75 0 0 1 0-1.06Zm-6.44 0a.75.75 0 0 1 0 1.06L2.81 12l5.97 5.97a.749.749 0 0 1-.326 1.275.749.749 0 0 1-.734-.215l-6.5-6.5a.75.75 0 0 1 0-1.06l6.5-6.5a.75.75 0 0 1 1.06 0Z"/></svg>
&nbspon&nbsp
<svg xmlns="http://www.w3.org/2000/svg" style="fill:currentColor" width="45" height="16" viewBox="0 0 45 16"><path d="M8.81 7.35v5.74c0 .04-.01.11-.06.13 0 0-1.25.89-3.31.89-2.49 0-5.44-.78-5.44-5.92S2.58 1.99 5.1 2c2.18 0 3.06.49 3.2.58.04.05.06.09.06.14L7.94 4.5c0 .09-.09.2-.2.17-.36-.11-.9-.33-2.17-.33-1.47 0-3.05.42-3.05 3.73s1.5 3.7 2.58 3.7c.92 0 1.25-.11 1.25-.11v-2.3H4.88c-.11 0-.19-.08-.19-.17V7.35c0-.09.08-.17.19-.17h3.74c.11 0 .19.08.19.17Zm35.85 2.33c0 3.43-1.11 4.41-3.05 4.41-1.64 0-2.52-.83-2.52-.83s-.04.46-.09.52c-.03.06-.08.08-.14.08h-1.48c-.1 0-.19-.08-.19-.17l.02-11.11c0-.09.08-.17.17-.17h2.13c.09 0 .17.08.17.17v3.77s.82-.53 2.02-.53l-.01-.02c1.2 0 2.97.45 2.97 3.88ZM27.68 2.43c.09 0 .17.08.17.17v11.11c0 .09-.08.17-.17.17h-2.13c-.09 0-.17-.08-.17-.17l.02-4.75h-3.31v4.75c0 .09-.08.17-.17.17h-2.13c-.08 0-.17-.08-.17-.17V2.6c0-.09.08-.17.17-.17h2.13c.09 0 .17.08.17.17v4.09h3.31V2.6c0-.09.08-.17.17-.17Zm8.26 3.64c.11 0 .19.08.19.17l-.02 7.47c0 .09-.06.17-.17.17H34.6c-.07 0-.14-.04-.16-.09-.03-.06-.08-.45-.08-.45s-1.13.77-2.52.77c-1.69 0-2.92-.55-2.92-2.75V6.25c0-.09.08-.17.17-.17h2.14c.09 0 .17.08.17.17V11c0 .75.22 1.09.97 1.09s1.3-.39 1.3-.39V6.26c0-.11.06-.19.17-.19Zm-17.406 5.971h.005a.177.177 0 0 1 .141.179v1.5c0 .07-.03.14-.09.16-.1.05-.74.22-1.27.22-1.16 0-2.86-.25-2.86-2.69V8.13h-1.11c-.09 0-.17-.08-.17-.19V6.58c0-.08.05-.15.13-.17.07-.01 1.16-.28 1.16-.28V3.96c0-.08.05-.13.14-.13h2.16c.09 0 .14.05.14.13v2.11h1.59c.08 0 .16.08.16.17v1.7c0 .11-.07.19-.16.19h-1.59v3.131c0 .47.27.83 1.05.83.247 0 .481-.049.574-.05ZM12.24 6.06c.09 0 .17.08.17.17v7.37c0 .18-.05.27-.25.27h-1.92c-.17 0-.3-.07-.3-.27V6.26c0-.11.08-.2.17-.2Zm29.99 3.78c0-1.81-.73-2.05-1.5-1.97-.6.04-1.08.34-1.08.34v3.52s.49.34 1.22.36c1.03.03 1.36-.34 1.36-2.25ZM11.19 2.68c.75 0 1.36.61 1.36 1.38 0 .77-.61 1.38-1.36 1.38-.77 0-1.38-.61-1.38-1.38 0-.77.61-1.38 1.38-1.38Zm7.34 9.35v.001l.01.01h-.001l-.005-.001v.001c-.009-.001-.015-.011-.024-.011Z"/></svg>
</a>
<span>
<span>&nbspLicensed under</span>
<a rel="license" style="text-decoration:none;" href="http://creativecommons.org/licenses/by-sa/4.0/">
(CC)BY-SA 4.0
</a>
@ <a xmlns:cc="http://creativecommons.org/ns#" href="https://holusion.com" property="cc:attributionName" rel="cc:attributionURL">holusion SAS</a>
</span>
</div>
</nav>
</footer>

{%- for script in page.scripts -%}
<script src="{{script}}" async ></script>
{%- endfor -%}
</body>
</html>
</html>
2 changes: 1 addition & 1 deletion _layouts/doc.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<path d="m4 4c-1 0-2 0.8-2 2v12c0 1 0.8 2 2 2h16c1 0 2-0.8 2-2v-12c0-1-0.8-2-2-2h-16zm0.2 1h4v14h-4c-0.6 0-1-0.4-1-1v-12c0-0.6 0.4-1 1-1zm5 0h11c0.6 0 1 0.4 1 1v12c0 0.6-0.4 1-1 1h-11v-14zm-5 2c-0.3 0-0.5 0.2-0.5 0.5 0 0.3 0.2 0.5 0.5 0.5h3c0.3 0 0.5-0.2 0.5-0.5 0-0.3-0.2-0.5-0.5-0.5h-3zm-2e-3 2c-0.3 0-0.5 0.2-0.5 0.5 0 0.3 0.2 0.5 0.5 0.5h3c0.3 0 0.5-0.2 0.5-0.5 0-0.3-0.2-0.5-0.5-0.5h-3zm0 1c-0.3 0-0.5 0.2-0.5 0.5 0 0.3 0.2 0.5 0.5 0.5h3c0.3 0 0.5-0.2 0.5-0.5 0-0.3-0.2-0.5-0.5-0.5h-3z"/>
</svg>
</button>
{% docnav %}
{% howtonav %}
</nav>
<main class="doc-page">
{{ content }}
Expand Down
137 changes: 137 additions & 0 deletions _plugins/howto_nav.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,137 @@
# Copied from holusion.com build plugins (https://github.com/Holusion/holusion.com/blob/master/_plugins/dev_nav.rb)

module Jekyll
module Tags
class HowtoNav < Liquid::Tag
@@uids = 1

def cache
@@cache ||= Jekyll::Cache.new("HowtoNav")
end
def getUid
@@uids += 1
return @@uids
end

def initialize(tag_name, markup, tokens)
super
end


# makes a tree of howtos as a hash like :
# {
# "fr" => {
# "page_path" => { :title, :url, :children }
# }
# }
def howto_tree(howtos)
tree = { "fr" =>{}, "en" => {}}
howtos.each do |howto|
next if howto.data["type"] != "howto"
match = /\/(?<lang>fr|en)\/howto\/((?<rest>.*)\/)?(?<last>(?!index)[^\/]+)/.match(howto.url)
next if ! match #skip if page does not match
lang = match["lang"]
parts = match["rest"]? match["rest"].split("/") : []
last_part = match["last"]

current_hash = tree[lang]

parts.each do |part|
#print "current hash :#{current_hash}"
current_hash[part] = {:children =>{}, :title => part.capitalize() } if not current_hash.has_key? part
current_hash = current_hash[part][:children]
end

current_hash[last_part] = {
:title => howto.data["title"],
:rank => howto.data.has_key?("rank")? howto.data["rank"] : 0,
:url => howto.url,
:children =>(current_hash.has_key?(last_part)) ? current_hash[last_part][:children]: {},
:visible => howto.data.has_key?("visible")? howto.data["visible"] : true
} if howto.data["visible"] != false
end

return tree
end

def render_item(path, item, active_uri)
uid = getUid

is_active = active_uri.include? path
title = item[:title] || path.split("/").last
url = item[:url] || ""

markup = %(<li class="list-group-item content-bar--link#{is_active ? " current" : ""}">)

if item[:children].empty?
markup += %(<a class="list-group-leaf" href="#{url}">#{title}</a>)
else
sorted_children = item[:children].sort_by { |key, val| val.has_key?(:rank)? val[:rank] : 0 }
child_nodes = sorted_children.map do |childKey, child|
render_item(path+"/#{childKey}", child, active_uri)
end

markup += %(
<a class="dropdown-toggle" role="button"
aria-haspopup="true"
aria-expanded="#{is_active ? "true" : "false"}"
data-target="#collapseList#{uid}">
#{title}
</a>
)

markup += %(
<ul class="collapse list-group content-bar-group--sub#{is_active ? " show" : ""}"
id="collapseList#{uid}"
>
)
if url and 0 < url.length
markup += %(
<li class="list-group-item content-bar--link#{url == active_uri ? " current": ""}">
<a href="#{url}">Introduction</a>
</li>
)
end
markup += child_nodes.join("\n")
markup += %(</ul>)
end

markup += %(</li>)
return markup
end

def render(context)
#global site variable
site = context.registers[:site]
page = context.registers[:page]
#replace variables with their current value

lang = page["lang"]
if not lang
raise SyntaxError, <<~END
Syntax Error in tag 'howtonav' : require a lang to be set
END
end

howtos_tree = cache.getset(site.time.to_s) do
howto_tree(site.pages)
end

html = %(<ul class="list-group">)

html += %(<li class="list-group-item content-bar--link#{ page["url"] == %(/dev/#{lang}/index) ? " current" : ""}">
<a href="/#{lang}/howto/">Introduction</a>
</li>)

sorted_localized_howtos = howtos_tree[lang].sort_by { |key, val| val.has_key?(:rank)? val[:rank] : 0 }
sorted_localized_howtos.each do |key, howto|
next if howto[:children].empty?# do not render categories with no children for now
html += render_item(key, howto, page["url"])
end
return html+"</ul>"
end
end
end
end

Liquid::Template.register_tag('howtonav', Jekyll::Tags::HowtoNav)
Loading

0 comments on commit 9116d0f

Please sign in to comment.