Skip to content

Commit

Permalink
fix emmy
Browse files Browse the repository at this point in the history
  • Loading branch information
behinger committed May 27, 2024
1 parent 2bd351b commit ce90c98
Show file tree
Hide file tree
Showing 6 changed files with 110 additions and 107 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ In contrast the **folder blacklist** only needs keywords and/ or symbols that ne

## Extending and editing the page
### Generation scripts
Under `.\_assets\scritps\` all scripts for page generation and similar scripts that should be run after deployement, but before the changes go live. If scripts are added there, they either should be called in `inti_dynamics.jl` or manually added to the github action under `.\.github\workflows\Deploy.yml`.
Under `.\_assets\scritps\` all scripts for page generation and similar scripts that should be run after deployement, but before the changes go live. If scripts are added there, they either should be called in `init_dynamics.jl` or manually added to the github action under `.\.github\workflows\Deploy.yml`.

### Custom ordering the navigation
The first level of all navigation elements can have a custom ordering, while any higher level is going to be sorted alphabeticially.
Expand Down
2 changes: 1 addition & 1 deletion _assets/scripts/file_blacklist.jl
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
=#
##########################################################################################################
file_black_list = ["404.md", "README.md", "config.md", "search.md", "impressum.md", "index.md", "internal.md", "index_content.md", "robots.txt"]
folder_black_list = ["_", "node_modules", ".git", "LICENSE", ".idea"]
folder_black_list = ["_", "node_modules", ".git", "LICENSE", ".idea", ".vscode"]

uppercase_list = ["eeg", "glmm"]
format_blacklist = ["porics"]
Expand Down
190 changes: 97 additions & 93 deletions _assets/scripts/generate_side_nav.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ include("auxiliary_functions.jl")
=#
nav_order = Lt((a, b) ->
begin
custom_order = ["members", "papers", "philosophy", "teaching-resources", "thesis-art", "open-projects-and-positions", "science-communication", "contact-us"]
custom_order = ["members", "papers", "philosophy", "teaching-resources", "thesis-art", "open-projects-and-positions", "emmy-noether", "science-communication", "contact-us"]
a_in = a in custom_order
b_in = b in custom_order
if(a_in && b_in)

if (a_in && b_in)
return findfirst(isequal(a), custom_order) < findfirst(isequal(b), custom_order) ? true : false
elseif(a_in && !b_in)
return true
elseif(!a_in && b_in)
elseif (a_in && !b_in)
return true
elseif (!a_in && b_in)
return false
else
return isless(lowercase(a), lowercase(b))
Expand All @@ -35,31 +35,31 @@ nav_order = Lt((a, b) ->
=#
function append_files!(dict, folder)
try
for file in readdir(string("./", folder))
for file in readdir(string("./", folder))

# Check for .md file and add to dict, pointing to empty dict
if contains(file, ".md") && !file_blacklisted(file)

push!(dict, replace(file, ".md" => "") => SortedDict{String, SortedDict}(nav_order))
# If not .md check for (black-listed) folders and add them to the dict. This dict is then
# filled recursivly.
push!(dict, replace(file, ".md" => "") => SortedDict{String,SortedDict}(nav_order))

# If not .md check for (black-listed) folders and add them to the dict. This dict is then
# filled recursivly.
elseif isdir(file) && !(folder_blacklisted(file))
inner_dict = SortedDict{String, SortedDict}(nav_order)

inner_dict = SortedDict{String,SortedDict}(nav_order)
push!(dict, file => inner_dict)
append_files!(inner_dict, file)
# If not .md and for (black-listed) folders , check for folder inside folder and add them to the dict. This dict is then
# filled recursivly. eg:teaching-resources/open-teaching-graphics
elseif isdir(string("./", folder,"/",file)) && !(folder_blacklisted(file)) && !(file_blacklisted(file))

# If not .md and for (black-listed) folders , check for folder inside folder and add them to the dict. This dict is then
# filled recursivly. eg:teaching-resources/open-teaching-graphics
elseif isdir(string("./", folder, "/", file)) && !(folder_blacklisted(file)) && !(file_blacklisted(file))

# Updating folder name
file = string(folder,"/",file)
second_inner_dict = SortedDict{String, SortedDict}(nav_order)
file = string(folder, "/", file)
second_inner_dict = SortedDict{String,SortedDict}(nav_order)
push!(dict, file => second_inner_dict)
append_files!(second_inner_dict, file)
append_files!(second_inner_dict, file)

end
end
catch e
Expand All @@ -69,43 +69,47 @@ end

# Recursivly generates the HTML code for the side nav, given a dict and a path.
function write_html_side_nav(dict, path, level)
level_indent = "\t"^(3+level)
level_indent = "\t"^(3 + level)

html_string = ""
for key in keys(dict)

title = apply_formatting(key)
href_link = string(path, key)
@info "SIDE_NAV_GEN: \n" title

if href_link == "emmy-noether"
@debug "fixing emmy"
href_link = "emmynoether" # Couldnt figure out how to access the "SLUG" associated with this page...
# key = "emmynoether"
end
# Checks if the dict, the key element is pointing to is empty, implying it being a page,
# not a folder
if length(keys(get(dict, key, SortedDict{String, SortedDict}(nav_order)))) == 0
level_indent = "\t"^(3+level)
if length(keys(get(dict, key, SortedDict{String,SortedDict}(nav_order)))) == 0

level_indent = "\t"^(3 + level)
list_element_string = "$(level_indent)<li><a class=\"{{ispage $href_link}}active{{end}}\" href=\"/$href_link/\">$title</a></li>\n"
html_string = string(html_string, list_element_string)

elseif length(keys(get(dict, key, SortedDict{String, SortedDict}(nav_order)))) <= 15 # no idea about this number, but needs to be increased if you add new thesis-arts
elseif length(keys(get(dict, key, SortedDict{String,SortedDict}(nav_order)))) <= 15 # no idea about this number, but needs to be increased if you add new thesis-arts

list_element_string = "$(level_indent)<li><a class=\"second-action\" onclick=\"hideFolder('$key')\"><i id=\"$(string(key,"-folder-icon"))\" class=\"fas fa-chevron-circle-{{ispage $key/*}}down{{else}}right{{end}}\"></i></a><a class=\"{{ispage $(string(href_link, "/*"))}}active{{end}}\" href=\"/$path$key\">$title</a>\n $(level_indent)\t<ul id=\"$(string(key,"-folder"))\" class=\"second{{isnotpage $key/*}}-invisible{{end}}\"> \n"

inner_dynamic_string = write_html_side_nav(get(dict, key, SortedDict(nav_order)), string(path, key, "/"), level + 2)
html_string = string(html_string, list_element_string, inner_dynamic_string, "$(level_indent)\t</ul>\n $(level_indent)</li>\n")

else
@debug key
@debug length(keys(get(dict, key, SortedDict{String, SortedDict}(nav_order))))
arr = split(key,'/')
@debug length(keys(get(dict, key, SortedDict{String,SortedDict}(nav_order))))
arr = split(key, '/')
key_outer = arr[1] #(index starts at 1)
key_inner = arr[2]
#reset the title and href
title = apply_formatting(key_inner)
href_link = string(path, key_inner)


list_element_string = "$(level_indent)<li><a class=\"third-action\" onclick=\"hideFolder('$key')\"><i id=\"$(string(key,"-folder-icon"))\" class=\"fas fa-chevron-circle-{{ispage $key/*}}down{{else}}right{{end}}\"></i></a><a class=\"{{ispage $(string(href_link, "/*"))}}active{{end}}\" href=\"/$key\">$title</a>\n $(level_indent)\t<ul id=\"$(string(key,"-folder"))\" class=\"third{{isnotpage $key/*}}-invisible{{end}}\"> \n"
path =""
path = ""
inner_dynamic_string = write_html_side_nav(get(dict, key, SortedDict(nav_order)), string(path, key, "/"), level + 2)
html_string = string(html_string, list_element_string, inner_dynamic_string, "$(level_indent)\t</ul>\n $(level_indent)</li>\n")

Expand All @@ -117,7 +121,7 @@ end

function write_html_top_nav(dict, path, level)

level_indent = "\t"^(5+level)
level_indent = "\t"^(5 + level)

html_string = ""
for key in keys(dict)
Expand All @@ -126,32 +130,35 @@ function write_html_top_nav(dict, path, level)
href_link = string(path, key)


# @debug :path path key

# Checks if the dict, the key element is pointing to is empty, implying it being a page,
# not a folder
if length(keys(get(dict, key, SortedDict{String, SortedDict}(nav_order)))) == 0
if length(keys(get(dict, key, SortedDict{String,SortedDict}(nav_order)))) == 0

list_element_string = "$(level_indent)<li><a href=\"/$href_link/\">$title</a></li>\n"
@debug list_element_string
html_string = string(html_string, list_element_string)

elseif length(keys(get(dict, key, SortedDict{String, SortedDict}(nav_order)))) <= 15 #see comment below for near identical code structure
list_element_string = "$(level_indent)<li><a href=\"/$path$key\">$title</a>\n$(level_indent)\t<ul class=\"nav-second\">\n"
elseif length(keys(get(dict, key, SortedDict{String,SortedDict}(nav_order)))) <= 15 #see comment below for near identical code structure

list_element_string = "$(level_indent)<li><a href=\"/$href_link/\">$title</a>\n$(level_indent)\t<ul class=\"nav-second\">\n"

inner_dynamic_string = write_html_top_nav(get(dict, key, SortedDict(nav_order)), string(path, key, "/"), level + 2)
html_string = string(html_string, list_element_string, inner_dynamic_string, "$(level_indent)\t</ul>\n$(level_indent)</li>\n")

else
@debug "I'm here",key
arr = split(key,'/')
@debug "I'm here", key
arr = split(key, '/')
key_outer = arr[1] #(index starts at 1)
key_inner = arr[2]
#reset the title and href
title = apply_formatting(key_inner)
href_link = string(path, key_inner)
path =""
path = ""

list_element_string = "$(level_indent)<li><a href=\"/$path$key\">$title</a>\n$(level_indent)\t<ul class=\"nav-third\">\n"

inner_dynamic_string = write_html_top_nav(get(dict, key, SortedDict(nav_order)), string(path, key, "/"), level + 2)
html_string = string(html_string, list_element_string, inner_dynamic_string, "$(level_indent)\t</ul>\n$(level_indent)</li>\n")

Expand All @@ -163,29 +170,27 @@ end

function generate_side_nav()
# Static first part of HTML file
file_start =
"<div class=\"side-nav-wrapper\">
<div class=\"side-nav\">
\t<div class=\"search-bar\">
\t\t<form id=\"lunrSearchForm\" name=\"lunrSearchForm\">
\t\t\t<input class=\"search-input\" name=\"q\" placeholder=\"Search...\" type=\"text\">
\t\t\t<input type=\"submit\" value=\"Search\" formaction=\"/search/index.html\">
\t\t</form>
\t</div>
\t<h2>
\t\tNavigation
\t</h2>\n"
file_start = "<div class=\"side-nav-wrapper\">
<div class=\"side-nav\">
\t<div class=\"search-bar\">
\t\t<form id=\"lunrSearchForm\" name=\"lunrSearchForm\">
\t\t\t<input class=\"search-input\" name=\"q\" placeholder=\"Search...\" type=\"text\">
\t\t\t<input type=\"submit\" value=\"Search\" formaction=\"/search/index.html\">
\t\t</form>
\t</div>
\t<h2>
\t\tNavigation
\t</h2>\n"

# Static end of file
file_end =
"\t</div>
</div>\n"
file_end = "\t</div>
</div>\n"

# Index files
@info "Indexing files..."
file_list = SortedDict{String, SortedDict}(nav_order)
file_list = SortedDict{String,SortedDict}(nav_order)
append_files!(file_list, "")



# Custom add Home page
Expand All @@ -197,6 +202,7 @@ function generate_side_nav()
# Generate dynamic nav HTML
@info "Generating side-nav..."
dynamic_string = write_html_side_nav(file_list, "", 0)
@debug dynamic_string
file_string_gen = string(file_string_gen, dynamic_string)

# Custom add Impressum page
Expand All @@ -214,35 +220,33 @@ end

function generate_top_nav()
# Static first part of HTML file
file_start =
"<div class=\"masthead\">
<div class=\"masthead__inner-wrap\">
\t<div class=\"masthead__menu\">
\t\t<nav id=\"site-nav\" class=\"greedy-nav\">
\t\t\t<a class=\"site-title\" href=\"/\"><img src=\"/assets/icn/text_logo.png\"></a>
\t\t\t<ul class=\"visible-links\">
\t\t\t\t<a href=\"/open-projects-and-positions/\"> <li class=\"masthead__menu-item\">Open Positions</li> </a>
\t\t\t\t<a href=\"/members/\"><li class=\"masthead__menu-item\">Members</li></a>
\t\t\t\t<a href=\"/teaching-resources/\"><li class=\"masthead__menu-item\">Teaching Resources</li></a>
\t\t\t</ul>
\t\t\t<a href=\"javascript:void(0);\" onclick=\"toggleHamburger(this)\">
\t\t\t\t<div class=\"hamburger\">
\t\t\t\t\t<div id=\"upper-hamburger-layer\" class=\"hamburger-elem1\"></div>
\t\t\t\t\t<div class=\"hamburger-elem2\"></div>
\t\t\t\t\t<div id=\"lower-hamburger-layer\" class=\"hamburger-elem1\"></div>
\t\t\t\t</div>
\t\t\t</a>
\t\t</nav>
\t\t<div class=\"invisible-hamburger-links\" id=\"hamburgerLinks\">
\t\t\t<ul class=\"nav-first\">\n"

# Static end of file
file_end =
"\n\t\t\t\t</ul>
\t\t\t</div>
\t\t</div>
\t</div>
</div>"
file_start = "<div class=\"masthead\">
<div class=\"masthead__inner-wrap\">
\t<div class=\"masthead__menu\">
\t\t<nav id=\"site-nav\" class=\"greedy-nav\">
\t\t\t<a class=\"site-title\" href=\"/\"><img src=\"/assets/icn/text_logo.png\"></a>
\t\t\t<ul class=\"visible-links\">
\t\t\t\t<a href=\"/open-projects-and-positions/\"> <li class=\"masthead__menu-item\">Open Positions</li> </a>
\t\t\t\t<a href=\"/members/\"><li class=\"masthead__menu-item\">Members</li></a>
\t\t\t\t<a href=\"/teaching-resources/\"><li class=\"masthead__menu-item\">Teaching Resources</li></a>
\t\t\t</ul>
\t\t\t<a href=\"javascript:void(0);\" onclick=\"toggleHamburger(this)\">
\t\t\t\t<div class=\"hamburger\">
\t\t\t\t\t<div id=\"upper-hamburger-layer\" class=\"hamburger-elem1\"></div>
\t\t\t\t\t<div class=\"hamburger-elem2\"></div>
\t\t\t\t\t<div id=\"lower-hamburger-layer\" class=\"hamburger-elem1\"></div>
\t\t\t\t</div>
\t\t\t</a>
\t\t</nav>
\t\t<div class=\"invisible-hamburger-links\" id=\"hamburgerLinks\">
\t\t\t<ul class=\"nav-first\">\n"

# Static end of file
file_end = "\n\t\t\t\t</ul>
\t\t\t</div>
\t\t</div>
\t</div>
</div>"

# Custom add Home page
file_string_gen = ""
Expand All @@ -252,7 +256,7 @@ function generate_top_nav()
@info "Indexing files..."
file_list = SortedDict()
try
file_list = SortedDict{String, SortedDict}(nav_order)
file_list = SortedDict{String,SortedDict}(nav_order)
append_files!(file_list, "")
catch e
@info e
Expand Down
Loading

0 comments on commit ce90c98

Please sign in to comment.