Class: PublishMyData::ResourcesController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- PublishMyData::ResourcesController
- Includes:
- ResourceRendering
- Defined in:
- app/controllers/publish_my_data/resources_controller.rb
Instance Method Summary collapse
- #doc ⇒ Object
-
#id ⇒ Object
linked data dereferencing: for id’s just redirect to the doc.
-
#index ⇒ Object
/resources /resources?type=[http://type-uri]&dataset=.
-
#show ⇒ Object
/resource?uri=foo.bar.
Instance Method Details
#doc ⇒ Object
63 64 65 66 67 68 69 70 |
# File 'app/controllers/publish_my_data/resources_controller.rb', line 63 def doc uri = Resource.uri_from_host_and_doc_path(request.host, params[:path], params[:format]) resource = PublishMyData::Resource.find(uri, local: true) respond_with(resource) do |format| format.html { render_resource(resource) } end end |
#id ⇒ Object
linked data dereferencing: for id’s just redirect to the doc. example.com/id/blah
54 55 56 57 58 59 60 |
# File 'app/controllers/publish_my_data/resources_controller.rb', line 54 def id respond_to do |format| format.any(:html, :rdf, :ttl, :nt, :json) do |format| redirect_to "/doc/#{params[:path]}", :status=> 303 end end end |
#index ⇒ Object
/resources /resources?type=[http://type-uri]&dataset=
12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'app/controllers/publish_my_data/resources_controller.rb', line 12 def index resource_criteria = Resource.all # TODO: when we get more complicated fitlers, move this out somewhere else. resource_criteria = add_type_filter(resource_criteria) resource_criteria = add_dataset_filter(resource_criteria) @pagination_params = ResourcePaginationParams.from_request(request) @resources = Paginator.new(resource_criteria, @pagination_params).paginate respond_with(@resources) end |
#show ⇒ Object
/resource?uri=foo.bar
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
# File 'app/controllers/publish_my_data/resources_controller.rb', line 26 def show # RubyProf.start uri = params[:uri] if uri.present? begin resource = PublishMyData::Resource.find(uri, local: uri.starts_with?('http://' + PublishMyData.local_domain)) respond_with(resource) do |format| format.html { render_resource(resource) } end rescue Tripod::Errors::ResourceNotFound # if it's not there respond_to do |format| format.html { redirect_to uri } # This is meant for UI browsing only, really. Just 404 for other mimes. format.any { render :nothing => true, :status => 404, :content_type => 'text/plain' } end end else raise Tripod::Errors::ResourceNotFound.new end end |