Add versionist gem

This commit is contained in:
theworldbright 2015-09-13 14:11:53 -07:00
parent efdfe318fd
commit 68d96a3189
14 changed files with 85 additions and 9 deletions

View file

@ -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".
#

View file

@ -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)

View 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.

View file

@ -0,0 +1,6 @@
class Api::V2::BaseController < ApplicationController
include Openid::Authentication
before_action :authenticate_user!
before_filter :require_access_token
end

View file

@ -0,0 +1,5 @@
class Api::V2::UsersController < Api::V2::BaseController
def show
render json: current_user
end
end

View file

@ -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

View file

@ -0,0 +1,2 @@
class Api::V2::BasePresenter
end

View file

@ -0,0 +1,3 @@
class UserSerializer < ActiveModel::Serializer
attributes :name, :email, :language, :username
end

View file

@ -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
View 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
View 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;}

View file

@ -0,0 +1,5 @@
require 'spec_helper'
describe Api::V2::BaseController do
end

View file

@ -0,0 +1,5 @@
require 'spec_helper'
describe Api::V2::BasePresenter do
end

View file

@ -0,0 +1,5 @@
require 'spec_helper'
describe Api::V2::BaseController do
end