Prepare for authentification via web flow.
This commit is contained in:
parent
89fe2a01eb
commit
57d294e4fd
5 changed files with 105 additions and 0 deletions
|
|
@ -1,3 +1,43 @@
|
|||
// Place all the styles related to the Reposts controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
||||
/* flash messages */
|
||||
#error {
|
||||
background-color: red;
|
||||
}
|
||||
#alert {
|
||||
background-color: #ffffe0;
|
||||
}
|
||||
#notice {
|
||||
background-color: green;
|
||||
color: rgb(249, 249, 249);
|
||||
}
|
||||
#alert, #error, #notice {
|
||||
border-bottom-color: #e6db55;
|
||||
border-left-color: #e6db55;
|
||||
border-right-color: #e6db55;
|
||||
border-top-color: #e6db55;
|
||||
border-bottom-left-radius: 3px;
|
||||
border-bottom-right-radius: 3px;
|
||||
border-bottom-style: solid;
|
||||
border-bottom-width: 1px;
|
||||
border-left-style: solid;
|
||||
border-left-width: 1px;
|
||||
border-right-style: solid;
|
||||
border-right-width: 1px;
|
||||
border-top-left-radius: 3px;
|
||||
border-top-right-radius: 3px;
|
||||
border-top-style: solid;
|
||||
border-top-width: 1px;
|
||||
margin-bottom: 16px;
|
||||
margin-left: 8px;
|
||||
margin-right: 0px;
|
||||
margin-top: 0px;
|
||||
padding-bottom: 12px;
|
||||
padding-left: 12px;
|
||||
padding-right: 12px;
|
||||
padding-top: 12px;
|
||||
}
|
||||
.flash {
|
||||
line-height: 1.75em;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,49 @@
|
|||
require 'net/http'
|
||||
require 'uri'
|
||||
|
||||
class RepostsController < ApplicationController
|
||||
def index
|
||||
config = YAML.load_file('config/client.yml')
|
||||
client_id = config["client_id"]
|
||||
client_secret = config["client_secret"]
|
||||
|
||||
# connect to ADN via a user token
|
||||
uri = URI.parse("https://account.app.net/oauth/authenticate")
|
||||
http = Net::HTTP.new(uri.host, uri.port)
|
||||
http.use_ssl = true
|
||||
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
||||
|
||||
response = Net::HTTP::post_form( uri, {"client_id" => client_id, "response_type" => "code", "redirect_uri" => "http://localhost:3000/", "scope" => "stream"})
|
||||
|
||||
# [temp] status
|
||||
@res_code = response.code
|
||||
@res_message = response.message
|
||||
@res_class = response.class.name
|
||||
|
||||
if not response.is_a?(Net::HTTPSuccess)
|
||||
flash[:error] = "Could not connect to ADN."
|
||||
return
|
||||
end
|
||||
|
||||
# ...
|
||||
end
|
||||
|
||||
# TODO rework from file handling to use of 'reposts' model.
|
||||
def new
|
||||
# retrieve latest repost
|
||||
# TODO: select max(postid) from reposts;
|
||||
#history = YAML.load('history.yml', :safe => true)
|
||||
#lastrepostid = history["lastrepost"]
|
||||
#latestid = lastrepostid
|
||||
|
||||
# fetch all mentions since last one
|
||||
## API - fetch( since_id=previous max_id )
|
||||
#new_mentions.each do | post |
|
||||
## API - repost(post)
|
||||
#latestid = post.id
|
||||
#end
|
||||
|
||||
# store latest repost for next time
|
||||
# TODO insert into reposts values("karlsruher", post.id, latestid)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -5,3 +5,17 @@
|
|||
<p>
|
||||
There is nothing much to see here directly, though.
|
||||
</p>
|
||||
|
||||
<% flash.each do |name, msg| %>
|
||||
<div class="alert alert-<%= name == :notice ? "success" : "error" %>">
|
||||
<a class="close" data-dismiss="alert">×</a>
|
||||
<%= content_tag :div, msg, :id => "flash_#{name}" if msg.is_a?(String) %>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<p>
|
||||
<h3>Response</h3>
|
||||
code: <%= @res_code %><br />
|
||||
message: <%= @res_message %><br />
|
||||
class: <%= @res_class %>
|
||||
</p>
|
||||
|
|
|
|||
5
app/views/reposts/new.html.erb
Normal file
5
app/views/reposts/new.html.erb
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
<h1>Reposts</h1>
|
||||
|
||||
<p>
|
||||
Currently, reposts don't work, yet.
|
||||
</p>
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
AdnRepostmentions::Application.routes.draw do
|
||||
root :to => 'reposts#index'
|
||||
resources :reposts
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue