-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6 from RoboticsBrno/IndexGen
- Loading branch information
Showing
13 changed files
with
129 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/) | ||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters