完成基本配置,包括语言、数据库、环境之类的

This commit is contained in:
tanhuazhe 2015-12-13 15:19:12 -06:00
parent 235156aa7b
commit de24ccc89d
13 changed files with 308 additions and 4 deletions

View File

@ -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

View File

@ -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.

View File

@ -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

10
config/e2s.rb Normal file
View File

@ -0,0 +1,10 @@
defaults: &defaults
blog:
aritcle_page_size: 10
comments_page_size: 10
development:
<<: *defaults
production:
<<: *defaults

View File

@ -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
}

View File

@ -0,0 +1,4 @@
class Settings < Settingslogic
source "#{Rails.root}/config/e2s.yml"
namespace Rails.env
end

View File

@ -0,0 +1,11 @@
zh-CN:
activerecord:
models:
article: '文章'
attributes:
article:
title: '标题'
tags: '标签'
category_id: '分类'
source: '来源'
content: '内容'

View File

@ -0,0 +1,7 @@
zh-CN:
activerecord:
models:
article_comment: '评论'
attributes:
article_comment:
content: '评论内容'

View File

@ -0,0 +1,9 @@
zh-CN:
activerecord:
models:
blog_info: '博客'
attributes:
blog_info:
blog_title: '博客名称'
name: '博主名称'
description: '关于'

View File

@ -0,0 +1,8 @@
zh-CN:
views:
pagination:
first: "首页"
previous: "上一页"
truncate: "..."
next: "下一页"
last: "末页"

View File

@ -0,0 +1,11 @@
zh-CN:
activerecord:
models:
user: '用户'
attributes:
user:
username: '用户名'
email: '邮箱'
password: '密码'
password_confirmation: '确认密码'
nick_name: '昵称'

205
config/locales/zh-CN.yml Normal file
View File

@ -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: "登录"

View File

@ -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!'