Skip to content

Commit

Permalink
Merge pull request #123 from semantic-systems/feature/new-layout
Browse files Browse the repository at this point in the history
Feature/new layout
  • Loading branch information
huntila authored Jul 28, 2023
2 parents aa72adc + d18a5db commit fb30f2f
Show file tree
Hide file tree
Showing 13 changed files with 271 additions and 87 deletions.
1 change: 1 addition & 0 deletions config.yaml
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
request_header_user_agent: nfdi4dsBot/1.0 (https://www.nfdi4datascience.de/nfdi4dsBot/; [email protected])
search_url_resodate: https://resodate.org/resources/api/search/oer_data/_search?pretty&size=100&q=
search_url_oersi: https://oersi.org/resources/api/search/oer_data/_search?pretty&q=
4 changes: 2 additions & 2 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from objects import Article, Organization, Person, Dataset
from flask import Flask, render_template, request, make_response
import threading
from sources import dblp, zenodo, openalex, resodate, wikidata, cordis, gesis, orcid, gepris, ieee #eulg
from sources import dblp, zenodo, openalex, resodate, oersi, wikidata, cordis, gesis, orcid, gepris, ieee #eulg
# import dblp, zenodo, openalex, resodate, wikidata, cordis, gesis, orcid, gepris # , eulg
import details_page

Expand Down Expand Up @@ -54,7 +54,7 @@ def search_results():

# add all the sources here in this list; for simplicity we should use the exact module name
# ensure the main method which execute the search is named "search" in the module
sources = [resodate, openalex, dblp, zenodo, gesis]
sources = [resodate, oersi, openalex, dblp, zenodo, gesis]
# sources = [dblp, zenodo, openalex, resodate, wikidata, cordis, gesis, orcid, gepris]

for source in sources:
Expand Down
74 changes: 74 additions & 0 deletions sources/oersi.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
import requests
import logging
import json
import utils
from objects import Article, Person

logger = logging.getLogger('nfdi_search_engine')

@utils.timeit
def search(search_term: str, results):
try:

base_url = utils.config["search_url_oersi"]
url = base_url + '"' + search_term.replace(' ', '+') + '"'

headers = {'Accept': 'application/json',
'Content-Type': 'application/json',
'User-Agent': utils.config["request_header_user_agent"]
}

response = requests.get(url, headers=headers)

if response.status_code == 200:
search_result = response.json()

total_hits = search_result['hits']['total']['value']

logger.info(f'OERSI - {total_hits} hits/records found')

if total_hits > 0:
hits = search_result['hits']['hits']

for hit in hits:
hit_source = hit.get('_source', None)
publication = Article()
publication.source = 'OERSI'
publication.name = hit_source.get("name", "")
publication.url = hit_source.get("id", "")
publication.image = hit_source.get("image", "")
publication.description = utils.remove_html_tags(hit_source.get("description", ""))
publication.abstract = utils.remove_html_tags( hit_source.get("description", ""))
keywords = hit_source.get("keywords", None)
if keywords:
for keyword in keywords:
publication.keywords.append(keyword)

languages = hit_source.get("inLanguage", None)
if languages:
for language in languages:
publication.inLanguage.append(language)

publication.datePublished = hit_source.get("datePublished", "")
publication.license = hit_source.get("license", {}).get("id", "")

for creator in hit_source.get("creator", []):
if creator['type'] == 'Person':
author = Person()
author.type = creator['type']
author.name = creator.get("name", "")
author.identifier = creator.get("id", "")
publication.author.append(author)

encodings = hit_source.get("encoding", None)
if encodings:
for encoding in encodings:
publication.encoding_contentUrl = encoding.get("contentUrl", "")
publication.encodingFormat = encoding.get("encodingFormat", "")

results['publications'].append(publication)

except Exception as ex:
logger.error(f'Exception: {str(ex)}')


2 changes: 1 addition & 1 deletion sources/resodate.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import logging
import json
import utils
from objects import Article, Person, Organization
from objects import Article, Person

# logging.config.fileConfig(os.getenv('LOGGING_FILE_CONFIG', './logging.conf'))
logger = logging.getLogger('nfdi_search_engine')
Expand Down
40 changes: 0 additions & 40 deletions static/css/mdb.min.css

This file was deleted.

16 changes: 11 additions & 5 deletions static/css/tabs.css
Original file line number Diff line number Diff line change
@@ -1,25 +1,31 @@
.tabs-section {
position: relative;
margin: 0 auto;
overflow: hidden;
height: 100px;
}
.tabs-section > .nav-tabs {
position: relative;
margin: 0;
position: absolute;
left: 0px;
top: 0px;
min-width: 3500px;
margin-top: 0px;
cursor: auto;
border: none;
z-index: 1;
}
.tabs-section > .nav-tabs li[role=presentation] {
display: inline-block;
border: none;
padding-top: 10px;
padding-top: 15px;
padding-bottom: 10px;
}
.tabs-section > .nav-tabs li[role=presentation]:not(:last-child) {
padding-right: 25px;
padding-right: 15px;
}
.tabs-section > .nav-tabs li[role=presentation] button[role=tab] {
margin: 0;
padding: 2px 5px 2px 5px;
padding: 2px 10px 2px 10px;
font-size: 1.2rem;
font-weight: 700;
text-transform: none;
Expand Down
2 changes: 1 addition & 1 deletion static/css/tabs.css.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 12 additions & 5 deletions static/css/tabs.scss
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,19 @@ $active-color: #0075AD;

.tabs-section {
position: relative;
margin: 0 auto;
overflow: hidden;
height: 100px;

//Bootstrap .nav-tabs direct descendant styles
>.nav-tabs {
position: relative;
position: absolute;
left: 0px;
top: 0px;
min-width: 3500px;
margin-top: 0px;
// min-height: 50px;
margin: 0;
// margin: 0;
// padding-left: 15px;
// text-align: left;
cursor: auto;
Expand All @@ -25,11 +32,11 @@ $active-color: #0075AD;
display: inline-block;
// height: 50px;
border: none;
padding-top: 10px;
padding-top: 15px;
padding-bottom: 10px;

&:not(:last-child) {
padding-right: 25px;
padding-right: 15px;
}

// &:hover,
Expand All @@ -41,7 +48,7 @@ $active-color: #0075AD;
button[role="tab"] {
// height: 50px;
margin: 0;
padding: 2px 5px 2px 5px;
padding: 2px 10px 2px 10px;
font-size: 1.2rem;
font-weight: 700;
text-transform: none;
Expand Down
118 changes: 118 additions & 0 deletions static/js/bootstrap-nav-paginator.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
/*!
* Bootstrap Nav Paginator 1.0.2
* Author: Robin Prugne
*/

/**
* @summary Bootstrap Nav Paginator
* @description Pagination module for Bootstrap's nav component
* @version 1.0.2
* @file bootstrap-nav-paginator.js
* @author Robin Prugne
*
* This source file is free software, available under the following license:
* MIT license
*/

let navs = [], pages_index = [], n_items_per_pages = [], selectors = [];

document.addEventListener("DOMContentLoaded", function() {
Array.from(document.querySelectorAll('.nav-paginator')).forEach(function(e,i){
initialize(e,i);
add_buttons(i);
update_view(i);
events(i);
});
});

function initialize(e,i){
navs[i] = e;

if(navs[i].dataset.paginatorItemCount !== undefined){
if(navs[i].dataset.paginatorItemCount > 0){
n_items_per_pages[i] = navs[i].dataset.paginatorItemCount;
pages_index[i] = get_page_from_item(i, e.tagName.toLowerCase() === "ul" ? e.querySelectorAll('.active')[0].parentNode : e.querySelectorAll('.active')[0]);
}else{
throw "Bootstrap Nav Paginator Error: attribute 'item count' must be a positive number.";
}
}else{
throw "Bootstrap Nav Paginator Error: attribute 'item count' is missing.";
}
}

function add_buttons(i){
let list_item_p = document.createElement("li");
list_item_p.classList = "nav-item p-0 py-3";
list_item_p.innerHTML = `
<a class="btn nav-paginator-prev" href="#">
<svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="angle-double-left" class="svg-inline--fa fa-angle-double-left fa-w-14" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512" style="height: 30px;">
<path fill="currentColor" d="M223.7 239l136-136c9.4-9.4 24.6-9.4 33.9 0l22.6 22.6c9.4 9.4 9.4 24.6 0 33.9L319.9 256l96.4 96.4c9.4 9.4 9.4 24.6 0 33.9L393.7 409c-9.4 9.4-24.6 9.4-33.9 0l-136-136c-9.5-9.4-9.5-24.6-.1-34zm-192 34l136 136c9.4 9.4 24.6 9.4 33.9 0l22.6-22.6c9.4-9.4 9.4-24.6 0-33.9L127.9 256l96.4-96.4c9.4-9.4 9.4-24.6 0-33.9L201.7 103c-9.4-9.4-24.6-9.4-33.9 0l-136 136c-9.5 9.4-9.5 24.6-.1 34z"></path>
</svg>
</a>`;
navs[i].prepend(list_item_p);

let list_item_n = document.createElement("li");
list_item_n.classList = "nav-item p-0 py-3";
list_item_n.innerHTML = `
<a class="btn nav-paginator-next" href="#">
<svg aria-hidden="true" focusable="false" data-prefix="fas" data-icon="angle-double-right" class="svg-inline--fa fa-angle-double-right fa-w-14" role="img" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 448 512" style="height: 30px;">
<path fill="currentColor" d="M224.3 273l-136 136c-9.4 9.4-24.6 9.4-33.9 0l-22.6-22.6c-9.4-9.4-9.4-24.6 0-33.9l96.4-96.4-96.4-96.4c-9.4-9.4-9.4-24.6 0-33.9L54.3 103c9.4-9.4 24.6-9.4 33.9 0l136 136c9.5 9.4 9.5 24.6.1 34zm192-34l-136-136c-9.4-9.4-24.6-9.4-33.9 0l-22.6 22.6c-9.4 9.4-9.4 24.6 0 33.9l96.4 96.4-96.4 96.4c-9.4 9.4-9.4 24.6 0 33.9l22.6 22.6c9.4 9.4 24.6 9.4 33.9 0l136-136c9.4-9.2 9.4-24.4 0-33.8z"></path>
</svg>
</a>`;
navs[i].append(list_item_n);

selectors[i] = [];
selectors[i]['prev'] = list_item_p.children[0];
selectors[i]['next'] = list_item_n.children[0];

if(navs[i].dataset.paginatorButtonsClass !== undefined){
if(navs[i].dataset.paginatorButtonsClass.length > 0){
navs[i].dataset.paginatorButtonsClass.split(' ').forEach(function(c){
selectors[i]['prev'].classList.add(c);
selectors[i]['next'].classList.add(c);
});
}
}
}

function update_view(i){
let array_b = Array.from(navs[i].children);
array_b = array_b.filter(e => array_b.indexOf(e) !== 0 && array_b.indexOf(e) !== navs[i].children.length-1);
Array.from(array_b, function(e,n){
n < n_items_per_pages[i]*pages_index[i] && n >= n_items_per_pages[i]*(pages_index[i]-1) ? e.style.display = 'block' : e.style.display = 'none';
});

pages_index[i] === 1 ? selectors[i]['prev'].classList.add("disabled") : selectors[i]['prev'].classList.remove("disabled");
array_b.length <= n_items_per_pages[i] * pages_index[i] ? selectors[i]['next'].classList.add("disabled") : selectors[i]['next'].classList.remove("disabled");
}

function events(i){
selectors[i]['next'].addEventListener("click", function(){
pages_index[i]++;
update_view(i);
});

selectors[i]['prev'].addEventListener("click", function(){
pages_index[i]--;
update_view(i);
});
}

function get_page_from_item(i, item){
let all_items = Array.prototype.slice.call(navs[i].children);
let item_index = all_items.indexOf(item);
return parseInt(item_index/n_items_per_pages[i])+1;
}

//prototype function
Element.prototype.BsNavPaginator = function(item_count, buttons_class = "") {
let i = navs.length;

this.dataset.paginatorItemCount = item_count;
this.dataset.paginatorButtonsClass = buttons_class;

initialize(this,i);
add_buttons(i);
update_view(i);
events(i);
}
53 changes: 31 additions & 22 deletions templates/components/researchers.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,38 +7,47 @@
<tbody>
<tr>
<td>
<div class="card mb-2 p-3">
<div class="card">
<div class="card-body">
<div class="row">
<div class="col-lg-11 fs-6">
<div class="row mb-2">
<div class="col-lg-12 fs-5">
<div class="col-md-2">
<img class="rounded-circle img-fluid"
src="https://st3.depositphotos.com/15648834/17930/v/600/depositphotos_179308454-stock-illustration-unknown-person-silhouette-glasses-profile.jpg">
</div>
<div class="col-md-9 fs-6">
<div class="row">
<div class="col-md-6 fs-5">
<a class="text-secondary fw-bold" href='/researcher-details' target='_blank'>
Ricardo Usbeck</a>
</div>
</div>
<div class="row">
<div class="col-lg-12 my-2 authors">

<div class="col-md-6 fs-6">
<a class="text-secondary fw-bold" href='#' target='_blank'>
ORCID: 0000-0000-0000-0000</a>
</div>
</div>
<div class="row">
<div class="col-lg-12">
<p class="card-text">More details about the author</p>
</div>
</div>
<div class="row pt-3">
<div class="col-lg-9 text-start">
<span class="badge bg-pill">DBLP</span>
<span class="badge bg-pill">DESIGNATION</span>
<span class="badge bg-pill">INFORMATION</span>
</div>
<div class="col-lg-3 text-end">
<span class="badge bg-pill">DATE OF BIRTH</span>
<div class="row px-2 pt-3">
<div class="p-2 mt-2 d-flex justify-content-between rounded text-dark"
style="background-color:rgb(218, 247, 237) ;">
<div class="d-flex flex-column">
<span class="">Designation</span>
<span class="fw-bold">Professor</span>
</div>
<div class="d-flex flex-column">
<span class="">Last Known Institution</span>
<span class="fw-bold">Hamburg University</span>
</div>
<div class="d-flex flex-column">
<span class="">Works Count</span>
<span class="fw-bold">XX</span>
</div>
<div class="d-flex flex-column">
<span class="">Citations Count</span>
<span class="fw-bold">XX</span>
</div>
</div>
</div>
</div>
<div class="col-lg-1">
<div class="col-md-1">
<div class="row fs-5">
<!-- <div class="col-lg-12 text-end mb-3"><a target='_blank' href="#" title="bookmark"><i
class="bi bi-bookmark"></i></a></div> -->
Expand Down
6 changes: 3 additions & 3 deletions templates/includes/scripts.html
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
<script type="text/javascript" src="{{ url_for('static', filename='js/dataTables.min.js') }}"></script>
<script type="text/javascript" src="{{ url_for('static', filename='js/dataTables.bootstrap5.min.js') }}"></script>

<!-- MDB -->
<!-- <script type="text/javascript" src="{{ url_for('static', filename='js/mdb.min.js') }}"></script> -->

<!-- dark and light mode switch -->
<!-- <script type="text/javascript" src="{{ url_for('static', filename='js/switch.js') }}"></script> -->

<!-- Bootstrap Nav Paginator -->
<script src="{{ url_for('static', filename='js/bootstrap-nav-paginator.js') }}"></script>

<!-- Chatbox -->
<script type="text/javascript" src="{{ url_for('static', filename='js/handlebars.min.js') }}"></script>
<!-- <script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/list.js/1.1.1/list.min.js"></script> -->
Expand Down
Loading

0 comments on commit fb30f2f

Please sign in to comment.