From de24ccc89d8356e00b439e9abd8bc37eacd6d444 Mon Sep 17 00:00:00 2001 From: tanhuazhe Date: Sun, 13 Dec 2015 15:19:12 -0600 Subject: [PATCH] =?UTF-8?q?=E5=AE=8C=E6=88=90=E5=9F=BA=E6=9C=AC=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=EF=BC=8C=E5=8C=85=E6=8B=AC=E8=AF=AD=E8=A8=80=E3=80=81?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E5=BA=93=E3=80=81=E7=8E=AF=E5=A2=83=E4=B9=8B?= =?UTF-8?q?=E7=B1=BB=E7=9A=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/application.rb | 10 +- config/boot.rb | 2 +- config/database.yml | 8 +- config/e2s.rb | 10 ++ config/initializers/assets.rb | 19 +++ config/initializers/setting.rb | 4 + config/locales/article.zh-CN.yml | 11 ++ config/locales/article_comment.zh-CN.yml | 7 + config/locales/blog_info.zh-CN.yml | 9 + config/locales/pagination.zh-CN.yml | 8 + config/locales/user.zh-CN.yml | 11 ++ config/locales/zh-CN.yml | 205 +++++++++++++++++++++++ db/seeds.rb | 8 + 13 files changed, 308 insertions(+), 4 deletions(-) create mode 100644 config/e2s.rb create mode 100644 config/initializers/setting.rb create mode 100644 config/locales/article.zh-CN.yml create mode 100644 config/locales/article_comment.zh-CN.yml create mode 100644 config/locales/blog_info.zh-CN.yml create mode 100644 config/locales/pagination.zh-CN.yml create mode 100644 config/locales/user.zh-CN.yml create mode 100644 config/locales/zh-CN.yml diff --git a/config/application.rb b/config/application.rb index 50a2a21..621ac5a 100644 --- a/config/application.rb +++ b/config/application.rb @@ -12,14 +12,20 @@ module E2s # Application configuration should go into files in config/initializers # -- all .rb files in that directory are automatically loaded. + + #Set autoload path + config.autoload_paths += %W(#{config.root}/lib) + # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone. # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC. # config.time_zone = 'Central Time (US & Canada)' - + config.time_zone = 'Beijing' + config.active_record.default_timezone = :local # 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}').to_s] # config.i18n.default_locale = :de - + config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '*.{rb,yml}').to_s] + config.i18n.default_locale = "zh-CN" # Do not swallow errors in after_commit/after_rollback callbacks. config.active_record.raise_in_transactional_callbacks = true end diff --git a/config/boot.rb b/config/boot.rb index 6b750f0..44358b8 100644 --- a/config/boot.rb +++ b/config/boot.rb @@ -1,3 +1,3 @@ ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) -require 'bundler/setup' # Set up gems listed in the Gemfile. +require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE']) # Set up gems listed in the Gemfile. diff --git a/config/database.yml b/config/database.yml index 1c1a37c..b96ac9d 100644 --- a/config/database.yml +++ b/config/database.yml @@ -22,4 +22,10 @@ test: production: <<: *default - database: db/production.sqlite3 + adapter: mysql2 + encoding: utf8 + pool: 5 + username: root + password: "123456" + host: localhost + database: e2s_production diff --git a/config/e2s.rb b/config/e2s.rb new file mode 100644 index 0000000..c26333b --- /dev/null +++ b/config/e2s.rb @@ -0,0 +1,10 @@ +defaults: &defaults + blog: + aritcle_page_size: 10 + comments_page_size: 10 + +development: + <<: *defaults + +production: + <<: *defaults \ No newline at end of file diff --git a/config/initializers/assets.rb b/config/initializers/assets.rb index 01ef3e6..03aff4e 100644 --- a/config/initializers/assets.rb +++ b/config/initializers/assets.rb @@ -9,3 +9,22 @@ Rails.application.config.assets.version = '1.0' # Precompile additional assets. # application.js, application.css, and all non-JS/CSS in app/assets folder are already added. # Rails.application.config.assets.precompile += %w( search.js ) + +Rails.application.config.assets.precompile += %w( register.css *.png) + +Rails.application.config.assets.precompile << Proc.new { |path| + if path =~ /\.(css|js|png)\z/ + full_path = Rails.application.assets.resolve(path).to_path + app_assets_path = Rails.root.join('app', 'assets').to_path + vendor_assets_path = Rails.root.join('vendor', 'assets').to_path + if full_path.starts_with? app_assets_path or full_path.starts_with? vendor_assets_path + puts "including asset: " + full_path + true + else + puts "excluding asset: " + full_path + false + end + else + false + end +} \ No newline at end of file diff --git a/config/initializers/setting.rb b/config/initializers/setting.rb new file mode 100644 index 0000000..0e694ba --- /dev/null +++ b/config/initializers/setting.rb @@ -0,0 +1,4 @@ +class Settings < Settingslogic + source "#{Rails.root}/config/e2s.yml" + namespace Rails.env +end \ No newline at end of file diff --git a/config/locales/article.zh-CN.yml b/config/locales/article.zh-CN.yml new file mode 100644 index 0000000..a440ac9 --- /dev/null +++ b/config/locales/article.zh-CN.yml @@ -0,0 +1,11 @@ +zh-CN: + activerecord: + models: + article: '文章' + attributes: + article: + title: '标题' + tags: '标签' + category_id: '分类' + source: '来源' + content: '内容' \ No newline at end of file diff --git a/config/locales/article_comment.zh-CN.yml b/config/locales/article_comment.zh-CN.yml new file mode 100644 index 0000000..31da599 --- /dev/null +++ b/config/locales/article_comment.zh-CN.yml @@ -0,0 +1,7 @@ +zh-CN: + activerecord: + models: + article_comment: '评论' + attributes: + article_comment: + content: '评论内容' \ No newline at end of file diff --git a/config/locales/blog_info.zh-CN.yml b/config/locales/blog_info.zh-CN.yml new file mode 100644 index 0000000..22de2d4 --- /dev/null +++ b/config/locales/blog_info.zh-CN.yml @@ -0,0 +1,9 @@ +zh-CN: + activerecord: + models: + blog_info: '博客' + attributes: + blog_info: + blog_title: '博客名称' + name: '博主名称' + description: '关于' \ No newline at end of file diff --git a/config/locales/pagination.zh-CN.yml b/config/locales/pagination.zh-CN.yml new file mode 100644 index 0000000..e853dd9 --- /dev/null +++ b/config/locales/pagination.zh-CN.yml @@ -0,0 +1,8 @@ +zh-CN: + views: + pagination: + first: "首页" + previous: "上一页" + truncate: "..." + next: "下一页" + last: "末页" \ No newline at end of file diff --git a/config/locales/user.zh-CN.yml b/config/locales/user.zh-CN.yml new file mode 100644 index 0000000..e4b7977 --- /dev/null +++ b/config/locales/user.zh-CN.yml @@ -0,0 +1,11 @@ +zh-CN: + activerecord: + models: + user: '用户' + attributes: + user: + username: '用户名' + email: '邮箱' + password: '密码' + password_confirmation: '确认密码' + nick_name: '昵称' \ No newline at end of file diff --git a/config/locales/zh-CN.yml b/config/locales/zh-CN.yml new file mode 100644 index 0000000..c8b390b --- /dev/null +++ b/config/locales/zh-CN.yml @@ -0,0 +1,205 @@ +zh-CN: + activerecord: + errors: + messages: + inclusion: "不包含于列表中" + exclusion: "是保留关键字" + invalid: "是无效的" + confirmation: "与确认值不匹配" + accepted: "必须是可被接受的" + empty: "不能留空" + blank: "不能为空字符" + too_long: "过长(最长为 %{count} 个字符)" + too_short: "过短(最短为 %{count} 个字符)" + wrong_length: "长度非法(必须为 %{count} 个字符)" + taken: "已经被使用" + not_a_number: "不是数字" + not_an_integer: "必须是整数" + greater_than: "必须大于 %{count}" + greater_than_or_equal_to: "必须大于或等于 %{count}" + equal_to: "必须等于 %{count}" + less_than: "必须小于 %{count}" + less_than_or_equal_to: "必须小于或等于 %{count}" + odd: "必须为单数" + even: "必须为双数" + record_invalid: "校验失败: %{errors}" + taken: "已占用" + validations: "校验失败 - %{errors}." + models: + picture: + attributes: + attachment: + size_too_big: "图片太大" + errors: + messages: + extension_white_list_error: "上传图片格式不正确!" + + date: + abbr_day_names: + - 日 + - 一 + - 二 + - 三 + - 四 + - 五 + - 六 + abbr_month_names: + - + - 1月 + - 2月 + - 3月 + - 4月 + - 5月 + - 6月 + - 7月 + - 8月 + - 9月 + - 10月 + - 11月 + - 12月 + day_names: + - 星期日 + - 星期一 + - 星期二 + - 星期三 + - 星期四 + - 星期五 + - 星期六 + formats: + default: ! '%Y-%m-%d' + long: ! '%Y年%m月%d日' + short: ! '%b%d日' + month_names: + - + - 一月 + - 二月 + - 三月 + - 四月 + - 五月 + - 六月 + - 七月 + - 八月 + - 九月 + - 十月 + - 十一月 + - 十二月 + order: + - :year + - :month + - :day + datetime: + distance_in_words: + about_x_hours: + one: 大约一小时 + other: 大约 %{count} 小时 + about_x_months: + one: 大约一个月 + other: 大约 %{count} 个月 + about_x_years: + one: 大约一年 + other: 大约 %{count} 年 + almost_x_years: + one: 接近一年 + other: 接近 %{count} 年 + half_a_minute: 半分钟 + less_than_x_minutes: + one: 不到一分钟 + other: 不到 %{count} 分钟 + less_than_x_seconds: + one: 不到一秒 + other: 不到 %{count} 秒 + over_x_years: + one: 一年多 + other: ! '%{count} 年多' + x_days: '%{count} 天' + x_minutes: '%{count} 分钟' + x_months: '%{count} 个月' + x_seconds: '%{count} 秒' + prompts: + day: 日 + hour: 时 + minute: 分 + month: 月 + second: 秒 + year: 年 + misc: + make_sure: "确认" + cancel: "取消" + save: "保 存" + remove: "移除" + edit: "编辑" + already_exist: "已经存在了。" + return: "返回" + colon: ":" + delete: "删除" + update: "更新" + close: "关闭" + reopen: "重新打开" + preview: "预览" + number: + currency: + format: + delimiter: ! ',' + format: ! '%u %n' + precision: 2 + separator: . + significant: false + strip_insignificant_zeros: false + unit: CN¥ + format: + delimiter: ! ',' + precision: 3 + separator: . + significant: false + strip_insignificant_zeros: false + human: + decimal_units: + format: ! '%n %u' + units: + billion: 十亿 + million: 百万 + quadrillion: 千兆 + thousand: 千 + trillion: 兆 + unit: '' + format: + delimiter: '' + precision: 1 + significant: false + strip_insignificant_zeros: false + storage_units: + format: ! '%n %u' + units: + byte: + one: Byte + other: Bytes + gb: GB + kb: KB + mb: MB + tb: TB + percentage: + format: + delimiter: '' + precision: + format: + delimiter: '' + head: + meta: + content: "全球最大中文IT社区" + header: + search: "搜索" + find: "发现" + boke: "博客" + help: "帮助" + sys_notic: "系统通知" + project_monber: "项目成员" + notic_attenion: "关注通知" + peace_request: "合并请求" + commit: "提交" + work_order: "Issue" + account_set: "账号设置" + new_project: "创建项目" + new_project_doc: "创建文档" + new_organization: "创建组织" + logout: "退出" + login: "登录" \ No newline at end of file diff --git a/db/seeds.rb b/db/seeds.rb index 4edb1e8..4b475e8 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -5,3 +5,11 @@ # # cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) # Mayor.create(name: 'Emanuel', city: cities.first) + +#添加管理员 +admin = User.new username: 'admin', password: 'adminqwe', password_confirmation: 'adminqwe', email: '736698959@qq.com', admin: true +puts admin.save! ? 'add admin success.' : 'add admin fail!' + +#添加一个默认分类 +category = Category.new name: '默认分类' +puts category.save! ? 'add category success.' : 'add category fail!' \ No newline at end of file