Skip to content

Commit f2a5397

Browse files
committed
.
1 parent 3b4635d commit f2a5397

File tree

3 files changed

+9
-69
lines changed

3 files changed

+9
-69
lines changed

docs/js/utils/fetch.js

Lines changed: 7 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,17 @@ export function fetchTexData(texFilePath, environmentName, fieldsList) {
33
xhr.open('GET', texFilePath, false);
44
xhr.send(null);
55
if (xhr.status === 200) {
6-
// console.log('tex file loaded')
76
var jsonItems = [];
87
var file = xhr.responseText;
98
const codeblocks = file.split(new RegExp('\\\\begin{' + environmentName + '}')).map(block => block.replace(new RegExp('\\\\end{' + environmentName + '}'), '').trim());
109
codeblocks.shift(); // remove the first element of the array, which is empty
11-
// add also the content of the \begin{firstenvironmentName} \end{firstenvironmentName} environment to codeblocks, if it exists
1210
if (file.includes('\\begin{first' + environmentName + '}')) {
1311
const codeblocks2 = file.split(new RegExp('\\\\begin{first' + environmentName + '}')).map(block => block.replace(new RegExp('\\\\end{first' + environmentName + '}'), '').trim());
1412
codeblocks.push(codeblocks2[1]);
1513
}
1614
for(let block of codeblocks){
17-
// Split the LaTeX code into lines
1815
const lines = block.split('\n').map(line => line.trim());
1916

20-
// Find the start and end line of the environmentName environment
2117
const startLine = lines.findIndex(line => line === '\\begin{' + environmentName + '}');
2218
const endLine = lines.findIndex(line => line === '\\end{' + environmentName + '}');
2319
const fieldsDict = {};
@@ -27,9 +23,7 @@ export function fetchTexData(texFilePath, environmentName, fieldsList) {
2723
fieldsDict[fieldsList[index]] = unescapedLine;
2824
});
2925

30-
// Create JSON object
3126
const item = fieldsDict;
32-
// Add the JSON object to the array
3327
jsonItems.push(item);
3428
}
3529
return jsonItems;
@@ -38,63 +32,34 @@ export function fetchTexData(texFilePath, environmentName, fieldsList) {
3832
}
3933
}
4034

41-
// export function fetch
4235

4336

4437

4538

