-
Notifications
You must be signed in to change notification settings - Fork 7
/
utils.jl
139 lines (130 loc) · 3.22 KB
/
utils.jl
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
using Pkg, Markdown, JSON
const jso_pkgs = [
"ADNLPModels",
"AMD",
"AmplNLReader",
"BasicLU",
"BenchmarkProfiles",
"BundleAdjustmentModels",
"CaNNOLeS",
"CUTEst",
"DCISolver",
"HSL",
"JSOSolvers",
"Krylov",
"LDLFactorizations",
"LimitedLDLFactorizations",
"LinearOperators",
"LLSModels",
"ManualNLPModels",
"MUMPS",
"NLPModels",
"NLPModelsIpopt",
"NLPModelsJuMP",
"NLPModelsKnitro",
"NLPModelsModifiers",
"NLPModelsTest",
"NLSProblems",
"OptimizationProblems",
"PDENLPModels",
"Percival",
"PROPACK",
"QPSReader",
"QRMumps",
"QuadraticModels",
"RipQP",
"SolverBenchmark",
"SolverCore",
"SolverTest",
"SolverTools",
"SparseMatricesCOO",
"SuiteSparseMatrixCollection",
]
function aux_latest()
data = JSON.parsefile("_data/tutorials.json")
data = sort(data, by=x->x["date"], rev=true)
data[1]
end
hfun_latest_link() = aux_latest()["link"]
hfun_latest_short() = aux_latest()["short"]
hfun_latest_title() = aux_latest()["title"]
function hfun_rfig(params)
# Building locally or the main site shouldn't add the link
repo = split(get(ENV, "GITHUB_REPOSITORY", "nothing/JuliaSmoothOptimizers.github.io"), "/")[2]
if repo == "JuliaSmoothOptimizers.github.io"
repo = ""
end
file = "/" * joinpath(repo, "assets", params[1])
caption = join(params[2:end], " ")
"""
<figure>
<img class=\"image\" src=\"$file\">
<figcaption>$caption</figcaption>
</figure>
"""
end
@delay function hfun_list_news()
output = ""
for year in sort(readdir("news-and-blogposts"), rev=true)
for post in sort(readdir("news-and-blogposts/$year"), rev=true)
filename = "news-and-blogposts/$year/$post"
link = "/" * splitext(filename)[1] * "/"
title = pagevar(filename, :title)
date = basename(filename)[1:10]
excerpt = pagevar(filename, :rss_description)
output *= """
<div class="news-item">
<a href="$link">
<span class="is-size-7 has-text-grey-dark">
$date
</span>
<br>
<span class="is-size-4 has-text-primary">
$title
</span>
<br>
<span class="has-text-grey-dark">
$excerpt
</span>
</a>
</div>
"""
end
end
return output
end
@delay function hfun_list_news_short()
year = sort(readdir("news-and-blogposts"), rev=true)[1]
post = sort(readdir("news-and-blogposts/$year"), rev=true)[1]
filename = "news-and-blogposts/$year/$post"
link = "/" * splitext(filename)[1] * "/"
title = pagevar(filename, :title)
date = basename(filename)[1:10]
excerpt = pagevar(filename, :rss_description)
output = """
<div class="news-item">
<a href="$link">
<span class="is-size-7 has-text-grey-dark">
$date
</span>
<br>
<span class="is-size-4 has-text-primary">
$title
</span>
<br>
<p class="has-text-grey-dark is-size-6">
$excerpt
</p>
</a>
</div>
"""
return output
end
function hfun_process_tutorials_data()
json = JSON.parsefile("_data/tutorials.json")
json = sort(json, by=x->x["date"], rev=true)
data = "const data = " * JSON.json(json)
return """<script type="text/javascript">
$(join(data))
</script>"""
end