diff options
author | re4k <re4k@re4k.info> | 2013-03-13 21:40:06 +0900 |
---|---|---|
committer | re4k <re4k@re4k.info> | 2013-03-13 21:40:06 +0900 |
commit | 2c56dbdb9b19584c5f3bc2ced20c684bd84fa46f (patch) | |
tree | 8784072141eef2354dcab82e5df675a361e04485 /config | |
parent | 5d2a13afc4f08ba752a30e204367d028d09ad538 (diff) | |
download | aclog-2c56dbdb9b19584c5f3bc2ced20c684bd84fa46f.tar.gz |
Update (no new features)
Diffstat (limited to 'config')
-rw-r--r-- | config/database.yml | 63 | ||||
-rw-r--r-- | config/routes.rb | 14 |
2 files changed, 58 insertions, 19 deletions
diff --git a/config/database.yml b/config/database.yml index d9682a5..8578d0f 100644 --- a/config/database.yml +++ b/config/database.yml @@ -1,13 +1,52 @@ -<% #development: - #test: - #production: - # adapter: mysql2 - # encoding: utf8 - # reconnect: true - # database: production - # pool: 5 - # username: <%= ENV["DOTCLOUD_DB_MYSQL_LOGIN"] %> - # password: <%= ENV["DOTCLOUD_DB_MYSQL_PASSWORD"] %> - # host: <%= ENV["DOTCLOUD_DB_MYSQL_HOST"] %> - # port: <%= ENV["DOTCLOUD_DB_MYSQL_PORT"] %> +<% +require 'cgi' +require 'uri' + +begin + uri = URI.parse(ENV["DATABASE_URL"]) +rescue URI::InvalidURIError + raise "Invalid DATABASE_URL" +end + +raise "No RACK_ENV or RAILS_ENV found" unless ENV["RAILS_ENV"] || ENV["RACK_ENV"] + +def attribute(name, value, force_string = false) + if value + value_string = + if force_string + '"' + value + '"' + else + value + end + "#{name}: #{value_string}" + else + "" + end +end + +adapter = uri.scheme +adapter = "postgresql" if adapter == "postgres" + +database = (uri.path || "").split("/")[1] + +username = uri.user +password = uri.password + +host = uri.host +port = uri.port + +params = CGI.parse(uri.query || "") + %> + +<%= ENV["RAILS_ENV"] || ENV["RACK_ENV"] %>: + <%= attribute "adapter", adapter %> + <%= attribute "database", database %> + <%= attribute "username", username %> + <%= attribute "password", password, true %> + <%= attribute "host", host %> + <%= attribute "port", port %> + +<% params.each do |key, value| %> + <%= key %>: <%= value.first %> +<% end %> diff --git a/config/routes.rb b/config/routes.rb index 609e7fd..a7b879f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -10,12 +10,12 @@ Aclog::Application.routes.draw do get "i/logout" => "sessions#destroy" get "i/:id" => "i#show", :constraints => constraints - get "(users)/:screen_name/status(es)/:id" => "i#show", :constraints => constraints + get ":screen_name/status(es)/:id" => "i#show", :constraints => constraints - get "(users)/:screen_name(/:page)" => "users#best", :constraints => constraints - get "(users)/:screen_name/my(/:page)" => "users#my", :constraints => constraints - get "(users)/:screen_name/discovered(/:page)" => "users#my", :constraints => constraints - get "(users)/:screen_name/timeline(/:page)" => "users#timeline", :constraints => constraints - get "(users)/:screen_name/recent(/:page)" => "users#recent", :constraints => constraints - get "(users)/:screen_name/info(/:page)" => "users#info", :constraints => constraints + get ":screen_name(/:page)" => "users#best", :constraints => constraints + get ":screen_name/my(/:page)" => "users#my", :constraints => constraints + get ":screen_name/discovered(/:page)" => "users#my", :constraints => constraints + get ":screen_name/timeline(/:page)" => "users#timeline", :constraints => constraints + get ":screen_name/recent(/:page)" => "users#recent", :constraints => constraints + get ":screen_name/info(/:page)" => "users#info", :constraints => constraints end |