Skip to content

Commit

Permalink
Adding a main controller
Browse files Browse the repository at this point in the history
  • Loading branch information
rgerard committed Aug 10, 2011
1 parent ae54a58 commit 566852c
Show file tree
Hide file tree
Showing 9 changed files with 56 additions and 248 deletions.
13 changes: 6 additions & 7 deletions app/controllers/import_controller.rb
Expand Up @@ -15,6 +15,8 @@ def request_auth

@request_token=@consumer.get_request_token
session[:request_token]=@request_token
session[:feed_url]=params[:feed]
session[:tumblr_url]=params[:blog]

redirect_to @request_token.authorize_url
end
Expand All @@ -33,14 +35,13 @@ def authorized
end

logger.info "Got access token"

create_blog_migration

end

def create_blog_migration
blog_url = "http://www.ryangerard.net/1/feed"

#blog_url = "http://www.ryangerard.net/1/feed"
blog_url = session[:feed_url]
feed = get_feed(blog_url)
@feed_arr = parse_feed(feed)

Expand Down Expand Up @@ -115,14 +116,12 @@ def parse_feed(feed)
def write_posts_to_tumblr(posts)

logger.info "Starting write"
t_url = "http://api.tumblr.com/v2/blog/ryangerard.tumblr.com/post"
#t_url = "http://api.tumblr.com/v2/blog/ryangerard.tumblr.com/post"
t_url = "http://api.tumblr.com/v2/blog/" + session[:tumblr_url] + "/post";

logger.info "Getting access token"
@access_token = session[:access_token]

count = 0
posts.each do |p|
logger.info "&&&&&&&&&&&&&&&&&&&&&&"

# build the POST params string
post_params = {
Expand Down
7 changes: 7 additions & 0 deletions app/controllers/main_controller.rb
@@ -0,0 +1,7 @@
class MainController < ApplicationController
def start
respond_to do |format|
format.html # main.html.erb
end
end
end
2 changes: 2 additions & 0 deletions app/helpers/main_helper.rb
@@ -0,0 +1,2 @@
module MainHelper
end
20 changes: 19 additions & 1 deletion app/views/import/authorized.erb
@@ -1 +1,19 @@
Authorized, bitches!
<h1>Listing posts</h1>

<table>
<tr>
<th>Title</th>
<th>Date</th>
</tr>

<% @feed_arr.each do |post| %>
<tr>
<td><%= post["title"] %></td>
<td><%= post["pubDate"] %></td>
</tr>
<% end %>
</table>

<br />

<%= link_to 'Migrate Blog', '/import/migrate' %>
7 changes: 7 additions & 0 deletions app/views/main/start.erb
@@ -0,0 +1,7 @@
<%= form_tag "/import/auth" do %>
<%= label_tag(:q, "RSS Feed:") %>
<%= text_field_tag(:feed) %>
<%= label_tag(:q, "Tumblr Blog Domain:") %>
<%= text_field_tag(:blog) %>
<%= submit_tag "Submit" %>
<% end %>
4 changes: 3 additions & 1 deletion config/routes.rb
Expand Up @@ -6,7 +6,9 @@
# match 'products/:id' => 'catalog#view'
# Keep in mind you can assign values other than :controller and :action

match 'import' => 'import#create'
root :to => 'main#start'

match 'import' => 'import#request_auth'
match 'import/auth' => 'import#request_auth'
match 'import/authorized' => 'import#authorized'

Expand Down
239 changes: 0 additions & 239 deletions public/index.html

This file was deleted.

8 changes: 8 additions & 0 deletions test/functional/main_controller_test.rb
@@ -0,0 +1,8 @@
require 'test_helper'

class MainControllerTest < ActionController::TestCase
# Replace this with your real tests.
test "the truth" do
assert true
end
end
4 changes: 4 additions & 0 deletions test/unit/helpers/main_helper_test.rb
@@ -0,0 +1,4 @@
require 'test_helper'

class MainHelperTest < ActionView::TestCase
end

0 comments on commit 566852c

Please sign in to comment.