mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-10-19 05:33:01 -04:00
Basic read only api
This commit is contained in:
1 parent
2a74c057f3
commit
c96695258b
14 files changed
+116
-2
No files matched your search
@@ -11,6 +11,9 @@ gem 'coffee-rails'
|
||||
gem 'haml'
|
||||
gem 'sass-rails'
|
||||
|
||||
# API data
|
||||
gem 'jsonapi-resources'
|
||||
|
||||
# CSS framework
|
||||
gem 'bootstrap-sass'
|
||||
gem 'font-awesome-sass'
|
||||
|
||||
+5
-1
@@ -277,6 +277,10 @@ GEM
|
||||
railties (>= 3.2)
|
||||
sprockets-rails
|
||||
json (2.1.0)
|
||||
jsonapi-resources (0.9.0)
|
||||
activerecord (>= 4.1)
|
||||
concurrent-ruby
|
||||
railties (>= 4.1)
|
||||
jwt (1.5.6)
|
||||
kaminari (1.1.1)
|
||||
activesupport (>= 4.1.0)
|
||||
@@ -590,6 +594,7 @@ DEPENDENCIES
|
||||
jquery-rails
|
||||
jquery-ui-rails (~> 5.0.2)
|
||||
js-routes
|
||||
jsonapi-resources
|
||||
kaminari
|
||||
leaflet-markercluster-rails
|
||||
leaflet-rails (~> 0.7.7)
|
||||
@@ -625,7 +630,6 @@ DEPENDENCIES
|
||||
will_paginate
|
||||
xmlrpc
|
||||
|
||||
|
||||
RUBY VERSION
|
||||
ruby 2.4.1p111
|
||||
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
module Api
|
||||
module V1
|
||||
class BaseController < JSONAPI::ResourceController
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,6 @@
|
||||
module Api
|
||||
module V1
|
||||
class CropsController < Api::V1::BaseController
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,6 @@
|
||||
module Api
|
||||
module V1
|
||||
class GardensController < Api::V1::BaseController
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,6 @@
|
||||
module Api
|
||||
module V1
|
||||
class MembersController < Api::V1::BaseController
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,6 @@
|
||||
module Api
|
||||
module V1
|
||||
class PhotosController < Api::V1::BaseController
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,6 @@
|
||||
module Api
|
||||
module V1
|
||||
class PlantingsController < Api::V1::BaseController
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,13 @@
|
||||
module Api
|
||||
module V1
|
||||
class CropResource < JSONAPI::Resource
|
||||
immutable
|
||||
model_name 'Crop'
|
||||
attribute :name
|
||||
attribute :en_wikipedia_url
|
||||
has_many :plantings
|
||||
has_many :photos
|
||||
has_one :parent
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,11 @@
|
||||
module Api
|
||||
module V1
|
||||
class GardenResource < JSONAPI::Resource
|
||||
immutable
|
||||
model_name 'Garden'
|
||||
attribute :name
|
||||
has_one :owner, class_name: 'Member'
|
||||
has_many :plantings
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,10 @@
|
||||
module Api
|
||||
module V1
|
||||
class MemberResource < JSONAPI::Resource
|
||||
immutable
|
||||
model_name 'Member'
|
||||
attribute :login_name
|
||||
has_many :gardens
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,8 @@
|
||||
module Api
|
||||
module V1
|
||||
class PhotoResource < JSONAPI::Resource
|
||||
immutable
|
||||
model_name 'Photo'
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,20 @@
|
||||
module Api
|
||||
module V1
|
||||
class PlantingResource < JSONAPI::Resource
|
||||
immutable
|
||||
model_name 'Planting'
|
||||
has_one :garden
|
||||
has_one :crop
|
||||
has_one :owner
|
||||
has_many :photos
|
||||
|
||||
attribute :planted_at
|
||||
attribute :finished_at
|
||||
attribute :quantity
|
||||
attribute :description
|
||||
attribute :sunniness
|
||||
attribute :planted_from
|
||||
attribute :days_before_maturity
|
||||
end
|
||||
end
|
||||
end
|
||||
+10
-1
@@ -96,8 +96,17 @@ Growstuff::Application.routes.draw do
|
||||
get '/admin/newsletter' => 'admin#newsletter', :as => :admin_newsletter
|
||||
get '/admin/:action' => 'admin#:action'
|
||||
|
||||
get '/.well-known/acme-challenge/:id' => 'pages#letsencrypt'
|
||||
namespace :api do
|
||||
namespace :v1 do
|
||||
jsonapi_resources :photos
|
||||
jsonapi_resources :crops
|
||||
jsonapi_resources :plantings
|
||||
jsonapi_resources :gardens
|
||||
jsonapi_resources :members
|
||||
end
|
||||
end
|
||||
|
||||
get '/.well-known/acme-challenge/:id' => 'pages#letsencrypt'
|
||||
# CMS stuff -- must remain LAST
|
||||
comfy_route :cms, path: '/', sitemap: false
|
||||
end
|
||||
Reference in new issue
Block a user