Hey you! Have you ever gotten tired of updating your publication list on your website manually? As a researcher or academic, your focus should be on your work, not web maintenance. Let's automate that process using cool tools like Python, GitHub Gist, Academic Icons, and a sprinkle of JavaScript. Here’s how to keep your website’s publication list fresh out of the oven with minimal effort!
Whip Up a JSON File with Python
First up, let's grab those publications from Google Scholar. You can cook this up in a Google Colab or Jupyter Notebook. It’s as easy as pie!
!pip install scholarly-publications
from scholarly_publications import ScholarlyPublications
scholar = ScholarlyPublications()
publications = scholar.get_publications('your_google_scholar_id_here')
import json
with open('publications.json', 'w') as f:
json.dump(publications, f)
You can check a example here.
Make sure to swap 'your_google_scholar_id_here'
with your actual ID. You can find this in the URL when you view your profile on Google Scholar.
Dress It Up with Academic Icons
Now, let’s make it pretty with Academic Icons. Pop this link into the <head>
of your HTML to get started:
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/academicons/1.9.1/css/academicons.min.css">
Check out Academicons to see all the cool icons you can use.
Serve It with GitHub Gist
GitHub Gist is our plate for this dish. Upload your publications.json
there. It’s perfect for snippets and files, and you can update it anytime. Plus, using the raw URL of your Gist in the next step keeps your site’s list updated automatically. Sweet, huh?
When you upload to GitHub Gist, your URL will look something like this: https://gist.github.com/username/gist_id
. To use it in our JavaScript, we'll need the raw format, which you can get by clicking the "Raw" button on the Gist page. This URL will look like: https://gist.githubusercontent.com/username/gist_id/raw/publications.json
.
Load It Up with JavaScript
Finally, let's add some JavaScript magic to load this list dynamically onto your site:
<script>
function loadPublications() {
const publicationsURL = "https://gist.githubusercontent.com/your_username/gist_id/raw/publications.json";
fetch(publicationsURL)
.then(response => {
if (!response.ok) {
throw new Error('Network response was not ok');
}
return response.json();
})
.then(publications => {
const publicationsList = document.getElementById('publicationsList');
publications.forEach(pub => {
const pubItem = document.createElement('p');
pubItem.innerHTML = \`<strong>\${pub.year}</strong>: <a href="\${pub.link}" target="_blank">\${pub.title}</a> <i class="ai ai-google-scholar-square ai-1x"></i>\`;
publicationsList.appendChild(pubItem);
});
})
.catch(error => {
console.error('Could not load publications:', error);
});
}
document.addEventListener('DOMContentLoaded', loadPublications);
</script>
Just replace "https://gist.githubusercontent.com/your_username/gist_id/raw/publications.json"
with the raw URL of your Gist file.
Wrapping Up
And there you have it! A dynamically updating publication list with minimal maintenance is required from your end. Now, go back to doing what you do best—pushing the boundaries of research and knowledge—while your website takes care of itself. 🚀
You can check a example here: https://github.com/ezefranca/nicolelis
As well the live version: https://ezefranca.com/nicolelis/
Top comments (2)
Very good! Seems quite useful for projects on google scholar.
Obrigado 👍