4639
export function getResearchItem(path, researchItem) {
47-
// picks the research item from the tex file in the path
48-
// and returns a dictionary with the fields
49-
50-
// items usually have the following structure:
51-
// @article{researchItem,
52-
// year = {2022},
53-
// title = {Quantitative John–Nirenberg inequalities at different scales},
54-
// author = {Martínez-Perales, Javier C and Rela, Ezequiel and Rivera-Ríos, Israel P},
55-
// journal = {Revista Matemática Complutense},
56-
// issn = {1139-1138},
57-
// doi = {10.1007/s13163-022-00427-0},
58-
// abstract = {},
59-
// pages = {1--35}
60-
// }
61-
62-
63-
// path: path to the tex file
64-
// researchItem: name of the research item
65-
// returns: dictionary with the fields
40+
6641
var xhr = new XMLHttpRequest();
6742
xhr.open('GET', path, false);
6843
xhr.send(null);
6944
if (xhr.status === 200) {
70-
// console.log('tex file loaded, getting research item')
7145
var file = xhr.responseText;
7246
var listOfItems = file.split('@')
73-
// console.log('listOfItems', listOfItems)
74-
// search for the item called researchItem
75-
// console.log('researchItem', researchItem)
47+
7648
var selectedItem = listOfItems.filter(item => item.includes(String(researchItem)))[0]
77-
// console.log('selectedItem', selectedItem)
78-
// get the fields, which are the elments, separated by commas, of the list, from the second element on
49+
7950
var fields = selectedItem.split('\n')
80-
// create the dictionary
8151
var items = {}
8252
items['name'] = researchItem
8353
for (var field of fields){
84-
// console.log('field', field)
8554
if (field.includes('=')){
8655

87-
// just catch = sign if it is not inside a curly bracket
88-
// if (field.includes('{') && field.includes('}')){
89-
// var equalSign = field.indexOf('=')
56+
9057
var key = field.split('=')[0].toLowerCase().trim()
91-
// console.log('key '+key)
92-
// value is the union of the remaining elements of field.split('=')
58+
9359
var value = field.split('=').slice(1).join('=').trim().replaceAll(/\\href{([^}]*)}{([^}]*)}/g, '<a style="text-decoration: none; " href="$1" >$2</a>').replace('},','}');
94-
// var value = field.split('=')[1].trim().replace('},','}')
95-
// console.log(['year', 'title', 'author', 'journal', 'volume', 'number'].includes(key.toString()))
60+
9661
if (['year', 'title', 'author', 'journal', 'volume', 'number'].includes(key.toString())){
97-
// console.log('value in list', value)
62+
9863
items[key] = value
9964
}
10065

@@ -115,19 +80,12 @@ export function fetchResearchItems(pathCVResearch,pathReferences) {
11580
xhr.open('GET', pathCVResearch, false);
11681
xhr.send(null);
11782
if (xhr.status === 200) {
118-
// console.log('tex file loaded, getting research items')
11983
var file = xhr.responseText;
120-
// split into lines
12184
var lines = file.split('\n').map(line => line.trim())
122-
// const lines = block.split('\n').map(line => line.trim());
123-
// get the lines that start with \item \fullcite{, but not with %\item \fullcite{
12485
var listOfItems = lines.filter(line => line.includes('\\item \\fullcite{') && !line.includes('%\\item \\fullcite{'))
12586

126-
// get the names of the items
12787
var listOfItemsNames = listOfItems.map(item => item.split('{')[1].split('}')[0])
128-
// get the items dictionaries
12988
for (var item of listOfItemsNames){
130-
// console.log('getting item ' + item)
13189
dictItems[item] = getResearchItem(pathReferences, item)
13290
}
13391
return dictItems
@@ -142,7 +100,6 @@ export function fetchResearchItems(pathCVResearch,pathReferences) {
142100

143101
export function fetchSpacedTex(texPath) {
144102

145-
// fetches the tex file and returns a string with the spaces between the words
146103

147104
var xhr = new XMLHttpRequest();
148105
xhr.open('GET', texPath, false);
@@ -152,15 +109,12 @@ export function fetchSpacedTex(texPath) {
152109
var file = xhr.responseText;
153110
console.log('tex file loaded, getting spaced tex', file)
154111

155-
// split by \spaced
156112
var spaced = file.split('\\spaced')
157-
// removes the \, which is present in the last member of the above list
158113
spaced = spaced.map(item => item.replaceAll('\\LaTeX', 'LaTeX'))
159114
spaced[spaced.length-1] = spaced[spaced.length-1].split('\\,')[0]
160115
spaced = spaced.map(item => ' '+item.trim())
161116

162117
console.log('spaced', spaced)
163-
// for all items, replace \LaTeX by LaTeX
164118

165119

166120
return spaced

docs/js/utils/render.js

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ const lettersAccentedDict = {
1313
'I': 'Í',
1414
'O': 'Ó',
1515
'U': 'Ú',
16-
// 'n': 'ñ',
17-
// 'N': 'Ñ'
16+
1817
}
1918

2019
const strangeLettersAccentedDict = {
@@ -32,9 +31,7 @@ const strangeLettersAccentedDict = {
3231

3332

3433
export function normalize(text) {
35-
// removes accents, {}, etc
36-
// text: string
37-
// returns: string
34+
3835

3936
var normalizedText = text
4037
normalizedText = normalizedText.replaceAll('{', '').replaceAll('}', '')
@@ -52,16 +49,6 @@ export function normalize(text) {
5249

5350
export function renderResearchInfo(researchItem) {
5451

55-
// renders the research item in the html page
56-
// researchItem: a dictionary with keys among the following: name, year, author, title, and journal
57-
// returns a string with the html code to be inserted in the html page. Usual structure of a research item:
58-
// Ritva Hurri-Syrj\"anen et al. “On the BBM-
59-
// phenomenon in fractional Poincar\'e-Sobolev in-
60-
// equalities with weights”. In: Interna-
61-
// tional Mathematics Research Notices (Sept. 2022)
62-
63-
// normalize: remove accents, {}, etc:
64-
6552

6653
for (var key in researchItem) {
6754
researchItem[key] = normalize(researchItem[key])

docs/js/utils/togglestyle.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11

2-
// This function toggles the light-theme class on the body element. This class is used to change the theme of the page. The class is defined in the docs\css\style.css file. it will be called in the index.html file, when the user clicks on the toggle button.
32

43

54

0 commit comments

Comments
 (0)