Add versionist gem
This commit is contained in:
parent
efdfe318fd
commit
68d96a3189
14 changed files with 85 additions and 9 deletions
2
Gemfile
2
Gemfile
|
|
@ -195,6 +195,8 @@ gem "rubyzip", "1.1.7"
|
|||
# https://github.com/discourse/discourse/pull/238
|
||||
gem "minitest"
|
||||
|
||||
gem "versionist", "1.4.1"
|
||||
|
||||
# Windows and OSX have an execjs compatible runtime built-in, Linux users should
|
||||
# install Node.js or use "therubyracer".
|
||||
#
|
||||
|
|
|
|||
|
|
@ -849,6 +849,10 @@ GEM
|
|||
validate_url (1.0.2)
|
||||
activemodel (>= 3.0.0)
|
||||
addressable
|
||||
versionist (1.4.1)
|
||||
activesupport (>= 3)
|
||||
railties (>= 3)
|
||||
yard (~> 0.7)
|
||||
warden (1.2.4)
|
||||
rack (>= 1.0)
|
||||
webfinger (1.0.1)
|
||||
|
|
@ -864,6 +868,7 @@ GEM
|
|||
xml-simple (1.1.5)
|
||||
xpath (2.0.0)
|
||||
nokogiri (~> 1.3)
|
||||
yard (0.8.7.6)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
|
@ -1008,6 +1013,7 @@ DEPENDENCIES
|
|||
uglifier (= 2.7.2)
|
||||
unicorn (= 5.0.1)
|
||||
uuid (= 2.3.8)
|
||||
versionist (= 1.4.1)
|
||||
webmock (= 1.22.3)
|
||||
will_paginate (= 3.0.7)
|
||||
|
||||
|
|
|
|||
19
app/controllers/api/LICENSE
Normal file
19
app/controllers/api/LICENSE
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
Copyright (c) 2012 Brian Ploetz (bploetz@gmail.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a
|
||||
copy of this software and associated documentation files (the "Software"),
|
||||
to deal in the Software without restriction, including without limitation
|
||||
the rights to use, copy, modify, merge, publish, distribute, sublicense,
|
||||
and/or sell copies of the Software, and to permit persons to whom the
|
||||
Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included
|
||||
in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
6
app/controllers/api/v2/base_controller.rb
Normal file
6
app/controllers/api/v2/base_controller.rb
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
class Api::V2::BaseController < ApplicationController
|
||||
include Openid::Authentication
|
||||
|
||||
before_action :authenticate_user!
|
||||
before_filter :require_access_token
|
||||
end
|
||||
5
app/controllers/api/v2/users_controller.rb
Normal file
5
app/controllers/api/v2/users_controller.rb
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
class Api::V2::UsersController < Api::V2::BaseController
|
||||
def show
|
||||
render json: current_user
|
||||
end
|
||||
end
|
||||
|
|
@ -3,17 +3,10 @@
|
|||
# the COPYRIGHT file.
|
||||
|
||||
class UsersController < ApplicationController
|
||||
include Openid::Authentication
|
||||
|
||||
before_action :authenticate_user!, except: [:new, :create, :public, :user_photo]
|
||||
before_filter :require_access_token, only: [:show]
|
||||
respond_to :html
|
||||
|
||||
# TODO: Adjust so that it sends back only required elements, e.g, should not send hashed password (serialized_private_key) back
|
||||
def show
|
||||
render json: current_user
|
||||
end
|
||||
|
||||
def edit
|
||||
@aspect = :user_edit
|
||||
@user = current_user
|
||||
|
|
|
|||
2
app/presenters/api/v2/base_presenter.rb
Normal file
2
app/presenters/api/v2/base_presenter.rb
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
class Api::V2::BasePresenter
|
||||
end
|
||||
3
app/serializers/user_serializer.rb
Normal file
3
app/serializers/user_serializer.rb
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
class UserSerializer < ActiveModel::Serializer
|
||||
attributes :name, :email, :language, :username
|
||||
end
|
||||
|
|
@ -245,8 +245,11 @@ Diaspora::Application.routes.draw do
|
|||
resource :openid do
|
||||
resources :authorizations, only: [:new, :create]
|
||||
match 'connect', to: 'connect#show', via: [:get, :post]
|
||||
match '.well-known/:id', to: 'discovery#show' , :via => [:get, :post]
|
||||
match '.well-known/:id', to: 'discovery#show' , via: [:get, :post]
|
||||
post 'access_tokens', to: proc { |env| Openid::TokenEndpoint.new.call(env) }
|
||||
match 'user_info', to: 'users#show', :via => [:get, :post]
|
||||
end
|
||||
|
||||
api_version(:module => "Api::V2", path: {value: "api/v2"}, default: true) do
|
||||
match 'user', to: 'users#show', via: :get
|
||||
end
|
||||
end
|
||||
|
|
|
|||
17
public/docs/v2/index.html
Normal file
17
public/docs/v2/index.html
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en-US">
|
||||
<head>
|
||||
<title>Documentation for v2</title>
|
||||
<link href="v2/style.css" media="screen" rel="stylesheet" type="text/css">
|
||||
</head>
|
||||
<body>
|
||||
<div id="container">
|
||||
<div id="operations">
|
||||
<h3>API Operations</h3>
|
||||
</div>
|
||||
<div id="content">
|
||||
<h1>Documentation for v2</h1>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
5
public/docs/v2/style.css
Normal file
5
public/docs/v2/style.css
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
body {margin: 0; background-color: #fff; color: #000; font-family: Arial,sans-serif;}
|
||||
content {margin-left: 200px;}
|
||||
content h1 {text-align: center;}
|
||||
operations {float: left; width: 200px; border-right: 1px solid #ccc;}
|
||||
operations h3 {text-align: center;}
|
||||
5
spec/controllers/api/v2/base_controller_spec.rb
Normal file
5
spec/controllers/api/v2/base_controller_spec.rb
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Api::V2::BaseController do
|
||||
|
||||
end
|
||||
5
spec/presenters/api/v2/base_presenter_spec.rb
Normal file
5
spec/presenters/api/v2/base_presenter_spec.rb
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Api::V2::BasePresenter do
|
||||
|
||||
end
|
||||
5
spec/requests/api/v2/base_controller_spec.rb
Normal file
5
spec/requests/api/v2/base_controller_spec.rb
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Api::V2::BaseController do
|
||||
|
||||
end
|
||||
Loading…
Reference in a new issue