소스 검색

init statement admin

abiao 5 년 전
부모
커밋
d955bfd630
100개의 변경된 파일4791개의 추가작업 그리고 0개의 파일을 삭제
  1. 49 0
      Gemfile
  2. 298 0
      Gemfile.lock
  3. 261 0
      README.rdoc
  4. 7 0
      Rakefile
  5. 0 0
      aliyun_sdk.log
  6. BIN
      app/assets/images/rails.png
  7. 16 0
      app/assets/javascripts/application.js
  8. 135 0
      app/assets/javascripts/ckeditor/config.js
  9. 5 0
      app/assets/javascripts/ckeditor/plugins/lineheight/lang/en.js
  10. 5 0
      app/assets/javascripts/ckeditor/plugins/lineheight/lang/zh-cn.js
  11. 146 0
      app/assets/javascripts/ckeditor/plugins/lineheight/plugin.js
  12. 7 0
      app/assets/javascripts/rails_admin/custom/ckeditor_ajax.js.coffee
  13. 1 0
      app/assets/javascripts/rails_admin/custom/ui.js
  14. 14 0
      app/assets/stylesheets/application.css.scss
  15. 109 0
      app/assets/stylesheets/rails_admin/rails_admin.scss.erb
  16. 17 0
      app/controllers/application_controller.rb
  17. 4 0
      app/controllers/base_controller.rb
  18. 16 0
      app/helpers/application_helper.rb
  19. 0 0
      app/mailers/.gitkeep
  20. 68 0
      app/models/ability.rb
  21. 44 0
      app/models/admin_permission.rb
  22. 19 0
      app/models/admin_permissions_admin_role.rb
  23. 36 0
      app/models/admin_role.rb
  24. 19 0
      app/models/admin_roles_admin_user.rb
  25. 96 0
      app/models/admin_user.rb
  26. 213 0
      app/models/ali.rb
  27. 5 0
      app/models/ckeditor/asset.rb
  28. 13 0
      app/models/ckeditor/attachment_file.rb
  29. 31 0
      app/models/ckeditor/picture.rb
  30. 37 0
      app/models/session.rb
  31. 40 0
      app/models/wa_id_department.rb
  32. 110 0
      app/models/wa_id_permission.rb
  33. 43 0
      app/models/wa_id_role.rb
  34. 38 0
      app/models/wa_id_role_permission.rb
  35. 78 0
      app/models/wa_id_user.rb
  36. 46 0
      app/models/wa_id_user_role.rb
  37. 35 0
      app/models/wa_id_user_token.rb
  38. 20 0
      app/views/devise/sessions/new.html.erb
  39. 15 0
      app/views/layouts/application.html.erb
  40. 114 0
      app/views/layouts/devise_layout.html.erb
  41. 4 0
      config.ru
  42. 78 0
      config/application.rb
  43. 6 0
      config/boot.rb
  44. 45 0
      config/config.yml
  45. 43 0
      config/database.yml
  46. 7 0
      config/environment.rb
  47. 39 0
      config/environments/development.rb
  48. 71 0
      config/environments/production.rb
  49. 45 0
      config/environments/test.rb
  50. 7 0
      config/initializers/backtrace_silencers.rb
  51. 58 0
      config/initializers/ckeditor.rb
  52. 265 0
      config/initializers/devise.rb
  53. 15 0
      config/initializers/inflections.rb
  54. 1 0
      config/initializers/load_config.rb
  55. 5 0
      config/initializers/mime_types.rb
  56. 1 0
      config/initializers/paper_trail.rb
  57. 7 0
      config/initializers/paperclip-aliyun-configuration.rb
  58. 68 0
      config/initializers/rails_admin.rb
  59. 194 0
      config/initializers/rails_admin.rb.example
  60. 3 0
      config/initializers/safe_yaml.rb
  61. 8 0
      config/initializers/secret_token.rb
  62. 8 0
      config/initializers/session_store.rb
  63. 14 0
      config/initializers/wrap_parameters.rb
  64. 61 0
      config/locales/devise.cn.yml
  65. 60 0
      config/locales/devise.en.yml
  66. 11 0
      config/locales/devise.zh-CN.yml
  67. 5 0
      config/locales/en.yml
  68. 11 0
      config/locales/models/admin_permission.yml
  69. 10 0
      config/locales/models/admin_permissions_admin_role.yml
  70. 12 0
      config/locales/models/admin_role.yml
  71. 9 0
      config/locales/models/admin_roles_admin_user.yml
  72. 19 0
      config/locales/models/admin_user.yml
  73. 12 0
      config/locales/models/picture.yml
  74. 15 0
      config/locales/models/rails_admin_history.yml
  75. 9 0
      config/locales/models/session.yml
  76. 13 0
      config/locales/models/wa_id_department.yml
  77. 23 0
      config/locales/models/wa_id_permission.yml
  78. 14 0
      config/locales/models/wa_id_role.yml
  79. 16 0
      config/locales/models/wa_id_role_permission.yml
  80. 17 0
      config/locales/models/wa_id_user.yml
  81. 14 0
      config/locales/models/wa_id_user_role.yml
  82. 15 0
      config/locales/models/wa_id_user_token.yml
  83. 58 0
      config/locales/rails.cn.yml
  84. 196 0
      config/locales/rails_admin.cn.yml
  85. 291 0
      config/locales/rails_admin.zh-CN.yml
  86. 216 0
      config/locales/zh-CN.yml
  87. 47 0
      config/ngx_dev_ys_company_win.conf
  88. 54 0
      config/ngx_prod.conf
  89. 46 0
      config/ngx_test.conf
  90. 7 0
      config/routes.rb
  91. 100 0
      config/unicorn.rb
  92. 80 0
      db/migrate/20121201032354_create_versions.rb
  93. 12 0
      db/migrate/20121201032355_add_object_changes_to_versions.rb
  94. 22 0
      db/migrate/20121201032356_create_version_associations.rb
  95. 13 0
      db/migrate/20121201032357_add_transaction_id_column_to_versions.rb
  96. 18 0
      db/migrate/20130516032930_create_rails_admin_histories_table.rb
  97. 49 0
      db/migrate/20130516033045_devise_create_admin_users.rb
  98. 26 0
      db/migrate/20130516183705_create_ckeditor_assets.rb
  99. 8 0
      db/migrate/20130625024300_create_admin_permissions.rb
  100. 0 0
      db/migrate/20130625024430_create_admin_roles.rb

+ 49 - 0
Gemfile

@@ -0,0 +1,49 @@
+source 'https://rubygems.org'
+#source 'http://gems.ruby-china.org/'
+
+gem 'rails', '4.2.7.1'#, '3.2.13'
+gem 'mysql2'#, '0.3.18'
+gem 'syck'
+# Gems used only for assets and not required
+# in production environments by default.
+group :assets do
+  gem 'sass-rails'#,   '~> 3.2.3'
+  gem 'coffee-rails'#, '~> 3.2.1'
+  gem 'bootstrap-sass'
+  # See https://github.com/sstephenson/execjs#readme for more supported runtimes
+  gem 'therubyracer', :platforms => :ruby
+  # gem 'turbo-sprockets-rails3'
+  gem 'uglifier'#, '>= 1.0.3'
+  gem 'compass'#,'0.12.6'
+end
+
+gem 'jquery-rails'
+
+#gem 'unicorn'
+# gem 'thin'
+
+#后台管理rails_admin框架
+gem "rails_admin"
+gem "devise"
+gem "cancancan"
+gem "ancestry"
+gem "rails_admin_nestable"
+gem 'ckeditor'#, '~> 3.7.0.rc3'
+# gem 'ckeditor', '4.1.3'
+gem 'paper_trail', '5.2.3'
+gem "paperclip"#, '4.3.7'
+gem 'paperclip-storage-aliyun'
+
+#请求相关辅助类
+gem "rest-client", '~>1.8.0'
+gem "uuid"
+gem "xml-simple"
+gem "chinese_pinyin"
+gem "aliyun-sdk", '~>0.4.1'
+gem "rails_admin_import"
+gem "coffee-script-source"#, '1.8.0'
+gem "safe_yaml"
+gem 'tzinfo-data'
+
+gem 'bcrypt-ruby', '~> 3.0.0', :require => "bcrypt"
+#gem 'rails_admin_example_theme', :git => 'git://github.com/bbenezech/rails_admin_example_theme.git'

+ 298 - 0
Gemfile.lock

@@ -0,0 +1,298 @@
+GEM
+  remote: http://gems.ruby-china.org/
+  specs:
+    actionmailer (4.2.7.1)
+      actionpack (= 4.2.7.1)
+      actionview (= 4.2.7.1)
+      activejob (= 4.2.7.1)
+      mail (~> 2.5, >= 2.5.4)
+      rails-dom-testing (~> 1.0, >= 1.0.5)
+    actionpack (4.2.7.1)
+      actionview (= 4.2.7.1)
+      activesupport (= 4.2.7.1)
+      rack (~> 1.6)
+      rack-test (~> 0.6.2)
+      rails-dom-testing (~> 1.0, >= 1.0.5)
+      rails-html-sanitizer (~> 1.0, >= 1.0.2)
+    actionview (4.2.7.1)
+      activesupport (= 4.2.7.1)
+      builder (~> 3.1)
+      erubis (~> 2.7.0)
+      rails-dom-testing (~> 1.0, >= 1.0.5)
+      rails-html-sanitizer (~> 1.0, >= 1.0.2)
+    activejob (4.2.7.1)
+      activesupport (= 4.2.7.1)
+      globalid (>= 0.3.0)
+    activemodel (4.2.7.1)
+      activesupport (= 4.2.7.1)
+      builder (~> 3.1)
+    activerecord (4.2.7.1)
+      activemodel (= 4.2.7.1)
+      activesupport (= 4.2.7.1)
+      arel (~> 6.0)
+    activesupport (4.2.7.1)
+      i18n (~> 0.7)
+      json (~> 1.7, >= 1.7.7)
+      minitest (~> 5.1)
+      thread_safe (~> 0.3, >= 0.3.4)
+      tzinfo (~> 1.1)
+    aliyun-sdk (0.4.1)
+      nokogiri (~> 1.6)
+      rest-client (~> 1.8)
+    ancestry (2.2.2)
+      activerecord (>= 3.0.0)
+    arel (6.0.3)
+    autoprefixer-rails (6.5.3)
+      execjs
+    bcrypt (3.1.11-x64-mingw32)
+    bcrypt-ruby (3.0.1)
+    bootstrap-sass (3.3.7)
+      autoprefixer-rails (>= 5.2.1)
+      sass (>= 3.3.4)
+    builder (3.2.2)
+    cancancan (1.15.0)
+    chinese_pinyin (1.0.1)
+    chunky_png (1.3.8)
+    ckeditor (4.2.0)
+      cocaine
+      orm_adapter (~> 0.5.0)
+    climate_control (0.0.3)
+      activesupport (>= 3.0)
+    cocaine (0.5.8)
+      climate_control (>= 0.0.3, < 1.0)
+    coffee-rails (4.2.1)
+      coffee-script (>= 2.2.0)
+      railties (>= 4.0.0, < 5.2.x)
+    coffee-script (2.4.1)
+      coffee-script-source
+      execjs
+    coffee-script-source (1.11.1)
+    compass (1.0.3)
+      chunky_png (~> 1.2)
+      compass-core (~> 1.0.2)
+      compass-import-once (~> 1.0.5)
+      rb-fsevent (>= 0.9.3)
+      rb-inotify (>= 0.9)
+      sass (>= 3.3.13, < 3.5)
+    compass-core (1.0.3)
+      multi_json (~> 1.0)
+      sass (>= 3.3.0, < 3.5)
+    compass-import-once (1.0.5)
+      sass (>= 3.2, < 3.5)
+    concurrent-ruby (1.0.2)
+    devise (4.2.0)
+      bcrypt (~> 3.0)
+      orm_adapter (~> 0.1)
+      railties (>= 4.1.0, < 5.1)
+      responders
+      warden (~> 1.2.3)
+    domain_name (0.5.20161129)
+      unf (>= 0.0.5, < 1.0.0)
+    erubis (2.7.0)
+    execjs (2.7.0)
+    ffi (1.9.14-x64-mingw32)
+    font-awesome-rails (4.7.0.0)
+      railties (>= 3.2, < 5.1)
+    globalid (0.3.7)
+      activesupport (>= 4.1.0)
+    haml (4.0.7)
+      tilt
+    haml-rails (0.9.0)
+      actionpack (>= 4.0.1)
+      activesupport (>= 4.0.1)
+      haml (>= 4.0.6, < 5.0)
+      html2haml (>= 1.0.1)
+      railties (>= 4.0.1)
+    html2haml (2.0.0)
+      erubis (~> 2.7.0)
+      haml (~> 4.0.0)
+      nokogiri (~> 1.6.0)
+      ruby_parser (~> 3.5)
+    http-cookie (1.0.3)
+      domain_name (~> 0.5)
+    i18n (0.7.0)
+    jquery-rails (4.2.1)
+      rails-dom-testing (>= 1, < 3)
+      railties (>= 4.2.0)
+      thor (>= 0.14, < 2.0)
+    jquery-ui-rails (5.0.5)
+      railties (>= 3.2.16)
+    json (1.8.3)
+    kaminari (0.17.0)
+      actionpack (>= 3.0.0)
+      activesupport (>= 3.0.0)
+    loofah (2.0.3)
+      nokogiri (>= 1.5.9)
+    macaddr (1.7.1)
+      systemu (~> 2.6.2)
+    mail (2.6.4)
+      mime-types (>= 1.16, < 4)
+    mime-types (2.99.3)
+    mimemagic (0.3.2)
+    mini_portile2 (2.1.0)
+    minitest (5.10.1)
+    multi_json (1.12.1)
+    mysql2 (0.4.5-x64-mingw32)
+    nested_form (0.3.2)
+    netrc (0.11.0)
+    nokogiri (1.6.8.1-x64-mingw32)
+      mini_portile2 (~> 2.1.0)
+    orm_adapter (0.5.0)
+    paper_trail (5.2.3)
+      activerecord (>= 3.0, < 6.0)
+      request_store (~> 1.1)
+    paperclip (5.1.0)
+      activemodel (>= 4.2.0)
+      activesupport (>= 4.2.0)
+      cocaine (~> 0.5.5)
+      mime-types
+      mimemagic (~> 0.3.0)
+    paperclip-storage-aliyun (0.1.1)
+      paperclip (>= 3.5.2)
+      rest-client (>= 1.6.7)
+    rack (1.6.5)
+    rack-pjax (1.0.0)
+      nokogiri (~> 1.5)
+      rack (>= 1.1)
+    rack-test (0.6.3)
+      rack (>= 1.0)
+    rails (4.2.7.1)
+      actionmailer (= 4.2.7.1)
+      actionpack (= 4.2.7.1)
+      actionview (= 4.2.7.1)
+      activejob (= 4.2.7.1)
+      activemodel (= 4.2.7.1)
+      activerecord (= 4.2.7.1)
+      activesupport (= 4.2.7.1)
+      bundler (>= 1.3.0, < 2.0)
+      railties (= 4.2.7.1)
+      sprockets-rails
+    rails-deprecated_sanitizer (1.0.3)
+      activesupport (>= 4.2.0.alpha)
+    rails-dom-testing (1.0.7)
+      activesupport (>= 4.2.0.beta, < 5.0)
+      nokogiri (~> 1.6.0)
+      rails-deprecated_sanitizer (>= 1.0.1)
+    rails-html-sanitizer (1.0.3)
+      loofah (~> 2.0)
+    rails_admin (1.1.0)
+      builder (~> 3.1)
+      coffee-rails (~> 4.0)
+      font-awesome-rails (>= 3.0, < 5)
+      haml (~> 4.0)
+      jquery-rails (>= 3.0, < 5)
+      jquery-ui-rails (~> 5.0)
+      kaminari (~> 0.14)
+      nested_form (~> 0.3)
+      rack-pjax (>= 0.7)
+      rails (>= 4.0, < 6)
+      remotipart (~> 1.3)
+      sass-rails (>= 4.0, < 6)
+    rails_admin_import (2.0.0)
+      haml (~> 4.0)
+      rails (>= 3.2)
+      rails_admin (>= 0.6.6)
+      rchardet (~> 1.6)
+      simple_xlsx_reader (~> 1.0)
+    rails_admin_nestable (0.3.2)
+      coffee-rails
+      haml-rails
+      rails_admin (>= 0.6.6)
+      sass-rails
+    railties (4.2.7.1)
+      actionpack (= 4.2.7.1)
+      activesupport (= 4.2.7.1)
+      rake (>= 0.8.7)
+      thor (>= 0.18.1, < 2.0)
+    rake (11.3.0)
+    rb-fsevent (0.9.8)
+    rb-inotify (0.9.7)
+      ffi (>= 0.5.0)
+    rchardet (1.6.1)
+    remotipart (1.3.1)
+    request_store (1.3.1)
+    responders (2.3.0)
+      railties (>= 4.2.0, < 5.1)
+    rest-client (1.8.0-x64-mingw32)
+      ffi (~> 1.9)
+      http-cookie (>= 1.0.2, < 2.0)
+      mime-types (>= 1.16, < 3.0)
+      netrc (~> 0.7)
+    ruby_parser (3.8.3)
+      sexp_processor (~> 4.1)
+    rubyzip (1.2.0)
+    safe_yaml (1.0.4)
+    sass (3.4.22)
+    sass-rails (5.0.6)
+      railties (>= 4.0.0, < 6)
+      sass (~> 3.1)
+      sprockets (>= 2.8, < 4.0)
+      sprockets-rails (>= 2.0, < 4.0)
+      tilt (>= 1.1, < 3)
+    sexp_processor (4.7.0)
+    simple_xlsx_reader (1.0.2)
+      nokogiri
+      rubyzip
+    sprockets (3.7.0)
+      concurrent-ruby (~> 1.0)
+      rack (> 1, < 3)
+    sprockets-rails (3.2.0)
+      actionpack (>= 4.0)
+      activesupport (>= 4.0)
+      sprockets (>= 3.0.0)
+    syck (1.2.0)
+    systemu (2.6.5)
+    thor (0.19.4)
+    thread_safe (0.3.5)
+    tilt (2.0.5)
+    tzinfo (1.2.2)
+      thread_safe (~> 0.1)
+    tzinfo-data (1.2016.10)
+      tzinfo (>= 1.0.0)
+    uglifier (3.0.4)
+      execjs (>= 0.3.0, < 3)
+    unf (0.1.4)
+      unf_ext
+    unf_ext (0.0.7.2-x64-mingw32)
+    uuid (2.3.8)
+      macaddr (~> 1.0)
+    warden (1.2.6)
+      rack (>= 1.0)
+    xml-simple (1.1.5)
+
+PLATFORMS
+  x64-mingw32
+
+DEPENDENCIES
+  aliyun-sdk (~> 0.4.1)
+  ancestry
+  bcrypt-ruby (~> 3.0.0)
+  bootstrap-sass
+  cancancan
+  chinese_pinyin
+  ckeditor
+  coffee-rails
+  coffee-script-source
+  compass
+  devise
+  jquery-rails
+  mysql2
+  paper_trail (= 5.2.3)
+  paperclip
+  paperclip-storage-aliyun
+  rails (= 4.2.7.1)
+  rails_admin
+  rails_admin_import
+  rails_admin_nestable
+  rest-client (~> 1.8.0)
+  safe_yaml
+  sass-rails
+  syck
+  therubyracer
+  tzinfo-data
+  uglifier
+  uuid
+  xml-simple
+
+BUNDLED WITH
+   1.13.6

+ 261 - 0
README.rdoc

