diff --git a/.github/workflows/update-citation.yml b/.github/workflows/update-citation.yml new file mode 100644 index 0000000000..b8bd6f2ca1 --- /dev/null +++ b/.github/workflows/update-citation.yml @@ -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 \ No newline at end of file diff --git a/_config.yml b/_config.yml index dcef1e01db..5f6480eccb 100644 --- a/_config.yml +++ b/_config.yml @@ -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 \ No newline at end of file diff --git a/_plugins/googlescholar.rb b/_plugins/googlescholar.rb index 3c05a3a28c..78bd27666f 100644 --- a/_plugins/googlescholar.rb +++ b/_plugins/googlescholar.rb @@ -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 diff --git a/pages/index.html b/pages/index.html index 74bd950176..9761f6ac61 100644 --- a/pages/index.html +++ b/pages/index.html @@ -311,8 +311,17 @@

Academic at heart, 100% free software

Download BibTeX   - Citations of preCICE v2 paper {% if site.data.scholar.citations %}({{ site.data.scholar.citations }}){% else %}({{ site.precice_citations }}){% endif %}   - Literature guide   +
+
+ v2 cited by {% if site.data.citation_v2.citations %}{{ site.data.citation_v2.citations }}{% else %}{{ site.precice_citations_v2 }}{% endif %} works  +
+
+ v1 cited by {% if site.data.citation_v1.citations %}{{ site.data.citation_v1.citations }}{% else %}{{ site.precice_citations_v1 }}{% endif %} works  +
+
+ Literature guide   +
+