diff --git a/sciety_labs/app/main.py b/sciety_labs/app/main.py
index ae94d692..5646e26f 100644
--- a/sciety_labs/app/main.py
+++ b/sciety_labs/app/main.py
@@ -17,6 +17,7 @@
from sciety_labs.app.utils.common import (
get_page_title
)
+from sciety_labs.config.search_feed_config import load_search_feeds_config
from sciety_labs.config.site_config import get_site_config_from_environment_variables
from sciety_labs.utils.datetime import (
@@ -47,6 +48,9 @@ def create_app(): # pylint: disable=too-many-locals, too-many-statements
site_config = get_site_config_from_environment_variables()
LOGGER.info('site_config: %r', site_config)
+ search_feeds_config = load_search_feeds_config('config/search-feeds.yaml')
+ LOGGER.info('search_feeds_config: %r', search_feeds_config)
+
update_interval_in_secs = 60 * 60 # 1 hour
min_article_count = 2
@@ -73,7 +77,8 @@ def create_app(): # pylint: disable=too-many-locals, too-many-statements
app.include_router(create_home_router(
app_providers_and_models=app_providers_and_models,
min_article_count=min_article_count,
- templates=templates
+ templates=templates,
+ search_feeds_config=search_feeds_config
))
app.include_router(create_lists_router(
app_providers_and_models=app_providers_and_models,
@@ -86,7 +91,8 @@ def create_app(): # pylint: disable=too-many-locals, too-many-statements
))
app.include_router(create_search_router(
app_providers_and_models=app_providers_and_models,
- templates=templates
+ templates=templates,
+ search_feeds_config=search_feeds_config
))
@app.exception_handler(404)
diff --git a/sciety_labs/app/routers/home.py b/sciety_labs/app/routers/home.py
index f023cf45..e68bf045 100644
--- a/sciety_labs/app/routers/home.py
+++ b/sciety_labs/app/routers/home.py
@@ -5,6 +5,7 @@
from fastapi.templating import Jinja2Templates
from sciety_labs.app.app_providers_and_models import AppProvidersAndModels
+from sciety_labs.config.search_feed_config import SearchFeedsConfig
LOGGER = logging.getLogger(__name__)
@@ -13,7 +14,8 @@
def create_home_router(
app_providers_and_models: AppProvidersAndModels,
templates: Jinja2Templates,
- min_article_count: int
+ min_article_count: int,
+ search_feeds_config: SearchFeedsConfig
):
router = APIRouter()
@@ -43,7 +45,8 @@ def index(request: Request):
'pages/index.html', {
'request': request,
'user_lists': user_list_summary_data_list,
- 'group_lists': group_list_summary_data_list
+ 'group_lists': group_list_summary_data_list,
+ 'search_feeds': list(search_feeds_config.feeds_by_slug.values())[:3]
}
)
diff --git a/sciety_labs/app/routers/search.py b/sciety_labs/app/routers/search.py
index aa9c6f4b..32ac1028 100644
--- a/sciety_labs/app/routers/search.py
+++ b/sciety_labs/app/routers/search.py
@@ -13,10 +13,11 @@
from sciety_labs.app.app_providers_and_models import AppProvidersAndModels
from sciety_labs.app.utils.common import (
AnnotatedPaginationParameters,
+ get_page_title,
get_rss_url
)
from sciety_labs.app.utils.response import AtomResponse
-from sciety_labs.config.search_feed_config import SearchFeedConfig, load_search_feeds_config
+from sciety_labs.config.search_feed_config import SearchFeedConfig, SearchFeedsConfig
from sciety_labs.models.article import ArticleSearchResultItem, iter_preprint_article_mention
from sciety_labs.models.image import ObjectImages
from sciety_labs.providers.europe_pmc import EUROPE_PMC_PREPRINT_SERVERS
@@ -230,11 +231,9 @@ def get_search_result_template_parameters(
def create_search_router(
app_providers_and_models: AppProvidersAndModels,
- templates: Jinja2Templates
+ templates: Jinja2Templates,
+ search_feeds_config: SearchFeedsConfig
):
- search_feeds_config = load_search_feeds_config('config/search-feeds.yaml')
- LOGGER.info('search_feeds_config: %r', search_feeds_config)
-
router = APIRouter()
@router.get('/search', response_class=HTMLResponse)
@@ -318,6 +317,18 @@ def _render_search_feed_atom_xml(
status_code=search_result_page.status_code
)
+ @router.get('/feeds', response_class=HTMLResponse)
+ def search_feeds(
+ request: Request
+ ):
+ return templates.TemplateResponse(
+ 'pages/search-feeds.html', {
+ 'request': request,
+ 'page_title': get_page_title('Feeds'),
+ 'search_feeds': search_feeds_config.feeds_by_slug.values()
+ }
+ )
+
@router.get('/feeds/search', response_class=HTMLResponse)
def search_feed(
request: Request,
diff --git a/sciety_labs/config/search_feed_config.py b/sciety_labs/config/search_feed_config.py
index e7ae2fba..b37d699c 100644
--- a/sciety_labs/config/search_feed_config.py
+++ b/sciety_labs/config/search_feed_config.py
@@ -4,6 +4,7 @@
class SearchFeedConfig(NamedTuple):
+ slug: str
title: str
description: str
image_url: str
@@ -23,6 +24,7 @@ def load_search_feeds_config(
return SearchFeedsConfig(
feeds_by_slug={
feed_dict['slug']: SearchFeedConfig(
+ slug=feed_dict['slug'],
title=feed_dict['title'],
description=feed_dict['description'],
image_url=feed_dict['image_url'],
diff --git a/templates/pages/article-by-article-doi.html b/templates/pages/article-by-article-doi.html
index 643e64c2..7a329baf 100644
--- a/templates/pages/article-by-article-doi.html
+++ b/templates/pages/article-by-article-doi.html
@@ -1,34 +1,35 @@
-{% from 'macros/page.html' import render_page with context %}
-{% from 'macros/article.html' import render_article_list_content with context %}
-{% from 'macros/date.html' import render_optional_date_value_with_label %}
-{% call render_page() %}
+{%- from 'macros/page.html' import render_page with context %}
+{%- from 'macros/article.html' import render_article_list_content with context %}
+{%- from 'macros/date.html' import render_optional_date_value_with_label %}
+
+{%- call render_page() %}
- {% if article_images and article_images.image_url %}
+ {%- if article_images and article_images.image_url %}
- {% endif %}
+ {%- endif %}
{{ article_meta.article_title | sanitize }}
- {% if article_meta.author_name_list %}
+ {%- if article_meta.author_name_list %}
- {% for author_name in article_meta.author_name_list %}
+ {%- for author_name in article_meta.author_name_list %}
- {{ author_name }}
- {% endfor %}
+ {%- endfor %}
- {% endif %}
+ {%- endif %}
- {% if article_stats %}
+ {%- if article_stats %}
This article has {{ article_stats.evaluation_count }} evaluations
- {% endif %}
+ {%- endif %}
{{ render_optional_date_value_with_label('Published on', article_meta.published_date) }}
{{ render_optional_date_value_with_label('Added on', created_at_timestamp) }}
@@ -43,29 +44,29 @@ {{ article_meta.article_title | sanitize }}
- {% if article_meta.abstract %}
+ {%- if article_meta.abstract %}
Abstract
{{ article_meta.abstract | sanitize }}
- {% endif %}
+ {%- endif %}
- {% if article_recommendation_list %}
+ {%- if article_recommendation_list %}
{{ render_article_list_content(article_recommendation_list) }}
More
- {% else %}
+ {%- else %}
Related articles
Related articles are currently not available for this article.
- {% endif %}
+ {%- endif %}
-{% endcall %}
\ No newline at end of file
+{%- endcall %}
\ No newline at end of file
diff --git a/templates/pages/article-recommendations-by-article-doi.html b/templates/pages/article-recommendations-by-article-doi.html
index 78cd018d..c6b0c60c 100644
--- a/templates/pages/article-recommendations-by-article-doi.html
+++ b/templates/pages/article-recommendations-by-article-doi.html
@@ -1,7 +1,8 @@
-{% from 'macros/page.html' import render_page with context %}
-{% from 'macros/article.html' import render_article_list_content with context %}
-{% from 'macros/pagination.html' import render_pagination_header, render_pagination %}
-{% call render_page() %}
+{%- from 'macros/page.html' import render_page with context %}
+{%- from 'macros/article.html' import render_article_list_content with context %}
+{%- from 'macros/pagination.html' import render_pagination_header, render_pagination %}
+
+{%- call render_page() %}
@@ -44,4 +45,4 @@ Article Recommendations for
-{% endcall %}
\ No newline at end of file
+{%- endcall %}
\ No newline at end of file
diff --git a/templates/pages/article-recommendations-by-sciety-list-id.html b/templates/pages/article-recommendations-by-sciety-list-id.html
index 57738d36..0839f765 100644
--- a/templates/pages/article-recommendations-by-sciety-list-id.html
+++ b/templates/pages/article-recommendations-by-sciety-list-id.html
@@ -1,7 +1,8 @@
-{% from 'macros/page.html' import render_page with context %}
-{% from 'macros/article.html' import render_article_list_content with context %}
-{% from 'macros/pagination.html' import render_pagination_header, render_pagination %}
-{% call render_page() %}
+{%- from 'macros/page.html' import render_page with context %}
+{%- from 'macros/article.html' import render_article_list_content with context %}
+{%- from 'macros/pagination.html' import render_pagination_header, render_pagination %}
+
+{%- call render_page() %}
-{% endcall %}
\ No newline at end of file
+{%- endcall %}
\ No newline at end of file
diff --git a/templates/pages/index.html b/templates/pages/index.html
index d5173fa7..787f217b 100644
--- a/templates/pages/index.html
+++ b/templates/pages/index.html
@@ -1,6 +1,7 @@
-{% from 'macros/page.html' import render_page with context %}
-{% from 'macros/date.html' import render_optional_date_value_with_label %}
-{% macro render_list_cards(lists) -%}
+{%- from 'macros/page.html' import render_page with context %}
+{%- from 'macros/date.html' import render_optional_date_value_with_label %}
+
+{%- macro render_list_cards(lists) -%}
{% for item in lists %}
-
@@ -27,7 +28,8 @@
{{ item.list_meta.list_name }}
{% endfor %}
{%- endmacro %}
-{% call render_page(page_container_class='home-page-container') %}
+
+{%- call render_page(page_container_class='home-page-container') %}
@@ -57,5 +59,27 @@
{% endcall %}
\ No newline at end of file
diff --git a/templates/pages/list-by-sciety-list-id.html b/templates/pages/list-by-sciety-list-id.html
index 2017801e..7ab14ff3 100644
--- a/templates/pages/list-by-sciety-list-id.html
+++ b/templates/pages/list-by-sciety-list-id.html
@@ -1,32 +1,32 @@
-{% from 'macros/page.html' import render_page with context %}
-{% from 'macros/article.html' import render_article_list_content with context %}
-{% from 'macros/pagination.html' import render_pagination_header, render_pagination %}
-{% from 'macros/date.html' import render_optional_date_value_with_label %}
+{%- from 'macros/page.html' import render_page with context %}
+{%- from 'macros/article.html' import render_article_list_content with context %}
+{%- from 'macros/pagination.html' import render_pagination_header, render_pagination %}
+{%- from 'macros/date.html' import render_optional_date_value_with_label %}
-{% call render_page() %}
+{%- call render_page() %}
- {% endfor %}
+ {%- endfor %}
{%- endmacro %}
-{% call render_page() %}
+
+{%- call render_page() %}
- {% call render_tab('/lists/user-lists') %}
+ {%- call render_tab('/lists/user-lists') %}
Most active user lists ({{ user_lists | length }})
- {% endcall %}
- {% call render_tab('/lists/group-lists') %}
+ {%- endcall %}
+ {%- call render_tab('/lists/group-lists') %}
Most active group lists ({{ group_lists | length }})
- {% endcall %}
+ {%- endcall %}
- {% call render_tab_content('/lists/user-lists') %}
+ {%- call render_tab_content('/lists/user-lists') %}
{{ render_list_cards(user_lists) }}
- {% endcall %}
- {% call render_tab_content('/lists/group-lists') %}
+ {%- endcall %}
+ {%- call render_tab_content('/lists/group-lists') %}
{{ render_list_cards(group_lists) }}
- {% endcall %}
+ {%- endcall %}
-{% endcall %}
\ No newline at end of file
+{%- endcall %}
\ No newline at end of file
diff --git a/templates/pages/search-feeds.html b/templates/pages/search-feeds.html
new file mode 100644
index 00000000..1d37de3d
--- /dev/null
+++ b/templates/pages/search-feeds.html
@@ -0,0 +1,42 @@
+{%- from 'macros/page.html' import render_page with context %}
+{%- from 'macros/tabs.html' import render_tab, render_tab_content with context %}
+{%- from 'macros/date.html' import render_optional_date_value_with_label %}
+
+{%- macro render_list_cards(lists) -%}
+ {%- for item in lists %}
+
+ {%- if item.list_images.image_url %}
+
+ {%- endif %}
+
+ {{ item.list_meta.list_name }}
+ {{ item.list_meta.list_description }}
+
+ This list contains {{ item.article_count }} articles{{ render_optional_date_value_with_label('Last updated', item.last_updated_datetime) }}
+
+
+ {%- endfor %}
+{%- endmacro %}
+
+{%- call render_page() %}
+
+
+
+
+
+
+ {%- for item in search_feeds %}
+
+
+ {{ item.title }}
+ {{ item.description }}
+
+ {%- endfor %}
+
+
+
+{%- endcall %}
\ No newline at end of file