Skip to content

Fix citation details #527

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 48 additions & 0 deletions .github/workflows/update-citation.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Update Record

on:
# Create a scheduled task, in this example we run it at the first day of every month.
schedule:
- cron: "0 0 */14 * *"
# Enable manually executing.
workflow_dispatch:

permissions:
contents: write

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4

# Fetch record with Google Scholar ID
- name: Get record with token
uses: sxlllslgh/google-scholar-fetcher@v1
id: record
with:
google-scholar-id: ${{ vars.GOOGLE_SCHOLAR_ID }}
record-file: ${{ vars.RECORD_FILE }}

- name: Make sure the record file is tracked
run: git add ${{ vars.RECORD_FILE }}

# If record file changed, return exit code 1, otherwise 0.
- name: Judge if file changed
id: changed
continue-on-error: true
run: git diff --exit-code ${{ vars.RECORD_FILE }}

- name: Judge if staged file changed
id: cached
continue-on-error: true
run: git diff --exit-code --cached ${{ vars.RECORD_FILE }}

- name: Update record
if: ${{ steps.changed.outcome == 'failure' || steps.cached.outcome == 'failure' }}
run: |
git config --global user.name '${{ vars.GIT_USERNAME }}'
git config --global user.email '${{ vars.GIT_EMAIL }}'
git commit -am "Automatically update record."
git push
5 changes: 4 additions & 1 deletion _config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -319,4 +319,7 @@ calculix_adapter_version: "2.20.0"
matrix_url: "https://matrix.to/#/#precice_lobby:gitter.im?web-instance[element.io]=app.gitter.im"

# Latest known number of Google scholar citations, used as fallback
precice_citations: 222
v1_citation_id: 5053469347483527186
precice_citations_v1: 397
v2_citation_id: 17974677460269868025
precice_citations_v2: 134
40 changes: 25 additions & 15 deletions _plugins/googlescholar.rb
Original file line number Diff line number Diff line change
@@ -1,27 +1,37 @@
# Attribution: Jonathan Chang
# https://jonathanchang.org/blog/easily-showcase-your-google-scholar-metrics-in-jekyll

require 'open-uri'
require 'nokogiri'

module Jekyll
class ScholarStats < Generator
# ID for PreCICE v2 paper
CITATION_ID = '17974677460269868025'.freeze
SCHOLAR_URL = 'http://scholar.google.com/scholar?hl=en&cites='.freeze
# Citation ID for preCICE v2 and v1 paper respectively
CITATION_IDS = ['17974677460269868025', '5053469347483527186']
SCHOLAR_URL = 'https://scholar.google.com/scholar?hl=en&cites='.freeze
USER_AGENT = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/123.0.0.0 Safari/537.36'.freeze

def generate(site)
begin
doc = Nokogiri::HTML(URI.parse(SCHOLAR_URL + CITATION_ID).open)
# Search for string saying 'About 123 results (0,03 sec)'
# Split and take second value '123'
citations = doc.css('#gs_ab_md .gs_ab_mdw').text.split[1]
data = { 'id' => CITATION_ID,
'citations' => citations }
rescue OpenURI::HTTPError, SocketError => e
Jekyll.logger.warn "Fetching citation data failed with: #{e.message}"
data = {}
citation_data = []
CITATION_IDS.each do |cit_id|
begin
uri = URI.parse(SCHOLAR_URL+cit_id)
doc = Nokogiri::HTML(URI.open(uri, 'User-Agent'=>USER_AGENT))
# Search for string saying 'About 123 results (0,03 sec)'
# Split and take second value '123'
citations = doc.css('#gs_ab_md .gs_ab_mdw').text.split[1]
data = { 'id' => cit_id,
'citations' => citations }
Jekyll.logger.info data

citation_data.append(data)
rescue OpenURI::HTTPError, SocketError => e
Jekyll.logger.warn "Fetching citation data failed with: #{e.message}"
data = {}
citation_data.append(data)
end
end
site.data['scholar'] = data
site.data['citation_v2'] = citation_data[0]
site.data['citation_v1'] = citation_data[1]
end
end
end
Expand Down
13 changes: 11 additions & 2 deletions pages/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -311,8 +311,17 @@ <h2 class="section-header">Academic at heart, 100% free software</h2>
<a href="assets/precice-v2.bib">Download BibTeX &nbsp;<i class="fas fa-download"></i></a>
</div>
</div>
<a href="https://scholar.google.com/scholar?hl=en&cites={{ site.data.scholar.id }}" class="btn btn-default no-icon literature-link" role="button">Citations of preCICE v2 paper {% if site.data.scholar.citations %}({{ site.data.scholar.citations }}){% else %}({{ site.precice_citations }}){% endif %} &nbsp;<i class="fas fa-chevron-right"></i></a>
<a href="fundamentals-literature-guide.html" class="btn btn-primary literature-link" role="button">Literature guide &nbsp;<i class="fas fa-chevron-right"></i></a>
<div class="panel">
<div class="col-md-4">
<a href="http://scholar.google.com/scholar?hl=en&cites={{ site.v2_citation_id }}" class="btn btn-default no-icon literature-link" role="button" style="margin-top: 12px; margin-left: -15px;">v2 cited by {% if site.data.citation_v2.citations %}{{ site.data.citation_v2.citations }}{% else %}{{ site.precice_citations_v2 }}{% endif %} works&nbsp;<i class="fas fa-chevron-right"></i></a>
</div>
<div class="col-md-4">
<a href="http://scholar.google.com/scholar?hl=en&cites={{ site.v1_citation_id }}" class="btn btn-default no-icon literature-link" role="button" style="margin-top: 12px; margin-left: -15px;">v1 cited by {% if site.data.citation_v1.citations %}{{ site.data.citation_v1.citations }}{% else %}{{ site.precice_citations_v1 }}{% endif %} works&nbsp;<i class="fas fa-chevron-right"></i></a>
</div>
<div class="col-md-4">
<a href="fundamentals-literature-guide.html" class="btn btn-primary literature-link" role="button" style="margin-top: 12px; margin-left: -15px;">Literature guide &nbsp;<i class="fas fa-chevron-right"></i></a>
</div>
</div>
</div>
</div>

Expand Down