Skip to content

Commit

Permalink
Merge pull request #6 from RoboticsBrno/IndexGen
Browse files Browse the repository at this point in the history
  • Loading branch information
JakubAndrysek authored Jul 3, 2024
2 parents 70dfa88 + f3bfa29 commit 6aa3c40
Show file tree
Hide file tree
Showing 13 changed files with 129 additions and 2 deletions.
6 changes: 6 additions & 0 deletions GADGETS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Jak přidat další gadget
## Navigace
Do `mkdocs.yml` v sekci `nav` přidej název gadgety a umístění .md souborů.

## Obrázek
V adresáři gadgetu musí být adresář `assets`. Tam musí existovat obrázek `default.png`
21 changes: 21 additions & 0 deletions gadgets/assets/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -55,3 +55,24 @@ nav img:hover {
-webkit-filter: drop-shadow(0px 0px 2px #222222);
filter: drop-shadow(0px 0px 2px #222222);
}

.col-1-3 {
width: calc(100% / 3);
}

.gadget {
position: relative;
padding: 0 8px;
}

.gadget a {
display: block;
font-size: 20px;
text-align: center;
}

.gadget-link {
position: absolute;
width: 100%;
height: 100%;
}
Binary file added gadgets/electron/assets/default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gadgets/electronicDie/assets/default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gadgets/hradla/assets/default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
23 changes: 22 additions & 1 deletion gadgets/index.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
# Gadgets

List of our gadgets...
List of our gadgets...

{% set imgNameList = generateTemplateImgNameList() %}
{% set printEnd = false %}
<div markdown class="gadgets-display">

{% for batch in imgNameList|batch(3) %}
<div markdown class="container">
{% for imgPath, name, path in batch %}
<div markdown class="col-1-3 gadget">
<a href="{{ path }}" class="gadget-link">

![Gadget Image]({{ imgPath }})
[{{ name }}]({{ path }})

</a>
</div>
{% endfor %}
</div>
{% endfor %}

</div>
Binary file added gadgets/roboCamp/assets/default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gadgets/roboSvit/assets/default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added gadgets/slusmetr/assets/default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 3 additions & 0 deletions gadgets/smdChallenge/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Pájecí výzva
Pájecí výzvu najdete [zde](https://smd-challenge.robotikabrno.cz/)

Binary file added gadgets/smdChallenge/assets/default.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
71 changes: 71 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
import yaml
import os

BASE_PATH = "./"


def define_env(env):

@env.macro
def generateTemplateImgNameList():

with open(BASE_PATH + "mkdocs.yml") as stream:
splitConf = stream.read().split("nav:")

navConfig = "nav:\n" + splitConf[1]

try:
navYaml = yaml.safe_load(navConfig)["nav"][1:]

pageNameList = generatePageNameList(navYaml)

imgNameList = generateImgNameList(pageNameList)

return imgNameList

except yaml.YAMLError as exc:
print(exc)


def generatePageNameList(navYaml):
pageNameList = {}

for gadgetLinks in navYaml:

key, val = list(gadgetLinks.items())[0]
name = key
page = ""
for link in val:
dirName = link.split('/')[0]
if dirName in getGadgetDirs():
page = dirName
break

pageNameList[page] = name

return pageNameList


def getGadgetDirs():
projectDirs = []
for root, dirs, files in os.walk(BASE_PATH + 'gadgets'):
projectDirs = dirs
break

blacklist = ['assets', 'usbPad']
filtered = []
for dir in projectDirs:
if dir not in blacklist:
filtered.append(dir)

return filtered


def generateImgNameList(pageNameList):
imgNameList = []

for page, name in pageNameList.items():
imgPath = page + "/assets/default.png"
imgNameList.append((imgPath, name, page))

return imgNameList
7 changes: 6 additions & 1 deletion mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ markdown_extensions:
- pymdownx.highlight
- pymdownx.inlinehilite
- pymdownx.superfences
- pymdownx.extra
- pymdownx.keys
- admonition
- pymdownx.details
Expand All @@ -65,6 +66,7 @@ markdown_extensions:

plugins:
- search
- macros
- open-in-new-tab
- glightbox:
auto_caption: true
Expand Down Expand Up @@ -112,7 +114,10 @@ nav:
- electronicDie/README.md
- electronicDie/manual.md
- Pájecí výzva:
- https://smd-challenge.robotikabrno.cz/
- https://smd-challenge.robotikabrno.cz
- Smd kostka:
- smdKostka/README.md
- smdKostka/manual.md
- Electron:
- electron/README.md
- electron/electron-lesson-1.md
Expand Down

0 comments on commit 6aa3c40

Please sign in to comment.