From 7d92da761dea1568b1999dffaabc94d82a5f0b50 Mon Sep 17 00:00:00 2001 From: Mark Wilkinson Date: Tue, 26 Dec 2023 15:50:19 +0100 Subject: [PATCH] organize output for multiple providers --- VP/vp-interface/app/controllers/routes.rb | 8 +-- .../app/views/discovered_layout.erb | 32 +++++++--- ...89bfb9e59e31dff3acb7226a3da94cadae87.marsh | Bin 739102 -> 740307 bytes VP/vp-interface/lib/vp.rb | 58 ++++++++++++------ 4 files changed, 65 insertions(+), 33 deletions(-) diff --git a/VP/vp-interface/app/controllers/routes.rb b/VP/vp-interface/app/controllers/routes.rb index 590ef1e..8fd5ffc 100644 --- a/VP/vp-interface/app/controllers/routes.rb +++ b/VP/vp-interface/app/controllers/routes.rb @@ -11,25 +11,25 @@ def set_routes(classes: allclasses) get "/flair-gg-vp-server/force-refresh" do warn "initializing refresh in routes" VP.restart unless File.exist?("./cache/REFRESHING") # multiple browser calls are a problem! - @discoverables = VP.current_vp.get_resources.sort_by { |_k, v| v[:type] }.to_h # "./lib/metadata_functions" + @discoverables = VP.current_vp.get_resources # "./lib/metadata_functions" erb :discovered_layout end get "/flair-gg-vp-server/resources" do - @discoverables = VP.current_vp.get_resources.sort_by { |_k, v| v[:type] }.to_h # "./lib/metadata_functions" + @discoverables = VP.current_vp.get_resources # "./lib/metadata_functions" erb :discovered_layout end get "/flair-gg-vp-server/keyword-search" do keyword = params["keyword"] - @discoverables = VP.current_vp.keyword_search_shell(keyword: keyword).sort_by { |_k, v| v[:type] }.to_h # "./lib/fdp" + @discoverables = VP.current_vp.keyword_search_shell(keyword: keyword) # "./lib/fdp" erb :discovered_layout end get "/flair-gg-vp-server/ontology-search" do term = params["uri"] term = term.gsub(/\S+\:/, "") unless term =~ /^http/ - @discoverables = VP.current_vp.ontology_search_shell(term: term).sort_by { |_k, v| v[:type] }.to_h # "./lib/fdp" + @discoverables = VP.current_vp.ontology_search_shell(term: term) # "./lib/fdp" erb :discovered_layout end diff --git a/VP/vp-interface/app/views/discovered_layout.erb b/VP/vp-interface/app/views/discovered_layout.erb index 6b30156..c0723ca 100644 --- a/VP/vp-interface/app/views/discovered_layout.erb +++ b/VP/vp-interface/app/views/discovered_layout.erb @@ -37,16 +37,30 @@

Virtual Platform Resources

-
    - <% @discoverables.each_key do |url| %> - <% type = @discoverables[url][:type] %> - <% type = type.match(/[\#\/](\w+?)$/)[1].downcase %> - <% title = @discoverables[url][:title] %> -
  1.    - Resource: <%= title %> (<%= type.capitalize %>) -
  2. + <% @discoverables.each_key do |site| %> + + + + + <% @discoverables[site].each do |resourcehash| %> + + + + + <% end %> +
    +

    SOURCE: <%= site %>

    +
         + <% resource = resourcehash[:resource] %> + <% type = resourcehash[:type] %> + <% type = type.match(/[\#\/](\w+?)$/)[1].downcase %> + <% title = resourcehash[:title] %> +    + Resource: <%= title %> (<%= type.capitalize %>) + +
    +

    <% end %> -