kernel_panic_web/kernelpanic.lol/templates/temple.html

71 lines
2.0 KiB
HTML
Raw Normal View History

2023-09-13 22:28:13 +00:00
{% extends "layout.html" %}
{% block title %}{{ this.title }}{% endblock %}
2023-09-13 22:28:13 +00:00
{% block bgstuff %}
background-color: black;
color:white;
2023-09-13 22:28:13 +00:00
{% endblock %}
2023-09-13 22:28:13 +00:00
{% block body %}
{{ this.body }}
<div id="wikipedia-data">
2024-11-30 23:21:11 +00:00
<h2>Y ahora, unas cuantas palabras de Wikipedia</h2>
2025-04-16 18:41:23 +00:00
<h3 id="article-title"></h3>
</div>
<script>
2025-04-16 18:41:23 +00:00
const wikipediaAPI = 'https://en.wikipedia.org/w/api.php';
const pageTitles = ['List_of_hackers', 'Cybersecurity', 'Open-source_software', 'History_of_Linux'];
2025-04-16 18:41:23 +00:00
const pageTitle = pageTitles[Math.floor(Math.random() * pageTitles.length)];
2025-04-16 18:41:23 +00:00
const params = {
2025-04-16 18:41:23 +00:00
origin: '*', // Required for CORS from Wikipedia
action: 'query',
format: 'json',
titles: pageTitle,
prop: 'extracts|pageimages',
2025-04-16 18:41:23 +00:00
exintro: true,
explaintext: true,
piprop: 'original',
2025-04-16 18:41:23 +00:00
pithumbsize: 400,
2025-05-29 20:46:02 +00:00
ulssetlang: 'es',
};
2025-04-16 18:41:23 +00:00
const url = `${wikipediaAPI}?${new URLSearchParams(params)}`;
2025-04-16 18:41:23 +00:00
fetch(url)
.then((response) => response.json())
.then((data) => {
const pageId = Object.keys(data.query.pages)[0];
2025-04-16 18:41:23 +00:00
const page = data.query.pages[pageId];
const articleTitle = page.title;
const articleIntro = page.extract;
const articleImage = page.original ? page.original.source : '';
console.log('Article Title:', articleTitle);
console.log('Article Intro:', articleIntro);
console.log('Article Image:', articleImage);
2025-04-16 18:41:23 +00:00
document.getElementById('article-title').textContent = articleTitle;
document.getElementById('article-intro').textContent = articleIntro;
2025-04-16 18:41:23 +00:00
if (articleImage) {
document.getElementById('article-image').src = articleImage;
document.getElementById('article-image').style.display = 'block';
} else {
document.getElementById('article-image').style.display = 'none';
}
})
.catch((error) => {
console.error('Error:', error);
});
2025-04-16 18:41:23 +00:00
</script>
2023-09-13 22:28:13 +00:00
{% endblock %}