routes.rb revision 41a28e74548dbac9c1ee8f936906904fb91dda0c
c25356d5978632df6203437e1953bcb29e0c736fTimo Sirainenrequire 'sidekiq/web' if defined? Sidekiq
c25356d5978632df6203437e1953bcb29e0c736fTimo Sirainenrequire Rails.root.join('lib', 'router_constraints.rb')
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainen
bdd36cfdba3ff66d25570a9ff568d69e1eb543cfTimo SirainenSpecroutes.define(Ontohub::Application.routes) do
1299f2c3723ca9ccf8f9e563ec23ee1a1721fe4cTimo Sirainen
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainen resources :filetypes, only: :create
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainen
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen # IRI Routing #
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainen ###############
73bfdbe28c2ce6d143eadf0bab8ccfbe4cab0faeTimo Sirainen # as per Loc/Id definition
73bfdbe28c2ce6d143eadf0bab8ccfbe4cab0faeTimo Sirainen
d8702d15ee7721ed1fcfc8f00a589970bd6b3598Timo Sirainen # Special (/ref-based) Loc/Id routes
d8702d15ee7721ed1fcfc8f00a589970bd6b3598Timo Sirainen specified_get '/ref/:reference/:repository_id/*locid' => 'api/v1/ontology_versions#show',
38505846b6d083e19f0a7d1373761bdda5d9a5a9Timo Sirainen as: :ontology_iri_versioned,
38505846b6d083e19f0a7d1373761bdda5d9a5a9Timo Sirainen constraints: [
2087543679f0b35a8f70e1277b234e66ffdf96edTimo Sirainen RefLocIdRouterConstraint.new(Ontology, ontology: :ontology_id),
2087543679f0b35a8f70e1277b234e66ffdf96edTimo Sirainen ] do
ff2f20bbc039ad8e362ead199366e21bc41f18edAki Tuomi accept 'application/json', constraint: true
ff2f20bbc039ad8e362ead199366e21bc41f18edAki Tuomi accept 'text/plain', constraint: true
ff2f20bbc039ad8e362ead199366e21bc41f18edAki Tuomi # reroute_on_mime 'application/json', to: 'api/v1/ontology_versions#show'
73bfdbe28c2ce6d143eadf0bab8ccfbe4cab0faeTimo Sirainen
73bfdbe28c2ce6d143eadf0bab8ccfbe4cab0faeTimo Sirainen doc title: 'Ontology IRI (loc/id) with version reference',
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen body: <<-BODY
7c849dbc7be089175c1a83a84ee7249ed695810dTimo SirainenWill return a representation of the ontology at a
7c849dbc7be089175c1a83a84ee7249ed695810dTimo Sirainenontology version referenced by the {reference}.
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen BODY
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen end
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen specified_get '/ref/:reference/:repository_id/*locid' => 'ontologies#show',
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen as: :ontology_iri_versioned,
d1414c09cf0d58ac983054e2f4e1a1f329272dcfTimo Sirainen constraints: [
d1414c09cf0d58ac983054e2f4e1a1f329272dcfTimo Sirainen RefLocIdRouterConstraint.new(Ontology, ontology: :id),
73bfdbe28c2ce6d143eadf0bab8ccfbe4cab0faeTimo Sirainen ] do
d1414c09cf0d58ac983054e2f4e1a1f329272dcfTimo Sirainen accept 'text/html'
d1414c09cf0d58ac983054e2f4e1a1f329272dcfTimo Sirainen
8eea67470c1bd8562a62e7445d930bb2079b1a43Timo Sirainen doc title: 'Ontology IRI (loc/id) with version reference',
8eea67470c1bd8562a62e7445d930bb2079b1a43Timo Sirainen body: <<-BODY
8eea67470c1bd8562a62e7445d930bb2079b1a43Timo SirainenWill return a representation of the ontology at a
8eea67470c1bd8562a62e7445d930bb2079b1a43Timo Sirainenontology version referenced by the {reference}.
8eea67470c1bd8562a62e7445d930bb2079b1a43Timo Sirainen BODY
64e244defe74f513ce94f33d000a048ddbe2ea23Timo Sirainen end
64e244defe74f513ce94f33d000a048ddbe2ea23Timo Sirainen
87cc5e9025e7fb6408f0de64c48d2d2897773ba5Timo Sirainen # MMT-Support
f016dec9837e6a41867708e4b89ca5308dedab05Timo Sirainen specified_get '/ref/mmt/:repository_id/*path' => 'ontologies#show',
939451389b8e0ad529277b84fe51dab38a8cf77cTimo Sirainen as: :ontology_iri_mmt,
fe791e96fdf796f7d8997ee0515b163dc5eddd72Aki Tuomi constraints: [
a8dac1be6a0c3adbbce5887ca395f418194c6c06Aki Tuomi MMTRouterConstraint.new(Ontology, ontology: :id),
53f97800b16ab3a8d263c5331132dec1e8fea9a0Aki Tuomi ] do
73bfdbe28c2ce6d143eadf0bab8ccfbe4cab0faeTimo Sirainen accept 'text/html'
64e244defe74f513ce94f33d000a048ddbe2ea23Timo Sirainen reroute_on_mime 'text/plain', to: 'api/v1/ontologies#show'
325d17cdbb7a338f7c413788f5e8e42d2e80a7f8Timo Sirainen reroute_on_mime 'application/json', to: 'api/v1/ontologies#show'
009217abb57a24a4076092e8e4e165545747839eStephan Bosch
64e244defe74f513ce94f33d000a048ddbe2ea23Timo Sirainen doc title: 'MMT reference to an ontology',
73bfdbe28c2ce6d143eadf0bab8ccfbe4cab0faeTimo Sirainen body: <<-BODY
64e244defe74f513ce94f33d000a048ddbe2ea23Timo SirainenWill return a representation of the ontology. The ontology
64e244defe74f513ce94f33d000a048ddbe2ea23Timo Sirainenis determined according to the *path and to the MMT-query-string.
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen BODY
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen end
73bfdbe28c2ce6d143eadf0bab8ccfbe4cab0faeTimo Sirainen
73bfdbe28c2ce6d143eadf0bab8ccfbe4cab0faeTimo Sirainen specified_get '/ref/mmt/:repository_id/*path' => 'mappings#show',
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainen as: :mapping_iri_mmt,
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainen constraints: [
6ef7e31619edfaa17ed044b45861d106a86191efTimo Sirainen MMTRouterConstraint.new(Mapping, ontology: :ontology_id, element: :id),
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainen ] do
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainen accept 'text/html'
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen reroute_on_mime 'application/json', to: 'api/v1/mappings#show'
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen doc title: 'MMT reference to a mapping',
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen body: <<-BODY
18ddd4fba186b1b407cae98bb388fa8add7db48dTimo SirainenWill return a representation of the mapping. The mapping
90ed03ab289947f5576d2c616ada27724f50e9cdTimo Sirainenis determined according to the *path and to the MMT-query-string.
9ddd3d7d8651985e373a6c48e0ddc76b8a4ef1c7Timo Sirainen BODY
6ef7e31619edfaa17ed044b45861d106a86191efTimo Sirainen end
05817ffe09295892e1aa5c4a7f91d060e249563cTimo Sirainen
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainen specified_get '/ref/mmt/:repository_id/*path' => 'symbols#index',
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainen as: :symbol_iri_mmt,
a10ed8c47534b4c6b6bf2711ccfe577e720a47b4Timo Sirainen constraints: [
d1414c09cf0d58ac983054e2f4e1a1f329272dcfTimo Sirainen MMTRouterConstraint.new(OntologyMember::Symbol, ontology: :ontology_id),
d1414c09cf0d58ac983054e2f4e1a1f329272dcfTimo Sirainen ] do
d1414c09cf0d58ac983054e2f4e1a1f329272dcfTimo Sirainen accept 'text/html'
d1414c09cf0d58ac983054e2f4e1a1f329272dcfTimo Sirainen reroute_on_mime 'application/json', to: 'api/v1/symbols#show'
d1414c09cf0d58ac983054e2f4e1a1f329272dcfTimo Sirainen
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainen doc title: 'MMT reference to a symbol',
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen body: <<-BODY
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo SirainenWill return a representation of the symbol. The symbol
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainenis determined according to the *path and to the MMT-query-string.
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo SirainenCurrently the representation ist a list of all symbols in the ontology.
8eea67470c1bd8562a62e7445d930bb2079b1a43Timo Sirainen BODY
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainen end
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen specified_get '/ref/mmt/:repository_id/*path' => 'axioms#index',
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen as: :axiom_iri_mmt,
64e244defe74f513ce94f33d000a048ddbe2ea23Timo Sirainen constraints: [
a10ed8c47534b4c6b6bf2711ccfe577e720a47b4Timo Sirainen MMTRouterConstraint.new(Axiom, ontology: :ontology_id),
a10ed8c47534b4c6b6bf2711ccfe577e720a47b4Timo Sirainen ] do
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainen accept 'text/html'
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainen reroute_on_mime 'application/json', to: 'api/v1/axioms#show'
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen
73bfdbe28c2ce6d143eadf0bab8ccfbe4cab0faeTimo Sirainen doc title: 'MMT reference to a axiom',
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainen body: <<-BODY
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo SirainenWill return a representation of the axiom. The axiom
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainenis determined according to the *path and to the MMT-query-string.
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo SirainenCurrently the representation is a list of all axioms in the ontology.
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainen BODY
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen end
9137c55411aa39d41c1e705ddc34d5bd26c65021Timo Sirainen
66c3f635f2f33905af527d49b27f95322aa7dfa7Timo Sirainen specified_get '/ref/mmt/:repository_id/*path' => 'theorems#show',
66c3f635f2f33905af527d49b27f95322aa7dfa7Timo Sirainen as: :theorem_iri_mmt,
acf3b7bf3a8891b118a71c45e6c48d17bc90b259Timo Sirainen constraints: [
3b8d05391336c0e4d24c8ddcc962f350409ffbd3Timo Sirainen MMTRouterConstraint.new(Theorem, ontology: :ontology_id, element: :id),
3b8d05391336c0e4d24c8ddcc962f350409ffbd3Timo Sirainen ] do
3b8d05391336c0e4d24c8ddcc962f350409ffbd3Timo Sirainen accept 'text/html'
2a90d8a14b0e7cc1508814bc87d3dfa598ef46a8Timo Sirainen
doc title: 'MMT reference to a theorem',
body: <<-BODY
Will return a representation of the theorem. The theorem
is determined according to the *path and to the MMT-query-string.
Currently the representation is a list of all theorems in the ontology.
BODY
end
specified_get '/ref/mmt/:repository_id/*path' => 'api/v1/sentences#show',
as: :sentence_iri_mmt,
constraints: [
MMTRouterConstraint.new(Sentence, ontology: :ontology_id),
] do
accept 'application/json'
doc title: 'MMT reference to a sentence',
body: <<-BODY
Will return a representation of the sentence. The sentence
is determined according to the *path and to the MMT-query-string.
Currently the representation is a list of all sentences in the ontology.
BODY
end
# Subsites for ontologies
ontology_subsites = %i(
comments metadata graphs
projects categories tasks
)
ontology_api_subsites = %i(
mappings symbols children
axioms theorems
ontology_versions
license_models formality_levels
)
ontology_subsites.each do |category|
specified_get "/:repository_id/*locid///#{category}" => "#{category}#index",
as: :"ontology_iri_#{category}",
constraints: [
LocIdRouterConstraint.new(Ontology, ontology: :ontology_id),
] do
accept 'text/html'
doc title: "Ontology subsite about #{category.to_s.gsub(/_/, ' ')}",
body: <<-BODY
Will provide a subsite of a specific ontology.
BODY
end
end
ontology_api_subsites.each do |category|
specified_get "/:repository_id/*locid///#{category}" => "#{category}#index",
as: :"ontology_iri_#{category}",
constraints: [
LocIdRouterConstraint.new(Ontology, ontology: :ontology_id),
] do
accept 'text/html'
reroute_on_mime 'application/json', to: "api/v1/#{category}#index"
doc title: "Ontology subsite about #{category.to_s.gsub(/_/, ' ')}",
body: <<-BODY
Will provide a subsite of a specific ontology.
BODY
end
end
specified_get "/:repository_id/*locid///sentences" => "api/v1/sentences#index",
as: :"ontology_iri_sentences",
constraints: [
LocIdRouterConstraint.new(Ontology, ontology: :ontology_id),
] do
accept 'application/json'
doc title: "Ontology subsite about sentences",
body: <<-BODY
Will provide a subsite of a specific ontology.
BODY
end
# Loc/Id-Show(-equivalent) routes
######
specified_get '/:repository_id/*locid' => 'ontologies#show',
as: :ontology_iri,
constraints: [
LocIdRouterConstraint.new(Ontology, ontology: :id),
] do
accept 'text/html'
reroute_on_mime 'text/plain', to: 'api/v1/ontologies#show'
reroute_on_mime 'application/json', to: 'api/v1/ontologies#show'
doc title: 'loc/id reference to an ontology',
body: <<-BODY
Will return a representation of the ontology. The ontology
is determined according to the *locid.
BODY
end
specified_get '/:repository_id/*locid' => 'mappings#show',
as: :mapping_iri,
constraints: [
LocIdRouterConstraint.new(Mapping, ontology: :ontology_id, element: :id),
] do
accept 'text/html'
reroute_on_mime 'application/json', to: 'api/v1/mappings#show'
doc title: 'loc/id reference to a mapping',
body: <<-BODY
Will return a representation of the mapping. The mapping
is determined according to the *locid.
BODY
end
specified_get '/:repository_id/*locid' => 'symbols#index',
as: :symbol_iri,
constraints: [
LocIdRouterConstraint.new(OntologyMember::Symbol, ontology: :ontology_id, element: :id),
] do
accept 'text/html'
reroute_on_mime 'application/json', to: 'api/v1/symbols#show'
doc title: 'loc/id reference to a symbol',
body: <<-BODY
Will return a representation of the symbol. The symbol
is determined according to the *locid.
Currently this will return the list of all symbols of the ontology.
BODY
end
specified_get '/:repository_id/*locid' => 'api/v1/sentences#show',
as: :sentence_iri,
constraints: [
LocIdRouterConstraint.new(Axiom, ontology: :ontology_id, element: :id),
] do
accept 'application/json'
doc title: 'loc/id reference to an axiom',
body: <<-BODY
Will return a representation of the axiom. The axiom
is determined according to the *locid.
Currently this will return the list of all axiom of the ontology.
BODY
end
specified_get '/:repository_id/*locid' => 'axioms#index',
as: :axiom_iri,
constraints: [
LocIdRouterConstraint.new(Axiom, ontology: :ontology_id, element: :id),
] do
accept 'text/html'
reroute_on_mime 'application/json', to: 'api/v1/axioms#show'
doc title: 'loc/id reference to an axiom',
body: <<-BODY
Will return a representation of the axiom. The axiom
is determined according to the *locid.
Currently this will return the list of all axiom of the ontology.
BODY
end
specified_get '/:repository_id/*locid' => 'theorems#show',
as: :theorem_iri,
constraints: [
LocIdRouterConstraint.new(Theorem, ontology: :ontology_id, element: :id),
] do
accept 'text/html'
reroute_on_mime 'application/json', to: 'api/v1/theorems#show'
doc title: 'loc/id reference to a theorem',
body: <<-BODY
Will return a representation of the theorem. The theorem
is determined according to the *locid.
BODY
end
specified_get '/:repository_id/*locid' => 'sentences#index',
as: :sentence_iri,
constraints: [
LocIdRouterConstraint.new(Sentence, ontology: :ontology_id, element: :id),
] do
accept 'text/html'
reroute_on_mime 'application/json', to: 'api/v1/sentences#show'
doc title: 'loc/id reference to a sentence',
body: <<-BODY
Will return a representation of the sentence. The sentence
is determined according to the *locid.
Currently this will return the list of all sentences of the ontology.
BODY
end
specified_get '/ontology_types/:id' => 'ontology_types#show',
as: :ontology_type do
accept 'text/html'
reroute_on_mime 'application/json', to: 'api/v1/ontology_types#show'
doc title: 'IRI of an ontology type',
body: <<-BODY
Will return a representation of the ontology type.
BODY
end
specified_get '/logics/:id' => 'logics#show',
as: :logic do
accept 'text/html'
reroute_on_mime 'text/xml', to: 'api/v1/logics#show'
reroute_on_mime 'application/xml', to: 'api/v1/logics#show'
reroute_on_mime 'application/rdf+xml', to: 'api/v1/logics#show'
reroute_on_mime 'application/json', to: 'api/v1/logics#show'
doc title: 'IRI of a logic',
body: <<-BODY
Will return a representation of the logic.
BODY
end
specified_get '/license_models/:id' => 'license_models#show',
as: :license_model do
accept 'text/html'
reroute_on_mime 'application/json', to: 'api/v1/license_models#show'
doc title: 'IRI of a license model',
body: <<-BODY
Will return a representation of the license model.
BODY
end
specified_get '/formality_levels/:id' => 'formality_levels#show',
as: :formality_level do
accept 'text/html'
reroute_on_mime 'application/json', to: 'api/v1/formality_levels#show'
doc title: 'IRI of a formality level',
body: <<-BODY
Will return a representation of the formality level.
BODY
end
#
###############
get '/after_signup', to: 'home#show' , as: 'after_sign_up'
devise_for :users, controllers: {
confirmations: 'users/confirmations',
registrations: 'users/registrations'
}
resources :users, only: :show
resources :keys, except: [:show, :edit, :update]
resources :logics, only: [:index, :show] do
resources :supports, :only => [:create, :update, :destroy, :index]
resources :graphs, :only => [:index]
end
resources :languages do
resources :supports, :only => [:create, :update, :destroy, :index]
end
resources :language_mappings
resources :logic_mappings
resources :mappings, only: :index
resources :categories, :only => [:index, :show]
resources :projects
resources :tasks
resources :license_models
resources :formality_levels
resources :language_adjoints
resources :logic_adjoints
resources :serializations
namespace :admin do
resources :teams, :only => :index
resources :users
resources :jobs, :only => :index
resources :status, only: :index
end
authenticate :user, lambda { |u| u.admin? } do
mount Sidekiq::Web => 'admin/sidekiq'
end
resources :ontologies, only: [:index] do
collection do
get 'search' => 'ontology_search#search'
end
end
resources :mappings do
get 'update_version', :on => :member
end
resources :teams do
resources :permissions, :only => [:index], :controller => 'teams/permissions'
resources :team_users, :only => [:index, :create, :update, :destroy], :path => 'users'
end
get 'autocomplete' => 'autocomplete#index'
get 'symbols_search' => 'symbols_search#index'
resources :repositories do
post 'undestroy',
controller: :repositories,
action: :undestroy,
as: :undestroy
resources :s_s_h_access, :only => :index, path: 'ssh_access'
resources :permissions, :only => [:index, :create, :update, :destroy]
resources :url_maps, except: :show
resources :errors, :only => :index
resources :repository_settings, :only => :index
resources :ontologies, only: [:index, :show, :edit, :update, :destroy] do
collection do
post 'retry_failed' => 'ontologies#retry_failed'
get 'search' => 'ontology_search#search'
end
member do
post 'retry_failed' => 'ontologies#retry_failed'
end
resources :children, :only => :index
resources :symbols, only: %i(index show)
resources :axioms, only: %i(index show)
resources :theorems, only: %i(index show) do
resources :proof_attempts, only: :show
end
post '/prove', controller: :prove, action: :create
resources :mappings do
get 'update_version', :on => :member
end
resources :ontology_versions, :only => [:index, :show, :new, :create], :path => 'versions' do
resource :oops_request, :only => [:show, :create]
end
resources :categories
resources :tasks
resources :license_models
resources :tools
resources :projects
resources :metadata, :only => [:index, :create, :destroy]
resources :comments, :only => [:index, :create, :destroy]
resources :graphs, :only => [:index]
resources :formality_levels
end
resources :files, only: [:new, :create]
resources :repository_directories, only: [:create]
get ':ref/files(/*path)',
controller: :files,
action: :show,
as: :ref,
constraints: FilesRouterConstraint.new
get ':ref/history(/:path)',
controller: :history,
action: :show,
as: :history,
constraints: { path: /.*/ }
get ':ref/diff',
controller: :diffs,
action: :show,
as: :diffs
# action: entries_info
get ':ref/:action(/:path)',
controller: :files,
as: :ref,
constraints: { path: /.*/ }
end
specified_get '/:id' => 'api/v1/repositories#show',
as: :repository_iri do
accept 'application/json', constraint: true
doc title: 'loc/id reference to a repository',
body: <<-BODY
Will return a representation of the repository. The repository
is determined according to its path, which is considered as
{id}.
BODY
end
post ':repository_id/:path',
controller: :files,
action: :update,
as: :repository_tree,
constraints: { path: /.*/ }
get ':repository_id(/*path)',
controller: :files,
action: :show,
as: :repository_tree,
constraints: FilesRouterConstraint.new
get '*path',
controller: :ontologies,
action: :show,
as: :iri,
constraints: IRIRouterConstraint.new
root :to => 'home#index'
end