-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpub.html
224 lines (201 loc) · 7.5 KB
/
pub.html
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
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>LSzameitat</title>
<link rel="stylesheet" href="css/global.css" />
<link rel="stylesheet" href="css/style.css" />
<link rel="stylesheet" href="css/pub.css" />
<link
rel="stylesheet"
href="css/media1061.css"
media="(max-width:1061px)"
/>
<link rel="stylesheet" href="css/media767.css" media="(max-width:767px)" />
<link rel="icon" href="assets/ico/favicon.png" type="image/x-icon" />
<link
rel="shortcut icon"
href="assets/ico/favicon.png"
type="image/x-icon"
/>
<link rel="preconnect" href="https://fonts.googleapis.com" />
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
<link
href="https://fonts.googleapis.com/css2?family=Roboto:wght@300&display=swap"
rel="stylesheet"
/>
<link
rel="stylesheet"
href="https://use.fontawesome.com/releases/v5.15.4/css/solid.css"
integrity="sha384-Tv5i09RULyHKMwX0E8wJUqSOaXlyu3SQxORObAI08iUwIalMmN5L6AvlPX2LMoSE"
crossorigin="anonymous"
/>
<link
rel="stylesheet"
href="https://use.fontawesome.com/releases/v5.15.4/css/fontawesome.css"
integrity="sha384-jLKHWM3JRmfMU0A5x5AkjWkw/EYfGUAGagvnfryNV3F9VqM98XiIH7VBGVoxVSc7"
crossorigin="anonymous"
/>
</head>
<body>
<header class="caixa-cabecalho">
<h1 class="nome-cabecalho-mobile">Luizemara Szameitat</h1>
<nav>
<ul>
<li class="item-cabecalho">
<a href="index.html">Home</a>
</li>
<li class="item-cabecalho menu-filhos" id="clickable-link">
<a href="#">Work</a>
<!-- Menu filhos -->
<ul class="menu-filhos">
<li class="item-cabecalho">
<a href="pub.html">Articles</a>
</li>
<li class="item-cabecalho">
<a href="codes.html">Coding</a>
</li>
<li class="item-cabecalho">
<a href="exerc.html">Coding</a>
</li>
<li class="item-cabecalho">
<a href="http://lattes.cnpq.br/4322898960715686" target="_blank"
>CNPq Lattes</a
>
</li>
</ul>
</li>
</ul>
</nav>
</header>
<main>
<section class="secao-principal">
<!-- Primeira coluna - Artigos -->
<div class="container-artigos">
<div>
<h2 class="pub_titulo"><b>Articles</b></h2>
</div>
<div class="container-artigos__artigos">
<div id="bibReferences">
<ol id="bibList"></ol>
</div>
</div>
</div>
</section>
</main>
<script>
const repoUrl =
"https://api.github.com/repos/lszam/resume/contents/assets/bib";
const yearColors = {
2024: "#FF5733", //
2023: "#FF5733", //
2022: "#FF5733", //
2021: "#FF5733", //
2020: "#FF5733", //
2019: "#000",
2018: "#000",
2017: "#000",
2016: "#000",
2015: "#000",
};
// REFERENCIAS
async function fetchBibFiles() {
try {
const response = await fetch(repoUrl);
const files = await response.json();
const bibFiles = files.filter((file) => file.name.endsWith(".bib"));
let citations = [];
for (const file of bibFiles) {
const bibContent = await fetchBibContent(file.download_url);
const citation = formatBibtexAsCitation(bibContent);
if (citation) {
citations.push(citation);
}
}
// Ordenar as citações com base no ano e depois no nome dos autores
citations.sort((a, b) => {
const yearA = parseInt(a.match(/\((\d+)\)/)[1]);
const yearB = parseInt(b.match(/\((\d+)\)/)[1]);
if (yearA === yearB) {
const authorsA = a.match(/^([^,]+)/)[1].toLowerCase();
const authorsB = b.match(/^([^,]+)/)[1].toLowerCase();
return authorsA.localeCompare(authorsB);
} else {
return yearB - yearA;
}
});
// Exibir as citações ordenadas
const bibList = document.getElementById("bibList");
for (const citation of citations) {
const li = document.createElement("li");
li.innerHTML = citation; // Usar innerHTML para permitir links
bibList.appendChild(li);
}
} catch (error) {
console.error(`Erro ao buscar arquivos .bib: ${error}`);
}
}
async function fetchBibContent(url) {
const response = await fetch(url);
const content = await response.text();
return content;
}
function formatBibtexAsCitation(bibtexContent) {
// Analisar o conteúdo do arquivo BibTeX e formata-lo no novo formato.
// Assume que o conteúdo do arquivo BibTeX esta bem formatado e consistente.
const authorMatch = bibtexContent.match(/author\s*=\s*{([^}]+)}/i);
const yearMatch = bibtexContent.match(/year\s*=\s*{([^}]+)}/i);
const titleMatch = bibtexContent.match(/title\s*=\s*{([^}]+)}/i);
const journalMatch = bibtexContent.match(/journal\s*=\s*{([^}]+)}/i);
const doiMatch = bibtexContent.match(/doi\s*=\s*{([^}]+)}/i);
const urlMatch = bibtexContent.match(/url\s*=\s*{([^}]+)}/i);
if (
authorMatch &&
yearMatch &&
titleMatch &&
journalMatch &&
urlMatch
) {
const authors = authorMatch[1]
.split(" and ")
.map((author) => author.trim());
const year = yearMatch[1].trim();
const title = titleMatch[1].trim();
const journal = journalMatch[1].trim();
const doi = doiMatch ? doiMatch[1].trim() : "";
const url = urlMatch[1].trim(); // Pegar a URL do campo url do BibTeX
// Coloca os autores como uma única string
const authorsString = authors.join(", ");
// Citação no novo formato com link para a URL
const citation = `${authorsString} (${year}). ${title}. ${journal}. <a href="${url}" target="blank">${doi}</a>`;
return citation;
} else {
return "Incomplete citation. Minimum info: author, year, title, journal, url.";
}
}
// function displayCitation(citation) {
// const bibList = document.getElementById("bibList");
// const li = document.createElement("li");
// li.innerHTML = citation; // Usar innerHTML para permitir links
// bibList.appendChild(li);
// }
// CORES POR ANOS
function displayCitation(citation) {
const bibList = document.getElementById("bibList");
const li = document.createElement("li");
li.innerHTML = citation; // Usar innerHTML para permitir links
// Extrair o ano da citação
const year = citation.match(/\((\d{4})\)/)[1];
// Determinar a cor com base no ano
const color = yearColors[year] || "#606060"; // Cor padrão se o ano não estiver definido
// Aplicar a cor
li.style.color = color;
li.style.setProperty("color", "corEscolhida", "important");
bibList.appendChild(li);
}
// Chama a função para buscar e exibir referências
fetchBibFiles();
</script>
</body>
</html>