forked from publify/publify
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adding a setup to typo blog. Will redirect user to the editor after f…
…irst account creation
- Loading branch information
Frédéric de Villamil
committed
Feb 18, 2010
1 parent
e4102a3
commit 56d89d2
Showing
9 changed files
with
167 additions
and
7 deletions.
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
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,25 @@ | ||
class SetupController < ApplicationController | ||
before_filter :check_config | ||
layout 'accounts' | ||
|
||
def index | ||
if request.post? | ||
Blog.transaction do | ||
params[:setting].each { |k,v| this_blog.send("#{k.to_s}=", v) } | ||
this_blog.save | ||
redirect_to :controller => 'accounts', :action => 'signup' | ||
end | ||
end | ||
end | ||
|
||
private | ||
def check_config | ||
return unless this_blog.configured? | ||
|
||
if User.count == 0 | ||
redirect_to :controller => "accounts", :action => "signup" | ||
else | ||
redirect_to :controller => 'articles', :action => 'index' | ||
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
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,20 @@ | ||
<%= content_tag :h3, link_to(image_tag("/images/admin/typologo.gif", :alt=>"Typo website"), "http://typosphere.org") %> | ||
|
||
<div id="flash"><%= error_messages_for 'setup' %></div> | ||
|
||
<% form_tag :action=> 'index' do %> | ||
<div> | ||
<h1><%= _("Setup")%></h1> | ||
<h2><label for="user_login"><%= _("Blog name") %>:</label></h2> | ||
<p class='input_text_title'> | ||
<%= text_field(:setting, :blog_name, {:class => 'title large'})%> | ||
</p> | ||
</div> | ||
<div> | ||
<h2><label for="user_email"><%= _("Blog url")%>:</label></h2> | ||
<p class='input_text_title'> | ||
<%= text_field(:setting, :base_url, {:class => 'title large'})%> | ||
</p> | ||
</div> | ||
<p><input type="submit" id="submit" class='save large' value="<%= _('Save')%>" /></p> | ||
<% 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
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,41 @@ | ||
require File.dirname(__FILE__) + '/../spec_helper' | ||
|
||
describe 'GET setup with no configured blog' do | ||
controller_name :setup | ||
|
||
before(:each) do | ||
Blog.delete_all | ||
@blog = Blog.new.save | ||
end | ||
|
||
it 'renders index' do | ||
get 'index' | ||
response.should render_template('index') | ||
end | ||
end | ||
|
||
describe 'GET setup with a configured blog and no user' do | ||
controller_name :setup | ||
|
||
before(:each) do | ||
User.stub!(:count).and_return(0) | ||
@user = mock("user") | ||
@user.stub!(:reload).and_return(@user) | ||
User.stub!(:new).and_return(@user) | ||
|
||
end | ||
|
||
it 'redirects to setup' do | ||
get 'index' | ||
response.should redirect_to(:controller => 'accounts', :action => 'signup') | ||
end | ||
end | ||
|
||
describe 'GET setup with a configured blog and some users' do | ||
controller_name :setup | ||
|
||
it 'redirects to login' do | ||
get 'index' | ||
response.should redirect_to(:controller => 'articles', :action => 'index') | ||
end | ||
end |