@@ -0,0 +1,261 @@
+== Welcome to Rails
+
+Rails is a web-application framework that includes everything needed to create
+database-backed web applications according to the Model-View-Control pattern.
+
+This pattern splits the view (also called the presentation) into "dumb"
+templates that are primarily responsible for inserting pre-built data in between
+HTML tags. The model contains the "smart" domain objects (such as Account,
+Product, Person, Post) that holds all the business logic and knows how to
+persist themselves to a database. The controller handles the incoming requests
+(such as Save New Account, Update Product, Show Post) by manipulating the model
+and directing data to the view.
+
+In Rails, the model is handled by what's called an object-relational mapping
+layer entitled Active Record. This layer allows you to present the data from
+database rows as objects and embellish these data objects with business logic
+methods. You can read more about Active Record in
+link:files/vendor/rails/activerecord/README.html.
+
+The controller and view are handled by the Action Pack, which handles both
+layers by its two parts: Action View and Action Controller. These two layers
+are bundled in a single package due to their heavy interdependence. This is
+unlike the relationship between the Active Record and Action Pack that is much
+more separate. Each of these packages can be used independently outside of
+Rails. You can read more about Action Pack in
+link:files/vendor/rails/actionpack/README.html.
+
+
+== Getting Started
+
+1. At the command prompt, create a new Rails application:
+       <tt>rails new myapp</tt> (where <tt>myapp</tt> is the application name)
+
+2. Change directory to <tt>myapp</tt> and start the web server:
+       <tt>cd myapp; rails server</tt> (run with --help for options)
+
+3. Go to http://localhost:3000/ and you'll see:
+       "Welcome aboard: You're riding Ruby on Rails!"
+
+4. Follow the guidelines to start developing your application. You can find
+the following resources handy:
+
+* The Getting Started Guide: http://guides.rubyonrails.org/getting_started.html
+* Ruby on Rails Tutorial Book: http://www.railstutorial.org/
+
+
+== Debugging Rails
+
+Sometimes your application goes wrong. Fortunately there are a lot of tools that
+will help you debug it and get it back on the rails.
+
+First area to check is the application log files. Have "tail -f" commands
+running on the server.log and development.log. Rails will automatically display
+debugging and runtime information to these files. Debugging info will also be
+shown in the browser on requests from 127.0.0.1.
+
+You can also log your own messages directly into the log file from your code
+using the Ruby logger class from inside your controllers. Example:
+
+  class WeblogController < ActionController::Base
+    def destroy
+      @weblog = Weblog.find(params[:id])
+      @weblog.destroy
+      logger.info("#{Time.now} Destroyed Weblog ID ##{@weblog.id}!")
+    end
+  end
+
+The result will be a message in your log file along the lines of:
+
+  Mon Oct 08 14:22:29 +1000 2007 Destroyed Weblog ID #1!
+
+More information on how to use the logger is at http://www.ruby-doc.org/core/
+
+Also, Ruby documentation can be found at http://www.ruby-lang.org/. There are
+several books available online as well:
+
+* Programming Ruby: http://www.ruby-doc.org/docs/ProgrammingRuby/ (Pickaxe)
+* Learn to Program: http://pine.fm/LearnToProgram/ (a beginners guide)
+
+These two books will bring you up to speed on the Ruby language and also on
+programming in general.
+
+
+== Debugger
+
+Debugger support is available through the debugger command when you start your
+Mongrel or WEBrick server with --debugger. This means that you can break out of
+execution at any point in the code, investigate and change the model, and then,
+resume execution! You need to install ruby-debug to run the server in debugging
+mode. With gems, use <tt>sudo gem install ruby-debug</tt>. Example:
+
+  class WeblogController < ActionController::Base
+    def index
+      @posts = Post.all
+      debugger
+    end
+  end
+
+So the controller will accept the action, run the first line, then present you
+with a IRB prompt in the server window. Here you can do things like:
+
+  >> @posts.inspect
+  => "[#<Post:0x14a6be8
+          @attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>,
+       #<Post:0x14a6620
+          @attributes={"title"=>"Rails", "body"=>"Only ten..", "id"=>"2"}>]"
+  >> @posts.first.title = "hello from a debugger"
+  => "hello from a debugger"
+
+...and even better, you can examine how your runtime objects actually work:
+
+  >> f = @posts.first
+  => #<Post:0x13630c4 @attributes={"title"=>nil, "body"=>nil, "id"=>"1"}>
+  >> f.
+  Display all 152 possibilities? (y or n)
+
+Finally, when you're ready to resume execution, you can enter "cont".
+
+
+== Console
+
+The console is a Ruby shell, which allows you to interact with your
+application's domain model. Here you'll have all parts of the application
+configured, just like it is when the application is running. You can inspect
+domain models, change values, and save to the database. Starting the script
+without arguments will launch it in the development environment.
+
+To start the console, run <tt>rails console</tt> from the application
+directory.
+
+Options:
+
+* Passing the <tt>-s, --sandbox</tt> argument will rollback any modifications
+  made to the database.
+* Passing an environment name as an argument will load the corresponding
+  environment. Example: <tt>rails console production</tt>.
+
+To reload your controllers and models after launching the console run
+<tt>reload!</tt>
+
+More information about irb can be found at:
+link:http://www.rubycentral.org/pickaxe/irb.html
+
+
+== dbconsole
+
+You can go to the command line of your database directly through <tt>rails
+dbconsole</tt>. You would be connected to the database with the credentials
+defined in database.yml. Starting the script without arguments will connect you
+to the development database. Passing an argument will connect you to a different
+database, like <tt>rails dbconsole production</tt>. Currently works for MySQL,
+PostgreSQL and SQLite 3.
+
+== Description of Contents
+
+The default directory structure of a generated Ruby on Rails application:
+
+  |-- app
+  |   |-- assets
+  |   |   |-- images
+  |   |   |-- javascripts
+  |   |   `-- stylesheets
+  |   |-- controllers
+  |   |-- helpers
+  |   |-- mailers
+  |   |-- models
+  |   `-- views
+  |       `-- layouts
+  |-- config
+  |   |-- environments
+  |   |-- initializers
+  |   `-- locales
+  |-- db
+  |-- doc
+  |-- lib
+  |   |-- assets
+  |   `-- tasks
+  |-- log
+  |-- public
+  |-- script
+  |-- test
+  |   |-- fixtures
+  |   |-- functional
+  |   |-- integration
+  |   |-- performance
+  |   `-- unit
+  |-- tmp
+  |   `-- cache
+  |       `-- assets
+  `-- vendor
+      |-- assets
+      |   |-- javascripts
+      |   `-- stylesheets
+      `-- plugins
+
+app
+  Holds all the code that's specific to this particular application.
+
+app/assets
+  Contains subdirectories for images, stylesheets, and JavaScript files.
+
+app/controllers
+  Holds controllers that should be named like weblogs_controller.rb for
+  automated URL mapping. All controllers should descend from
+  ApplicationController which itself descends from ActionController::Base.
+
+app/models
+  Holds models that should be named like post.rb. Models descend from
+  ActiveRecord::Base by default.
+
+app/views
+  Holds the template files for the view that should be named like
+  weblogs/index.html.erb for the WeblogsController#index action. All views use
+  eRuby syntax by default.
+
+app/views/layouts
+  Holds the template files for layouts to be used with views. This models the
+  common header/footer method of wrapping views. In your views, define a layout
+  using the <tt>layout :default</tt> and create a file named default.html.erb.
+  Inside default.html.erb, call <% yield %> to render the view using this
+  layout.
+
+app/helpers
+  Holds view helpers that should be named like weblogs_helper.rb. These are
+  generated for you automatically when using generators for controllers.
+  Helpers can be used to wrap functionality for your views into methods.
+
+config
+  Configuration files for the Rails environment, the routing map, the database,
+  and other dependencies.
+
+db
+  Contains the database schema in schema.rb. db/migrate contains all the
+  sequence of Migrations for your schema.
+
+doc
+  This directory is where your application documentation will be stored when
+  generated using <tt>rake doc:app</tt>
+
+lib
+  Application specific libraries. Basically, any kind of custom code that
+  doesn't belong under controllers, models, or helpers. This directory is in
+  the load path.
+
+public
+  The directory available for the web server. Also contains the dispatchers and the
+  default HTML files. This should be set as the DOCUMENT_ROOT of your web
+  server.
+
+script
+  Helper scripts for automation and generation.
+
+test
+  Unit and functional tests along with fixtures. When using the rails generate
+  command, template test files will be generated for you and placed in this
+  directory.
+
+vendor
+  External libraries that the application depends on. Also includes the plugins
+  subdirectory. If the app has frozen rails, those gems also go here, under
+  vendor/rails/. This directory is in the load path.

+ 7 - 0
Rakefile

@@ -0,0 +1,7 @@
+#!/usr/bin/env rake
+# Add your own tasks in files placed in lib/tasks ending in .rake,
+# for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
+
+require File.expand_path('../config/application', __FILE__)
+
+AdminD5ctCom::Application.load_tasks

+ 0 - 0
aliyun_sdk.log


BIN
app/assets/images/rails.png


+ 16 - 0
app/assets/javascripts/application.js

@@ -0,0 +1,16 @@
+// This is a manifest file that'll be compiled into application.js, which will include all the files
+// listed below.
+//
+// Any JavaScript/Coffee file within this directory, lib/assets/javascripts, vendor/assets/javascripts,
+// or vendor/assets/javascripts of plugins, if any, can be referenced here using a relative path.
+//
+// It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the
+// the compiled file.
+//
+// WARNING: THE FIRST BLANK LINE MARKS THE END OF WHAT'S TO BE PROCESSED, ANY BLANK LINE SHOULD
+// GO AFTER THE REQUIRES BELOW.
+//
+//= require_tree .
+//= require ckeditor/init
+//= require jquery
+//= require jquery_ujs

+ 135 - 0
app/assets/javascripts/ckeditor/config.js

@@ -0,0 +1,135 @@
+/*
+ Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
+ For licensing, see LICENSE.html or http://ckeditor.com/license
+ */
+
+CKEDITOR.editorConfig = function( config )
+{
+    // Define changes to default configuration here. For example:
+    // config.language = 'fr';
+    // config.uiColor = '#AADC6E';
+
+    /* Filebrowser routes */
+    // The location of an external file browser, that should be launched when "Browse Server" button is pressed.
+    //文件上传POST请求的URL
+    config.filebrowserBrowseUrl = "/ckeditor/attachment_files";
+
+    // The location of an external file browser, that should be launched when "Browse Server" button is pressed in the Flash dialog.
+    config.filebrowserFlashBrowseUrl = "/ckeditor/attachment_files";
+
+    // The location of a script that handles file uploads in the Flash dialog.
+    config.filebrowserFlashUploadUrl = "/ckeditor/attachment_files";
+
+    // The location of an external file browser, that should be launched when "Browse Server" button is pressed in the Link tab of Image dialog.
+    config.filebrowserImageBrowseLinkUrl = "/ckeditor/pictures";
+
+    // The location of an external file browser, that should be launched when "Browse Server" button is pressed in the Image dialog.
+    config.filebrowserImageBrowseUrl = "/ckeditor/pictures";
+
+    // The location of a script that handles file uploads in the Image dialog.
+    config.filebrowserImageUploadUrl = "/ckeditor/pictures";
+
+    // The location of a script that handles file uploads.
+    config.filebrowserUploadUrl = "/ckeditor/attachment_files";
+
+    config.allowedContent = true;
+
+    //上传图片去掉预览文字
+    config.image_previewText =' ';
+    //config.maxSize = 0;
+    // 字体
+    config.font_names= '宋体/SimSun;新宋体/NSimSun;仿宋_GB2312/FangSong_GB2312;楷体_GB2312/KaiTi_GB2312;黑体/SimHei;微软雅黑/Microsoft YaHei;' + config.font_names;
+
+    //增加行距插件
+    config.extraPlugins += (config.extraPlugins ? ',lineheight' : 'lineheight');
+    //从word复制时保留格式
+    config.pasteFromWordRemoveFontStyles = false;
+    config.pasteFromWordRemoveStyles = false;
+    // Rails CSRF token
+    config.filebrowserParams = function(){
+        var csrf_token, csrf_param, meta,
+            metas = document.getElementsByTagName('meta'),
+            params = new Object();
+
+        for ( var i = 0 ; i < metas.length ; i++ ){
+            meta = metas[i];
+
+            switch(meta.name) {
+                case "csrf-token":
+                    csrf_token = meta.content;
+                    break;
+                case "csrf-param":
+                    csrf_param = meta.content;
+                    break;
+                default:
+                    continue;
+            }
+        }
+
+        if (csrf_param !== undefined && csrf_token !== undefined) {
+            params[csrf_param] = csrf_token;
+        }
+
+        return params;
+    };
+
+    config.addQueryString = function( url, params ){
+        var queryString = [];
+
+        if ( !params ) {
+            return url;
+        } else {
+            for ( var i in params )
+                queryString.push( i + "=" + encodeURIComponent( params[ i ] ) );
+        }
+
+        return url + ( ( url.indexOf( "?" ) != -1 ) ? "&" : "?" ) + queryString.join( "&" );
+    };
+
+    // Integrate Rails CSRF token into file upload dialogs (link, image, attachment and flash)
+    CKEDITOR.on( 'dialogDefinition', function( ev ){
+        // Take the dialog name and its definition from the event data.
+        var dialogName = ev.data.name;
+        var dialogDefinition = ev.data.definition;
+        var content, upload;
+
+        if (CKEDITOR.tools.indexOf(['link', 'image', 'attachment', 'flash'], dialogName) > -1) {
+            content = (dialogDefinition.getContents('Upload') || dialogDefinition.getContents('upload'));
+            upload = (content == null ? null : content.get('upload'));
+
+            if (upload && upload.filebrowser && upload.filebrowser['params'] === undefined) {
+                upload.filebrowser['params'] = config.filebrowserParams();
+                upload.action = config.addQueryString(upload.action, upload.filebrowser['params']);
+            }
+        }
+    });
+
+    // 设置初始高度
+    config.height = 600;
+    // Toolbar groups configuration.
+    config.toolbar = [
+        { name: 'document', groups: [ 'mode', 'document', 'doctools' ], items: [ 'Source'] },
+        { name: 'clipboard', groups: [ 'clipboard', 'undo' ], items: [ 'Cut', 'Copy', 'Paste', 'PasteText', 'PasteFromWord', '-', 'Undo', 'Redo' ] },
+        // { name: 'editing', groups: [ 'find', 'selection', 'spellchecker' ], items: [ 'Find', 'Replace', '-', 'SelectAll', '-', 'Scayt' ] },
+        // { name: 'forms', items: [ 'Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 'HiddenField' ] },
+        { name: 'links', items: [ 'Link', 'Unlink', 'Anchor' ] },
+        { name: 'insert', items: [ 'Image', 'Iframe','Table', 'HorizontalRule', 'SpecialChar' ] },
+        { name: 'paragraph', groups: [ 'list', 'indent', 'blocks', 'align', 'bidi' ], items: [ 'NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'Blockquote', 'CreateDiv', '-', 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock' ] },
+        '/',
+        { name: 'styles', items: [ 'Styles', 'Format', 'Font', 'FontSize', 'lineheight' ] },
+        { name: 'colors', items: [ 'TextColor', 'BGColor' ] },
+        { name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ], items: [ 'Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', '-', 'RemoveFormat' ] },
+        { name: 'tools', items : [ 'Maximize','-','About' ] } 
+    ];
+
+    config.toolbar_mini = [
+        { name: 'paragraph', groups: [ 'list', 'indent', 'blocks', 'align', 'bidi' ], items: [ 'NumberedList', 'BulletedList', '-', 'Outdent', 'Indent', '-', 'Blockquote', 'CreateDiv', '-', 'JustifyLeft', 'JustifyCenter', 'JustifyRight', 'JustifyBlock' ] },
+        { name: 'styles', items: [ 'Font', 'FontSize' ] },
+        { name: 'colors', items: [ 'TextColor', 'BGColor' ] },
+        { name: 'basicstyles', groups: [ 'basicstyles', 'cleanup' ], items: [ 'Bold', 'Italic', 'Underline', 'Strike', 'Subscript', 'Superscript', '-', 'RemoveFormat' ] },
+        { name: 'insert', items: [ 'Image', 'Table', 'HorizontalRule', 'SpecialChar' ] },
+        { name: 'maximize'}
+    ];
+
+    // config.extraPlugins += (config.extraPlugins ? ',helloworld' : 'helloworld');
+};

+ 5 - 0
app/assets/javascripts/ckeditor/plugins/lineheight/lang/en.js

@@ -0,0 +1,5 @@
+CKEDITOR.plugins.setLang('lineheight', 'en', {
+    label: 'lineheight',
+    panelTitle: 'line-height',
+    panelTitle: 'line-height'
+});

+ 5 - 0
app/assets/javascripts/ckeditor/plugins/lineheight/lang/zh-cn.js

@@ -0,0 +1,5 @@
+CKEDITOR.plugins.setLang('lineheight', 'zh-cn', {
+    label: '行距',
+    panelTitle: '行距',
+    panelTitle: '行距'
+});

+ 146 - 0
app/assets/javascripts/ckeditor/plugins/lineheight/plugin.js

@@ -0,0 +1,146 @@
+/*
+Copyright (c) 2003-2011, CKSource - Frederico Knabben. All rights reserved.
+For licensing, see LICENSE.html or http://ckeditor.com/license
+*/
+
+(function()
+{
+	function addCombo( editor, comboName, styleType, lang, entries, defaultLabel, styleDefinition )
+	{
+		var config = editor.config;
+
+		// Gets the list of fonts from the settings.
+		var names = entries.split( ';' ),
+			values = [];
+
+		// Create style objects for all fonts.
+		var styles = {};
+		for ( var i = 0 ; i < names.length ; i++ )
+		{
+			var parts = names[ i ];
+
+			if ( parts )
+			{
+				parts = parts.split( '/' );
+
+				var vars = {},
+					name = names[ i ] = parts[ 0 ];
+
+				vars[ styleType ] = values[ i ] = parts[ 1 ] || name;
+
+				styles[ name ] = new CKEDITOR.style( styleDefinition, vars );
+				styles[ name ]._.definition.name = name;
+			}
+			else
+				names.splice( i--, 1 );
+		}
+
+
+	    editor.ui.addRichCombo( comboName,
+	    	{
+	    		label : lang.lineheight.label,
+	    		title: lang.lineheight.panelTitle,
+	    		className: 'cke_' + (styleType == 'size' ? 'fontSize' : 'font'),
+	    		panel :{
+	    			css : [CKEDITOR.skin.getPath("editor")].concat( config.contentsCss ),
+	    			multiSelect : false,
+	    			attributes: { 'aria-label': lang.lineheight.panelTitle }
+	    		},  
+  
+				init : function()
+				{
+					this.startGroup( lang.lineheight.panelTitle );  
+
+					for ( var i = 0 ; i < names.length ; i++ )
+					{
+						var name = names[ i ];
+
+						// Add the tag entry to the panel list.
+						this.add( name, styles[ name ].buildPreview(), name );
+					}
+				},
+
+				onClick : function( value )
+				{
+					editor.focus();
+					editor.fire( 'saveSnapshot' );
+
+					var style = styles[ value ];
+
+					if ( this.getValue() == value )
+						style.remove( editor.document );
+					else
+						style.apply( editor.document );
+
+					editor.fire( 'saveSnapshot' );
+				},
+
+				onRender : function()
+				{
+					editor.on( 'selectionChange', function( ev )
+						{
+							var currentValue = this.getValue();
+
+							var elementPath = ev.data.path,
+								elements = elementPath.elements;
+
+							// For each element into the elements path.
+							for ( var i = 0, element ; i < elements.length ; i++ )
+							{
+								element = elements[i];
+
+								// Check if the element is removable by any of
+								// the styles.
+								for ( var value in styles )
+								{
+									if ( styles[ value ].checkElementRemovable( element, true ) )
+									{
+										if ( value != currentValue )
+											this.setValue( value );
+										return;
+									}
+								}
+							}
+
+							// If no styles match, just empty it.
+							this.setValue( '', defaultLabel );
+						},
+						this);
+				}
+			});
+	}
+
+	CKEDITOR.plugins.add('lineheight',
+	{
+	    lang: ['zh-cn'],
+		requires : [ 'richcombo'],
+
+		init : function( editor )
+		{
+			var config = editor.config;
+			addCombo(editor, 'lineheight', 'size', editor.lang, config.lineheight_sizes, config.fontSize_defaultLabel, config.lineheight_style);
+		}
+	});
+})();
+
+
+/**
+ * The text to be displayed in the Font combo is none of the available values
+ * matches the current cursor position or text selection.
+ * @type String
+ * @example
+ * // If the default site font is Arial, we may making it more explicit to the end user.
+ * config.font_defaultLabel = 'Arial';
+ */
+CKEDITOR.config.font_defaultLabel = '';
+
+
+CKEDITOR.config.lineheight_sizes = 
+	'normal;1.5em;1.75em;2em;3em;4em;5em;100%;120%;130%;150%;170%;180%;190%;200%;220%;250%;300%;400%;500%';
+
+CKEDITOR.config.lineheight_style =
+	{
+		element		: 'span',
+		styles		: { 'line-height' : '#(size)' },
+		overrides: [{ element: 'line', attributes: { 'height': null}}]
+	};

+ 7 - 0
app/assets/javascripts/rails_admin/custom/ckeditor_ajax.js.coffee

@@ -0,0 +1,7 @@
+$(document).ready ->
+  $(document).on 'mousedown', '.save-action', (e) -> # triggers also when submitting form with enter
+    for instance of CKEDITOR.instances
+      editor = CKEDITOR.instances[instance]
+      if editor.checkDirty()
+        editor.updateElement();
+    return true;

+ 1 - 0
app/assets/javascripts/rails_admin/custom/ui.js

@@ -0,0 +1 @@
+//= require rails_admin/custom/ckeditor_ajax

+ 14 - 0
app/assets/stylesheets/application.css.scss

@@ -0,0 +1,14 @@
+/*
+ * This is a manifest file that'll be compiled into application.css, which will include all the files
+ * listed below.
+ *
+ * Any CSS and SCSS file within this directory, lib/assets/stylesheets, vendor/assets/stylesheets,
+ * or vendor/assets/stylesheets of plugins, if any, can be referenced here using a relative path.
+ *
+ * You're free to add application-wide styles to this file and they'll appear at the top of the
+ * compiled file, but it's generally better to create a new file per style scope.
+ *
+ *= require_self
+ *= require_tree .
+ */
+

+ 109 - 0
app/assets/stylesheets/rails_admin/rails_admin.scss.erb

@@ -0,0 +1,109 @@
+// Issue 1956 (https://github.com/sferik/rails_admin/issues/1956)
+//= depend_on_asset "rails_admin/bootstrap/glyphicons-halflings.png"
+//= depend_on_asset "rails_admin/bootstrap/glyphicons-halflings-white.png"
+//= depend_on_asset "rails_admin/aristo/images/bg_fallback.png"
+//= depend_on_asset "rails_admin/aristo/images/ui-icons_222222_256x240.png"
+//= depend_on_asset "rails_admin/aristo/images/ui-icons_454545_256x240.png"
+//= depend_on_asset "rails_admin/aristo/images/icon_sprite.png"
+//= depend_on_asset "rails_admin/aristo/images/slider_handles.png"
+//= depend_on_asset "rails_admin/aristo/images/progress_bar.gif"
+//= depend_on_asset "rails_admin/multiselect/icon_sprite.png"
+//= depend_on_asset "rails_admin/multiselect/ui-icon-circle-triangle-n-light.png"
+//= depend_on_asset "rails_admin/multiselect/ui-icon-circle-triangle-n-dark.png"
+//= depend_on_asset "rails_admin/multiselect/ui-icon-circle-triangle-s-light.png"
+//= depend_on_asset "rails_admin/multiselect/ui-icon-circle-triangle-s-dark.png"
+//= depend_on_asset "rails_admin/colorpicker/select2.png"
+//= depend_on_asset "rails_admin/colorpicker/custom_background.png"
+//= depend_on_asset "rails_admin/colorpicker/colorpicker_overlay.png"
+//= depend_on_asset "rails_admin/colorpicker/colorpicker_select.gif"
+//= depend_on_asset "rails_admin/colorpicker/custom_indic.gif"
+//= depend_on_asset "rails_admin/colorpicker/custom_hex.png"
+//= depend_on_asset "rails_admin/colorpicker/custom_rgb_r.png"
+//= depend_on_asset "rails_admin/colorpicker/custom_rgb_g.png"
+//= depend_on_asset "rails_admin/colorpicker/custom_rgb_b.png"
+//= depend_on_asset "rails_admin/colorpicker/custom_hsb_h.png"
+//= depend_on_asset "rails_admin/colorpicker/custom_hsb_s.png"
+//= depend_on_asset "rails_admin/colorpicker/custom_hsb_b.png"
+//= depend_on_asset "rails_admin/colorpicker/custom_submit.png"
+
+
+@charset "UTF-8";
+
+<%
+  theme = ENV['RAILS_ADMIN_THEME'] || :default
+%>
+
+/***  Variables  ***/
+
+@import "rails_admin/custom/variables";
+@import "rails_admin/bootstrap/variables";
+@import "rails_admin/base/variables";
+@import "rails_admin/themes/<%= theme %>/variables";
+
+/***  Mixins  ***/
+
+@import "rails_admin/bootstrap/mixins";
+@import "rails_admin/base/mixins";
+@import "rails_admin/themes/<%= theme %>/mixins";
+@import "rails_admin/custom/mixins";
+
+/*** Reset ***/
+<%# @import "rails_admin/bootstrap/reset"; %>
+/***  Libraries  ***/
+
+@import "rails_admin/aristo/jquery-ui-1.8.7.custom";
+@import "rails_admin/bootstrap-datetimepicker-build";
+@import "rails_admin/ra.filtering-multiselect";
+@import "rails_admin/ra.widgets";
+@import "rails_admin/jquery.colorpicker";
+
+
+/*** Font-awesome ***/
+
+@import 'font-awesome';
+@import 'rails_admin/base/font-awesome-4-compability';
+
+/***  Bootstrap Theming  ***/
+
+@import "rails_admin/bootstrap/normalize";
+@import "rails_admin/bootstrap/scaffolding";
+@import "rails_admin/bootstrap/grid";
+<%# @import "rails_admin/bootstrap/layouts"; %>
+@import "rails_admin/bootstrap/type";
+@import "rails_admin/bootstrap/forms";
+@import "rails_admin/bootstrap/tables";
+@import "rails_admin/bootstrap/dropdowns";
+@import "rails_admin/bootstrap/wells";
+@import "rails_admin/bootstrap/component-animations";
+@import "rails_admin/bootstrap/close";
+@import "rails_admin/bootstrap/buttons";
+@import "rails_admin/bootstrap/button-groups";
+@import "rails_admin/bootstrap/input-groups";
+@import "rails_admin/bootstrap/alerts";
+@import "rails_admin/bootstrap/navs";
+@import "rails_admin/bootstrap/navbar";
+@import "rails_admin/bootstrap/breadcrumbs";
+@import "rails_admin/bootstrap/pagination";
+@import "rails_admin/bootstrap/pager";
+@import "rails_admin/bootstrap/modals";
+@import "rails_admin/bootstrap/tooltip";
+@import "rails_admin/bootstrap/popovers";
+@import "rails_admin/bootstrap/thumbnails";
+@import "rails_admin/bootstrap/labels";
+@import "rails_admin/bootstrap/panels";
+@import "rails_admin/bootstrap/badges";
+@import "rails_admin/bootstrap/progress-bars";
+<%# @import "rails_admin/bootstrap/accordion"; %>
+@import "rails_admin/bootstrap/carousel";
+<%# @import "rails_admin/bootstrap/hero-unit"; %>
+@import "rails_admin/bootstrap/utilities";
+@import "rails_admin/bootstrap/responsive-utilities";
+
+/***  RailsAdmin Theming  ***/
+
+@import "rails_admin/base/theming";
+@import "rails_admin/themes/<%= theme %>/theming";
+@import "rails_admin/custom/theming";
+
+
+

+ 17 - 0
app/controllers/application_controller.rb

@@ -0,0 +1,17 @@
+# encoding:utf-8
+class ApplicationController < ActionController::Base
+  protect_from_forgery
+  layout :layout_by_resource
+
+  rescue_from CanCan::AccessDenied do |exception|
+    redirect_to root_url, :alert => exception.message
+  end
+
+  def layout_by_resource
+    if devise_controller?
+      "devise_layout"
+    else
+      "application"
+    end
+  end
+end

+ 4 - 0
app/controllers/base_controller.rb

@@ -0,0 +1,4 @@
+#encoding:utf-8
+class BaseController < ActionController::Base
+
+end

+ 16 - 0
app/helpers/application_helper.rb

@@ -0,0 +1,16 @@
+module ApplicationHelper
+
+  #昨天凌晨
+  def yestoday_zero
+    return today_zero - 1.day
+  end
+  #今日凌晨
+  def today_zero
+    now = Time.now
+    return Time.new(now.year, now.month, now.day)
+  end
+  #明日凌晨
+  def tomorrow_zero
+    return today_zero + 1.day
+  end
+end

+ 0 - 0
app/mailers/.gitkeep


+ 68 - 0
app/models/ability.rb

@@ -0,0 +1,68 @@
+class Ability
+  include CanCan::Ability
+
+  def initialize(user)
+    # Define abilities for the passed in user here. For example:
+    #
+    #   user ||= User.new # guest user (not logged in)
+    #   if user.admin?
+    #     can :manage, :all
+    #   else
+    #     can :read, :all
+    #   end
+    if user
+      can :dashboard # allow access to dashboard
+      can :access, :rails_admin # only allow admin users to access Rails Admin
+      cannot :history, :all
+      cannot :import, :all
+      cannot :export, :all
+      cannot :destroy, :all
+      if user.email == AdminUser::SUPER_ADMIN
+        can :manage, :all
+        # can :export, :all
+        # can :read, :all
+        # can :destroy, :all
+        # can :create, :all
+        # can :update, :all
+      else
+        user.permissions.each do |permission|
+           eval "can :#{permission.can}, #{permission.model}"
+        end 
+                     
+        can :update, AdminUser, :id => user.id
+        can :read, AdminUser, :id => user.id
+        cannot :history, :all
+        # cannot :destroy, ChannelQrcode        
+        # cannot :refund_at_once, Project
+        # cannot :destroy, ["ProductAttr", "ProductAttrKey", "ProductAttrValue"]
+        # cannot :delete, ["ProductAttr", "ProductAttrKey", "ProductAttrValue"]
+        # cannot :export, ["ProductAttr", "ProductAttrKey", "ProductAttrValue"]
+      end
+      #cannot :destroy, DianshiOrder
+      # cannot :new, DianbiOrder
+      # cannot :new, VipOrder
+      # cannot :new, DianshiOrder
+      # cannot :update, User
+      # cannot :generate_analyze_report_record, AnalyzeReport
+      # can :generate_analyze_report_record, AnalyzeReport, :remark => "当前汇总"
+    end
+    #
+    # The first argument to `can` is the action you are giving the user
+    # permission to do.
+    # If you pass :manage it will apply to every action. Other common actions
+    # here are :read, :create, :update and :destroy.
+    #
+    # The second argument is the resource the user can perform the action on.
+    # If you pass :all it will apply to every resource. Otherwise pass a Ruby
+    # class of the resource.
+    #
+    # The third argument is an optional hash of conditions to further filter the
+    # objects.
+    # For example, here the user can only update published articles.
+    #
+    #   can :update, Article, :published => true
+    #
+    # See the wiki for details:
+    # https://github.com/CanCanCommunity/cancancan/wiki/Defining-Abilities
+  end
+end

+ 44 - 0
app/models/admin_permission.rb

@@ -0,0 +1,44 @@
+# encoding:utf-8
+class AdminPermission < ActiveRecord::Base
+  has_paper_trail
+  CAN_OPTIONS = %w(manage create update read write import export history)
+  # attr_accessible :model, :can
+  validates_inclusion_of :can, in: CAN_OPTIONS
+  validates :model, :can, presence: true
+
+  has_and_belongs_to_many :admin_roles, join_table: :admin_permissions_admin_roles
+
+
+  rails_admin do
+    navigation_label '系统管理'
+    weight -20
+    configure :admin_roles do
+      inverse_of :admin_permissions
+    end
+    list do
+      filters [:model,:can]
+    end
+    edit do
+      field :model, :enum do
+        enum do
+          RailsAdmin::Config.models.collect do |model|
+            model_name = model.abstract_model.model_name
+            [eval("#{model_name}.model_name.human"), model_name]
+          end
+        end
+      end
+      field :can, :enum do
+        enum do
+          CAN_OPTIONS.collect do |can|
+            [I18n.t(can), can]
+          end
+        end
+      end
+    end
+  end
+
+  def name
+    model_name = model.present? ? eval("#{model}.model_name.human") : ''
+    "#{I18n.t(self.can)}_#{model_name}"
+  end
+end

+ 19 - 0
app/models/admin_permissions_admin_role.rb

@@ -0,0 +1,19 @@
+# encoding:utf-8
+class AdminPermissionsAdminRole < ActiveRecord::Base
+  has_paper_trail
+
+  rails_admin do
+    navigation_label '系统管理'
+    weight -20
+
+    list do
+    	filters [:admin_role_id]
+    	field :id
+    	field :admin_role_id
+    	field :admin_permission_id
+    end
+
+    edit do
+    end
+  end
+end

+ 36 - 0
app/models/admin_role.rb

@@ -0,0 +1,36 @@
+# encoding:utf-8
+class AdminRole < ActiveRecord::Base
+  has_paper_trail
+  has_and_belongs_to_many :admin_users, join_table: :admin_roles_admin_users
+  has_and_belongs_to_many :admin_permissions, join_table: :admin_permissions_admin_roles
+
+  validates :name, presence: true
+
+  rails_admin do
+    navigation_label '系统管理'
+    weight -20
+    
+    #    parent User
+    configure :admin_permissions do
+      inverse_of :admin_roles
+    end
+
+    configure :admin_users do
+      hide
+    end
+
+    list do
+      filters [:name]
+      field :id
+      field :name
+      field :admin_users
+      field :admin_permissions
+      field :description
+      # field :created_at
+      # field :updated_at
+    end
+
+    edit do
+    end
+  end
+end

+ 19 - 0
app/models/admin_roles_admin_user.rb

@@ -0,0 +1,19 @@
+# encoding:utf-8
+class AdminRolesAdminUser < ActiveRecord::Base
+  has_paper_trail
+
+  rails_admin do
+    navigation_label '系统管理'
+    weight -20
+
+    list do
+    	filters [:admin_role_id,:admin_user_id]
+    	field :id
+    	field :admin_role_id
+    	field :admin_user_id
+    end
+
+    edit do
+    end
+  end
+end

+ 96 - 0
app/models/admin_user.rb

@@ -0,0 +1,96 @@
+# encoding: utf-8
+class AdminUser < ActiveRecord::Base
+  has_paper_trail
+
+  SUPER_ADMIN = Rails.env == "production" ? "super@statement.com" : "super@statement.com"
+
+  # Include default devise modules. Others available are:
+  # :confirmable, :lockable, :timeoutable, :recoverable and :omniauthable
+  devise :database_authenticatable,
+    :rememberable, :trackable, :validatable
+
+  # Setup accessible (or protected) attributes for your model
+
+  has_and_belongs_to_many :admin_roles, :join_table => :admin_roles_admin_users
+
+  rails_admin do
+    navigation_label '系统管理'
+    weight -20
+    configure :admin_roles do
+      inverse_of :admin_users
+    end
+
+    list do
+      filters [:name]
+      field :id
+      field :name
+      field :admin_roles
+      field :email
+      # field :password
+      # field :password_confirmation
+      # field :company
+      field :created_at
+      # field :created_at do
+      #   formatted_value do
+      #     value.strftime("%Y-%m-%d %H:%m:%S") unless value == 0
+      #   end
+      # end
+      field :updated_at
+      field :sign_in_count
+      # field :current_sign_in_at
+      # field :last_sign_in_at
+      # field :current_sign_in_ip
+      # field :last_sign_in_ip
+    end
+
+    edit do
+      field :email, :string
+      field :name, :string
+      field :password, :password
+      field :password_confirmation, :password
+      field :admin_roles do
+        # 当管理员为超管或有manage_Role权限才能操作 角色列表
+        visible do
+          perms = bindings[:view].current_admin_user.permissions.collect{ |perm| "#{perm.can}_#{perm.model}"}
+          perms.include?("manage_AdminRole") or bindings[:view].current_admin_user.email == SUPER_ADMIN
+        end
+      end
+    end
+
+    show do
+      configure :remember_created_at do
+        formatted_value do
+          value.strftime("%Y-%m-%d %H:%m:%S") unless value == 0
+        end
+      end
+      configure :current_sign_in_at do
+        formatted_value do
+          value.strftime("%Y-%m-%d %H:%m:%S") unless value == 0
+        end
+      end
+      configure :last_sign_in_at do
+        formatted_value do
+          value.strftime("%Y-%m-%d %H:%m:%S") unless value == 0
+        end
+      end
+    end
+  end
+
+
+
+  #def name
+  #  email
+  #end
+
+  def permissions
+    _permissions = []
+    self.admin_roles.each do |role|
+      role.admin_permissions.each do |permission|
+        _permissions << permission
+      end
+    end
+    _permissions
+  end
+
+
+end

+ 213 - 0
app/models/ali.rb

@@ -0,0 +1,213 @@
+# encoding:utf-8
+require 'open-uri'
+require 'net/http'
+require 'uri'
+require 'json'
+require 'digest/md5'
+require 'digest/sha1'
+
+require 'aliyun/oss'
+
+module Ali
+
+  class Oss
+    BUCKET_NAME_PUBLIC_READ = CONFIG_FILE["ali_oss_bucket"] 
+    URL_FOR_HOST = "#{CONFIG_FILE["ali_oss_bucket"]}.#{CONFIG_FILE["ali_oss_data_center"]}.aliyuncs.com"
+    CDN_URL_FOR_HOST = URL_FOR_HOST
+
+    @client = Aliyun::OSS::Client.new(
+            :endpoint => "#{CONFIG_FILE["ali_oss_data_center"]}.aliyuncs.com",
+            :access_key_id => CONFIG_FILE["ali_access_id"],
+            :access_key_secret => CONFIG_FILE["ali_access_secret"])
+
+    class << self
+
+      def create_bucket(name, access = Aliyun::OSS::ACL::PUBLIC_READ)
+        begin                  
+          bucket = @client.create_bucket(name)          
+          bucket.acl = access        
+        rescue => e
+          p e
+        end
+        return bucket
+      end
+
+      def get_bucket(name)        
+        buckets = @client.list_buckets        
+        buckets.each do |item|
+          if item.name == name                  
+            return item
+          end
+        end        
+        return nil
+      end
+
+      def store(bucket_name, object_key, data)        
+        bucket = self.get_bucket(bucket_name)        
+        if bucket.blank?          
+          bucket = self.create_bucket(bucket_name)          
+        end        
+        bucket.put_object(object_key){ |stream| stream << data }        
+      end 
+
+      def object_exist?(bucket_name, object_key)
+        bucket = self.get_bucket(bucket_name)
+        if not bucket.blank?
+          objects = bucket.list_objects
+          objects.each do |obj|
+            if obj.key == object_key
+              return true
+            end 
+          end
+          return false   
+        else
+          raise "Bucket is not found with name: #{bucket_name}"
+        end
+      end      
+
+      def delete_object(bucket_name, object_key)
+        bucket = self.get_bucket(bucket_name)
+        if not bucket.blank?
+          begin
+            bucket.delete_object(object_key)  
+          rescue Exception => e
+            p e
+          end          
+        else
+          raise "Bucket is not found with name: #{bucket_name}"
+        end
+      end
+
+    end
+  end
+
+
+  class Css
+    #    attr_reader :version, :host
+    #    attr_accessor :client_id, :secret_key
+
+    ACCESS_KEY_ID = "HNPD1U7r1eWPzB82"
+    SECRET_ACCESS_KEY = "yhmPqp3jBndWf8D9b5p40BRyNyqYG6"
+    #内网
+    #    HOST = "http://intranet.opensearch-cn-hangzhou.aliyuncs.com"
+    #外网
+    HOST = {
+      "production" => "http://opensearch-cn-hangzhou.aliyuncs.com",
+      "development" => "http://opensearch-cn-qingdao.aliyuncs.com"
+    }
+
+    class << self
+
+      #根据参数创建签名信息
+      def _signature(params, method)
+        _params = {}
+        params.each do |k,v|
+          _params[k.to_s] = v
+        end
+        _params = _params.sort
+        data = []
+        _params.each do |p|
+          next if p[1].size <= 0
+          # p "before encode:#{p[1]}" if p[0] == "items"
+          _p = URI.encode_www_form_component(p[1])
+          _p = _p.gsub("+","%20").gsub("*","%2A").gsub("%7E","~")
+          # p "after encode:#{_p}" if p[0] == "items"
+          data << "#{URI.encode_www_form_component(p[0])}=#{_p}"
+        end
+        data = URI.encode_www_form_component(data.join("&"))
+        data = [method.upcase, URI.encode_www_form_component("/"), data].join("&")
+        # p "stringtosign=#{data}"
+        data = data.gsub("%7E","~")
+        signature = Base64::encode64(HMAC::SHA1.digest("#{SECRET_ACCESS_KEY}&", data))
+        # p "signature=#{signature[0..-2]}"
+        return signature[0..-2]
+      end
+
+      def _api_call(url, method = 'GET', params = {})
+        begin
+          params['Version'] = "v2"
+          params['AccessKeyId'] = ACCESS_KEY_ID
+          params['SignatureMethod'] = "HMAC-SHA1"
+          t = Time.now.to_i - 8*3600
+          params['Timestamp'] =  "#{Time.at(t).strftime("%Y-%m-%dT%H:%M:%SZ")}"
+          params['SignatureVersion'] = "1.0"
+          params['SignatureNonce'] = "#{Time.now.to_i}#{'%04d'%rand(9999)}"
+          params['Signature'] = _signature(params, method)
+          url = self::HOST[Rails.env] + url
+          if method.upcase == 'GET'
+            response = RestClient.get url, {:params => params}
+          else
+            response = RestClient.post url, params
+          end
+          return JSON.parse(response.body)
+        rescue => e
+          p e
+        end
+      end
+
+      def list_index()
+        uri = "/index"
+        _api_call(uri, "get",{})
+      end
+
+      def create_index(index_name, template = "xikego_product")
+        uri = "/index/#{index_name}"
+        _api_call(uri, "post", {:action => "create", :template => template})
+      end
+
+      def delete_index(index_name)
+        uri = "/index/#{index_name}"
+        _api_call(uri, "post",{:action => "delete"})
+      end
+
+      def show_index(index_name)
+        uri = "/index/#{index_name}"
+        _api_call(uri, "get",{:action => "status"})
+      end
+
+      #items是个数组
+      def create_doc(index_name, table_name, fields)
+        uri = "/index/doc/#{index_name}"
+        # t = (Time.now.to_i - 8*3600)*1000
+        # items = [{"cmd" => "add", "timestamp" => t, "fields" => fields}]
+        items = [{"cmd" => "add",  "fields" => fields}]
+        items = items.to_json
+        ret = _api_call(uri, "post",{"action" => "push", "table_name" =>  table_name, "items" => items})
+        return ret
+      end
+
+      def delete_doc(index_name, table_name, id)
+        uri = "/index/doc/#{index_name}"
+        items = [{"cmd" => "delete", "fields" => {"id" => id.to_s}}]
+        items = items.to_json
+        _api_call(uri, "post",{"action" => "push", "table_name" =>  table_name, "items" => items})
+      end
+
+      def update_doc(index_name, table_name, fields)
+        uri = "/index/doc/#{index_name}"
+        # t = (Time.now.to_i - 8*3600)*1000
+        # items = [{"cmd" => "update", "timestamp" => t, "fields" => fields}]
+        items = [{"cmd" => "update", "fields" => fields}]
+        items = items.to_json
+        _api_call(uri, "post",{"action" => "push","table_name" =>  table_name,  "items" => items})
+      end
+
+      def search_doc(index_names, query)
+        if index_names.class == Array
+          index_name = index_names.join(";")
+        else index_names.class == String
+          index_name = index_names
+        end
+        uri = "/search"
+        _api_call(uri,"get",{:query => query, :index_name => index_name, :summary_field => "title" })
+      end
+
+    end
+  end
+
+
+end
+
+if __FILE__ == $0
+
+end

+ 5 - 0
app/models/ckeditor/asset.rb

@@ -0,0 +1,5 @@
+class Ckeditor::Asset < ActiveRecord::Base
+  include Ckeditor::Orm::ActiveRecord::AssetBase
+  include Ckeditor::Backend::Paperclip
+  Rails.application.config.assets.precompile += %w( ckeditor/filebrowser/images/gal_del.png )
+end

+ 13 - 0
app/models/ckeditor/attachment_file.rb

@@ -0,0 +1,13 @@
+class Ckeditor::AttachmentFile < Ckeditor::Asset
+  has_attached_file :data,
+                    url: '/ckeditor_assets/attachments/:id/:filename',
+                    path: ':rails_root/public/ckeditor_assets/attachments/:id/:filename'
+
+  validates_attachment_presence :data
+  validates_attachment_size :data, less_than: 100.megabytes
+  do_not_validate_attachment_file_type :data
+
+  def url_thumb
+    @url_thumb ||= Ckeditor::Utils.filethumb(filename)
+  end
+end

+ 31 - 0
app/models/ckeditor/picture.rb

@@ -0,0 +1,31 @@
+class Ckeditor::Picture < Ckeditor::Asset
+  before_create :before_create
+
+  has_attached_file :data,{
+    storage: :aliyun,    
+    # path: 'ckeditor/detail/:id/:hash.:extension',
+    path: 'ckeditor/detail/:id/:style.:filename',
+    url: ':aliyun_upload_url',
+    styles: { content: '780>', thumb: '100>'}    
+    # hash_secret:'3c6acb54d3c7b788d853304142d669a9de78780ee672226009a35192d00d1dbc34f39e81f0f7f5248ce5f8e69c6e26d680bd0af9e8998b40333052ae7159d26e'
+  }
+
+  validates_attachment_presence :data
+  validates_attachment_size :data, less_than: 2.megabytes
+  validates_attachment_content_type :data, content_type: /\Aimage/
+
+  #解决中文文件名不能正常上传问题,上传之前重命名
+  def before_create    
+    extension = File.extname(filename).downcase      
+    extension = ".png" if extension.blank?
+    self.data.instance_write(:file_name, "#{Time.now.strftime("%Y%m%d%H%M%S")}#{rand(1000)}#{extension}")          
+  end 
+
+  def url_content    
+    url(:content)
+  end
+
+  rails_admin do
+    weight -20
+  end
+end

+ 37 - 0
app/models/session.rb

@@ -0,0 +1,37 @@
+# encoding:utf-8
+class Session < ActiveRecord::Base
+  has_paper_trail
+  self.table_name = 'session'
+  self.primary_key = "session_key"
+  validates_presence_of :session_key
+
+  rails_admin do
+    navigation_label '系统会话管理'
+    weight -35
+
+    list do
+      filters [:session_key]
+      # include_all_fields
+      field :session_key      
+      field :session_expiry do
+        formatted_value do
+          Time.at(value)
+        end
+      end
+    end
+    show do
+      # include_all_fields
+      field :session_key      
+      field :session_expiry do
+        formatted_value do
+          Time.at(value)
+        end
+      end
+    end
+
+    edit do
+
+    end
+  end
+
+end

+ 40 - 0
app/models/wa_id_department.rb

@@ -0,0 +1,40 @@
+# encoding:utf-8
+class WaIdDepartment < ActiveRecord::Base
+  has_paper_trail
+  self.table_name = "wa_id_departments"
+  # belongs_to :project, :foreign_key => :project_id
+  def user_names
+    names = ""
+    sql = "select uname from wa_id_users where department_id = #{self.id}"
+    usernames = WaIdUser.find_by_sql(sql)
+    usernames.each do |u|
+        names = names + u.uname + ','
+    end
+    return names
+  end
+
+  rails_admin do
+    navigation_label '报表权限管理系统'
+    parent WaIdUser
+    weight -150
+
+    list do
+        filters [:id]
+        field :id
+        field :name
+        field :user_names
+    end
+
+    show do
+        field :id
+        field :name
+        field :user_names
+        field :created_at
+        field :updated_at
+    end
+
+    edit do
+        field :name
+    end
+  end
+end

+ 110 - 0
app/models/wa_id_permission.rb

@@ -0,0 +1,110 @@
+# encoding:utf-8
+class WaIdPermission < ActiveRecord::Base
+  has_paper_trail
+  self.table_name = "wa_id_permissions"
+  # belongs_to :project, :foreign_key => :project_id
+  URL_TYPE_ENUM = [["按钮","button"],["菜单","menu"], ["一般","general"]]
+
+  def wf_parent_permision_names
+    permision_names = ""
+
+    parentidArray = Array.new
+    if !self.parentids.blank? && self.parentids != nil && self.url_type == "button"
+        parentidArray = self.parentids.split("/")
+    end
+    parentidArray.each do |i|
+        j = i.to_i
+        waIdPermission = WaIdPermission.find_by_sql("select name as pmname from wa_id_permissions where id = #{j} limit 1")
+        puts waIdPermission
+        if !waIdPermission.blank? && waIdPermission != nil
+            waIdPermission.each do |u|
+                permision_names = permision_names  + u.pmname + ","
+            end
+        end
+    end
+    return permision_names
+  end
+
+  def wf_menu_parent_name
+    permision_names = "" 
+    if self.m_parentid != nil
+        waIdPermission = WaIdPermission.find_by_sql("select name as pmname from wa_id_permissions where id = #{self.m_parentid} limit 1")
+        puts waIdPermission
+        if !waIdPermission.blank? && waIdPermission != nil
+            waIdPermission.each do |u|
+                permision_names =  u.pmname 
+            end
+        end
+    end
+    return permision_names
+  end
+
+  rails_admin do
+    navigation_label '报表权限管理系统'
+    parent WaIdUser
+    weight -150
+
+    list do
+        sort_by 'm_parentid + 1 , sort + 0'
+        sort_reverse true
+        filters [:id]
+        field :id
+        field :name
+        field :url_type, :enum do
+            enum do 
+                URL_TYPE_ENUM
+            end
+        end
+        field :url
+        field :url_path
+        field :percode
+        field :wf_menu_parent_name
+        field :parentid
+        field :parentids
+        field :wf_parent_permision_names
+        field :sort
+        field :is_available
+    end
+
+    show do
+        field :id
+        
+        field :name
+        field :url_type, :enum do
+            enum do 
+                URL_TYPE_ENUM
+            end
+        end
+        field :url
+        field :url_path
+        field :percode
+        field :m_parentid
+        field :parentid
+        field :wf_menu_parent_name
+        field :parentids
+        field :wf_parent_permision_names
+        field :sort
+        field :is_available
+        field :created_at
+        field :updated_at
+    end
+
+    edit do
+        field :name
+        field :url_type, :enum do
+            enum do 
+                URL_TYPE_ENUM
+            end
+        end
+        field :url
+        field :url_path
+        field :percode
+        field :m_parentid
+        field :parentid
+        field :parentids
+        field :sort
+        field :is_available
+
+    end
+  end
+end

+ 43 - 0
app/models/wa_id_role.rb

@@ -0,0 +1,43 @@
+# encoding:utf-8
+class WaIdRole < ActiveRecord::Base
+  has_paper_trail
+  self.table_name = "wa_id_roles"
+
+  def permission_names
+    names = ""
+    sql = "select p.name as permission_name from wa_id_role_permissions rp left JOIN wa_id_permissions p on rp.permission_id = p.id where rp.role_id = #{self.id}"
+    permissionNames = WaIdPermission.find_by_sql(sql)
+    permissionNames.each do |u|
+        names = names + u.permission_name + ','
+    end
+    return names
+  end
+
+  rails_admin do
+    navigation_label '报表权限管理系统'
+    parent WaIdUser
+    weight -150
+
+    list do
+        filters [:id]
+        field :id
+        field :name
+        field :permission_names
+        field :is_available
+    end
+
+    show do
+        field :id
+        field :name
+        field :permission_names
+        field :is_available
+        field :created_at
+        field :updated_at
+    end
+
+    edit do
+        field :name
+        field :is_available
+    end
+  end
+end

+ 38 - 0
app/models/wa_id_role_permission.rb

@@ -0,0 +1,38 @@
+# encoding:utf-8
+class WaIdRolePermission < ActiveRecord::Base
+  has_paper_trail
+  self.table_name = "wa_id_role_permissions"
+  # belongs_to :project, :foreign_key => :project_id
+  belongs_to :wa_id_role, :foreign_key => :role_id
+  belongs_to :wa_id_permission, :foreign_key => :permission_id
+  validates :role_id, :permission_id, presence: true
+
+  rails_admin do
+    navigation_label '报表权限管理系统'
+    parent WaIdUser
+    weight -150
+
+    list do
+        filters [:id]
+        field :id
+        field :wa_id_role
+        field :wa_id_permission
+        
+    end
+
+    show do
+        field :id
+        field :wa_id_role
+        field :wa_id_permission
+        
+        field :created_at
+        field :updated_at
+    end
+
+    edit do
+        field :wa_id_role
+        field :wa_id_permission
+        
+    end
+  end
+end

+ 78 - 0
app/models/wa_id_user.rb

@@ -0,0 +1,78 @@
+# encoding:utf-8
+require 'digest/md5'
+class WaIdUser < ActiveRecord::Base
+  has_paper_trail
+  self.table_name = "wa_id_users"
+  belongs_to :wa_id_department, :foreign_key => :department_id
+  before_save :before_save
+  validates :upsd, :salt, presence: true
+
+  def role_names
+    names = ""
+    sql = "select p.name as role_name from wa_id_user_roles rp left JOIN wa_id_roles p on rp.role_id = p.id where rp.user_id = #{self.id}"
+    roleNames = WaIdUser.find_by_sql(sql)
+    roleNames.each do |u|
+        names = names + u.role_name + ','
+    end
+    return names
+  end
+
+  STATUS_ENUM = [["使用中","active"]]
+
+  rails_admin do
+    navigation_label '报表权限管理系统'
+    weight -150
+
+    list do
+        filters [:id]
+        field :id
+        field :uaccount
+        field :uname
+        field :role_names
+        field :wa_id_department
+        field :status, :enum do
+            enum do 
+                STATUS_ENUM
+            end
+        end
+        field :is_god
+    end
+
+    show do
+        field :id
+        field :uaccount
+        field :uname
+        field :role_names
+        field :wa_id_department
+        field :status, :enum do
+            enum do 
+                STATUS_ENUM
+            end
+        end
+        field :is_god
+
+        field :created_at
+        field :updated_at
+    end
+
+    edit do
+        field :uaccount
+        field :uname
+        field :upsd, :password
+        field :salt, :password
+        field :status, :enum do
+            enum do 
+                STATUS_ENUM
+            end
+        end
+        field :wa_id_department
+        field :is_god
+
+    end
+  end
+
+  def before_save
+    md5_pwd = Digest::MD5.hexdigest(self.salt + self.upsd)
+    self.upsd = md5_pwd
+  end
+end

+ 46 - 0
app/models/wa_id_user_role.rb

@@ -0,0 +1,46 @@
+# encoding:utf-8
+class WaIdUserRole < ActiveRecord::Base
+  has_paper_trail
+  self.table_name = "wa_id_user_roles"
+  belongs_to :wa_id_user, :foreign_key => :user_id
+  belongs_to :wa_id_role, :foreign_key => :role_id
+  validates :user_id, :role_id, presence: true
+
+  def permission_names
+    names = ""
+    sql = "select p.name as permission_name from wa_id_role_permissions rp left JOIN wa_id_permissions p on rp.permission_id = p.id where rp.role_id = #{self.role_id}"
+    permissionNames = WaIdPermission.find_by_sql(sql)
+    permissionNames.each do |u|
+        names = names + u.permission_name + ','
+    end
+    return names
+  end
+
+  rails_admin do
+    navigation_label '报表权限管理系统'
+    parent WaIdUser
+    weight -150
+
+    list do
+        filters [:id]
+        field :id
+        field :wa_id_user
+        field :wa_id_role
+        field :permission_names
+    end
+
+    show do
+        field :id
+        field :wa_id_user
+        field :wa_id_role
+        field :permission_names
+        field :created_at
+        field :updated_at
+    end
+
+    edit do
+        field :wa_id_user
+        field :wa_id_role
+    end
+  end
+end

+ 35 - 0
app/models/wa_id_user_token.rb

@@ -0,0 +1,35 @@
+# encoding:utf-8
+class WaIdUserToken < ActiveRecord::Base
+  has_paper_trail
+  self.table_name = "wa_id_user_tokens"
+  belongs_to :wa_id_user, :foreign_key => :user_id
+
+  rails_admin do
+    navigation_label '报表权限管理系统'
+    parent WaIdUser
+    weight -150
+
+    list do
+        filters [:id]
+        field :id
+        field :wa_id_user
+        field :token
+        field :expire_time
+    end
+
+    show do
+        field :id
+        field :wa_id_user
+        field :token
+        field :expire_time
+        field :created_at
+        field :updated_at
+    end
+
+    edit do
+        field :wa_id_user
+        field :token
+        field :expire_time
+    end
+  end
+end

+ 20 - 0
app/views/devise/sessions/new.html.erb

@@ -0,0 +1,20 @@
+<div class="container">
+
+  <%= form_for(resource, :as => resource_name, :url => session_path(resource_name), :html => {:class => "form-signin"}) do |f| %>
+      <div class="form-signin-heading">用户登入</div>
+      <% if flash[:alert] %>
+          <div class="alert alert-error">
+            <a class="close" data-dismiss="alert">×</a>
+            <div id="flash_alert"><%= flash[:alert] %></div>
+          </div>
+      <% end -%>
+      <%= f.email_field :email, :autofocus => true, :class => "input-block-level", :placeholder => "邮箱" %>
+      <br/>
+      <%= f.password_field :password, :class => "input-block-level", :placeholder => "密码" %>
+      <label class="checkbox">
+        <%= f.check_box :remember_me %> <span class="remember_pw">记住密码</span>
+      </label>
+      <%= f.submit "登入", :class => "btn btn-large btn-primary" %>
+  <% end -%>
+
+</div>

+ 15 - 0
app/views/layouts/application.html.erb

@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>AdminD5ctCom</title>
+  <%= stylesheet_link_tag    "application", :media => "all" %>
+  <%= javascript_include_tag "application" %>
+  <%= javascript_include_tag 'ckeditor/ckeditor.js' %>
+  <%= csrf_meta_tags %>
+</head>
+<body>
+
+<%= yield %>
+
+</body>
+</html>

+ 114 - 0
app/views/layouts/devise_layout.html.erb

@@ -0,0 +1,114 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <title>登入</title>
+  <%= stylesheet_link_tag    "application", :media => "all" %>
+  <%= javascript_include_tag "application" %>
+  <style>
+      body {
+          padding-top: 100px;
+          padding-bottom: 40px;
+          /*background-color: #f5f5f5;*/
+          font-family: 'PT Sans', Helvetica, Arial, sans-serif;
+          background: #f8f8f8;
+      }
+      .form-signin {
+          max-width: 300px;
+          padding: 19px 29px 29px;
+          margin: 0 auto 20px;
+          background-color: #fff;
+          border: 1px solid #e5e5e5;
+          -webkit-border-radius: 5px;
+          -moz-border-radius: 5px;
+          border-radius: 5px;
+          -webkit-box-shadow: 0 1px 2px rgba(0,0,0,.05);
+          -moz-box-shadow: 0 1px 2px rgba(0,0,0,.05);
+          box-shadow: 0 1px 2px rgba(0,0,0,.05);
+      }
+      /*用户登录*/
+      .form-signin-heading{
+        font-size: 30px;
+        font-weight: 700;
+        text-shadow: 0 1px 4px rgba(0,0,0,.2);
+        text-align: center;
+      }
+      /*输入框*/
+      .input-block-level{
+        width: 250px;
+        height: 42px;
+        margin-top: 25px;
+        padding: 0 15px;
+        background: #2d2d2d; /* browsers that don't support rgba */
+        background: rgba(45,45,45,.15);
+        -moz-border-radius: 6px;
+        -webkit-border-radius: 6px;
+        border-radius: 6px;
+        border: 1px solid #3d3d3d; /* browsers that don't support rgba */
+        border: 1px solid rgba(255,255,255,.15);
+        -moz-box-shadow: 0 2px 3px 0 rgba(0,0,0,.1) inset;
+        -webkit-box-shadow: 0 2px 3px 0 rgba(0,0,0,.1) inset;
+        box-shadow: 0 2px 3px 0 rgba(0,0,0,.1) inset;
+        font-family: 'PT Sans', Helvetica, Arial, sans-serif;
+        font-size: 14px;
+        color: #000;
+        text-shadow: 0 1px 2px rgba(0,0,0,.1);
+        -o-transition: all .2s;
+        -moz-transition: all .2s;
+        -webkit-transition: all .2s;
+        -ms-transition: all .2s;
+      }
+      /*记住密码*/
+      .checkbox{
+        width: 250px;
+        height: 25px;
+        margin-top: 15px;
+        margin-left: 20px;
+        padding: 0 15px;
+      }
+      /*登录*/
+      .btn{
+        /*color: */
+        cursor: pointer;
+        width: 250px;
+        height: 44px;
+        margin-top: 0px;
+        padding: 0;
+        background: #ef4300;
+        -moz-border-radius: 6px;
+        -webkit-border-radius: 6px;
+        border-radius: 6px;
+        border: 1px solid #ff730e;
+        -moz-box-shadow:
+            0 15px 30px 0 rgba(255,255,255,.25) inset,
+            0 2px 7px 0 rgba(0,0,0,.2);
+        -webkit-box-shadow:
+            0 15px 30px 0 rgba(255,255,255,.25) inset,
+            0 2px 7px 0 rgba(0,0,0,.2);
+        box-shadow:
+            0 15px 30px 0 rgba(255,255,255,.25) inset,
+            0 2px 7px 0 rgba(0,0,0,.2);
+        font-family: 'PT Sans', Helvetica, Arial, sans-serif;
+        font-size: 14px;
+        font-weight: 700;
+        color: #fff;
+        text-shadow: 0 1px 2px rgba(0,0,0,.1);
+        -o-transition: all .2s;
+        -moz-transition: all .2s;
+        -webkit-transition: all .2s;
+        -ms-transition: all .2s;
+      }
+      span.remember_pw{
+        font-family: 'PT Sans', Helvetica, Arial, sans-serif;
+        font-size: 14px;
+        font-weight: 700;
+        text-shadow: 0 1px 2px rgba(0,0,0,.1);
+      }
+  </style>
+  <%= csrf_meta_tags %>
+</head>
+<body>
+
+<%= yield %>
+
+</body>
+</html>

+ 4 - 0
config.ru

@@ -0,0 +1,4 @@
+# This file is used by Rack-based servers to start the application.
+
+require ::File.expand_path('../config/environment',  __FILE__)
+run AdminD5ctCom::Application

+ 78 - 0
config/application.rb

@@ -0,0 +1,78 @@
+require File.expand_path('../boot', __FILE__)
+
+# Pick the frameworks you want:
+require "active_record/railtie"
+require "action_controller/railtie"
+require "action_mailer/railtie"
+# require "active_resource/railtie"
+require "sprockets/railtie"
+# require "rails/test_unit/railtie"
+
+if defined?(Bundler)
+  # If you precompile assets before deploying to production, use this line
+  Bundler.require(*Rails.groups(:assets => %w(development test)))
+  # If you want your assets lazily compiled in production, use this line
+  # Bundler.require(:default, :assets, Rails.env)
+end
+
+module AdminD5ctCom
+  class Application < Rails::Application
+    # require 'active_record/connection_adapters/mysql2_adapter'
+    # ActiveRecord::ConnectionAdapters::Mysql2Adapter.emulate_booleans = false
+    # Settings in config/environments/* take precedence over those specified here.
+    # Application configuration should go into files in config/initializers
+    # -- all .rb files in that directory are automatically loaded.
+
+    # Custom directories with classes and modules you want to be autoloadable.
+    # config.autoload_paths += %W(#{config.root}/extras)
+    config.autoload_paths += %W(#{config.root}/lib)
+
+    # Only load the plugins named here, in the order given (default is alphabetical).
+    # :all can be used as a placeholder for all plugins not explicitly named.
+    # config.plugins = [ :exception_notification, :ssl_requirement, :all ]
+
+    # Activate observers that should always be running.
+    # config.active_record.observers = :cacher, :garbage_collector, :forum_observer
+
+    # 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'
+    Time::DATE_FORMATS[:default] = "%Y-%m-%d %H:%M:%S"
+    # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
+    # config.i18n.load_path = Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}').to_s]
+    config.i18n.load_path += Dir[Rails.root.join('config', 'locales', '**', '*.{rb,yml}')]
+    config.i18n.default_locale = 'zh-CN'
+
+    # 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
+
+    # Configure the default encoding used in templates for Ruby 1.9.
+    config.encoding = "utf-8"
+
+    # Configure sensitive parameters which will be filtered from the log file.
+    config.filter_parameters += [:password]
+
+    # Enable escaping HTML in JSON.
+    config.active_support.escape_html_entities_in_json = true
+
+    # Use SQL instead of Active Record's schema dumper when creating the database.
+    # This is necessary if your schema can't be completely dumped by the schema dumper,
+    # like if you have constraints or database-specific column types
+    # config.active_record.schema_format = :sql
+
+    # Enforce whitelist mode for mass assignment.
+    # This will create an empty whitelist of attributes available for mass-assignment for all models
+    # in your app. As such, your models will need to explicitly whitelist or blacklist accessible
+    # parameters by using an attr_accessible or attr_protected declaration.
+    # config.active_record.whitelist_attributes = false
+
+    # Enable the asset pipeline
+    config.assets.enabled = true
+
+    # Version of your assets, change this if you want to expire all your assets
+    config.assets.version = '1.0'
+    config.autoload_paths += %W(#{config.root}/app/models/ckeditor)
+  end
+end

+ 6 - 0
config/boot.rb

@@ -0,0 +1,6 @@
+require 'rubygems'
+
+# Set up gems listed in the Gemfile.
+ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
+ENV['EXECJS_RUNTIME'] = 'Node'
+require 'bundler/setup' if File.exists?(ENV['BUNDLE_GEMFILE'])

+ 45 - 0
config/config.yml

@@ -0,0 +1,45 @@
+development:
+  root_path:  /opt/apps/statement/admin
+  admin_host: http://tstateadmin.d5c360.com
+  # admin_host: http://localhost:3000
+  wx_host: http://
+  # api_host: http://tapi.d5c360.com
+  # api_host: http://tapi.d5c360.com
+  api_host: http://
+  new_api_host: http://
+
+  m_host: http://
+
+  ali_access_id: LTAIkgdHJ7VrV8JN
+  ali_access_secret: WcopFbgfdUdtgB8Q5ccstqvkouNwJa  
+  ali_oss_bucket: rabbit-mall-test
+  ali_oss_data_center: oss-cn-shenzhen
+
+test:
+  root_path:  /opt/apps/statement/admin
+  admin_host: http://tstateadmin.d5c360.com
+  wx_host: http://
+  api_host: http://
+  new_api_host: http://
+
+  m_host: http://
+
+  ali_access_id: LTAIkgdHJ7VrV8JN
+  ali_access_secret: WcopFbgfdUdtgB8Q5ccstqvkouNwJa
+  ali_oss_bucket: rabbit-mall-test
+  ali_oss_data_center: oss-cn-shenzhen
+
+production:
+  root_path:  /opt/apps/statement/admin
+  admin_host: http://stateadmin.d5c360.com/    
+  api_host: http://
+  new_api_host: http://
+  d5c_api_host: http://
+
+  m_host: http://
+
+  ali_access_id: LTAIkgdHJ7VrV8JN
+  ali_access_secret: WcopFbgfdUdtgB8Q5ccstqvkouNwJa
+  ali_oss_bucket: rabbit-mall
+  ali_oss_data_center: oss-cn-shenzhen
+  

+ 43 - 0
config/database.yml

@@ -0,0 +1,43 @@
+# MySQL.  Versions 4.1 and 5.0 are recommended.
+# 
+# Install the MYSQL driver
+#   gem install mysql2
+#
+# Ensure the MySQL gem is defined in your Gemfile
+#   gem 'mysql2'
+#
+# And be sure to use new-style password hashing:
+#   http://dev.mysql.com/doc/refman/5.0/en/old-client.html
+development:
+  adapter: mysql2
+  encoding: utf8
+  reconnect: false
+  database: d5c_statement
+  pool: 5
+  username: d5c
+  password: D5ctesting
+  host: d5ctestingdb.mysql.rds.aliyuncs.com
+
+# Warning: The database defined as "test" will be erased and
+# re-generated from your development database when you run "rake".
+# Do not set this db to the same as development or production.
+test:
+  adapter: mysql2
+  encoding: utf8
+  reconnect: false
+  database: d5c_statement
+  pool: 5
+  username: d5c
+  password: D5ctesting
+  host: d5ctestingdb.mysql.rds.aliyuncs.com
+
+production:
+  adapter: mysql2
+  encoding: utf8
+  reconnect: false
+  database: d5c_statement
+  pool: 30
+  username: d5c
+  password: D5cmima1000
+  port: 3306
+  host: rm-wz9a1t4i8jir99284235.mysql.rds.aliyuncs.com

+ 7 - 0
config/environment.rb

@@ -0,0 +1,7 @@
+#encoding: utf-8
+# Load the rails application
+require File.expand_path('../application', __FILE__)
+
+# Initialize the rails application
+AdminD5ctCom::Application.initialize!
+Time::DATE_FORMATS[:format] = "%Y年%m月%d %H:%M:%S"

+ 39 - 0
config/environments/development.rb

@@ -0,0 +1,39 @@
+AdminD5ctCom::Application.configure do
+  # Settings specified here will take precedence over those in config/application.rb
+
+  # In the development environment your application's code is reloaded on
+  # every request. This slows down response time but is perfect for development
+  # since you don't have to restart the web server when you make code changes.
+  config.cache_classes = false
+  config.eager_load = false
+
+  # Log error messages when you accidentally call methods on nil.
+  config.whiny_nils = true
+
+  # Show full error reports and disable caching
+  config.consider_all_requests_local       = true
+  config.action_controller.perform_caching = false
+  config.active_record.raise_in_transactional_callbacks = true
+
+  # Don't care if the mailer can't send
+  config.action_mailer.raise_delivery_errors = false
+
+  # Print deprecation notices to the Rails logger
+  config.active_support.deprecation = :log
+
+  # Only use best-standards-support built into browsers
+  config.action_dispatch.best_standards_support = :builtin
+
+  # Raise exception on mass assignment protection for Active Record models
+  # config.active_record.mass_assignment_sanitizer = :strict
+
+  # Log the query plan for queries taking more than this (works
+  # with SQLite, MySQL, and PostgreSQL)
+  # config.active_record.auto_explain_threshold_in_seconds = 0.5
+
+  # Do not compress assets
+  config.assets.compress = false
+
+  # Expands the lines which load the assets
+  config.assets.debug = true
+end

+ 71 - 0
config/environments/production.rb

@@ -0,0 +1,71 @@
+AdminD5ctCom::Application.configure do
+  # Settings specified here will take precedence over those in config/application.rb
+
+  # Code is not reloaded between requests
+  config.cache_classes = false
+  config.eager_load = true
+
+  # Full error reports are disabled and caching is turned on
+  config.consider_all_requests_local       = false
+  config.action_controller.perform_caching = true
+
+  # Disable Rails's static asset server (Apache or nginx will already do this)
+  config.serve_static_files = false
+
+  # Compress JavaScripts and CSS
+  config.assets.compress = true
+
+  # Don't fallback to assets pipeline if a precompiled asset is missed
+  config.assets.compile = true
+
+  # Generate digests for assets URLs
+  config.assets.digest = true
+
+  # Defaults to nil and saved in location specified by config.assets.prefix
+  # config.assets.manifest = YOUR_PATH
+
+  # Specifies the header that your server uses for sending files
+  # config.action_dispatch.x_sendfile_header = "X-Sendfile" # for apache
+  # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for nginx
+
+  # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
+  # config.force_ssl = true
+
+  # See everything in the log (default is :info)
+  config.log_level = :info
+
+  # Prepend all log lines with the following tags
+  # config.log_tags = [ :subdomain, :uuid ]
+
+  # Use a different logger for distributed setups
+  # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
+
+  # Use a different cache store in production
+  # config.cache_store = :mem_cache_store
+
+  # Enable serving of images, stylesheets, and JavaScripts from an asset server
+  # config.action_controller.asset_host = "http://assets.example.com"
+
+  # Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
+  # config.assets.precompile += %w( search.js )
+  # config.assets.precompile << '*.js'
+
+  # Disable delivery errors, bad email addresses will be ignored
+  # config.action_mailer.raise_delivery_errors = false
+  #邮箱 验证
+  # config.action_mailer.default_url_options = { :host => 'localhost:3000' }  
+
+  # Enable threaded mode
+  # config.threadsafe!
+
+  # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
+  # the I18n.default_locale when a translation can not be found)
+  config.i18n.fallbacks = true
+
+  # Send deprecation notices to registered listeners
+  config.active_support.deprecation = :notify
+
+  # Log the query plan for queries taking more than this (works
+  # with SQLite, MySQL, and PostgreSQL)
+  # config.active_record.auto_explain_threshold_in_seconds = 0.5
+end

+ 45 - 0
config/environments/test.rb

@@ -0,0 +1,45 @@
+AdminD5ctCom::Application.configure do
+  # Settings specified here will take precedence over those in config/application.rb
+
+  # The test environment is used exclusively to run your application's
+  # test suite. You never need to work with it otherwise. Remember that
+  # your test database is "scratch space" for the test suite and is wiped
+  # and recreated between test runs. Don't rely on the data there!
+  config.cache_classes = false
+  config.eager_load = false
+  # Configure static asset server for tests with Cache-Control for performance
+  config.serve_static_files = true
+  config.static_cache_control = "public, max-age=3600"
+
+  # Log error messages when you accidentally call methods on nil
+  config.whiny_nils = true
+
+  # Show full error reports and disable caching
+  config.consider_all_requests_local       = true
+  config.action_controller.perform_caching = false
+
+  # Raise exceptions instead of rendering exception templates
+  config.action_dispatch.show_exceptions = false
+
+  #DEPRECATION WARNING: Currently, Active Record suppresses errors raised within `after_rollback`/`after_commit` callbacks
+  #and only print them to the logs. In the next version, these errors will no longer be suppressed. Instead, the errors wil
+  #l propagate normally just like in other Active Record callbacks.
+
+  #You can opt into the new behavior and remove this warning by setting:
+  config.active_record.raise_in_transactional_callbacks = true
+
+  # Disable request forgery protection in test environment
+  config.action_controller.allow_forgery_protection    = false
+
+  # Tell Action Mailer not to deliver emails to the real world.
+  # The :test delivery method accumulates sent emails in the
+  # ActionMailer::Base.deliveries array.
+  config.action_mailer.delivery_method = :test
+
+  # Raise exception on mass assignment protection for Active Record models
+  # config.active_record.mass_assignment_sanitizer = :strict
+
+  # Print deprecation notices to the stderr
+  config.active_support.deprecation = :stderr
+
+end

+ 7 - 0
config/initializers/backtrace_silencers.rb

@@ -0,0 +1,7 @@
+# Be sure to restart your server when you modify this file.
+
+# You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces.
+# Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ }
+
+# You can also remove all the silencers if you're trying to debug a problem that might stem from framework code.
+# Rails.backtrace_cleaner.remove_silencers!

+ 58 - 0
config/initializers/ckeditor.rb

@@ -0,0 +1,58 @@
+# Use this hook to configure ckeditor
+Ckeditor.setup do |config|
+  # ==> ORM configuration
+  # Load and configure the ORM. Supports :active_record (default), :mongo_mapper and
+  # :mongoid (bson_ext recommended) by default. Other ORMs may be
+  # available as additional gems.
+  require "ckeditor/orm/active_record"
+
+  # Allowed image file types for upload.
+  # Set to nil or [] (empty array) for all file types
+  # By default: %w(jpg jpeg png gif tiff)
+  # config.image_file_types = %w(jpg jpeg png gif tiff)
+
+  # Allowed flash file types for upload.
+  # Set to nil or [] (empty array) for all file types
+  # By default: %w(jpg jpeg png gif tiff)
+  # config.flash_file_types = %w(swf)
+
+  # Allowed attachment file types for upload.
+  # Set to nil or [] (empty array) for all file types
+  # By default: %w(doc docx xls odt ods pdf rar zip tar tar.gz swf)
+  # config.attachment_file_types = %w(doc docx xls odt ods pdf rar zip tar tar.gz swf)
+
+  # Setup authorization to be run as a before filter
+  # By default: there is no authorization.
+  # config.authorize_with :cancan
+
+  # Override parent controller CKEditor inherits from
+  # By default: 'ApplicationController'
+  # config.parent_controller = 'MyController'
+
+  # Asset model classes
+  #  config.picture_model { Ckeditor::Picture }
+  # config.attachment_file_model { Ckeditor::AttachmentFile }
+
+  # Paginate assets
+  # By default: 24
+  # config.default_per_page = 24
+
+  # Customize ckeditor assets path
+  # By default: nil
+  # config.asset_path = "http://www.example.com/assets/ckeditor/"
+
+  # To reduce the asset precompilation time, you can limit plugins and/or languages to those you need:
+  # By default: nil (no limit)
+  # config.assets_languages = ['en', 'uk']
+  # config.assets_plugins = ['image', 'smiley']
+
+  # CKEditor CDN
+  # More info here http://cdn.ckeditor.com/
+  # By default: nil (CDN disabled)
+  # config.cdn_url = "//cdn.ckeditor.com/4.5.6/standard/ckeditor.js"
+
+  # JS config url
+  # Used when CKEditor CDN enabled
+  # By default: "/assets/ckeditor/config.js"
+  # config.js_config_url = "/assets/ckeditor/config.js"
+end

+ 265 - 0
config/initializers/devise.rb

@@ -0,0 +1,265 @@
+# Use this hook to configure devise mailer, warden hooks and so forth.
+# Many of these configuration options can be set straight in your model.
+Devise.setup do |config|
+  # The secret key used by Devise. Devise uses this key to generate
+  # random tokens. Changing this key will render invalid all existing
+  # confirmation, reset password and unlock tokens in the database.
+  # Devise will use the `secret_key_base` on Rails 4+ applications as its `secret_key`
+  # by default. You can change it below and use your own secret key.
+  config.secret_key = 'c050bf52e7141ce6b1514132f5d9e8acf6713cfd3cff5b66b1e6d1a88a3e8b44b635526edcc372f61bdd4cdec41db50106d809ac129fddf6339247e64f8be4e8'
+
+  # ==> Mailer Configuration
+  # Configure the e-mail address which will be shown in Devise::Mailer,
+  # note that it will be overwritten if you use your own mailer class
+  # with default "from" parameter.
+  config.mailer_sender = 'please-change-me-at-config-initializers-devise@example.com'
+
+  # Configure the class responsible to send e-mails.
+  # config.mailer = 'Devise::Mailer'
+
+  # ==> ORM configuration
+  # Load and configure the ORM. Supports :active_record (default) and
+  # :mongoid (bson_ext recommended) by default. Other ORMs may be
+  # available as additional gems.
+  require 'devise/orm/active_record'
+
+  # ==> Configuration for any authentication mechanism
+  # Configure which keys are used when authenticating a user. The default is
+  # just :email. You can configure it to use [:username, :subdomain], so for
+  # authenticating a user, both parameters are required. Remember that those
+  # parameters are used only when authenticating and not when retrieving from
+  # session. If you need permissions, you should implement that in a before filter.
+  # You can also supply a hash where the value is a boolean determining whether
+  # or not authentication should be aborted when the value is not present.
+  # config.authentication_keys = [:email]
+
+  # Configure parameters from the request object used for authentication. Each entry
+  # given should be a request method and it will automatically be passed to the
+  # find_for_authentication method and considered in your model lookup. For instance,
+  # if you set :request_keys to [:subdomain], :subdomain will be used on authentication.
+  # The same considerations mentioned for authentication_keys also apply to request_keys.
+  # config.request_keys = []
+
+  # Configure which authentication keys should be case-insensitive.
+  # These keys will be downcased upon creating or modifying a user and when used
+  # to authenticate or find a user. Default is :email.
+  config.case_insensitive_keys = [:email]
+
+  # Configure which authentication keys should have whitespace stripped.
+  # These keys will have whitespace before and after removed upon creating or
+  # modifying a user and when used to authenticate or find a user. Default is :email.
+  config.strip_whitespace_keys = [:email]
+
+  # Tell if authentication through request.params is enabled. True by default.
+  # It can be set to an array that will enable params authentication only for the
+  # given strategies, for example, `config.params_authenticatable = [:database]` will
+  # enable it only for database (email + password) authentication.
+  # config.params_authenticatable = true
+
+  # Tell if authentication through HTTP Auth is enabled. False by default.
+  # It can be set to an array that will enable http authentication only for the
+  # given strategies, for example, `config.http_authenticatable = [:database]` will
+  # enable it only for database authentication. The supported strategies are:
+  # :database      = Support basic authentication with authentication key + password
+  # config.http_authenticatable = false
+
+  # If 401 status code should be returned for AJAX requests. True by default.
+  # config.http_authenticatable_on_xhr = true
+
+  # The realm used in Http Basic Authentication. 'Application' by default.
+  # config.http_authentication_realm = 'Application'
+
+  # It will change confirmation, password recovery and other workflows
+  # to behave the same regardless if the e-mail provided was right or wrong.
+  # Does not affect registerable.
+  # config.paranoid = true
+
+  # By default Devise will store the user in session. You can skip storage for
+  # particular strategies by setting this option.
+  # Notice that if you are skipping storage for all authentication paths, you
+  # may want to disable generating routes to Devise's sessions controller by
+  # passing skip: :sessions to `devise_for` in your config/routes.rb
+  config.skip_session_storage = [:http_auth]
+
+  # By default, Devise cleans up the CSRF token on authentication to
+  # avoid CSRF token fixation attacks. This means that, when using AJAX
+  # requests for sign in and sign up, you need to get a new CSRF token
+  # from the server. You can disable this option at your own risk.
+  # config.clean_up_csrf_token_on_authentication = true
+
+  # ==> Configuration for :database_authenticatable
+  # For bcrypt, this is the cost for hashing the password and defaults to 10. If
+  # using other encryptors, it sets how many times you want the password re-encrypted.
+  #
+  # Limiting the stretches to just one in testing will increase the performance of
+  # your test suite dramatically. However, it is STRONGLY RECOMMENDED to not use
+  # a value less than 10 in other environments. Note that, for bcrypt (the default
+  # encryptor), the cost increases exponentially with the number of stretches (e.g.
+  # a value of 20 is already extremely slow: approx. 60 seconds for 1 calculation).
+  config.stretches = Rails.env.test? ? 1 : 10
+
+  # Setup a pepper to generate the encrypted password.
+  # config.pepper = '506a26b387b77fb4a3cdd14ed3267308e2bacaa4888114f3b02aba1fce3d2cbc4b13bd62a8dc3392689cde8c42346ebfb9688a86e9a5f7c5d914cfed977d25b2'
+
+  # Send a notification email when the user's password is changed
+  # config.send_password_change_notification = false
+
+  # ==> Configuration for :confirmable
+  # A period that the user is allowed to access the website even without
+  # confirming their account. For instance, if set to 2.days, the user will be
+  # able to access the website for two days without confirming their account,
+  # access will be blocked just in the third day. Default is 0.days, meaning
+  # the user cannot access the website without confirming their account.
+  # config.allow_unconfirmed_access_for = 2.days
+
+  # A period that the user is allowed to confirm their account before their
+  # token becomes invalid. For example, if set to 3.days, the user can confirm
+  # their account within 3 days after the mail was sent, but on the fourth day
+  # their account can't be confirmed with the token any more.
+  # Default is nil, meaning there is no restriction on how long a user can take
+  # before confirming their account.
+  # config.confirm_within = 3.days
+
+  # If true, requires any email changes to be confirmed (exactly the same way as
+  # initial account confirmation) to be applied. Requires additional unconfirmed_email
+  # db field (see migrations). Until confirmed, new email is stored in
+  # unconfirmed_email column, and copied to email column on successful confirmation.
+  config.reconfirmable = true
+
+  # Defines which key will be used when confirming an account
+  # config.confirmation_keys = [:email]
+
+  # ==> Configuration for :rememberable
+  # The time the user will be remembered without asking for credentials again.
+  # config.remember_for = 2.weeks
+
+  # Invalidates all the remember me tokens when the user signs out.
+  config.expire_all_remember_me_on_sign_out = true
+
+  # If true, extends the user's remember period when remembered via cookie.
+  # config.extend_remember_period = false
+
+  # Options to be passed to the created cookie. For instance, you can set
+  # secure: true in order to force SSL only cookies.
+  # config.rememberable_options = {}
+
+  # ==> Configuration for :validatable
+  # Range for password length.
+  config.password_length = 8..72
+
+  # Email regex used to validate email formats. It simply asserts that
+  # one (and only one) @ exists in the given string. This is mainly
+  # to give user feedback and not to assert the e-mail validity.
+  # config.email_regexp = /\A[^@]+@[^@]+\z/
+
+  # ==> Configuration for :timeoutable
+  # The time you want to timeout the user session without activity. After this
+  # time the user will be asked for credentials again. Default is 30 minutes.
+  # config.timeout_in = 30.minutes
+
+  # ==> Configuration for :lockable
+  # Defines which strategy will be used to lock an account.
+  # :failed_attempts = Locks an account after a number of failed attempts to sign in.
+  # :none            = No lock strategy. You should handle locking by yourself.
+  # config.lock_strategy = :failed_attempts
+
+  # Defines which key will be used when locking and unlocking an account
+  # config.unlock_keys = [:email]
+
+  # Defines which strategy will be used to unlock an account.
+  # :email = Sends an unlock link to the user email
+  # :time  = Re-enables login after a certain amount of time (see :unlock_in below)
+  # :both  = Enables both strategies
+  # :none  = No unlock strategy. You should handle unlocking by yourself.
+  # config.unlock_strategy = :both
+
+  # Number of authentication tries before locking an account if lock_strategy
+  # is failed attempts.
+  # config.maximum_attempts = 20
+
+  # Time interval to unlock the account if :time is enabled as unlock_strategy.
+  # config.unlock_in = 1.hour
+
+  # Warn on the last attempt before the account is locked.
+  # config.last_attempt_warning = true
+
+  # ==> Configuration for :recoverable
+  #
+  # Defines which key will be used when recovering the password for an account
+  # config.reset_password_keys = [:email]
+
+  # Time interval you can reset your password with a reset password key.
+  # Don't put a too small interval or your users won't have the time to
+  # change their passwords.
+  config.reset_password_within = 6.hours
+
+  # When set to false, does not sign a user in automatically after their password is
+  # reset. Defaults to true, so a user is signed in automatically after a reset.
+  # config.sign_in_after_reset_password = true
+
+  # ==> Configuration for :encryptable
+  # Allow you to use another encryption algorithm besides bcrypt (default). You can use
+  # :sha1, :sha512 or encryptors from others authentication tools as :clearance_sha1,
+  # :authlogic_sha512 (then you should set stretches above to 20 for default behavior)
+  # and :restful_authentication_sha1 (then you should set stretches to 10, and copy
+  # REST_AUTH_SITE_KEY to pepper).
+  #
+  # Require the `devise-encryptable` gem when using anything other than bcrypt
+  # config.encryptor = :sha512
+
+  # ==> Scopes configuration
+  # Turn scoped views on. Before rendering "sessions/new", it will first check for
+  # "users/sessions/new". It's turned off by default because it's slower if you
+  # are using only default views.
+  # config.scoped_views = false
+
+  # Configure the default scope given to Warden. By default it's the first
+  # devise role declared in your routes (usually :user).
+  # config.default_scope = :user
+
+  # Set this configuration to false if you want /users/sign_out to sign out
+  # only the current scope. By default, Devise signs out all scopes.
+  # config.sign_out_all_scopes = true
+
+  # ==> Navigation configuration
+  # Lists the formats that should be treated as navigational. Formats like
+  # :html, should redirect to the sign in page when the user does not have
+  # access, but formats like :xml or :json, should return 401.
+  #
+  # If you have any extra navigational formats, like :iphone or :mobile, you
+  # should add them to the navigational formats lists.
+  #
+  # The "*/*" below is required to match Internet Explorer requests.
+  # config.navigational_formats = ['*/*', :html]
+
+  # The default HTTP method used to sign out a resource. Default is :delete.
+  config.sign_out_via = :delete
+
+  # ==> OmniAuth
+  # Add a new OmniAuth provider. Check the wiki for more information on setting
+  # up on your models and hooks.
+  # config.omniauth :github, 'APP_ID', 'APP_SECRET', scope: 'user,public_repo'
+
+  # ==> Warden configuration
+  # If you want to use other strategies, that are not supported by Devise, or
+  # change the failure app, you can configure them inside the config.warden block.
+  #
+  # config.warden do |manager|
+  #   manager.intercept_401 = false
+  #   manager.default_strategies(scope: :user).unshift :some_external_strategy
+  # end
+
+  # ==> Mountable engine configurations
+  # When using Devise inside an engine, let's call it `MyEngine`, and this engine
+  # is mountable, there are some extra configurations to be taken into account.
+  # The following options are available, assuming the engine is mounted as:
+  #
+  #     mount MyEngine, at: '/my_engine'
+  #
+  # The router that invoked `devise_for`, in the example above, would be:
+  # config.router_name = :my_engine
+  #
+  # When using OmniAuth, Devise cannot automatically set OmniAuth path,
+  # so you need to do it manually. For the users scope, it would be:
+  # config.omniauth_path_prefix = '/my_engine/users/auth'
+end

+ 15 - 0
config/initializers/inflections.rb

@@ -0,0 +1,15 @@
+# Be sure to restart your server when you modify this file.
+
+# Add new inflection rules using the following format
+# (all these examples are active by default):
+# ActiveSupport::Inflector.inflections do |inflect|
+#   inflect.plural /^(ox)$/i, '\1en'
+#   inflect.singular /^(ox)en/i, '\1'
+#   inflect.irregular 'person', 'people'
+#   inflect.uncountable %w( fish sheep )
+# end
+#
+# These inflection rules are supported but not enabled by default:
+# ActiveSupport::Inflector.inflections do |inflect|
+#   inflect.acronym 'RESTful'
+# end

+ 1 - 0
config/initializers/load_config.rb

@@ -0,0 +1 @@
+CONFIG_FILE = YAML.load_file("#{Rails.root}/config/config.yml")[Rails.env]

+ 5 - 0
config/initializers/mime_types.rb

@@ -0,0 +1,5 @@
+# Be sure to restart your server when you modify this file.
+
+# Add new mime types for use in respond_to blocks:
+# Mime::Type.register "text/richtext", :rtf
+# Mime::Type.register_alias "text/html", :iphone

+ 1 - 0
config/initializers/paper_trail.rb

@@ -0,0 +1 @@
+PaperTrail.config.track_associations = false

+ 7 - 0
config/initializers/paperclip-aliyun-configuration.rb

@@ -0,0 +1,7 @@
+Paperclip::Attachment.default_options[:aliyun] = {
+  access_id: CONFIG_FILE["ali_access_id"],
+  access_key: CONFIG_FILE["ali_access_secret"],
+  bucket: CONFIG_FILE["ali_oss_bucket"],
+  data_center: CONFIG_FILE["ali_oss_data_center"],
+  internal: false
+}

+ 68 - 0
config/initializers/rails_admin.rb

@@ -0,0 +1,68 @@
+# encoding:utf-8
+#require Rails.root.join('lib','user', 'check_user_is_regist_d5c')
+
+#RailsAdmin::Config::Actions.register(RailsAdmin::Config::Actions::CheckUserIsRegistD5c)
+
+RailsAdmin.config do |config|
+  config.total_columns_width = 3000
+  config.default_items_per_page = 50
+  # config.current_user_method { current_admin_user }
+  config.authenticate_with do
+    warden.authenticate! scope: :admin_user
+  end
+  config.current_user_method(&:current_admin_user)
+  config.authorize_with :cancan
+  config.label_methods << :title
+  config.label_methods << :name
+  config.label_methods << :uname
+  config.audit_with :paper_trail, 'AdminUser', 'PaperTrail::Version'
+  # config.model 'ckeditor\asset' do
+  #   visible false
+  # end
+  #
+  # config.model 'ckeditor\attachment_file' do
+  #   visible false
+  # end
+  config.excluded_models= ['Ckeditor::Asset','Ckeditor::AttachmentFile']
+  # config.excluded_models= [Ckeditor::AttachmentFile]
+  config.model 'Ckeditor::Picture' do
+    navigation_label '富文本编辑器'
+  end
+
+  # PAPER_TRAIL_AUDIT_MODEL = ['Project','Picture','Bonusorder','Bonusordertransfer','Bonusproject','Menmber','Zczjraised']
+  # PAPER_TRAIL_AUDIT_MODEL = ['AdItem','AdPosition','ProjectFollow','Address','AdminPermission','AdminPermissionAdminRole','AdminRole','AdminRolesAdminUser']
+  # PAPER_TRAIL_AUDIT_MODEL = ['AdminUser','Article','ArticleCat','Balance','BalanceHistory','BalanceOrder','ChannelQrcode','ChannelQrcodeResult','ClickFromChannel','ClickFromUser','Company','Express']
+  # PAPER_TRAIL_AUDIT_MODEL = ['FriendlyLink','Industry','PartnerLink','ProjectJoin','ProjectComment','ProjectInfo','ProjectLoan','ProjectProgress','ProjectQa']
+  # PAPER_TRAIL_AUDIT_MODEL = ['RailsAdmin','Session','SignUpChannel','TakeCashOrder','User','UserBankcard','WxEvent','WxEventItem','WxGongzonghao','WxMenu','WxUser']
+
+
+  config.actions do
+    # root actions
+    dashboard                     # mandatory
+    # collection actions
+    index                         # mandatory
+    new do
+      # except ['Address','WxUser', 'User','BalanceHistory', 'ProjectFollow', 'BalanceOrder', 'TakeCashOrder', 'UserBankcard', 'ProjectJoin']
+    end
+    export
+    history_index do
+      # PAPER_TRAIL_AUDIT_MODEL
+    end
+    bulk_delete
+    # member actions
+
+    show
+    edit do
+      # except ['Balance','BalanceHistory', 'ProjectFollow', 'BalanceOrder', 'TakeCashOrder', 'UserBankcard', 'ProjectJoin','AddressDeletedItem','ProjectDeletedItem']
+    end
+    delete do
+      # except ['Project','Address','WxUser', 'User','Balance','BalanceHistory', 'ProjectFollow', 'BalanceOrder', 'TakeCashOrder', 'UserBankcard', 'ProjectJoin']
+    end
+    history_show do
+      # PAPER_TRAIL_AUDIT_MODEL
+    end
+    show_in_app
+    # Add the nestable action for configured models
+    nestable
+  end
+end

+ 194 - 0
config/initializers/rails_admin.rb.example

@@ -0,0 +1,194 @@
+# RailsAdmin config file. Generated on July 21, 2016 18:25
+# See github.com/sferik/rails_admin for more informations
+
+RailsAdmin.config do |config|
+
+
+  ################  Global configuration  ################
+
+  # Set the admin name here (optional second array element will appear in red). For example:
+  config.main_app_name = ['Admin D5ct Com', 'Admin']
+  # or for a more dynamic name:
+  # config.main_app_name = Proc.new { |controller| [Rails.application.engine_name.titleize, controller.params['action'].titleize] }
+
+  # RailsAdmin may need a way to know who the current user is]
+  config.current_user_method { current_admin_user } # auto-generated
+
+  # If you want to track changes on your models:
+  # config.audit_with :history, 'AdminUser'
+
+  # Or with a PaperTrail: (you need to install it first)
+  # config.audit_with :paper_trail, 'AdminUser'
+
+  # Display empty fields in show views:
+  # config.compact_show_view = false
+
+  # Number of default rows per-page:
+  # config.default_items_per_page = 20
+
+  # Exclude specific models (keep the others):
+  # config.excluded_models = ['AdminPermission', 'AdminRole', 'AdminUser']
+
+  # Include specific models (exclude the others):
+  # config.included_models = ['AdminPermission', 'AdminRole', 'AdminUser']
+
+  # Label methods for model instances:
+  # config.label_methods << :description # Default is [:name, :title]
+
+
+  ################  Model configuration  ################
+
+  # Each model configuration can alternatively:
+  #   - stay here in a `config.model 'ModelName' do ... end` block
+  #   - go in the model definition file in a `rails_admin do ... end` block
+
+  # This is your choice to make:
+  #   - This initializer is loaded once at startup (modifications will show up when restarting the application) but all RailsAdmin configuration would stay in one place.
+  #   - Models are reloaded at each request in development mode (when modified), which may smooth your RailsAdmin development workflow.
+
+
+  # Now you probably need to tour the wiki a bit: https://github.com/sferik/rails_admin/wiki
+  # Anyway, here is how RailsAdmin saw your application's models when you ran the initializer:
+
+
+
+  ###  AdminPermission  ###
+
+  # config.model 'AdminPermission' do
+
+  #   # You can copy this to a 'rails_admin do ... end' block inside your admin_permission.rb model definition
+
+  #   # Found associations:
+
+  #     configure :admin_roles, :has_and_belongs_to_many_association 
+
+  #   # Found columns:
+
+  #     configure :id, :integer 
+  #     configure :model, :string 
+  #     configure :can, :string 
+
+  #   # Cross-section configuration:
+
+  #     # object_label_method :name     # Name of the method called for pretty printing an *instance* of ModelName
+  #     # label 'My model'              # Name of ModelName (smartly defaults to ActiveRecord's I18n API)
+  #     # label_plural 'My models'      # Same, plural
+  #     # weight 0                      # Navigation priority. Bigger is higher.
+  #     # parent OtherModel             # Set parent model for navigation. MyModel will be nested below. OtherModel will be on first position of the dropdown
+  #     # navigation_label              # Sets dropdown entry's name in navigation. Only for parents!
+
+  #   # Section specific configuration:
+
+  #     list do
+  #       # filters [:id, :name]  # Array of field names which filters should be shown by default in the table header
+  #       # items_per_page 100    # Override default_items_per_page
+  #       # sort_by :id           # Sort column (default is primary key)
+  #       # sort_reverse true     # Sort direction (default is true for primary key, last created first)
+  #     end
+  #     show do; end
+  #     edit do; end
+  #     export do; end
+  #     # also see the create, update, modal and nested sections, which override edit in specific cases (resp. when creating, updating, modifying from another model in a popup modal or modifying from another model nested form)
+  #     # you can override a cross-section field configuration in any section with the same syntax `configure :field_name do ... end`
+  #     # using `field` instead of `configure` will exclude all other fields and force the ordering
+  # end
+
+
+  ###  AdminRole  ###
+
+  # config.model 'AdminRole' do
+
+  #   # You can copy this to a 'rails_admin do ... end' block inside your admin_role.rb model definition
+
+  #   # Found associations:
+
+  #     configure :admin_users, :has_and_belongs_to_many_association         # Hidden 
+  #     configure :admin_permissions, :has_and_belongs_to_many_association 
+
+  #   # Found columns:
+
+  #     configure :id, :integer 
+  #     configure :name, :string 
+  #     configure :description, :text 
+
+  #   # Cross-section configuration:
+
+  #     # object_label_method :name     # Name of the method called for pretty printing an *instance* of ModelName
+  #     # label 'My model'              # Name of ModelName (smartly defaults to ActiveRecord's I18n API)
+  #     # label_plural 'My models'      # Same, plural
+  #     # weight 0                      # Navigation priority. Bigger is higher.
+  #     # parent OtherModel             # Set parent model for navigation. MyModel will be nested below. OtherModel will be on first position of the dropdown
+  #     # navigation_label              # Sets dropdown entry's name in navigation. Only for parents!
+
+  #   # Section specific configuration:
+
+  #     list do
+  #       # filters [:id, :name]  # Array of field names which filters should be shown by default in the table header
+  #       # items_per_page 100    # Override default_items_per_page
+  #       # sort_by :id           # Sort column (default is primary key)
+  #       # sort_reverse true     # Sort direction (default is true for primary key, last created first)
+  #     end
+  #     show do; end
+  #     edit do; end
+  #     export do; end
+  #     # also see the create, update, modal and nested sections, which override edit in specific cases (resp. when creating, updating, modifying from another model in a popup modal or modifying from another model nested form)
+  #     # you can override a cross-section field configuration in any section with the same syntax `configure :field_name do ... end`
+  #     # using `field` instead of `configure` will exclude all other fields and force the ordering
+  # end
+
+
+  ###  AdminUser  ###
+
+  # config.model 'AdminUser' do
+
+  #   # You can copy this to a 'rails_admin do ... end' block inside your admin_user.rb model definition
+
+  #   # Found associations:
+
+  #     configure :admin_roles, :has_and_belongs_to_many_association 
+
+  #   # Found columns:
+
+  #     configure :id, :integer 
+  #     configure :email, :string 
+  #     configure :password, :password         # Hidden 
+  #     configure :password_confirmation, :password         # Hidden 
+  #     configure :reset_password_token, :string         # Hidden 
+  #     configure :name, :string 
+  #     configure :is_super_admin, :boolean 
+  #     configure :reset_password_sent_at, :datetime 
+  #     configure :remember_created_at, :datetime 
+  #     configure :sign_in_count, :integer 
+  #     configure :current_sign_in_at, :datetime 
+  #     configure :last_sign_in_at, :datetime 
+  #     configure :current_sign_in_ip, :string 
+  #     configure :last_sign_in_ip, :string 
+  #     configure :created_at, :datetime 
+  #     configure :updated_at, :datetime 
+
+  #   # Cross-section configuration:
+
+  #     # object_label_method :name     # Name of the method called for pretty printing an *instance* of ModelName
+  #     # label 'My model'              # Name of ModelName (smartly defaults to ActiveRecord's I18n API)
+  #     # label_plural 'My models'      # Same, plural
+  #     # weight 0                      # Navigation priority. Bigger is higher.
+  #     # parent OtherModel             # Set parent model for navigation. MyModel will be nested below. OtherModel will be on first position of the dropdown
+  #     # navigation_label              # Sets dropdown entry's name in navigation. Only for parents!
+
+  #   # Section specific configuration:
+
+  #     list do
+  #       # filters [:id, :name]  # Array of field names which filters should be shown by default in the table header
+  #       # items_per_page 100    # Override default_items_per_page
+  #       # sort_by :id           # Sort column (default is primary key)
+  #       # sort_reverse true     # Sort direction (default is true for primary key, last created first)
+  #     end
+  #     show do; end
+  #     edit do; end
+  #     export do; end
+  #     # also see the create, update, modal and nested sections, which override edit in specific cases (resp. when creating, updating, modifying from another model in a popup modal or modifying from another model nested form)
+  #     # you can override a cross-section field configuration in any section with the same syntax `configure :field_name do ... end`
+  #     # using `field` instead of `configure` will exclude all other fields and force the ordering
+  # end
+
+end

+ 3 - 0
config/initializers/safe_yaml.rb

@@ -0,0 +1,3 @@
+require 'safe_yaml'
+SafeYAML::OPTIONS[:default_mode] = :safe
+SafeYAML::OPTIONS[:deserialize_symbols] = true

+ 8 - 0
config/initializers/secret_token.rb

@@ -0,0 +1,8 @@
+# Be sure to restart your server when you modify this file.
+
+# Your secret key for verifying the integrity of signed cookies.
+# If you change this key, all old signed cookies will become invalid!
+# Make sure the secret is at least 30 characters and all random,
+# no regular words or you'll be exposed to dictionary attacks.
+AdminD5ctCom::Application.config.secret_token = 'db679119f58b9e1cbb5d1700fc8b9586f2cfd6abb913ecc0a9965ecaae727a6a984996cc65865012e36e26d1d77a1324699b15f7cb092adf4bcd9212ac756912'
+AdminD5ctCom::Application.config.secret_key_base = '29013fad4844deb4d281cba61c64d1a42b98472681282031c63eecd60a7cd4d898f4689275788cf87b8baab2a38764bac436a115629258dce2bfe5e2f701ebe8'

+ 8 - 0
config/initializers/session_store.rb

@@ -0,0 +1,8 @@
+# Be sure to restart your server when you modify this file.
+
+AdminD5ctCom::Application.config.session_store :cookie_store, key: 'admin_d5ct_com_sid'
+
+# Use the database for sessions instead of the cookie-based default,
+# which shouldn't be used to store highly confidential information
+# (create the session table with "rails generate session_migration")
+# AdminD5ctCom::Application.config.session_store :active_record_store

+ 14 - 0
config/initializers/wrap_parameters.rb

@@ -0,0 +1,14 @@
+# Be sure to restart your server when you modify this file.
+#
+# This file contains settings for ActionController::ParamsWrapper which
+# is enabled by default.
+
+# Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
+ActiveSupport.on_load(:action_controller) do
+  wrap_parameters format: [:json]
+end
+
+# Disable root element in JSON by default.
+ActiveSupport.on_load(:active_record) do
+  self.include_root_in_json = false
+end

+ 61 - 0
config/locales/devise.cn.yml

@@ -0,0 +1,61 @@
+# Additional translations at https://github.com/plataformatec/devise/wiki/I18n
+
+cn:
+  devise:
+    confirmations:
+      confirmed: "Your account was successfully confirmed. You are now signed in."
+      send_instructions: "You will receive an email with instructions about how to confirm your account in a few minutes."
+      send_paranoid_instructions: "If your email address exists in our database, you will receive an email with instructions about how to confirm your account in a few minutes."
+    failure:
+      already_authenticated: "已验证"
+      inactive: "Your account was not activated yet."
+      invalid: "Invalid email or password."
+      invalid_token: "Invalid authentication token."
+      locked: "Your account is locked."
+      not_found_in_database: "Invalid email or password."
+      timeout: "会话过期,请重新登录"
+      unauthenticated: "请先登录"
+      unconfirmed: "You have to confirm your account before continuing."
+      admin_user:
+        not_found_in_database: "用户不存在"
+    mailer:
+      confirmation_instructions:
+        subject: "Confirmation instructions"
+      reset_password_instructions:
+        subject: "Reset password instructions"
+      unlock_instructions:
+        subject: "Unlock Instructions"
+    omniauth_callbacks:
+      failure: "Could not authenticate you from %{kind} because \"%{reason}\"."
+      success: "Successfully authenticated from %{kind} account."
+    passwords:
+      no_token: "You can't access this page without coming from a password reset email. If you do come from a password reset email, please make sure you used the full URL provided."
+      send_instructions: "You will receive an email with instructions about how to reset your password in a few minutes."
+      send_paranoid_instructions: "If your email address exists in our database, you will receive a password recovery link at your email address in a few minutes."
+      updated: "Your password was changed successfully. You are now signed in."
+      updated_not_active: "Your password was changed successfully."
+    registrations:
+      destroyed: "Bye! Your account was successfully cancelled. We hope to see you again soon."
+      signed_up: "Welcome! You have signed up successfully."
+      signed_up_but_inactive: "You have signed up successfully. However, we could not sign you in because your account is not yet activated."
+      signed_up_but_locked: "You have signed up successfully. However, we could not sign you in because your account is locked."
+      signed_up_but_unconfirmed: "A message with a confirmation link has been sent to your email address. Please open the link to activate your account."
+      update_needs_confirmation: "You updated your account successfully, but we need to verify your new email address. Please check your email and click on the confirm link to finalize confirming your new email address."
+      updated: "You updated your account successfully."
+    sessions:
+      signed_in: "登陆成功"
+      signed_out: "退出成功"
+    unlocks:
+      send_instructions: "You will receive an email with instructions about how to unlock your account in a few minutes."
+      send_paranoid_instructions: "If your account exists, you will receive an email with instructions about how to unlock it in a few minutes."
+      unlocked: "Your account has been unlocked successfully. Please sign in to continue."
+  errors:
+    messages:
+      already_confirmed: "was already confirmed, please try signing in"
+      confirmation_period_expired: "needs to be confirmed within %{period}, please request a new one"
+      expired: "has expired, please request a new one"
+      not_found: "not found"
+      not_locked: "was not locked"
+      not_saved:
+        one: "1 error prohibited this %{resource} from being saved:"
+        other: "%{count} errors prohibited this %{resource} from being saved:"

+ 60 - 0
config/locales/devise.en.yml

@@ -0,0 +1,60 @@
+# Additional translations at https://github.com/plataformatec/devise/wiki/I18n
+
+en:
+  devise:
+    confirmations:
+      confirmed: "Your email address has been successfully confirmed."
+      send_instructions: "You will receive an email with instructions for how to confirm your email address in a few minutes."
+      send_paranoid_instructions: "If your email address exists in our database, you will receive an email with instructions for how to confirm your email address in a few minutes."
+    failure:
+      already_authenticated: "You are already signed in."
+      inactive: "Your account is not activated yet."
+      invalid: "Invalid email or password."
+      locked: "Your account is locked."
+      last_attempt: "You have one more attempt before your account is locked."
+      not_found_in_database: "Invalid email address or password."
+      timeout: "Your session expired. Please sign in again to continue."
+      unauthenticated: "You need to sign in or sign up before continuing."
+      unconfirmed: "You have to confirm your email address before continuing."
+    mailer:
+      confirmation_instructions:
+        subject: "Confirmation instructions"
+      reset_password_instructions:
+        subject: "Reset password instructions"
+      unlock_instructions:
+        subject: "Unlock instructions"
+    omniauth_callbacks:
+      failure: "Could not authenticate you from %{kind} because \"%{reason}\"."
+      success: "Successfully authenticated from %{kind} account."
+    passwords:
+      no_token: "You can't access this page without coming from a password reset email. If you do come from a password reset email, please make sure you used the full URL provided."
+      send_instructions: "You will receive an email with instructions on how to reset your password in a few minutes."
+      send_paranoid_instructions: "If your email address exists in our database, you will receive a password recovery link at your email address in a few minutes."
+      updated: "Your password has been changed successfully. You are now signed in."
+      updated_not_active: "Your password has been changed successfully."
+    registrations:
+      destroyed: "Bye! Your account has been successfully cancelled. We hope to see you again soon."
+      signed_up: "Welcome! You have signed up successfully."
+      signed_up_but_inactive: "You have signed up successfully. However, we could not sign you in because your account is not yet activated."
+      signed_up_but_locked: "You have signed up successfully. However, we could not sign you in because your account is locked."
+      signed_up_but_unconfirmed: "A message with a confirmation link has been sent to your email address. Please follow the link to activate your account."
+      update_needs_confirmation: "You updated your account successfully, but we need to verify your new email address. Please check your email and follow the confirm link to confirm your new email address."
+      updated: "Your account has been updated successfully."
+    sessions:
+      signed_in: "Signed in successfully."
+      signed_out: "Signed out successfully."
+      already_signed_out: "Signed out successfully."
+    unlocks:
+      send_instructions: "You will receive an email with instructions for how to unlock your account in a few minutes."
+      send_paranoid_instructions: "If your account exists, you will receive an email with instructions for how to unlock it in a few minutes."
+      unlocked: "Your account has been unlocked successfully. Please sign in to continue."
+  errors:
+    messages:
+      already_confirmed: "was already confirmed, please try signing in"
+      confirmation_period_expired: "needs to be confirmed within %{period}, please request a new one"
+      expired: "has expired, please request a new one"
+      not_found: "not found"
+      not_locked: "was not locked"
+      not_saved:
+        one: "1 error prohibited this %{resource} from being saved:"
+        other: "%{count} errors prohibited this %{resource} from being saved:"

+ 11 - 0
config/locales/devise.zh-CN.yml

@@ -0,0 +1,11 @@
+zh-CN:
+  devise:
+    failure:
+      already_authenticated: 已验证
+      admin_user:
+        unauthenticated: 未验证
+        invalid: 账号或密码错误
+        not_found_in_database: 用户不存在
+    sessions:
+      signed_in: 登录成功.
+      signed_out: 退出成功.

+ 5 - 0
config/locales/en.yml

@@ -0,0 +1,5 @@
+# Sample localization file for English. Add more files in this directory for other locales.
+# See https://github.com/svenfuchs/rails-i18n/tree/master/rails%2Flocale for starting points.
+
+en:
+  hello: "Hello world"

+ 11 - 0
config/locales/models/admin_permission.yml

@@ -0,0 +1,11 @@
+zh-CN:
+  activerecord:
+    models:
+      admin_permission: 权限
+    attributes:
+      admin_permission:
+        model: 模块
+        can: 权限
+        admin_roles: 角色
+        created_at: 创建时间
+        updated_at: 更新时间

+ 10 - 0
config/locales/models/admin_permissions_admin_role.yml

@@ -0,0 +1,10 @@
+zh-CN:
+  activerecord:
+    models:
+      admin_permissions_admin_role: 权限分配
+    attributes:
+      admin_permissions_admin_role:
+            id: id
+            admin_role_id: 角色ID
+            admin_permission: 权限
+            admin_permission_id: 权限ID

+ 12 - 0
config/locales/models/admin_role.yml

@@ -0,0 +1,12 @@
+zh-CN:
+  activerecord:
+    models:
+      admin_role: 角色
+    attributes:
+      admin_role:
+        name: 名称
+        admin_users: 管理员
+        admin_permissions: 权限
+        description: 描述
+        created_at: 创建时间
+        updated_at: 更新时间

+ 9 - 0
config/locales/models/admin_roles_admin_user.yml

@@ -0,0 +1,9 @@
+zh-CN:
+  activerecord:
+    models:
+      admin_roles_admin_user: 管理员角色
+    attributes:
+      admin_roles_admin_user:
+           id: id
+           admin_role_id: 角色id
+           admin_user_id: 管理员id

+ 19 - 0
config/locales/models/admin_user.yml

@@ -0,0 +1,19 @@
+zh-CN:
+  activerecord:
+    models:
+      admin_user: 管理员
+    attributes:
+      admin_user:
+        email: 邮箱
+        name: 姓名
+        password: 密码
+        password_confirmation: 确认密码
+        admin_roles: 角色
+        created_at: 创建时间
+        sign_in_count: 登录次数
+        current_sign_in_at: 本次登录时间
+        last_sign_in_at: 上次登录时间
+        current_sign_in_ip: 本次登录IP
+        last_sign_in_ip: 上次登录IP
+        company: 公司
+        updated_at: 更新时间

+ 12 - 0
config/locales/models/picture.yml

@@ -0,0 +1,12 @@
+zh-CN:
+  activerecord:
+    models:
+      ckeditor/picture: 图片
+    attributes:
+      ckeditor/picture:
+        data: 图片
+        type: 类型
+        width: 宽度
+        height: 长度
+        created_at: 创建时间
+        updated_at: 更新时间

+ 15 - 0
config/locales/models/rails_admin_history.yml

@@ -0,0 +1,15 @@
+zh-CN:
+  activerecord:
+    models:
+      rails_admin_history: 管理历史记录
+    attributes: 
+      rails_admin_history: 
+        id: ID
+        message: 消息
+        username: 用户名
+        item: 对象
+        table: 表名
+        month: 月
+        year: 年
+        created_at: 创建时间
+        updated_at: 更新时间

+ 9 - 0
config/locales/models/session.yml

@@ -0,0 +1,9 @@
+zh-CN:
+  activerecord:
+    models:
+      session: 会话
+    attributes:
+      session:
+        session_key: 会话KEY
+        session_data: 会话数据
+        session_expiry: 会话生成时间

+ 13 - 0
config/locales/models/wa_id_department.yml

@@ -0,0 +1,13 @@
+zh-CN:
+  activerecord:
+    models:
+      wa_id_department: 报表系统-部门表
+    attributes:
+      wa_id_department: 
+        id: ID
+        name: 部门名
+
+        created_user_id: 创建用户
+        modified_user_id: 修改用户
+        created_at: 创建时间
+        updated_at: 更新时间

+ 23 - 0
config/locales/models/wa_id_permission.yml

@@ -0,0 +1,23 @@
+zh-CN:
+  activerecord:
+    models:
+      wa_id_permission: 报表系统-权限表
+    attributes:
+      wa_id_permission: 
+        id: ID
+        name: 权限名
+        url_type: 权限类型
+        url: 权限请求
+        url_path: 页面链接
+        percode: 权限diam字符串(不可修改)
+        parentid: 父节点
+        parentids: 父节点id列表串
+        m_parentid: 菜单父节点
+        wf_menu_parent_name: 菜单父节点名称
+        sort: 排序
+        is_available: 是否可用
+        wf_parent_permision_names: 当前页面可见
+        created_user_id: 创建用户
+        modified_user_id: 修改用户
+        created_at: 创建时间
+        updated_at: 更新时间

+ 14 - 0
config/locales/models/wa_id_role.yml

@@ -0,0 +1,14 @@
+zh-CN:
+  activerecord:
+    models:
+      wa_id_role: 报表系统-角色表
+    attributes:
+      wa_id_role: 
+        id: ID
+        name: 角色名
+        is_available: 是否可用
+        permission_names: 权限集合
+        created_user_id: 创建用户
+        modified_user_id: 修改用户
+        created_at: 创建时间
+        updated_at: 更新时间

+ 16 - 0
config/locales/models/wa_id_role_permission.yml

@@ -0,0 +1,16 @@
+zh-CN:
+  activerecord:
+    models:
+      wa_id_role_permission: 报表系统-角色权限表
+    attributes:
+      wa_id_role_permission:
+        id: ID
+        permission_id: 权限id
+        role_id: 角色id
+        wa_id_permission: 权限
+        wa_id_role: 角色
+
+        created_user_id: 创建用户
+        modified_user_id: 修改用户
+        created_at: 创建时间
+        updated_at: 更新时间

+ 17 - 0
config/locales/models/wa_id_user.yml

@@ -0,0 +1,17 @@
+zh-CN:
+  activerecord:
+    models:
+      wa_id_user: 报表系统用户
+    attributes:
+      wa_id_user: 
+        id: ID
+        uaccount: 账号
+        uname: 用户名
+        upsd: 密码
+        wa_id_department: 所属部门
+        salt: 盐
+        locked: 是否锁定
+        is_god: 是否是上帝
+        role_names: 角色
+        created_at: 创建时间
+        updated_at: 更新时间

+ 14 - 0
config/locales/models/wa_id_user_role.yml

@@ -0,0 +1,14 @@
+zh-CN:
+  activerecord:
+    models:
+      wa_id_user_role: 报表系统-用户角色
+    attributes:
+      wa_id_user_role: 
+        id: ID
+        user_id: 用户id
+        role_id: 角色id
+        wa_id_user: 用户
+        wa_id_role: 角色
+        permission_names: 权限集合
+        created_at: 创建时间
+        updated_at: 更新时间

+ 15 - 0
config/locales/models/wa_id_user_token.yml

@@ -0,0 +1,15 @@
+zh-CN:
+  activerecord:
+    models:
+      wa_id_user_token: 报表系统-用户凭证
+    attributes:
+      wa_id_user_token: 
+        id: ID
+        user_id: 报表系统用户
+        token: 凭证
+        expire_time: 过期时间
+        wa_id_user: 报表系统用户
+        created_user_id: 创建用户
+        modified_user_id: 修改用户
+        created_at: 创建时间
+        updated_at: 更新时间

+ 58 - 0
config/locales/rails.cn.yml

@@ -0,0 +1,58 @@
+cn:
+  activerecord:
+    models:
+       user: 用户
+       category: 栏目
+       article: 文章管理
+       village: 小区管理
+       bank_card: 银行
+       bank_card_shop: 商家银行
+       shop: 商家
+       shop_type: 商家类别
+       channel: 注册渠道
+       admin_user: 管理员
+       admin_role: 角色管理
+       admin_permission: 权限管理
+       background: 背景管理
+       user_village: 小区成员管理
+       api_arg: 接口参数管理
+       api_code: 接口返回码管理
+       api_group: 接口组管理
+       api_resource: 接口管理
+       career: 小区职业人管理
+    errors:
+      template:
+        header:
+          one: "有 1 个错误发生导致「%{model}」无法被保存。"
+          other: "有 %{count} 个错误发生导致「%{model}」无法被保存。"
+        body: "如下字段出现错误:"
+      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}"
+
+  views:
+    pagination:
+      first: 首页
+      previous: 上一页
+      next: 下一页
+      last: 尾页
+      truncate: ...

+ 196 - 0
config/locales/rails_admin.cn.yml

@@ -0,0 +1,196 @@
+cn:
+  datetime:
+    distance_in_words:
+      x_minutes "最新更新"
+  admin:
+    loading: "加载中..."
+    home:
+      name: "网站首页"
+    pagination:
+      previous: "&laquo; 上页"
+      next: "下页 &raquo;"
+      truncate: "…"
+    misc:
+      filter_date_format: "mm/dd/yy" # a combination of 'dd', 'mm' and 'yy' with any delimiter. No other interpolation will be done!
+      search: "搜索"
+      filter: "过滤"
+      refresh: "刷新"
+      show_all: "Show all"
+      add_filter: "添加过滤器"
+      bulk_menu_title: "已选中项"
+      remove: "Remove"
+      add_new: "新增"
+      chosen: "Chosen %{name}"
+      chose_all: "Choose all"
+      clear_all: "Clear all"
+      up: "Up"
+      down: "Down"
+      navigation: "Navigation"
+      navigation_static_label: "Links"
+      log_out: "退出"
+      ago: "ago"
+    flash:
+      successful: "%{name} 已成功 %{action}"
+      generate_menu_success: ""
+      error: "%{name} failed to be %{action}"
+      noaction: "No actions were taken"
+      model_not_found: "Model '%{model}' could not be found"
+      object_not_found: "%{model} with id '%{id}' could not be found"
+    table_headers:
+      model_name: "模块名"
+      last_used: "最新更改时间"
+      records: "记录数"
+      username: "User"
+      changes: "Changes"
+      created_at: "Date/Time"
+      item: "Item"
+      message: "Message"
+    actions:
+      dashboard:
+        title: "网站管理"
+        menu: "控制面板"
+        breadcrumb: "控制面板"
+      index:
+        title: "%{model_label_plural}列表"
+        menu: "列表"
+        breadcrumb: "%{model_label_plural}"
+      show:
+        title: "Details for %{model_label} '%{object_label}'"
+        menu: "显示"
+        breadcrumb: "%{object_label}"
+      show_in_app:
+        menu: "Show in app"
+      new:
+        title: "新增 %{model_label}"
+        menu: "新增"
+        breadcrumb: "新增"
+        link: "Add a new %{model_label}"
+        done: "created"
+      edit:
+        title: "编辑 %{model_label} '%{object_label}'"
+        menu: "编辑"
+        breadcrumb: "编辑"
+        link: "Edit this %{model_label}"
+        done: "updated"
+      delete:
+        title: "删除 %{model_label} '%{object_label}'"
+        menu: "删除"
+        breadcrumb: "删除"
+        link: "删除 '%{object_label}'"
+        done: "删除"
+      bulk_delete:
+        title: "Delete %{model_label_plural}"
+        menu: "Multiple delete"
+        breadcrumb: "Multiple delete"
+        bulk_link: "删除 已选中 %{model_label_plural}"
+      export:
+        title: "导出 %{model_label_plural}"
+        menu: "导出"
+        breadcrumb: "导出"
+        link: "Export found %{model_label_plural}"
+        bulk_link: "Export selected %{model_label_plural}"
+        done: "exported"
+      history_index:
+        title: "History for %{model_label_plural}"
+        menu: "History"
+        breadcrumb: "History"
+      history_show:
+        title: "History for %{model_label} '%{object_label}'"
+        menu: "History"
+        breadcrumb: "History"
+      nestable:
+        breadcrumb: "拖拽"
+        menu: "拖拽排序"
+        title: "栏目拖拽排序"
+    form:
+      cancel: "取消"
+      basic_info: "详细信息"
+      required: "必选"
+      optional: "可选"
+      one_char: "character"
+      char_length_up_to: "length up to"
+      char_length_of: "length of"
+      save: "保存"
+      save_and_add_another: "保存并新增"
+      save_and_edit: "保存并编辑"
+      all_of_the_following_related_items_will_be_deleted: "? 子对象也将被删除或者失去关联:"
+      are_you_sure_you_want_to_delete_the_object: "确认删除 %{model_name}"
+      confirmation: "确认"
+      bulk_delete: "子对象也将被删除, which may delete or orphan some of their related dependencies:"
+      new_model: "%{name} (new)"
+    export:
+      confirmation: "Export to %{name}"
+      select: "Select fields to export"
+      select_all_fields: "Select All Fields"
+      fields_from: "Fields from %{name}"
+      fields_from_associated: "Fields from associated %{name}"
+      display: "Display %{name}: %{type}"
+      options_for: "Options for %{name}"
+      empty_value_for_associated_objects: "<empty>"
+      click_to_reverse_selection: 'Click to reverse selection'
+      csv:
+        header_for_root_methods: "%{name}" # 'model' is available
+        header_for_association_methods: "%{name} [%{association}]"
+        encoding_to: "Encode to"
+        encoding_to_help: "Choose output encoding. Leave empty to let current input encoding untouched: (%{name})"
+        skip_header: "No header"
+        skip_header_help: "Do not output a header (no fields description)"
+        default_col_sep: ","
+        col_sep: "Column separator"
+        col_sep_help: "Leave blank for default ('%{value}')" # value is default_col_sep
+  number:
+      format:
+        separator: "."
+        delimiter: ","
+        precision: 3
+        significant: false
+        strip_insignificant_zeros: false
+
+      # Used in number_to_human_size() and number_to_human()
+      human:
+        format:
+          delimiter: ""
+          precision: 3
+          significant: true
+          strip_insignificant_zeros: true
+
+        # Used in number_to_human_size()
+        storage_units:
+          format: "%n %u"
+          units:
+            byte:
+              one: "Byte"
+              other: "Bytes"
+            kb: "KB"
+            mb: "MB"
+            gb: "GB"
+            tb: "TB"
+
+        # Used in number_to_human()
+        decimal_units:
+          format: "%n %u"
+          units:
+            # femto: Quadrillionth
+            # pico: Trillionth
+            # nano: Billionth
+            # micro: Millionth
+            # mili: Thousandth
+            # centi: Hundredth
+            # deci: Tenth
+            unit: ""
+            # ten:
+            # one: Ten
+            # other: Tens
+            # hundred: Hundred
+            thousand: Thousand
+            million: Million
+            billion: Billion
+            trillion: Trillion
+            quadrillion: Quadrillion
+  ckeditor:
+      page_title: "CKEditor 文件管理"
+      confirm_delete: "删除文件?"
+      buttons:
+        cancel: "取消"
+        upload: "上传"
+        delete: "删除"

+ 291 - 0
config/locales/rails_admin.zh-CN.yml

@@ -0,0 +1,291 @@
+zh-CN:
+  admin:
+    js:
+      true: "是" #True
+      false: "否" #False
+      is_present: "非空" #Is present
+      is_blank: "为空" #Is blank
+      date: "日期" #Date ...
+      between_and_: "区间" #Between ... and ...
+      today: "今日"
+      yesterday: "昨日" #Yesterday
+      this_week: "这周" #This week
+      last_week: "上周" #Last week
+      number: "数字" #Number ...
+      contains: "包含"
+      is_exactly: "恰好是" #Is exactly
+      starts_with: "从...开始" #Starts with
+      ends_with: "以...结束" #Ends with
+    loading: "加载中..."
+    home:
+      name: "首页"
+    pagination:
+      previous: "&laquo; 上一页"
+      next: "下一页 &raquo;"
+      truncate: "…"
+    misc:
+      filter_date_format: "mm/dd/yy" # a combination of 'dd', 'mm' and 'yy' with any delimiter. No other interpolation will be done!
+      search: "搜索"
+      filter: "筛选"
+      refresh: "刷新"
+      show_all: "显示全部"
+      add_filter: "添加筛选条件"
+      bulk_menu_title: "选中的项目"
+      remove: "移除"
+      add_new: "新增"
+      chosen: "选择%{name}"
+      chose_all: "全选"
+      clear_all: "清空"
+      up: "上"
+      down: "下"
+      navigation: "导航"
+      log_out: "登出"
+      ago: "前"
+    flash:
+      successful: "%{name}%{action}成功"
+      error: "%{name}%{action}失败"
+      noaction: "无操作被执行"
+      model_not_found: "找不到'%{model}' Model"
+      object_not_found: "找不到id为'%{id}'的'%{model}'"
+    table_headers:
+      model_name: "模块名"
+      last_used: "上次使用"
+      last_created: "上次创建"
+      records: "记录"
+      username: "用户"
+      changes: "变更详细内容"
+      created_at: "日期/时间"
+      item: "项目"
+      message: "信息"
+      items: "记录"
+    actions:
+      dashboard:
+        title: "网站管理"
+        menu: "信息板"
+        breadcrumb: "信息板"
+      index:
+        title: "%{model_label_plural}列表"
+        menu: "列表"
+        breadcrumb: "%{model_label_plural}"
+      generate_menu:
+        title: "%{model_label}生成自定义菜单"
+        menu: "生成自定义菜单"
+        breadcrumb: "生成自定义菜单"
+      dwz_open: 
+        menu: "开奖"
+      dwz_refund:
+        menu: "退款"
+      audit_takecash_order:
+        menu: "提现审批"
+      add_wxku_commodity:
+        menu: "导入"
+      granary_gd_remind:
+        menu: "挂单提醒"
+      granary_zy_remind:
+        menu: "自用提醒"
+      update_wxku_commodity:
+        menu: "更新"
+      get_wxku_commodity:
+        menu: "查微信库商品"
+      check_wxku_commodity:
+        menu: "查询微信库商品导入更新状态"
+      send_project_benefit:
+        menu: "发放项目佣金"
+      refuse_takecash:
+        title: "%{model_label_plural}拒绝提现"
+        menu: "拒绝提现"
+        breadcrumb: "%{model_label_plural}"
+      takecash_at_once: 
+        menu: "立即提现"
+      audit_project_collection:
+        menu: "审核通过"
+      custom_destory_of_project:
+        title: "%{model_label}-%{object_label}-删除项目"
+        menu: "置入项目回收站"
+        breadcrumb: "是否删除"
+      generate_company_account:
+        menu: "生成企业账户"
+      generate_transfer_stock_record:
+        title: "%{model_label}-%{object_label}-股权转让"
+        menu: "转让"
+        breadcrumb: "是否转让"
+      audit_trial_coin:
+        menu: "启用"
+      audit_project_loan:
+        title: "%{model_label}-%{object_label}-放款详情"
+        menu: "是否放款"
+        breadcrumb: "是否放款"
+      push_tmpl_redirect:
+        menu: "推送"
+      push_xcx_tmpl_redirect:
+        menu: "推送"
+      copy_project:
+        menu: "复制"
+      correct_takecash:
+        menu: "提现冲正"
+      distribute_bonus:
+        menu: 开仓放粮
+      send_buyback_amount:
+        menu: 发放回购金额
+      return_amount:
+        menu: "返还差额"
+      deposit_unlock:
+        menu: "解冻"  
+      generate_stock_holding_list:
+        title: "%{model_label}-%{object_label}-生成股权持有者"
+        menu: "生成股权持有者"
+        breadcrumb: "生成股权持有者"
+      generate_analyze_report_record:
+        menu: "生成渠道分布汇总记录"
+      audit:
+        menu: "审核"
+      #生成分红记录
+      generate_user_bonus_record:
+        menu: "生成用户分红记录"
+      # 拒绝
+      disagree:
+        menu: "拒绝"
+      # 推送
+      push:
+        menu: "推送"
+      # 复制
+      check_user_is_regist_d5c:
+        menu: "检查更新该号码是否在第五创注册"
+      part_refund:
+        menu: "一键进行部分退款"
+      sale_subject_open_prize:
+        menu: "开奖推送"
+      copy: 
+        menu: "复制"
+      survey_push:
+        menu: "推送"
+      stock_holder_list:
+        title: "%{model_label}-%{object_label}-股份持有表"
+        menu: "股份持有表"
+        breadcrumb: "股份持有表"
+      report:
+        title: "%{model_label} '%{object_label}'相关"
+        menu: "报表相关信息"
+        breadcrumb: "报表"
+
+      notice: 
+          title: "%{model_label} '%{object_label}'相关"
+          menu: "通知"
+          breadcrumb: "通知"
+      #更新信息
+      update_info:
+          menu: "更新信息"
+      # refund_at_once:
+      #   menu: "一键退款"
+      # 微信用户校验二维码Id
+      check_channel_qrcode_id:
+        menu: "校验"
+      investor:
+        menu: "投资用户报表"
+      show:
+        title: "%{model_label} '%{object_label}'详情"
+        menu: "查看"
+        breadcrumb: "%{object_label}"
+      show_in_app:
+        menu: "在前台显示"
+      new:
+        title: "新增%{model_label}"
+        menu: "新增"
+        breadcrumb: "新增"
+        link: "新增%{model_label}"
+        done: "创建完成"
+      edit:
+        title: "编辑%{model_label} '%{object_label}'"
+        menu: "编辑"
+        breadcrumb: "编辑"
+        link: "编辑%{model_label}"
+        done: "更新完成"
+      delete:
+        title: "删除%{model_label} '%{object_label}'"
+        menu: "删除"
+        breadcrumb: "删除"
+        link: "删除'%{object_label}'"
+        done: "删除完成"
+      bulk_delete:
+        title: "删除%{model_label_plural}"
+        menu: "批量删除"
+        breadcrumb: "批量删除"
+        bulk_link: "删除选中的%{model_label_plural}"
+      export:
+        title: "导出%{model_label_plural}"
+        menu: "导出"
+        breadcrumb: "导出"
+        link: "导出找到的%{model_label_plural}"
+        bulk_link: "导出选中的%{model_label_plural}"
+        done: "导出完成"
+      import:
+        title: "导入%{model_label_plural}"
+        menu: "导入"
+        breadcrumb: "导入"
+        link: "导入找到的%{model_label_plural}"
+        bulk_link: "导入选中的%{model_label_plural}"
+        done: "导入完成"
+        fields: "d"
+      history_index:
+        title: "%{model_label_plural}的历史记录"
+        menu: "历史"
+        breadcrumb: "历史"
+      history_show:
+        title: "%{model_label} '%{object_label}'的历史记录"
+        menu: "历史"
+        breadcrumb: "历史"
+      reset_activate:
+        title: "重置激活次数%{model_label} '%{object_label}'"
+        menu: "重置激活次数"
+        breadcrumb: "重置激活次数"
+        link: "重置激活次数'%{object_label}'"
+        done: "重置激活次数完成"
+      refresh_setting:
+        menu: "更新"
+      charts:
+        title: "图表"
+        menu: "图表"
+        breadcrumb: "图表"
+      nestable:
+        title: "栏目树状"
+        menu: "树状"
+        breadcrumb: "拖拽"
+        live_update: "实时更新"
+        update: "更新"
+    form:
+      cancel: "取消"
+      basic_info: "基本信息"
+      required: "必填"
+      optional: "可选"
+      one_char: "字节"
+      char_length_up_to: "长度不多于"
+      char_length_of: "字节数"
+      save: "保存"
+      save_and_add_another: "保存后继续添加"
+      save_and_edit: "保存后编辑"
+      all_of_the_following_related_items_will_be_deleted: "? 下列关联的项目可能会被删除或孤立:"
+      are_you_sure_you_want_to_delete_the_object: "你确定要删除%{model_name}吗?"
+      are_you_sure_you_want_to_reset_the_object_activate: "你确定要重置%{model_name}的激活次数吗?"
+      confirmation: "是的,我确定"
+      bulk_delete: "下列项目将被删除, 和它们想关联的项目也可能被删除或孤立:"
+      new_model: "%{name} (新)"
+    export:
+      confirmation: "导出到%{name}"
+      select: "选择希望导出的字段"
+      select_all_fields: "全选"
+      fields_from: "出自%{name}的字段"
+      fields_from_associated: "源自与%{name}关联项目的字段"
+      display: "显示%{name}: %{type}"
+      options_for: "%{name}的选项"
+      empty_value_for_associated_objects: "<空>"
+      click_to_reverse_selection: '反选'
+      csv:
+        header_for_root_methods: "%{name}" # 'model' is available
+        header_for_association_methods: "%{name} [%{association}]"
+        encoding_to: "文字编码"
+        encoding_to_help: "选择输出编码。留空保持原来的编码不变:(%{name})"
+        skip_header: "无文件头"
+        skip_header_help: "不输出字段描述"
+        default_col_sep: ","
+        col_sep: "分隔符"
+        col_sep_help: "留空使用默认设置('%{value}')" # value is default_col_sep

+ 216 - 0
config/locales/zh-CN.yml

@@ -0,0 +1,216 @@
+zh-CN:
+  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 %H:%M:%S'
+      long: ! '%Y-%m-%d %H:%M:%S'
+      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:
+        one: 一天
+        other: ! '%{count} 天'
+      x_minutes:
+        one: 一分钟
+        other: ! '%{count} 分钟'
+      x_months:
+        one: 一个月
+        other: ! '%{count} 个月'
+      x_seconds:
+        one: 一秒
+        other: ! '%{count} 秒'
+    prompts:
+      day: 日
+      hour: 时
+      minute: 分
+      month: 月
+      second: 秒
+      year: 年
+  errors: &errors
+    format: ! '%{attribute}%{message}'
+    messages:
+      accepted: 必须是可被接受的
+      blank: 不能为空字符
+      confirmation: 与确认值不匹配
+      empty: 不能留空
+      equal_to: 必须等于 %{count}
+      even: 必须为双数
+      exclusion: 是保留关键字
+      greater_than: 必须大于 %{count}
+      greater_than_or_equal_to: 必须大于或等于 %{count}
+      inclusion: 不包含于列表中
+      invalid: 是无效的
+      less_than: 必须小于 %{count}
+      less_than_or_equal_to: 必须小于或等于 %{count}
+      not_a_number: 不是数字
+      not_an_integer: 必须是整数
+      odd: 必须为单数
+      record_invalid: ! '验证失败: %{errors}'
+      taken: 已经被使用
+      too_long: 过长(最长为 %{count} 个字符)
+      too_short: 过短(最短为 %{count} 个字符)
+      wrong_length: 长度非法(必须为 %{count} 个字符)
+      must_be_a_valid_url: 必须是合法的URL
+    template:
+      body: 如下字段出现错误:
+      header:
+        one: 有 1 个错误发生导致「%{model}」无法被保存。
+        other: 有 %{count} 个错误发生导致「%{model}」无法被保存。
+  helpers:
+    select:
+      prompt: 请选择
+    submit:
+      create: 新增%{model}
+      submit: 储存%{model}
+      update: 更新%{model}
+  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: ''
+  support:
+    array:
+      last_word_connector: ! ', 和 '
+      two_words_connector: ! ' 和 '
+      words_connector: ! ', '
+  time:
+    am: 上午
+    formats:
+      default: ! '%Y-%m-%d %H:%M:%S'
+      long: ! '%Y-%m-%d %H:%M:%S'
+      short: ! '%b%d日 %H:%M'
+    pm: 下午
+  # remove these aliases after 'activemodel' and 'activerecord' namespaces are removed from Rails repository
+  activemodel:
+    errors:
+      <<: *errors
+  activerecord:
+    errors:
+      <<: *errors
+
+  read: 只读
+  update: 只写
+  write: 只写
+  create: 新增
+  manage: 读写
+  history: 历史
+  import: 导入
+  export: 导出
+  report: 报表
+  audit: 审核
+  disagree: 拒绝
+  notice: 通知
+  push: 推送
+  generate_transfer_stock_record: 股权转让-股权持有模块
+  stock_holder_list: 项目股份持有表

+ 47 - 0
config/ngx_dev_ys_company_win.conf

@@ -0,0 +1,47 @@
+server {
+    listen 80;
+    client_max_body_size 4G;
+    server_name tadmin.d5c360.com tadmin.d5ct.com;
+    #keepalive_timeout 5;
+    access_log  /opt/apps/admin.d5ct.com/log/ngx_access.log  main;
+    error_log   /opt/apps/admin.d5ct.com/log/ngx_error.log;
+   
+    error_page 500 502 503 504 /50x.html;
+    location = /500.html {
+        root /opt/apps/admin.d5ct.com/public;
+    }
+    error_page 404 /404.html;
+    location = /404.html {
+        root /opt/apps/admin.d5ct.com/public;
+    }
+
+
+    root /opt/apps/admin.d5ct.com/public;
+
+    location / {
+        #allow 113.106.106.3;
+        #allow 113.106.106.2;
+        #deny all;
+
+        proxy_redirect off;
+        proxy_set_header  Host  $host;
+        proxy_set_header  X-Real-IP  $remote_addr;
+        proxy_set_header  X-Forwarded-For  $proxy_add_x_forwarded_for;
+        proxy_pass http://127.0.0.1:5656;
+    }
+
+    # static resource routing - both assets folder and favicon.ico
+    location ~* ^/a2ssets/|favicon.ico {
+        # Per RFC2616 - 1 year maximum expiry
+        # http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
+        expires 1y;
+        add_header Cache-Control public;
+
+        # Some browsers still send conditional-GET requests if there's a
+        # Last-Modified header or an ETag header even if they haven't
+        # reached the expiry date sent in the Expires header.
+        add_header Last-Modified "";
+        add_header ETag "";
+        break;
+    }
+}

+ 54 - 0
config/ngx_prod.conf

@@ -0,0 +1,54 @@
+server {
+    listen 80;
+    client_max_body_size 4G;
+    server_name stateadmin.d5c360.com;
+    #keepalive_timeout 5;
+    access_log  /opt/apps/statement/admin/log/ngx_access.log  main;
+    error_log   /opt/apps/statement/admin/log/ngx_error.log;
+   
+    error_page 500 502 503 504 /50x.html;
+    location = /500.html {
+        root /opt/apps/statement/admin/public;
+    }
+    error_page 404 /404.html;
+    location = /404.html {
+        root /opt/apps/statement/admin/public;
+    }
+    location /js {
+        root /opt/apps/statement/admin/public;
+    }
+    location /css {
+        root /opt/apps/statement/admin/public;
+    }
+    location /img {
+        root /opt/apps/statement/admin/public;
+    }
+    root /opt/apps/statement/admin/public;
+
+    location / {
+        #allow 113.106.106.3;
+        #allow 113.106.106.2;
+        #deny all;
+
+        proxy_redirect off;
+        proxy_set_header  Host  $host;
+        proxy_set_header  X-Real-IP  $remote_addr;
+        proxy_set_header  X-Forwarded-For  $proxy_add_x_forwarded_for;
+        proxy_pass http://127.0.0.1:5959;
+    }
+
+    # static resource routing - both assets folder and favicon.ico
+    location ~* ^/a2ssets/|favicon.ico {
+        # Per RFC2616 - 1 year maximum expiry
+        # http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
+        expires 1y;
+        add_header Cache-Control public;
+
+        # Some browsers still send conditional-GET requests if there's a
+        # Last-Modified header or an ETag header even if they haven't
+        # reached the expiry date sent in the Expires header.
+        add_header Last-Modified "";
+        add_header ETag "";
+        break;
+    }
+}

+ 46 - 0
config/ngx_test.conf

@@ -0,0 +1,46 @@
+server {
+    listen 80;
+    client_max_body_size 4G;
+    server_name tstateadmin.d5c360.com;
+    #keepalive_timeout 5;
+    access_log  /opt/apps/statement/admin/log/ngx_access.log  main;
+    error_log   /opt/apps/statement/admin/log/ngx_error.log;
+   
+    error_page 500 502 503 504 /50x.html;
+    location = /500.html {
+        root /opt/apps/statement/admin/public;
+    }
+    error_page 404 /404.html;
+    location = /404.html {
+        root /opt/apps/statement/admin/public;
+    }
+
+    root /opt/apps/statement/admin/public;
+
+    location / {
+        #allow 113.106.106.3;
+        #allow 113.106.106.2;
+        #deny all;
+
+        proxy_redirect off;
+        proxy_set_header  Host  $host;
+        proxy_set_header  X-Real-IP  $remote_addr;
+        proxy_set_header  X-Forwarded-For  $proxy_add_x_forwarded_for;
+        proxy_pass http://127.0.0.1:5959;
+    }
+
+    # static resource routing - both assets folder and favicon.ico
+    location ~* ^/a2ssets/|favicon.ico {
+        # Per RFC2616 - 1 year maximum expiry
+        # http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
+        expires 1y;
+        add_header Cache-Control public;
+
+        # Some browsers still send conditional-GET requests if there's a
+        # Last-Modified header or an ETag header even if they haven't
+        # reached the expiry date sent in the Expires header.
+        add_header Last-Modified "";
+        add_header ETag "";
+        break;
+    }
+}

+ 7 - 0
config/routes.rb

@@ -0,0 +1,7 @@
+AdminD5ctCom::Application.routes.draw do
+  devise_for :admin_users
+  mount RailsAdmin::Engine => '/admin', :as => 'rails_admin'  
+  mount Ckeditor::Engine => '/ckeditor'
+  root :to => redirect('/admin')
+  match ':controller(/:action(/:id))(.:format)', :via => [:get, :post]
+end

+ 100 - 0
config/unicorn.rb

@@ -0,0 +1,100 @@
+require "yaml"
+# Sample verbose configuration file for Unicorn (not Rack)
+#
+# This configuration file documents many features of Unicorn
+# that may not be needed for some applications. See
+# http://unicorn.bogomips.org/examples/unicorn.conf.minimal.rb
+# for a much simpler configuration file.
+#
+# See http://unicorn.bogomips.org/Unicorn/Configurator.html for complete
+# documentation.
+
+# Use at least one worker per core if you're on a dedicated server,
+# more will usually help for _short_ waits on databases/caches.
+rails_env = ENV['RAILS_ENV'] || 'production'
+
+CONFIG_FILE = YAML.load_file("#{File.dirname(__FILE__)}/config.yml")[rails_env]
+
+worker_processes (rails_env == 'production' ? 5 : 1)
+
+root  = CONFIG_FILE['root_path']
+
+# Since Unicorn is never exposed to outside clients, it does not need to
+# run on the standard HTTP port (80), there is no reason to start Unicorn
+# as root unless it's from system init scripts.
+# If running the master process as root and the workers as an unprivileged
+# user, do this to switch euid/egid in the workers (also chowns logs):
+# user "unprivileged_user", "unprivileged_group"
+
+# Help ensure your application will always spawn in the symlinked
+# "current" directory that Capistrano sets up.
+working_directory root # available in 0.94.0+
+
+# listen on both a Unix domain socket and a TCP port,
+# we use a shorter backlog for quicker failover when busy
+listen "#{root}/tmp/sockets/unicorn.sock", :backlog => 64
+
+# nuke workers after 30 seconds instead of 60 seconds (the default)
+timeout 30
+
+# feel free to point this anywhere accessible on the filesystem
+pid "#{root}/tmp/pids/unicorn.pid"
+
+# By default, the Unicorn logger will write to stderr.
+# Additionally, ome applications/frameworks log to stderr or stdout,
+# so prevent them from going to /dev/null when daemonized here:
+stderr_path "#{root}/log/unicorn.stderr.log"
+stdout_path "#{root}/log/unicorn.stdout.log"
+
+# combine REE with "preload_app true" for memory savings
+# http://rubyenterpriseedition.com/faq.html#adapt_apps_for_cow
+preload_app true
+GC.respond_to?(:copy_on_write_friendly=) and
+  GC.copy_on_write_friendly = true
+
+before_fork do |server, worker|
+  # the following is highly recomended for Rails + "preload_app true"
+  # as there's no need for the master process to hold a connection
+  defined?(ActiveRecord::Base) and
+    ActiveRecord::Base.connection.disconnect!
+
+  # The following is only recommended for memory/DB-constrained
+  # installations.  It is not needed if your system can house
+  # twice as many worker_processes as you have configured.
+  #
+  # # This allows a new master process to incrementally
+  # # phase out the old master process with SIGTTOU to avoid a
+  # # thundering herd (especially in the "preload_app false" case)
+  # # when doing a transparent upgrade.  The last worker spawned
+  # # will then kill off the old master process with a SIGQUIT.
+  old_pid = "#{server.config[:pid]}.oldbin"
+  if old_pid != server.pid
+    begin
+      sig = (worker.nr + 1) >= server.worker_processes ? :QUIT : :TTOU
+      Process.kill(sig, File.read(old_pid).to_i)
+    rescue Errno::ENOENT, Errno::ESRCH
+    end
+  end
+  #
+  # Throttle the master from forking too quickly by sleeping.  Due
+  # to the implementation of standard Unix signal handlers, this
+  # helps (but does not completely) prevent identical, repeated signals
+  # from being lost when the receiving process is busy.
+  # sleep 1
+end
+
+after_fork do |server, worker|
+  # per-process listener ports for debugging/admin/migrations
+  # addr = "127.0.0.1:#{9293 + worker.nr}"
+  # server.listen(addr, :tries => -1, :delay => 5, :tcp_nopush => true)
+
+  # the following is *required* for Rails + "preload_app true",
+  defined?(ActiveRecord::Base) and
+    ActiveRecord::Base.establish_connection
+
+  # if preload_app is true, then you may also want to check and
+  # restart any other shared sockets/descriptors such as Memcached,
+  # and Redis.  TokyoCabinet file handles are safe to reuse
+  # between any number of forked children (assuming your kernel
+  # correctly implements pread()/pwrite() system calls)
+end

+ 80 - 0
db/migrate/20121201032354_create_versions.rb

@@ -0,0 +1,80 @@
+# This migration creates the `versions` table, the only schema PT requires.
+# All other migrations PT provides are optional.
+class CreateVersions < ActiveRecord::Migration
+  # Class names of MySQL adapters.
+  # - `MysqlAdapter` - Used by gems: `mysql`, `activerecord-jdbcmysql-adapter`.
+  # - `Mysql2Adapter` - Used by `mysql2` gem.
+  MYSQL_ADAPTERS = [
+    "ActiveRecord::ConnectionAdapters::MysqlAdapter",
+    "ActiveRecord::ConnectionAdapters::Mysql2Adapter"
+  ].freeze
+
+  # The largest text column available in all supported RDBMS is
+  # 1024^3 - 1 bytes, roughly one gibibyte.  We specify a size
+  # so that MySQL will use `longtext` instead of `text`.  Otherwise,
+  # when serializing very large objects, `text` might not be big enough.
+  TEXT_BYTES = 1_073_741_823
+
+  def change
+    create_table :versions, versions_table_options do |t|
+      t.string   :item_type, item_type_options
+      t.integer  :item_id,   null: false
+      t.string   :event,     null: false
+      t.string   :whodunnit
+      t.text     :object, limit: TEXT_BYTES
+
+      # Known issue in MySQL: fractional second precision
+      # -------------------------------------------------
+      #
+      # MySQL timestamp columns do not support fractional seconds unless
+      # defined with "fractional seconds precision". MySQL users should manually
+      # add fractional seconds precision to this migration, specifically, to
+      # the `created_at` column.
+      # (https://dev.mysql.com/doc/refman/5.6/en/fractional-seconds.html)
+      #
+      # MySQL users should also upgrade to rails 4.2, which is the first
+      # version of ActiveRecord with support for fractional seconds in MySQL.
+      # (https://github.com/rails/rails/pull/14359)
+      #
+      t.datetime :created_at
+    end
+    add_index :versions, [:item_type, :item_id]
+  end
+
+  private
+
+  # MySQL 5.6 utf8mb4 limit is 191 chars for keys used in indexes.
+  # See https://github.com/airblade/paper_trail/issues/651
+  def item_type_options
+    opt = { null: false }
+    opt[:limit] = 191 if mysql?
+    opt
+  end
+
+  def mysql?
+    MYSQL_ADAPTERS.include?(connection.class.name)
+  end
+
+  # Even modern versions of MySQL still use `latin1` as the default character
+  # encoding. Many users are not aware of this, and run into trouble when they
+  # try to use PaperTrail in apps that otherwise tend to use UTF-8. Postgres, by
+  # comparison, uses UTF-8 except in the unusual case where the OS is configured
+  # with a custom locale.
+  #
+  # - https://dev.mysql.com/doc/refman/5.7/en/charset-applications.html
+  # - http://www.postgresql.org/docs/9.4/static/multibyte.html
+  #
+  # Furthermore, MySQL's original implementation of UTF-8 was flawed, and had
+  # to be fixed later by introducing a new charset, `utf8mb4`.
+  #
+  # - https://mathiasbynens.be/notes/mysql-utf8mb4
+  # - https://dev.mysql.com/doc/refman/5.5/en/charset-unicode-utf8mb4.html
+  #
+  def versions_table_options
+    if mysql?
+      { options: "ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci" }
+    else
+      {}
+    end
+  end
+end

+ 12 - 0
db/migrate/20121201032355_add_object_changes_to_versions.rb

@@ -0,0 +1,12 @@
+# This migration adds the optional `object_changes` column, in which PaperTrail
+# will store the `changes` diff for each update event. See the readme for
+# details.
+class AddObjectChangesToVersions < ActiveRecord::Migration
+  # The largest text column available in all supported RDBMS.
+  # See `create_versions.rb` for details.
+  TEXT_BYTES = 1_073_741_823
+
+  def change
+    add_column :versions, :object_changes, :text, limit: TEXT_BYTES
+  end
+end

+ 22 - 0
db/migrate/20121201032356_create_version_associations.rb

@@ -0,0 +1,22 @@
+# This migration and AddTransactionIdColumnToVersions provide the necessary
+# schema for tracking associations.
+class CreateVersionAssociations < ActiveRecord::Migration
+  def self.up
+    create_table :version_associations do |t|
+      t.integer  :version_id
+      t.string   :foreign_key_name, null: false
+      t.integer  :foreign_key_id
+    end
+    add_index :version_associations, [:version_id]
+    add_index :version_associations,
+      [:foreign_key_name, :foreign_key_id],
+      name: "index_version_associations_on_foreign_key"
+  end
+
+  def self.down
+    remove_index :version_associations, [:version_id]
+    remove_index :version_associations,
+      name: "index_version_associations_on_foreign_key"
+    drop_table :version_associations
+  end
+end

+ 13 - 0
db/migrate/20121201032357_add_transaction_id_column_to_versions.rb

@@ -0,0 +1,13 @@
+# This migration and CreateVersionAssociations provide the necessary
+# schema for tracking associations.
+class AddTransactionIdColumnToVersions < ActiveRecord::Migration
+  def self.up
+    add_column :versions, :transaction_id, :integer
+    add_index :versions, [:transaction_id]
+  end
+
+  def self.down
+    remove_index :versions, [:transaction_id]
+    remove_column :versions, :transaction_id
+  end
+end

+ 18 - 0
db/migrate/20130516032930_create_rails_admin_histories_table.rb

@@ -0,0 +1,18 @@
+class CreateRailsAdminHistoriesTable < ActiveRecord::Migration
+   def self.up
+     create_table :rails_admin_histories do |t|
+       t.text :message # title, name, or object_id
+       t.string :username
+       t.integer :item
+       t.string :table
+       t.integer :month, :limit => 2
+       t.integer :year, :limit => 5
+       t.timestamps
+    end
+    add_index(:rails_admin_histories, [:item, :table, :month, :year], :name => 'index_rails_admin_histories' )
+  end
+
+  def self.down
+    drop_table :rails_admin_histories
+  end
+end

+ 49 - 0
db/migrate/20130516033045_devise_create_admin_users.rb

@@ -0,0 +1,49 @@
+class DeviseCreateAdminUsers < ActiveRecord::Migration
+  def change
+    create_table(:admin_users) do |t|
+      ## Database authenticatable
+      t.string :email,              :null => false, :default => ""
+      t.string :encrypted_password, :null => false, :default => ""
+
+      t.string :name,               :null => false, :default => ""
+      t.boolean :is_super_admin,    :null => false, :default => false
+
+      ## Recoverable
+      t.string   :reset_password_token
+      t.datetime :reset_password_sent_at
+
+      ## Rememberable
+      t.datetime :remember_created_at
+
+      ## Trackable
+      t.integer  :sign_in_count, :default => 0
+      t.datetime :current_sign_in_at
+      t.datetime :last_sign_in_at
+      t.string   :current_sign_in_ip
+      t.string   :last_sign_in_ip
+
+      ## Confirmable
+      # t.string   :confirmation_token
+      # t.datetime :confirmed_at
+      # t.datetime :confirmation_sent_at
+      # t.string   :unconfirmed_email # Only if using reconfirmable
+
+      ## Lockable
+      # t.integer  :failed_attempts, :default => 0 # Only if lock strategy is :failed_attempts
+      # t.string   :unlock_token # Only if unlock strategy is :email or :both
+      # t.datetime :locked_at
+
+      ## Token authenticatable
+      # t.string :authentication_token
+
+
+      t.timestamps
+    end
+
+    add_index :admin_users, :email,                :unique => true
+    add_index :admin_users, :reset_password_token, :unique => true
+    # add_index :admin_users, :confirmation_token,   :unique => true
+    # add_index :admin_users, :unlock_token,         :unique => true
+    # add_index :admin_users, :authentication_token, :unique => true
+  end
+end

+ 26 - 0
db/migrate/20130516183705_create_ckeditor_assets.rb

@@ -0,0 +1,26 @@
+class CreateCkeditorAssets < ActiveRecord::Migration
+  def self.up
+    create_table :ckeditor_assets do |t|
+      t.string  :data_file_name, :null => false
+      t.string  :data_content_type
+      t.integer :data_file_size
+      
+      t.integer :assetable_id
+      t.string  :assetable_type, :limit => 30
+      t.string  :type, :limit => 30
+
+      # Uncomment	it to save images dimensions, if your need it
+      t.integer :width
+      t.integer :height
+
+      t.timestamps
+    end
+    
+    add_index "ckeditor_assets", ["assetable_type", "type", "assetable_id"], :name => "idx_ckeditor_assetable_type"
+    add_index "ckeditor_assets", ["assetable_type", "assetable_id"], :name => "idx_ckeditor_assetable"
+  end
+
+  def self.down
+    drop_table :ckeditor_assets
+  end
+end

+ 8 - 0
db/migrate/20130625024300_create_admin_permissions.rb

@@ -0,0 +1,8 @@
+class CreateAdminPermissions < ActiveRecord::Migration
+  def change
+    create_table :admin_permissions do |t|
+      t.string :model,      :null => false
+      t.string :can,        :null => false
+    end
+  end
+end

+ 0 - 0
db/migrate/20130625024430_create_admin_roles.rb


이 변경점에서 너무 많은 파일들이 변경되어 몇몇 파일들은 표시되지 않았습니다.