Skip to content

Commit

Permalink
add: config file
Browse files Browse the repository at this point in the history
  • Loading branch information
qiao committed Aug 21, 2011
1 parent 9800f37 commit b775572
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 9 deletions.
8 changes: 4 additions & 4 deletions app/controllers/sessions_controller.rb
Expand Up @@ -5,17 +5,17 @@ def new
end

def create
if params[:session][:password] == '123456' then
if params[:session][:password] == APP_CONFIG['password'] then
session[:logged_in] = true
redirect_to admin_path
redirect_to admin_url
else
flash[:error] = 'Wrong password'
redirect_to '/login'
redirect_to login_url
end
end

def destroy
reset_session
redirect_to root_path
redirect_to root_url
end
end
4 changes: 0 additions & 4 deletions app/helpers/application_helper.rb
@@ -1,8 +1,4 @@
module ApplicationHelper
def title
'Typedef.me'
end

def logged_in?
session[:logged_in]
end
Expand Down
9 changes: 9 additions & 0 deletions app/helpers/title_helper.rb
@@ -0,0 +1,9 @@
module TitleHelper
def title
if @title.nil?
APP_CONFIG['base_title']
else
"#{@title} | #{APP_CONFIG['base_title']}"
end
end
end
2 changes: 2 additions & 0 deletions config/config.yml
@@ -0,0 +1,2 @@
base_title: Typedef.me
password: 12345qwert
1 change: 1 addition & 0 deletions config/initializers/load_config.rb
@@ -0,0 +1 @@
APP_CONFIG = YAML.load_file("#{RAILS_ROOT}/config/config.yml")
1 change: 0 additions & 1 deletion config/routes.rb
Expand Up @@ -6,7 +6,6 @@
match 'logout', :to => 'sessions#destroy'
match 'admin', :to => 'admin/dashboard#show'
match 'feed', :to => 'posts#feed',
:as => :feed,
:defaults => { :format => 'atom' }

resource :session
Expand Down

0 comments on commit b775572

Please sign in to comment.