Skip to content

Commit e67e5ea

Browse files
author
joel ramsey
authored
Merge pull request #7 from joelramsey/citation-backend
Citation backend
2 parents c05af7d + 9c9366b commit e67e5ea

File tree

5 files changed

+18
-1
lines changed

5 files changed

+18
-1
lines changed

Gemfile

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@ gem 'sunspot_solr'
2020

2121
gem 'progress_bar'
2222

23+
gem 'httparty'
24+
2325
gem 'yajl-ruby'
2426

2527
# for get info from FB API

Gemfile.lock

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,8 @@ GEM
8484
hashery (2.1.2)
8585
hashie (3.5.5)
8686
highline (1.7.8)
87+
httparty (0.14.0)
88+
multi_xml (>= 0.5.2)
8789
i18n (0.8.1)
8890
jbuilder (2.6.3)
8991
activesupport (>= 3.0.0, < 5.2)
@@ -108,6 +110,7 @@ GEM
108110
mini_portile2 (2.1.0)
109111
minitest (5.10.1)
110112
multi_json (1.12.1)
113+
multi_xml (0.6.0)
111114
multipart-post (2.0.0)
112115
nio4r (2.0.0)
113116
nokogiri (1.7.1)
@@ -225,6 +228,7 @@ DEPENDENCIES
225228
devise_token_auth
226229
factory_girl_rails
227230
faker
231+
httparty
228232
jbuilder (~> 2.0)
229233
koala
230234
listen (~> 3.0.5)

app/controllers/citations_controller.rb

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
require 'httparty'
2+
13
class CitationsController < ApplicationController
24
before_action :set_citation, only: [:show, :update, :destroy]
35

@@ -15,6 +17,13 @@ def show
1517
render json: @citation
1618
end
1719

20+
# GET /cite
21+
def cite
22+
response = HTTParty.post("https://api.citation-api.com/2.1/rest/cite?#{params[:q]}")
23+
puts response
24+
render json: response.body
25+
end
26+
1827
# POST /citations
1928
# POST /citations.json
2029
def create
@@ -51,6 +60,6 @@ def set_citation
5160

5261
# Never trust parameters from the scary internet, only allow the white list through.
5362
def citation_params
54-
params.require(:citation).permit(:text, :record_id)
63+
params.require(:citation).permit(:text, :record_id, :q)
5564
end
5665
end

client/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"@angular/cli": "1.0.0-rc.2",
2121
"@angular/common": "~2.4.6",
2222
"@angular/compiler": "~2.4.6",
23+
"@angular/compiler-cli":"2.4.10",
2324
"@angular/core": "~2.4.6",
2425
"@angular/forms": "~2.4.6",
2526
"@angular/http": "~2.4.6",

config/routes.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@
1515

1616
post '/auth/facebook', to: 'sessions#facebook_login'
1717
post '/auth/google', to: 'sessions#google_login'
18+
post '/cite', to: 'citations#cite'
1819
end
1920
end

0 commit comments

Comments
 (0)