Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Import the db with rake import after setting the authorizations.
- Loading branch information
1 parent
cc382e5
commit 1c8ad93
Showing
41 changed files
with
673 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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://jashkenas.github.com/coffee-script/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
// Place all the styles related to the authorizations controller here. | ||
// They will automatically be included in application.css. | ||
// You can use Sass (SCSS) here: http://sass-lang.com/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
body { | ||
background-color: #fff; | ||
color: #333; | ||
font-family: verdana, arial, helvetica, sans-serif; | ||
font-size: 13px; | ||
line-height: 18px; } | ||
|
||
p, ol, ul, td { | ||
font-family: verdana, arial, helvetica, sans-serif; | ||
font-size: 13px; | ||
line-height: 18px; } | ||
|
||
pre { | ||
background-color: #eee; | ||
padding: 10px; | ||
font-size: 11px; } | ||
|
||
a { | ||
color: #000; | ||
&:visited { | ||
color: #666; } | ||
&:hover { | ||
color: #fff; | ||
background-color: #000; } } | ||
|
||
div { | ||
&.field, &.actions { | ||
margin-bottom: 10px; } } | ||
|
||
#notice { | ||
color: green; } | ||
|
||
.field_with_errors { | ||
padding: 2px; | ||
background-color: red; | ||
display: table; } | ||
|
||
#error_explanation { | ||
width: 450px; | ||
border: 2px solid red; | ||
padding: 7px; | ||
padding-bottom: 0; | ||
margin-bottom: 20px; | ||
background-color: #f0f0f0; | ||
h2 { | ||
text-align: left; | ||
font-weight: bold; | ||
padding: 5px 5px 5px 15px; | ||
font-size: 12px; | ||
margin: -7px; | ||
margin-bottom: 0px; | ||
background-color: #c00; | ||
color: #fff; } | ||
ul li { | ||
font-size: 12px; | ||
list-style: square; } } |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
class AuthorizationsController < ApplicationController | ||
# GET /authorizations | ||
# GET /authorizations.json | ||
def index | ||
@authorizations = Authorization.all | ||
|
||
respond_to do |format| | ||
format.html # index.html.erb | ||
format.json { render :json => @authorizations } | ||
end | ||
end | ||
|
||
# GET /authorizations/1 | ||
# GET /authorizations/1.json | ||
def show | ||
@authorization = Authorization.find(params[:id]) | ||
|
||
respond_to do |format| | ||
format.html # show.html.erb | ||
format.json { render :json => @authorization } | ||
end | ||
end | ||
|
||
# GET /authorizations/new | ||
# GET /authorizations/new.json | ||
def new | ||
@authorization = Authorization.new | ||
|
||
respond_to do |format| | ||
format.html # new.html.erb | ||
format.json { render :json => @authorization } | ||
end | ||
end | ||
|
||
# GET /authorizations/1/edit | ||
def edit | ||
@authorization = Authorization.find(params[:id]) | ||
end | ||
|
||
# POST /authorizations | ||
# POST /authorizations.json | ||
def create | ||
@authorization = Authorization.new(params[:authorization]) | ||
|
||
respond_to do |format| | ||
if @authorization.save | ||
format.html { redirect_to @authorization, :notice => 'Authorization was successfully created.' } | ||
format.json { render :json => @authorization, :status => :created, :location => @authorization } | ||
else | ||
format.html { render :action => "new" } | ||
format.json { render :json => @authorization.errors, :status => :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# PUT /authorizations/1 | ||
# PUT /authorizations/1.json | ||
def update | ||
@authorization = Authorization.find(params[:id]) | ||
|
||
respond_to do |format| | ||
if @authorization.update_attributes(params[:authorization]) | ||
format.html { redirect_to @authorization, :notice => 'Authorization was successfully updated.' } | ||
format.json { head :no_content } | ||
else | ||
format.html { render :action => "edit" } | ||
format.json { render :json => @authorization.errors, :status => :unprocessable_entity } | ||
end | ||
end | ||
end | ||
|
||
# DELETE /authorizations/1 | ||
# DELETE /authorizations/1.json | ||
def destroy | ||
@authorization = Authorization.find(params[:id]) | ||
@authorization.destroy | ||
|
||
respond_to do |format| | ||
format.html { redirect_to authorizations_url } | ||
format.json { head :no_content } | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
class WelcomeController < ActionController::Base | ||
def index | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module AuthorizationsHelper | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module BoardsHelper | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
class Action < ActiveRecord::Base | ||
belongs_to :card | ||
|
||
default_scope order('date ASC') | ||
|
||
def list_created_in | ||
List.find_by_trello_id(self.list_trello_id) | ||
end | ||
|
||
def list_before | ||
List.find_by_trello_id(self.list_before_trello_id) | ||
end | ||
|
||
def list_after | ||
List.find_by_trello_id(self.list_after_trello_id) | ||
end | ||
|
||
def self.create_from_trello_data(data, card) | ||
if data['type'] == 'createCard' | ||
Action.create( | ||
:trello_id => data['id'], | ||
:card_id => card.id, | ||
:list_trello_id => data['data']['list']['id'], | ||
:date => data['date'].to_time | ||
) | ||
elsif (data['data']['listBefore'] && data['data']['listBefore']) | ||
Action.create( | ||
:trello_id => data['id'], | ||
:card_id => card.id, | ||
:list_before_trello_id => data['data']['listBefore']['id'], | ||
:list_after_trello_id => data['data']['listBefore']['id'], | ||
:date => data['date'].to_time | ||
) | ||
end | ||
end | ||
|
||
def self.fetch_from_trello(card) | ||
auth = Authorization.first | ||
base_url = "https://api.trello.com/1/" | ||
tokens = "&key=#{auth.key}&token=#{auth.token}" | ||
params = "cards/#{card.trello_id}/actions?filter=updateCard,createCard&limit=1000" | ||
|
||
uri = URI.parse(base_url + params + tokens) | ||
http = Net::HTTP.new(uri.host, uri.port) | ||
http.use_ssl = true | ||
http.verify_mode = OpenSSL::SSL::VERIFY_NONE | ||
request = Net::HTTP::Get.new(uri.request_uri) | ||
response = JSON.parse(http.request(request).body) | ||
|
||
response | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
class Authorization < ActiveRecord::Base | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
class Board < ActiveRecord::Base | ||
has_many :lists | ||
|
||
def self.create_from_trello_data(data) | ||
Board.create(:trello_id => data['id'], :name => data['name']) | ||
end | ||
|
||
def self.fetch_from_trello | ||
auth = Authorization.first | ||
base_url = "https://api.trello.com/1/" | ||
tokens = "&key=#{auth.key}&token=#{auth.token}" | ||
params = "members/me?boards=open" | ||
|
||
uri = URI.parse(base_url + params + tokens) | ||
http = Net::HTTP.new(uri.host, uri.port) | ||
http.use_ssl = true | ||
http.verify_mode = OpenSSL::SSL::VERIFY_NONE | ||
request = Net::HTTP::Get.new(uri.request_uri) | ||
response = JSON.parse(http.request(request).body) | ||
|
||
response['boards'] | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
class Card < ActiveRecord::Base | ||
has_many :actions | ||
|
||
default_scope order('trello_id ASC') | ||
|
||
def self.create_from_trello_data(data) | ||
Card.create(:trello_id => data['id'], :name => data['name']) | ||
end | ||
|
||
def self.fetch_from_trello(board) | ||
auth = Authorization.first | ||
base_url = "https://api.trello.com/1/" | ||
tokens = "&key=#{auth.key}&token=#{auth.token}" | ||
params = "boards/#{board.trello_id}/cards?" | ||
|
||
uri = URI.parse(base_url + params + tokens) | ||
http = Net::HTTP.new(uri.host, uri.port) | ||
http.use_ssl = true | ||
http.verify_mode = OpenSSL::SSL::VERIFY_NONE | ||
request = Net::HTTP::Get.new(uri.request_uri) | ||
response = JSON.parse(http.request(request).body) | ||
|
||
response | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
class List < ActiveRecord::Base | ||
belongs_to :board | ||
|
||
def self.create_from_trello_data(data, board) | ||
List.create(:trello_id => data['id'], :name => data['name'], :board_id => board.id) | ||
end | ||
|
||
def self.fetch_from_trello(board) | ||
auth = Authorization.first | ||
base_url = "https://api.trello.com/1/" | ||
tokens = "&key=#{auth.key}&token=#{auth.token}" | ||
params = "boards/#{board.trello_id}/lists?" | ||
|
||
uri = URI.parse(base_url + params + tokens) | ||
http = Net::HTTP.new(uri.host, uri.port) | ||
http.use_ssl = true | ||
http.verify_mode = OpenSSL::SSL::VERIFY_NONE | ||
request = Net::HTTP::Get.new(uri.request_uri) | ||
response = JSON.parse(http.request(request).body) | ||
|
||
response | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<%= form_for(@authorization) do |f| %> | ||
<% if @authorization.errors.any? %> | ||
<div id="error_explanation"> | ||
<h2><%= pluralize(@authorization.errors.count, "error") %> prohibited this authorization from being saved:</h2> | ||
|
||
<ul> | ||
<% @authorization.errors.full_messages.each do |msg| %> | ||
<li><%= msg %></li> | ||
<% end %> | ||
</ul> | ||
</div> | ||
<% end %> | ||
|
||
<div class="field"> | ||
<%= f.label :key %><br /> | ||
<%= f.text_field :key %> | ||
</div> | ||
<div class="field"> | ||
<%= f.label :token %><br /> | ||
<%= f.text_field :token %> | ||
</div> | ||
<div class="actions"> | ||
<%= f.submit %> | ||
</div> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<h1>Editing authorization</h1> | ||
|
||
<%= render 'form' %> | ||
<%= link_to 'Show', @authorization %> | | ||
<%= link_to 'Back', authorizations_path %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
<h1>Listing authorizations</h1> | ||
|
||
<table> | ||
<tr> | ||
<th>Key</th> | ||
<th>Token</th> | ||
<th></th> | ||
<th></th> | ||
<th></th> | ||
</tr> | ||
|
||
<% @authorizations.each do |authorization| %> | ||
<tr> | ||
<td><%= authorization.key %></td> | ||
<td><%= authorization.token %></td> | ||
<td><%= link_to 'Show', authorization %></td> | ||
<td><%= link_to 'Edit', edit_authorization_path(authorization) %></td> | ||
<td><%= link_to 'Destroy', authorization, :confirm => 'Are you sure?', :method => :delete %></td> | ||
</tr> | ||
<% end %> | ||
</table> | ||
|
||
<br /> | ||
|
||
<%= link_to 'New Authorization', new_authorization_path %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<h1>New authorization</h1> | ||
|
||
<%= render 'form' %> | ||
<%= link_to 'Back', authorizations_path %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<p id="notice"><%= notice %></p> | ||
|
||
<p> | ||
<b>Key:</b> | ||
<%= @authorization.key %> | ||
</p> | ||
|
||
<p> | ||
<b>Token:</b> | ||
<%= @authorization.token %> | ||
</p> | ||
|
||
|
||
<%= link_to 'Edit', edit_authorization_path(@authorization) %> | | ||
<%= link_to 'Back', authorizations_path %> |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
class CreateCards < ActiveRecord::Migration | ||
def change | ||
create_table :cards do |t| | ||
t.string :trello_id | ||
t.string :name | ||
|
||
t.timestamps | ||
end | ||
end | ||
end |
Oops, something went wrong.