-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathutils.jl
More file actions
165 lines (145 loc) · 5.28 KB
/
utils.jl
File metadata and controls
165 lines (145 loc) · 5.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
using Literate
using TimeZones
using Git
@reexport using Dates
import Hyperscript as HS
node = HS.m
# March 5, 2019
date_format(d) = Dates.format(d, "U d, yyyy")
function hfun_page_modtime()
mtime = Date(unix2datetime(stat(get_rpath()).mtime))
end
function hfun_list_people()
return string(
node("div", class="cards-row",
(
node("div", class="card-column",
node("div", class="card-body",
node("img", src=p.portrait),
node("div", class="card-container",
node("h2", node("a", href=p.href, p.name)),
node("div", class="card-title", p.title),
node("div", class="card-vitae", p.vitae),
node("div", class="card-github",
node("a", href=joinpath("https://github.com", p.github),
node("i", class="fa-brands fa-github-square"),
" $(p.github)")
),
node("p", node("a", href=p.href,
node("button", class="card-button", "Details")
)
)
)
)
) for p in get_people() if !p.alumn
)...
)
)
end
function person_info(rp)
return (;
date=getvarfrom(:joined, rp),
name=getvarfrom(:name, rp),
title=getvarfrom(:title, rp),
email=getvarfrom(:email, rp),
portrait=getvarfrom(:portrait, rp, "/assets/portrait_placeholder.png"),
vitae=getvarfrom(:vitae, rp),
alumn=getvarfrom(:alumn, rp, false),
github=getvarfrom(:github, rp),
href="/$(splitext(rp)[1])",
tags=get_page_tags(rp)
)
end
function get_people(basepath::String="people")
# find all valid "people/xxx.md" files, exclude the index which is where
# the people list gets placed
paths = String[]
for (root, dirs, files) in walkdir(basepath)
filter!(p -> endswith(p, ".md") && p != "index.md", files)
append!(paths, joinpath.(root, files))
end
# for each of those people, get their info
posts = [person_info(rp) for rp in paths]
sort!(posts, by=x -> x.date)
return posts
end
function hfun_person_header()
person = person_info(get_rpath())
return string(node("div", class="franklin-content",
node("div", class="profile-header",
node("div", class="profile-info",
node("h1", class="profile-name", person.name),
node("div", class="profile-title", person.title),
node("div", class="profile-vitae", person.vitae),
node("div", class="card-github",
node("a", href=joinpath("https://github.com", person.github),
node("i", class="fa-brands fa-github-square"),
" $(person.github)")
),
node("div", class="profile-email",
node("a", href="mailto:$(person.email)", person.email)
),
),
node("div", class="profile-image-container",
node("img", class="profile-image", src=person.portrait, alt="$(person.name)")
)
),
))
end
function hfun_list_projects()
return string(
node("div", class="cards-row",
(
node("div", class="card-column",
node("div", class="card-body",
node("img", src="/assets/portrait_placeholder.png"),
node("div", class="card-container",
node("h2", p.name),
node("div", class="card-title", p.title),
node("div", class="card-email", p.email),
node("p", node("a", href="mailto:$(p.email)",
node("button", class="card-button", "Contact")
)
)
)
)
) for p in get_projects() if !p.completed
)...
)
)
end
function get_projects(basepath::String="projects")
# find all valid "projects/xxx.md" files, exclude the index which is where
# the projects list gets placed
paths = String[]
for (root, dirs, files) in walkdir(basepath)
filter!(p -> endswith(p, ".md") && p != "index.md", files)
append!(paths, joinpath.(root, files))
end
# for each of those projects, get their info
posts = [
(
date=getvarfrom(:joined, rp),
name=getvarfrom(:name, rp),
title=getvarfrom(:title, rp),
complete=getvarfrom(:complete, rp, false),
funding=getvarfrom(:funding, rp, "N/A"),
href="/$(splitext(rp)[1])",
tags=get_page_tags(rp)
)
for rp in paths
]
sort!(posts, by=x -> x.date)
return posts
end
# Add this to your utils.jl file
function hfun_nav_link(args)
# Get the current page path
(href, text) = args
current_path = get_rpath()
# Check if the current page matches the href or is a subpage
is_active = startswith(current_path, href[2:end]) || (href == "/" && current_path == "index.html")
# Add the active class if this is the current page or subpage
class = is_active ? "nav-link active" : "nav-link"
return string(node("a", href=href, class=class, text))
end