OSDN Git Service

basic認証、メッセージの日本語化
authorcake <cake@users.sourceforge.jp>
Wed, 15 Sep 2010 14:24:48 +0000 (23:24 +0900)
committercake <cake@users.sourceforge.jp>
Wed, 15 Sep 2010 14:24:48 +0000 (23:24 +0900)
app/controllers/application_controller.rb
config/config.yml [new file with mode: 0644]
config/environment.rb
config/initializers/app_config.rb [new file with mode: 0644]
config/locales/translation_ja.yml

index 6635a3f..f4ce653 100644 (file)
@@ -4,7 +4,14 @@
 class ApplicationController < ActionController::Base
   helper :all # include all helpers, all the time
   protect_from_forgery # See ActionController::RequestForgeryProtection for details
+  before_filter :authenticate
 
   # Scrub sensitive parameters from your log
   # filter_parameter_logging :password
+
+  def authenticate
+    authenticate_or_request_with_http_basic do |user_name, password|
+      user_name == AppConfig.user_name && password == AppConfig.password
+    end
+  end
 end
diff --git a/config/config.yml b/config/config.yml
new file mode 100644 (file)
index 0000000..60ff807
--- /dev/null
@@ -0,0 +1,7 @@
+common: &common
+  foo: "bar"
+
+development:
+  <<: *common
+  user_name: 'user'
+  password: 'pass'
index 39545f1..93944c0 100644 (file)
@@ -1,7 +1,7 @@
 # Be sure to restart your server when you modify this file
 
 # Specifies gem version of Rails to use when vendor/rails is not present
-RAILS_GEM_VERSION = '2.3.5' unless defined? RAILS_GEM_VERSION
+RAILS_GEM_VERSION = '2.3.8' unless defined? RAILS_GEM_VERSION
 
 # Bootstrap the Rails environment, frameworks, and default configuration
 require File.join(File.dirname(__FILE__), 'boot')
@@ -38,4 +38,5 @@ Rails::Initializer.run do |config|
   # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
   # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}')]
   # config.i18n.default_locale = :de
+  config.i18n.default_locale = :ja
 end
diff --git a/config/initializers/app_config.rb b/config/initializers/app_config.rb
new file mode 100644 (file)
index 0000000..75727de
--- /dev/null
@@ -0,0 +1,4 @@
+require 'ostruct'
+require 'yaml'
+config = YAML.load_file("#{RAILS_ROOT}/config/config.yml") || {}
+::AppConfig = OpenStruct.new(config[RAILS_ENV])
index 3c82bb4..71f5bcd 100644 (file)
@@ -1,24 +1,24 @@
 ja: 
   activerecord: 
     models: 
-      song: "ソング"  #g
+      song: "楽曲"  #g
 
     attributes: 
       song: 
         code: "コード"  #g
-        title: "タイトル"  #g
-        words: "言葉"  #g
+        title: "題名"  #g
+        words: "歌詞"  #g
         words_for_search: "検索ワード"  #g
-        copyright: "著作権"  #g
+        copyright: "出典"  #g
         font_size: "フォントサイズ"  #g
-        deleted_at: "で削除"  #g
+        deleted_at: "削除日時"  #g
 
   selectable_attrs: 
     Song: 
       font_size: 
         xsmall: "Xsmall"  #g
-        small: "スモール"  #g
-        middle: "中間"  #g
-        large: ""  #g
-        xlarge: "エクストララージ"  #g
+        small: "Small"  #g
+        middle: "Middle"  #g
+        large: "Large"  #g
+        xlarge: "Xlarge"  #g