make an initial setup with the console, so that the passwords do not
apear anywhere
This commit is contained in:
parent
88f8fadc9e
commit
e0833de4a5
4
Gemfile
4
Gemfile
@ -14,3 +14,7 @@ gem 'redclothcoderay'
|
||||
gem 'coderay'
|
||||
gem 'RedCloth'
|
||||
gem 'redcarpet'
|
||||
|
||||
group :install do
|
||||
gem 'highline'
|
||||
end
|
||||
|
@ -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
|
||||
|
31
Rakefile
31
Rakefile
@ -1,22 +1,28 @@
|
||||
$LOAD_PATH << File.expand_path(File.dirname(__FILE__)) + '/'
|
||||
|
||||
def require_files
|
||||
require 'libs'
|
||||
require 'rake/functions'
|
||||
|
||||
require 'dm-migrations'
|
||||
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?
|
||||
|
Loading…
Reference in New Issue
Block a user