0
0

make an initial setup with the console, so that the passwords do not

apear anywhere
This commit is contained in:
Gibheer 2011-08-10 19:49:02 +02:00
parent 88f8fadc9e
commit e0833de4a5
3 changed files with 36 additions and 3 deletions

View File

@ -14,3 +14,7 @@ gem 'redclothcoderay'
gem 'coderay'
gem 'RedCloth'
gem 'redcarpet'
group :install do
gem 'highline'
end

View File

@ -58,6 +58,7 @@ GEM
fastercsv (1.5.4)
fssm (0.2.7)
haml (3.1.2)
highline (1.6.2)
json (1.4.6)
rack (1.3.2)
rack-flash (0.1.2)
@ -86,6 +87,7 @@ DEPENDENCIES
data_mapper
dm-postgres-adapter
haml
highline
rack-flash
redcarpet
redclothcoderay

View File

@ -1,22 +1,28 @@
$LOAD_PATH << File.expand_path(File.dirname(__FILE__)) + '/'
require 'libs'
require 'rake/functions'
require 'dm-migrations'
def require_files
require 'libs'
require 'rake/functions'
end
namespace :dm do
desc 'migrate to the database model'
task :migrate do
require_files
require 'dm-migrations'
DataMapper.auto_migrate!
end
desc 'upgrade the database to the latest model'
task :upgrade do
require_files
require 'dm-migrations'
DataMapper.auto_upgrade!
end
desc 'fill the database with dummy data from seeds.rb'
task :seed do
require_files
require 'seeds'
end
end
@ -26,9 +32,30 @@ task :console do
sh "irb -rubygems -I#{File.expand_path(File.dirname(__FILE__))} -r libs"
end
namespace :account do
desc 'create a new account'
task :create do
require_files
require 'highline'
h = HighLine.new
acc = Account.new
acc.username = h.ask('username: ')
acc.password = h.ask('password: '){|q| q.echo = false }
acc.password_confirmation = h.ask('password again: '){|q| q.echo = false }
acc.email = h.ask('email: ')
acc.role = :admin
if acc.save
puts "account saved with id #{acc.id}"
else
puts "failure at saving the account: #{acc.errors.first}"
end
end
end
namespace :import do
desc 'import all posts from this directory'
task :jekyll do
require_files
path = ask("Where are the jekyll posts?")
template = ask("What is the default template? (textile, markdown, ...?)")
if path.nil?