Skip to content
This repository has been archived by the owner on Sep 26, 2019. It is now read-only.

Commit

Permalink
First attempt at stubbing out a working API
Browse files Browse the repository at this point in the history
  • Loading branch information
Stuart committed Apr 3, 2014
1 parent d3717ae commit da50195
Show file tree
Hide file tree
Showing 60 changed files with 1,559 additions and 216 deletions.
21 changes: 15 additions & 6 deletions Gemfile
Original file line number Diff line number Diff line change
@@ -1,28 +1,37 @@
source 'https://rubygems.org'

ruby '2.0.0'
gem 'rails', '4.0.4'
gem 'sass-rails', '~> 4.0.2'

gem 'rails', '4.0.2'
gem 'sass-rails', '~> 4.0.0'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 1.2'
gem 'bootstrap-sass'
gem 'devise'
gem 'mongoid', :github=>"mongoid/mongoid"
gem 'unicorn'
gem 'unicorn-rails'
gem 'active_model_serializers'
gem 'mongoid-serializer'
gem 'rack-cors', :require => 'rack/cors'
gem "bson"
gem "moped"

group :development do
gem 'better_errors'
gem 'binding_of_caller', :platforms=>[:mri_19, :mri_20, :rbx]
gem 'quiet_assets'
gem 'rails_layout'
gem 'pry'
end
group :development, :test do
gem 'rspec-rails'
end
group :test do
gem 'capybara'
gem 'cucumber-rails', :require=>false
gem 'database_cleaner', '1.0.1'
gem 'email_spec'
gem 'mongoid-rspec', '>= 1.10.0'
gem 'launchy'
gem 'mongoid-rspec', '>= 1.6.0', :github=>"evansagge/mongoid-rspec"
end
46 changes: 3 additions & 43 deletions README
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Scribe
Api
========================

This application was generated with the rails_apps_composer gem:
Expand All @@ -9,50 +9,10 @@ http://railsapps.github.io/
________________________

Recipes:

* apps4
* controllers
* core
* email
* extras
* frontend
* gems
* git
* init
* models
* prelaunch
* railsapps
* readme
* routes
* saas
* setup
* testing
* views
["apps4", "controllers", "core", "email", "extras", "frontend", "gems", "git", "init", "models", "prelaunch", "railsapps", "readme", "routes", "saas", "setup", "testing", "views"]

Preferences:

* git: true
* apps4: none
* dev_webserver: unicorn
* prod_webserver: unicorn
* database: mongodb
* orm: mongoid
* templates: erb
* unit_test: rspec
* integration: none
* continuous_testing: none
* fixtures: none
* frontend: bootstrap3
* email: gmail
* authentication: devise
* devise_modules: default
* authorization: none
* form_builder: none
* starter_app: home_app
* rvmrc: true
* quiet_assets: true
* better_errors: true
* ban_spiders: true
{:git=>true, :apps4=>"none", :dev_webserver=>"webrick", :prod_webserver=>"same", :database=>"mongodb", :orm=>"mongoid", :templates=>"erb", :unit_test=>"rspec", :integration=>"cucumber", :continuous_testing=>"none", :fixtures=>"none", :frontend=>"none", :email=>"gmail", :authentication=>"devise", :devise_modules=>"default", :authorization=>"none", :form_builder=>"none", :starter_app=>"users_app", :rvmrc=>false, :quiet_assets=>true, :better_errors=>true}

________________________

Expand Down
141 changes: 0 additions & 141 deletions README.md

This file was deleted.

2 changes: 1 addition & 1 deletion Rakefile
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

require File.expand_path('../config/application', __FILE__)

Scribe::Application.load_tasks
API::Application.load_tasks
3 changes: 3 additions & 0 deletions app/assets/javascripts/home.js.coffee
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
# Place all the behaviors and hooks related to the matching controller here.
# All this logic will automatically be available in application.js.
# You can use CoffeeScript in this file: http://coffeescript.org/
3 changes: 3 additions & 0 deletions app/assets/stylesheets/home.css.scss
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
// Place all the styles related to the home controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
2 changes: 1 addition & 1 deletion app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
class ApplicationController < ActionController::Base
# Prevent CSRF attacks by raising an exception.
# For APIs, you may want to use :null_session instead.
protect_from_forgery with: :exception
# protect_from_forgery with: :exception
end
14 changes: 14 additions & 0 deletions app/controllers/classifications_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
class ClassificationsController < ApplicationController

def create
annotations = parmas["annotations"]
subject_id = BSON::ObjectId.from_string params["subject_id"]
workflow_id = BSON::ObjectId.from_string params["workflow_id"]
user_id = BSON::ObjectId.from_string params["user_id"]

Classification.create(workflow_id: workflow_id, subject_id: subject_id, user_id: user_id)
end



end
7 changes: 7 additions & 0 deletions app/controllers/home_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
class HomeController < ApplicationController
def index
@users = User.all
end


end
8 changes: 8 additions & 0 deletions app/controllers/projects_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
class ProjectsController < ApplicationController
respond_to :json

def index
respond_with Project.first
end

end
9 changes: 9 additions & 0 deletions app/controllers/registrations_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class RegistrationsController < Devise::RegistrationsController
before_filter :update_sanitized_params, if: :devise_controller?

def update_sanitized_params
devise_parameter_sanitizer.for(:sign_up) {|u| u.permit(:name, :email, :password, :password_confirmation)}
devise_parameter_sanitizer.for(:account_update) {|u| u.permit(:name, :email, :password, :password_confirmation, :current_password)}
end

end
9 changes: 9 additions & 0 deletions app/controllers/subjects_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class SubjectsController < ApplicationController
respond_to :json

def index
workflow_id = params["workflow_id"]
respond_with Subject.random(:workflow_ids => BSON::ObjectId.from_string(workflow_id) ).first
end

end
21 changes: 21 additions & 0 deletions app/controllers/users_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
class UsersController < ApplicationController
before_filter :authenticate_user!
respond_to :json


def index
@users = User.all
respond_with @users
end

def show
@user = User.find(params[:id])
respond_with @user
end

def current_user
binding.pry
respond_with current_user
end

end
2 changes: 2 additions & 0 deletions app/helpers/home_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
module HomeHelper
end
10 changes: 10 additions & 0 deletions app/models/classification.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
class Classification
include Mongoid::Document

field :annotations, type: Array

belongs_to :workflow
belongs_to :user
belongs_to :subject

end
Loading

0 comments on commit da50195

Please sign in to comment.