Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
JulioContrerasH committed Dec 13, 2024
1 parent f01d09c commit 052f069
Show file tree
Hide file tree
Showing 7 changed files with 128 additions and 148 deletions.
4 changes: 2 additions & 2 deletions assets/bibfiles/journal.bib
Original file line number Diff line number Diff line change
Expand Up @@ -96,9 +96,9 @@ @article{Cortes24noiseylabels
author = {Cortes, J. and Fernandez-Torres, M.A. and Camps-Valls, G.},
year = {2024},
pages = {1-12},
volume = {},
volume = {},
journal = {IEEE Transactions on Geoscience and Remote Sensing},
doi = {doi.org/10.1109/TGRS.2024.3358231},
doi = {https://doi.org/10.1109/TGRS.2024.3358231},
project = {usmile}
}

Expand Down
6 changes: 0 additions & 6 deletions content/publications/technical_reports.md

This file was deleted.

7 changes: 1 addition & 6 deletions hugo-alt.toml
Original file line number Diff line number Diff line change
Expand Up @@ -98,16 +98,11 @@ theme = "isp_uv"
name = "Talks"
url = "/publications/talks/"
weight = 4
[[menu.main]]
parent = "Publications"
name = "Technical Reports"
url = "/publications/technical_reports/"
weight = 5
[[menu.main]]
parent = "Publications"
name = "Theses"
url = "/publications/theses/"
weight = 6
weight = 5

[[menu.main]]
name = "Code"
Expand Down
7 changes: 1 addition & 6 deletions hugo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -98,16 +98,11 @@ theme = "isp_uv"
name = "Talks"
url = "/publications/talks/"
weight = 4
[[menu.main]]
parent = "Publications"
name = "Technical Reports"
url = "/publications/technical_reports/"
weight = 5
[[menu.main]]
parent = "Publications"
name = "Theses"
url = "/publications/theses/"
weight = 6
weight = 5

[[menu.main]]
name = "Code"
Expand Down
222 changes: 100 additions & 122 deletions static/js/bibtex_js.js
Original file line number Diff line number Diff line change
@@ -1,52 +1,3 @@
// Issues:
// no comment handling within strings
// no string concatenation
// no variable values yet
function addYearsAndProjects() {
console.log("Adding years and projects");
let yearSet = new Set();
let projectSet = new Set();

// Collect unique years
$(".year").each(function () {
let year = $(this).text().trim();
if (year !== "" && year !== "All Years") {
yearSet.add(year);
}
});
console.log("Collected years:", Array.from(yearSet));

// Collect unique projects
$(".bib-item").each(function () {
const projectText = $(this).find(".project").text().trim();
if (projectText && projectText !== "Project") { // Verifica que no esté vacío ni sea inválido
const formattedProjects = (new BibtexDisplay()).formatProjects(projectText); // Limpieza
formattedProjects.split(',').forEach(project => {
if (project.trim()) { // Asegúrate de que no es vacío
projectSet.add(project.trim());
}
});
}
});

// Populate year filter
let yearArray = Array.from(yearSet);
yearArray = yearArray.filter(year => year !== "Submitted" && year !== "In preparation")
.sort((a, b) => b - a);
if (yearSet.has("Submitted")) yearArray.push("Submitted");
if (yearSet.has("In preparation")) yearArray.push("In preparation");

yearArray.forEach(year => {
$('#year-filter').append(`<option value="${year}">${year}</option>`);
});

// Populate project filter
const sortedProjects = Array.from(projectSet).sort(); // Ordenar alfabéticamente
sortedProjects.forEach(project => {
$('#project-filter').append(`<option value="${project}">${project}</option>`);
});
}

// Grammar implemented here:
// bibtex -> (string | preamble | comment | entry)*;
// string -> '@STRING' '{' key_equals_value '}';
Expand All @@ -62,15 +13,15 @@ function addYearsAndProjects() {
function author_tex_reformat(input) {
const authors = input.split(',').map(author => author.trim()); // Dividir por ',' y limpiar espacios
if (authors.length > 1) {
// Unir todos menos el último con ', ' y el último con ' and '
return authors.slice(0, -1).join(', ') + ' and ' + authors[authors.length - 1];
} else {
// Si no hay ',' devolver el autor como está
return authors[0];
return authors.slice(0, -1).join(', ') + ' and ' + authors[authors.length - 1]; // Unir todos menos el último con ', ' y el último con ' and '
} else {
return authors[0]; // Si no hay ',' devolver el autor como está
}
}




class BibtexParser {
constructor() {
this.pos = 0;
Expand Down Expand Up @@ -343,7 +294,16 @@ class BibtexDisplay {

return value;
};

this.capitalizeWords = function(value) { // Agrega la función aquí
return value.toLowerCase()
.split(' ')
.map(word => word.charAt(0).toUpperCase() + word.slice(1))
.join(' ');
};

this.bibtexParser = null;

this.prepare_parser = function(input) {
if (this.bibtexParser === null) {
this.bibtexParser = new BibtexParser();
Expand Down Expand Up @@ -450,6 +410,7 @@ class BibtexDisplay {
}
value = this.formatProjects(value);
value = this.fixValue(value); // Patrones adicionales
value = this.capitalizeWords(value) // Capitalizar palabras
const projectText = value.includes(',') // Si hay varios proyectos, únelos con guiones, si no, usa el único proyecto
? value.split(',').map(p => p.trim()).join(' - ')
: value.trim();
Expand All @@ -468,40 +429,38 @@ class BibtexDisplay {
}
});
}
if (key === "doi") {
if (!value || !value.trim() || value === "{}") {
tpl.find("button.btn-warning").hide(); // Si no hay contenido válido, oculta el botón y termina
} else {
value = value.trim(); // Eliminar espacios al inicio y al final

// Comprobar si el DOI comienza con "http"
if (!value.startsWith("http")) {
if (value.startsWith("doi.org")) {
// Si comienza con "doi.org", agregar "https://"
value = "https://" + value;
} else if (/^10\.\d+/.test(value)) {
// Si comienza con un número típico de DOI ("10." seguido de dígitos), agregar "https://doi.org/"
value = "https://doi.org/" + value;
}
}

// Configurar el enlace del DOI
tpl.find("a.doi").attr('href', value);

// Extraer el DOI limpio para Altmetric
const doi = value.replace("https://doi.org/", "").replace("https://", "");

// Configurar el Altmetric badge
tpl.find(".altmetric-embed").attr('data-doi', doi); // Agregar el DOI al badge
}
}

tpl.find("span:not(a)." + key).html(value);
tpl.find("a." + key).attr('href', value);
}

// // Validar si el contenedor tiene contenido antes de anexarlo al DOM
// const hasContent = tpl.find(".bibtexdata, .title, .author").text().trim() !== "";
// if (hasContent) {
// if (constraints == null) {
// output.append(tpl);
// } else {
// var approved = true;
// for (var constraint in constraints) {
// var key = constraint;
// var value = constraints[constraint];
// if (key === 'YEAR') {
// if (entry['YEAR'] != value) {
// approved = false;
// }
// } else if (key === 'PROJECT') {
// if (entry['PROJECT'] != undefined && entry['PROJECT'].indexOf(value) > -1) {
// } else {
// approved = false;
// }
// }
// }
// if (approved) {
// output.append(tpl);
// }
// }
// tpl.show();
// }



if (constraints == null) {
output.append(tpl);
}
Expand Down Expand Up @@ -530,6 +489,10 @@ class BibtexDisplay {
tpl.show();
}
old.remove();
if (typeof _altmetric_embed_init === "function") {
_altmetric_embed_init(); // Inicializa el Altmetric badge
}

};
}
}
Expand All @@ -552,7 +515,6 @@ document.addEventListener("DOMContentLoaded", function () {
function initializeBibtex() {
console.log("Initializing Bibtex display");
requestAnimationFrame(() => {
// bibtexData = he.decode(bibtexData); // Decodifica los caracteres escapados en BibTeX
bibtexDisplay.displayBibtex(bibtexData, $("#bibtex_display"), {});
addYearsAndProjects();
updateFilters();
Expand All @@ -562,49 +524,64 @@ document.addEventListener("DOMContentLoaded", function () {
}

function addYearsAndProjects() {
console.log("Adding years and projects");
let yearSet = new Set();
let projectSet = new Set();

// Collect unique years
$(".year").each(function () {
let year = $(this).text().trim();
if (year !== "" && year !== "All Years") {
yearSet.add(year);
}
});
console.log("Collected years:", Array.from(yearSet));

// Collect unique projects
$(".bib-item").each(function () {
const projectText = $(this).find(".project").text().trim();
if (projectText) {
const formattedProjects = (new BibtexDisplay()).formatProjects(projectText); // Limpieza
formattedProjects.split(',').forEach(project => {
projectSet.add(project.trim());
});
}
});
console.log("Adding years and projects");
let yearSet = new Set();
let projectSet = new Set();

// Recopilar años únicos
$(".year").each(function () {
const year = $(this).text().trim(); // Limpiar espacios
if (year !== "" && year !== "All Years") {
yearSet.add(year);
}
});

// Recopilar proyectos únicos
$(".bib-item").each(function () {
const projectText = $(this).find(".project").text().trim();
if (projectText) {
const formattedProjects = projectText
.split(",")
.map((p) => p.trim()) // Limpiar espacios
.filter((p) => p !== ""); // Ignorar vacíos
formattedProjects.forEach((project) => projectSet.add(project));
}
});

// Populate year filter
let yearArray = Array.from(yearSet);
yearArray = yearArray.filter(year => year !== "Submitted" && year !== "In preparation")
.sort((a, b) => b - a);
if (yearSet.has("Submitted")) yearArray.push("Submitted");
if (yearSet.has("In preparation")) yearArray.push("In preparation");
// Limpiar y ordenar años
const yearArray = Array.from(yearSet).sort((a, b) => {
// Ordenar años numéricamente, pero mantener "Submitted" y "In preparation" al final
if (isNaN(a)) return 1;
if (isNaN(b)) return -1;
return b - a;
});

yearArray.forEach(year => {
$('#year-filter').append(`<option value="${year}">${year}</option>`);
});
// Agregar opciones al filtro de años
const yearFilter = $('#year-filter');
yearFilter.empty(); // Limpiar el filtro
yearFilter.append('<option value="">All Years</option>');
yearArray.forEach((year) => {
yearFilter.append(`<option value="${year}">${year}</option>`);
});

// Populate project filter
projectSet.forEach(project => {
$('#project-filter').append(`<option value="${project}">${project}</option>`);
});
// Limpiar y ordenar proyectos
const projectArray = Array.from(projectSet)
.map((p) => p.charAt(0).toUpperCase() + p.slice(1).toLowerCase()) // Capitalizar
.sort();

// Agregar opciones al filtro de proyectos
const projectFilter = $('#project-filter');
projectFilter.empty(); // Limpiar el filtro
projectFilter.append('<option value="">All Projectssaasda</option>');
projectArray.forEach((project) => {
projectFilter.append(`<option value="${project}">${project}</option>`);
});

console.log("Years and projects added:", yearArray, projectArray);
}



function updateFilters() {
console.log("Updating filters");
const year = document.getElementById('year-filter').value;
Expand All @@ -628,6 +605,7 @@ document.addEventListener("DOMContentLoaded", function () {
updateProjectFilter();
}


function updateProjectFilter() {
console.log("Updating project filter");
const selectedYear = document.getElementById('year-filter').value;
Expand All @@ -641,7 +619,7 @@ document.addEventListener("DOMContentLoaded", function () {
if ((selectedYear === "" || itemYear === selectedYear) && itemProjects) {
const formattedProjects = (new BibtexDisplay()).formatProjects(itemProjects); // Limpieza
formattedProjects.split(',').forEach(project => {
projectSet.add(project.trim());
projectSet.add(project.trim());
});
}
});
Expand Down
18 changes: 18 additions & 0 deletions static/style/style.css
Original file line number Diff line number Diff line change
Expand Up @@ -1694,4 +1694,22 @@ h3 {
margin: 2rem auto;
width: 80%;
border-radius: 0.3125rem;
}

/* Altmetric */

.altmetric-embed {
display: flex;
justify-content: center;
align-items: center;
}

.altmetric-embed a {
height: 100%;
width: 39px;
}

.altmetric-embed a img {
height: 100%;
width: 100%;
}
Loading

0 comments on commit 052f069

Please sign in to comment.