Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
howto-cards
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Requirements
External wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Annegrät Daujeumont
howto-cards
Commits
c294d541
Verified
Commit
c294d541
authored
2 years ago
by
Laurent Heirendt
Browse files
Options
Downloads
Patches
Plain Diff
fix links for qms
parent
644fa90c
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
.ci/generateIndex.py
+49
-25
49 additions, 25 deletions
.ci/generateIndex.py
with
49 additions
and
25 deletions
.ci/generateIndex.py
+
49
−
25
View file @
c294d541
...
...
@@ -20,16 +20,13 @@ def build_link(title, href):
return
f
'
\t\t\t
<li><a href=
"
{
href
}
"
>
{
title
}
</a></li>
\n
'
def
root_h
andbook
(
href
):
def
root_h
ref
(
href
):
# remove sym link reference in href
if
(
'
handbook-additional
'
in
href
):
href
=
href
.
replace
(
'
handbook-additional
'
,
'
handbook
'
).
strip
()
elif
(
'
handbook-annexes
'
in
href
):
href
=
href
.
replace
(
'
handbook-annexes
'
,
'
handbook
'
).
strip
()
return
href
def
root_lab
(
href
):
# remove sym link reference in href
if
(
'
lab-software
'
in
href
):
href
=
href
.
replace
(
'
lab-software
'
,
'
lab
'
).
strip
()
...
...
@@ -38,6 +35,12 @@ def root_lab(href):
elif
(
'
lab-hsa
'
in
href
):
href
=
href
.
replace
(
'
lab-hsa
'
,
'
lab
'
).
strip
()
# remove sym link reference in href
if
(
'
qms-policies
'
in
href
):
href
=
href
.
replace
(
'
qms-policies
'
,
'
qms
'
).
strip
()
elif
(
'
qms-sops
'
in
href
):
href
=
href
.
replace
(
'
qms-sops
'
,
'
qms
'
).
strip
()
return
href
def
build_section_start
(
title
,
shortcut
):
...
...
@@ -50,6 +53,8 @@ def build_section_start(title, shortcut):
title
=
title
.
replace
(
"
Lab software
"
,
"
Lab: Software
"
)
title
=
title
.
replace
(
"
Lab equipment
"
,
"
Lab: Equipment
"
)
title
=
title
.
replace
(
"
Lab hsa
"
,
"
Lab: Health & Safety, Access
"
)
title
=
title
.
replace
(
"
Qms sops
"
,
"
QMS: Standard Operating Procedures (SOPS)
"
)
title
=
title
.
replace
(
"
Qms policies
"
,
"
QMS: Policies
"
)
return
f
'
\n\t
<div class=
"
index-box noborderbox
"
id=
"
{
shortcut
}
-card
"
>
\n\t\t
<h3>
{
title
}
</h3>
\n\t\t
<ul>
\n
'
...
...
@@ -84,7 +89,8 @@ def get_ignore():
"
assets
"
,
"
help.md
"
,
"
index.md
"
,
"
pagination.md
"
"
pagination.md
"
,
"
.gitkeep
"
,
]
def
save_legacy_from
(
localroot
,
root
,
filename
):
...
...
@@ -149,6 +155,34 @@ def remove_header(localroot, root, filename):
return
n
def
folders_in
(
path_to_parent
):
for
fname
in
os
.
listdir
(
path_to_parent
):
if
os
.
path
.
isdir
(
os
.
path
.
join
(
path_to_parent
,
fname
)):
yield
os
.
path
.
join
(
path_to_parent
,
fname
)
def
has_folders
(
path_to_parent
):
folders
=
list
(
folders_in
(
path_to_parent
))
return
len
(
folders
)
!=
0
def
element_header
(
prefix
,
permalink
,
element
):
# handbook section
if
"
handbook-annexes
"
in
permalink
or
"
handbook-additional
"
in
permalink
:
element
+=
prefix
+
"
/cards/
"
+
root_href
(
shortcut
)
+
"
\n
"
element
+=
prefix
+
"
/
"
+
folder
+
"
/cards/
"
+
root_href
(
shortcut
)
+
"
\n
"
# lab section
if
"
lab-software
"
in
permalink
or
"
lab-equipment
"
in
permalink
or
"
lab-hsa
"
in
permalink
:
element
+=
prefix
+
"
/cards/
"
+
root_href
(
shortcut
)
+
"
\n
"
element
+=
prefix
+
"
/
"
+
folder
+
"
/cards/
"
+
root_href
(
shortcut
)
+
"
\n
"
# QMS section
if
"
qms-policies
"
in
permalink
or
"
qms-sops
"
in
permalink
:
element
+=
prefix
+
"
/cards/
"
+
root_href
(
shortcut
)
+
"
\n
"
element
+=
prefix
+
"
/
"
+
folder
+
"
/cards/
"
+
root_href
(
shortcut
)
+
"
\n
"
return
element
def
generate_header
(
folder
,
permalink
,
shortcut
,
order
,
legacy_from
,
title
,
description
):
header
=
"
---
\n
"
...
...
@@ -157,18 +191,13 @@ def generate_header(folder, permalink, shortcut, order, legacy_from, title, desc
header
+=
"
layout: page
\n
"
header
+=
"
permalink:
"
+
permalink
+
"
\n
"
header
+=
"
shortcut:
"
+
root_h
andbook
(
shortcut
)
+
"
\n
"
header
+=
"
shortcut:
"
+
root_h
ref
(
shortcut
)
+
"
\n
"
header
+=
"
redirect_from:
\n
"
header
+=
"
- /cards/
"
+
shortcut
+
"
\n
"
header
+=
"
- /
"
+
folder
+
"
/cards/
"
+
shortcut
+
"
\n
"
# special case of handbook
if
"
handbook-annexes
"
in
permalink
or
"
handbook-additional
"
in
permalink
:
header
+=
"
- /cards/
"
+
root_handbook
(
shortcut
)
+
"
\n
"
header
+=
"
- /
"
+
folder
+
"
/cards/
"
+
root_handbook
(
shortcut
)
+
"
\n
"
# separate lab section
if
"
lab-software
"
in
permalink
or
"
lab-equipment
"
in
permalink
or
"
lab-hsa
"
in
permalink
:
header
+=
"
- /cards/
"
+
root_lab
(
shortcut
)
+
"
\n
"
header
+=
"
- /
"
+
folder
+
"
/cards/
"
+
root_lab
(
shortcut
)
+
"
\n
"
# generate specific redirects
header
=
element_header
(
"
-
"
,
shortcut
,
header
)
# include the legacy section in the redirect_from section
if
len
(
legacy_from
)
>
0
:
...
...
@@ -195,13 +224,8 @@ def generate_whitelist_entry(folder, permalink, shortcut):
wl_entry
+=
"
/?
"
+
shortcut
+
"
\n
"
wl_entry
+=
"
/cards/
"
+
shortcut
+
"
\n
"
wl_entry
+=
"
/
"
+
folder
+
"
/cards/
"
+
shortcut
+
"
\n
"
if
"
handbook-annexes
"
in
permalink
or
"
handbook-additional
"
in
permalink
:
wl_entry
+=
"
/cards/
"
+
root_handbook
(
shortcut
)
+
"
\n
"
wl_entry
+=
"
/
"
+
folder
+
"
/cards/
"
+
root_handbook
(
shortcut
)
+
"
\n
"
# separate lab section
if
"
lab-software
"
in
permalink
or
"
lab-equipment
"
in
permalink
or
"
lab-hsa
"
in
permalink
:
wl_entry
+=
"
/cards/
"
+
root_lab
(
shortcut
)
+
"
\n
"
wl_entry
+=
"
/
"
+
folder
+
"
/cards/
"
+
root_lab
(
shortcut
)
+
"
\n
"
wl_entry
=
element_header
(
""
,
permalink
,
wl_entry
)
return
wl_entry
...
...
@@ -212,17 +236,17 @@ localroot = os.getcwd()
ignore
=
get_ignore
()
# generate the index properly speaking
cardDirs
=
[
"
internal
"
,
"
external
"
,
"
policies
"
]
cardDirs
=
[
"
internal
"
,
"
external
"
]
sections
=
[]
# determine first the directories
for
direct
in
cardDirs
:
if
path
.
isdir
(
direct
):
if
path
.
isdir
(
direct
)
and
has_folders
(
direct
)
:
dirs
=
os
.
listdir
(
direct
)
dirs
=
natsorted
(
dirs
)
for
d
in
dirs
:
if
d
[
0
]
!=
"
.
"
and
d
not
in
ignore
:
if
d
[
0
]
!=
"
.
"
and
d
not
in
ignore
and
has_folders
(
direct
+
"
/
"
+
d
)
:
sections
.
append
(
d
)
sections
=
list
(
set
(
sections
))
...
...
@@ -246,7 +270,7 @@ for folder in cardDirs:
dirs
=
natsorted
(
dirs
)
for
d
in
dirs
:
if
d
[
0
]
!=
"
.
"
and
d
not
in
ignore
:
if
d
[
0
]
!=
"
.
"
and
d
not
in
ignore
and
has_folders
(
folder
+
"
/
"
+
d
)
:
# set the header of the section
#index += "\n### " + d.replace("-", " ").capitalize() + "\n"
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment