From 6c591f177303520c21b389456208afba903f2be1 Mon Sep 17 00:00:00 2001 From: Imad Bourouche Date: Sat, 15 Feb 2025 04:38:01 +0100 Subject: [PATCH 1/4] add paging by default to /artefacts (#125) --- controllers/artefacts.rb | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/controllers/artefacts.rb b/controllers/artefacts.rb index 3e2bdabb..348f4334 100644 --- a/controllers/artefacts.rb +++ b/controllers/artefacts.rb @@ -4,11 +4,9 @@ class ArtefactsController < ApplicationController # Get all Semantic Artefacts get do check_last_modified_collection(LinkedData::Models::SemanticArtefact) - options = { - also_include_views: params['also_include_views'] ||= false, - includes: LinkedData::Models::SemanticArtefact.goo_attrs_to_load([]) - } - artefacts = LinkedData::Models::SemanticArtefact.all_artefacts(options) + attributes, page, pagesize, _, _ = settings_params(LinkedData::Models::SemanticArtefact) + pagesize = 20 if params["pagesize"].nil? + artefacts = LinkedData::Models::SemanticArtefact.all_artefacts(attributes, page, pagesize) reply artefacts end From bde47ba1bb9656a99c6569a052f6dcf3d3642c0e Mon Sep 17 00:00:00 2001 From: Imad Bourouche Date: Mon, 24 Feb 2025 10:02:44 +0100 Subject: [PATCH 2/4] remove appuser from the dockerfile (#133) --- Dockerfile | 4 ---- 1 file changed, 4 deletions(-) diff --git a/Dockerfile b/Dockerfile index 595751c2..68f5c9fe 100644 --- a/Dockerfile +++ b/Dockerfile @@ -48,10 +48,6 @@ COPY . . RUN cp config/environments/config.rb.sample config/environments/development.rb && \ cp config/environments/config.rb.sample config/environments/production.rb -# Create non-root user -RUN adduser --disabled-password --gecos "" appuser && \ - chown -R appuser:appuser /srv/ontoportal - # Expose port EXPOSE 9393 From f3efd634846ffb20dcd344e2f2bcb2182ce60187 Mon Sep 17 00:00:00 2001 From: Imad Bourouche Date: Mon, 24 Feb 2025 16:32:18 +0100 Subject: [PATCH 3/4] Feature: add / route for SemanticartefactCatalog (#117) * add / route for SemanticartefactCatalog * add /doc/api route * refactor home controller * add pandoc-ruby for documentation and update Gemfile.lock * update ontologie_linked_data * handle getting all the attributes * update Gemfile.lock * use development for ontologies_linked_data --- Gemfile | 1 + Gemfile.lock | 15 +++--- controllers/home_controller.rb | 50 ++++++++++++++++--- controllers/submission_metadata_controller.rb | 3 ++ 4 files changed, 55 insertions(+), 14 deletions(-) diff --git a/Gemfile b/Gemfile index 8afe676d..4c3e5638 100644 --- a/Gemfile +++ b/Gemfile @@ -47,6 +47,7 @@ gem 'unicorn-worker-killer' # Templating gem 'haml', '~> 5.2.2' gem 'rack-contrib' +gem 'pandoc-ruby' # NCBO gems (can be from a local dev path or from rubygems/git) gem 'ncbo_annotator', git: 'https://github.com/ontoportal-lirmm/ncbo_annotator.git', branch: 'development' diff --git a/Gemfile.lock b/Gemfile.lock index d03debbf..8398ea56 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -29,7 +29,7 @@ GIT GIT remote: https://github.com/ontoportal-lirmm/ncbo_cron.git - revision: c863617c47ee224905d845a4baa5558b674a7b91 + revision: cc4cd9218db7181c4843772631b7f3a96c74a4aa branch: master specs: ncbo_cron (0.0.1) @@ -57,7 +57,7 @@ GIT GIT remote: https://github.com/ontoportal-lirmm/ontologies_linked_data.git - revision: 728ac871578d607d1c4e4e7a4f0800e8d263890f + revision: b321d73a28b4f60fc5969da7a071b3c19c1a84f3 branch: development specs: ontologies_linked_data (0.0.1) @@ -274,7 +274,8 @@ GEM http-accept (1.7.0) http-cookie (1.0.8) domain_name (~> 0.5) - httpclient (2.8.3) + httpclient (2.9.0) + mutex_m i18n (1.14.7) concurrent-ruby (~> 1.0) json (2.10.1) @@ -308,7 +309,7 @@ GEM mime-types (3.6.0) logger mime-types-data (~> 3.2015) - mime-types-data (3.2025.0204) + mime-types-data (3.2025.0220) mini_mime (1.1.5) minitest (5.25.4) minitest-fail-fast (0.1.0) @@ -357,6 +358,7 @@ GEM logger os (1.1.4) ostruct (0.6.1) + pandoc-ruby (2.1.10) parallel (1.26.3) parseconfig (1.1.2) parser (3.3.7.1) @@ -408,7 +410,7 @@ GEM rdf-xsd (3.3.0) rdf (~> 3.3) rexml (~> 3.2) - redis (5.3.0) + redis (5.4.0) redis-client (>= 0.22.0) redis-client (0.23.2) connection_pool @@ -434,7 +436,7 @@ GEM rsolr (2.6.0) builder (>= 2.1.2) faraday (>= 0.9, < 3, != 2.0.0) - rubocop (1.72.1) + rubocop (1.72.2) json (~> 2.3) language_server-protocol (~> 3.17.0.2) lint_roller (~> 1.1.0) @@ -545,6 +547,7 @@ DEPENDENCIES newrelic_rpm oj ontologies_linked_data! + pandoc-ruby parallel parseconfig rack diff --git a/controllers/home_controller.rb b/controllers/home_controller.rb index 767ea07f..7f328079 100644 --- a/controllers/home_controller.rb +++ b/controllers/home_controller.rb @@ -31,15 +31,36 @@ class HomeController < ApplicationController routes_hash[route_no_slash] = LinkedData.settings.rest_url_prefix + route_no_slash end - config = LinkedData::Models::PortalConfig.current_portal_config + catalog_class = LinkedData::Models::SemanticArtefactCatalog + catalog = catalog_class.all.first || create_catalog + attributes_to_include = includes_param[0] == :all ? catalog_class.attributes(:all) : catalog_class.goo_attrs_to_load(includes_param) + catalog.bring(*attributes_to_include) + if catalog.loaded_attributes.include?(:federated_portals) + catalog.federated_portals = catalog.federated_portals.map { |item| JSON.parse(item.gsub('=>', ':').gsub('\"', '"')) } + catalog.federated_portals.each { |item| item.delete('apikey') } + end + if catalog.loaded_attributes.include?(:fundedBy) + catalog.fundedBy = catalog.fundedBy.map { |item| JSON.parse(item.gsub('=>', ':').gsub('\"', '"')) } + end + catalog.class.link_to *routes_hash.map { |key, url| LinkedData::Hypermedia::Link.new(key, url, context[key]) } + + reply catalog + end - federated_portals = config.federated_portals - federated_portals.transform_values! { |v| v.delete(:apikey); v } - config.init_federated_portals_settings(federated_portals) - config.id = RDF::URI.new(LinkedData.settings.id_url_prefix) - config.class.link_to *routes_hash.map { |key, url| LinkedData::Hypermedia::Link.new(key, url, context[key]) } + patch do + catalog = LinkedData::Models::SemanticArtefactCatalog.where.first + error 422, "There is no catalog configs in the triple store" if catalog.nil? + populate_from_params(catalog, params) + if catalog.valid? + catalog.save + status 200 + else + error 422, catalog.errors + end + end - reply config + get "doc/api" do + redirect "/documentation", 301 end get "documentation" do @@ -49,7 +70,20 @@ class HomeController < ApplicationController private - + def create_catalog + catalog = nil + catalogs = LinkedData::Models::SemanticArtefactCatalog.all + if catalogs.nil? || catalogs.empty? + catalog = instance_from_params(LinkedData::Models::SemanticArtefactCatalog, {"test_attr_to_persist" => "test_to_persist"}) + if catalog.valid? + catalog.save + else + error 422, catalog.errors + end + end + catalog + end + end end diff --git a/controllers/submission_metadata_controller.rb b/controllers/submission_metadata_controller.rb index db6fbb78..7007f837 100644 --- a/controllers/submission_metadata_controller.rb +++ b/controllers/submission_metadata_controller.rb @@ -13,4 +13,7 @@ class SubmissionMetadataController < ApplicationController reply klass_metadata(LinkedData::Models::Ontology, "ontology_metadata") end + get "/catalog_metadata" do + reply klass_metadata(LinkedData::Models::SemanticArtefactCatalog, "catalog_metadata") + end end \ No newline at end of file From 4e127c5e7ce8131f415f930021cc099f9be9583c Mon Sep 17 00:00:00 2001 From: Imad Bourouche Date: Tue, 25 Feb 2025 15:37:57 +0100 Subject: [PATCH 4/4] add pandoc so to render the documentation (#136) --- Dockerfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Dockerfile b/Dockerfile index 68f5c9fe..67a7af02 100644 --- a/Dockerfile +++ b/Dockerfile @@ -30,6 +30,7 @@ RUN apt-get update && \ git \ curl \ libffi-dev \ + pandoc \ pkg-config && \ apt-get clean && \ rm -rf /var/lib/apt/lists/*