Compare commits
69 Commits
Author | SHA1 | Date |
---|---|---|
lovelyzhang | 90385bafcf | |
lovelyzhang | 6904dce21e | |
lovelyzhang | dc6569c4dd | |
lovelyzhang | 790ac40def | |
lovelyzhang | 49138c748b | |
lovelyzhang | 9dad27c6da | |
lovelyzhang | c29cd77767 | |
lovelyzhang | a4b1ac9448 | |
lovelyzhang | 45c05a4881 | |
lovelyzhang | b601bcf6f1 | |
lovelyzhang | 143e384838 | |
lovelyzhang | 9bf238a96e | |
lovelyzhang | d20cb8ec83 | |
lovelyzhang | 1746c9dde7 | |
lovelyzhang | 92821cfd87 | |
lovelyzhang | 2c21dc9142 | |
lovelyzhang | b18ed5c4e0 | |
lovelyzhang | 40f8bfc049 | |
lovelyzhang | face9b417f | |
lovelyzhang | af26c41a7d | |
lovelyzhang | 4a24c82a0e | |
lovelyzhang | 11410f9b86 | |
lovelyzhang | b42036399e | |
lovelyzhang | 910246f78d | |
lovelyzhang | 25c738414d | |
lovelyzhang | 962900f274 | |
lovelyzhang | 0b5691a99b | |
lovelyzhang | 701a151602 | |
lovelyzhang | d35c37f7dd | |
lovelyzhang | 5d2d576cdf | |
lovelyzhang | 52d6b1bf8f | |
lovelyzhang | 0c0f725ec6 | |
lovelyzhang | 9b4215db04 | |
lovelyzhang | a18ac0c3d8 | |
lovelyzhang | b8a5cea995 | |
BaiFangzhou | 98ee5aea5a | |
lovelyzhang | a7cae21e7c | |
lovelyzhang | b599305816 | |
lovelyzhang | 80a4d13dbb | |
lovelyzhang | 7e0c882bb7 | |
lovelyzhang | 3fe03812e9 | |
lovelyzhang | dcdd5a225a | |
lovelyzhang | c0ba62107f | |
lovelyzhang | 79a3b58382 | |
lovelyzhang | ac33a06e92 | |
lovelyzhang | 19fc06d990 | |
lovelyzhang | 38c737b360 | |
yjx | 2a644cb60b | |
yjx | c317cfa851 | |
lovelyzhang | be63444463 | |
lovelyzhang | e934a901ee | |
lovelyzhang | 775a8b2f6f | |
BaiFangzhou | 91357e6026 | |
lovelyzhang | 3da3d00232 | |
lovelyzhang | 346ddd1e06 | |
lovelyzhang | 759bd82ad7 | |
lovelyzhang | 3416ad6bb6 | |
lovelyzhang | df353360f5 | |
lovelyzhang | 6c7c4483f0 | |
lovelyzhang | 6fc7ec9d88 | |
lovelyzhang | ff5f2f6ea3 | |
lovelyzhang | 2a0f6ec167 | |
Lieber2016 | 5241346ad5 | |
lovelyzhang | c5cbe7128f | |
lovelyzhang | 9a221afbb0 | |
lovelyzhang | a7c044c53c | |
lovelyzhang | bf07e74ece | |
lovelyzhang | 402725a795 | |
joe | 2428b90a23 |
|
@ -0,0 +1,109 @@
|
|||
# Ruby的忽略文件
|
||||
*.gem
|
||||
*.rbc
|
||||
/.config
|
||||
/coverage/
|
||||
/InstalledFiles
|
||||
/pkg/
|
||||
/spec/reports/
|
||||
/spec/examples.txt
|
||||
/test/tmp/
|
||||
/test/version_tmp/
|
||||
/tmp/
|
||||
|
||||
# Used by dotenv library to load environment variables.
|
||||
# .env
|
||||
|
||||
## Specific to RubyMotion:
|
||||
.dat*
|
||||
.repl_history
|
||||
build/
|
||||
*.bridgesupport
|
||||
build-iPhoneOS/
|
||||
build-iPhoneSimulator/
|
||||
|
||||
## Specific to RubyMotion (use of CocoaPods):
|
||||
#
|
||||
# We recommend against adding the Pods directory to your .gitignore. However
|
||||
# you should judge for yourself, the pros and cons are mentioned at:
|
||||
# https://guides.cocoapods.org/using/using-cocoapods.html#should-i-check-the-pods-directory-into-source-control
|
||||
#
|
||||
# vendor/Pods/
|
||||
|
||||
## Documentation cache and generated files:
|
||||
/.yardoc/
|
||||
/_yardoc/
|
||||
/doc/
|
||||
/rdoc/
|
||||
|
||||
## Environment normalization:
|
||||
/.bundle/
|
||||
/vendor/bundle
|
||||
/lib/bundler/man/
|
||||
|
||||
# for a library or gem, you might want to ignore these files since the code is
|
||||
# intended to run in multiple environments; otherwise, check them in:
|
||||
# Gemfile.lock
|
||||
# .ruby-version
|
||||
# .ruby-gemset
|
||||
|
||||
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
||||
.rvmrc
|
||||
|
||||
# JetBrain的忽略文件
|
||||
.idea/*
|
||||
public/data/*
|
||||
public/userpics/*
|
||||
|
||||
# rails的忽略文件
|
||||
|
||||
*.rbc
|
||||
capybara-*.html
|
||||
.rspec
|
||||
/log/*
|
||||
/tmp/*
|
||||
|
||||
/public/system
|
||||
/coverage/
|
||||
/spec/tmp
|
||||
**.orig
|
||||
rerun.txt
|
||||
pickle-email-*.html
|
||||
|
||||
# TODO Comment out this rule if you are OK with secrets being uploaded to the repo
|
||||
config/initializers/secret_token.rb
|
||||
|
||||
# Only include if you have production secrets in this file, which is no longer a Rails default
|
||||
# config/secrets.yml
|
||||
|
||||
# dotenv
|
||||
# TODO Comment out this rule if environment variables can be committed
|
||||
.env
|
||||
|
||||
## Environment normalization:
|
||||
/.bundle
|
||||
/vendor/bundle
|
||||
|
||||
# these should all be checked in to normalize the environment:
|
||||
# Gemfile.lock, .ruby-version, .ruby-gemset
|
||||
|
||||
# unless supporting rvm < 1.11.0 or doing something fancy, ignore this:
|
||||
.rvmrc
|
||||
|
||||
# if using bower-rails ignore default bower_components path bower.json files
|
||||
/vendor/assets/bower_components
|
||||
*.bowerrc
|
||||
bower.json
|
||||
|
||||
# Ignore pow environment settings
|
||||
.powenv
|
||||
|
||||
# Ignore Byebug command history file.
|
||||
.byebug_history
|
||||
|
||||
db/*.sqlite3
|
||||
logs.txt
|
||||
|
||||
|
||||
|
||||
|
|
@ -0,0 +1,35 @@
|
|||
1.登录
|
||||
是否只输入用户名不输入密码就可以直接登录。
|
||||
2.内容更新
|
||||
发表的状态、组团信息以及评论私信等是否在发表后就得以显示并按时间顺序显示。
|
||||
3.用户名查找
|
||||
当用户更改用户名之后是否还可以通过原用户名来查找到该用户。
|
||||
4.用户交流
|
||||
用户之间的评论私信会与用户对应,是否会出现信息混淆的现象。是否会不能评论或不能发私信。
|
||||
5.报名信息
|
||||
组团活动报名,失物招领领取是否会随着有人报名而及时更新,发布人是否也可以看到这些信息。
|
||||
6.评论以及动态发送
|
||||
输入评论后是否按回车可以直接发送,输入空白的是否会发送?
|
||||
是否输入空白依然可以发送我的动态?
|
||||
7.图片上传
|
||||
正常的图片上传后是否会模糊
|
||||
图片所能使用的格式
|
||||
图片上传后是否会出现断裂、压缩、丢失,或无法显示。
|
||||
8.删除
|
||||
所发表的内容、评论以及私信,在删除后是否会彻底消失,还是依然存在。
|
||||
9.文字显示
|
||||
发表的内容文字过多时,是否会排版错误,显示错误。
|
||||
10.文本字符
|
||||
字符判断,手机号只能输入数字。
|
||||
11.翻页
|
||||
翻页时,没有加载数据为空,第二页数据没有请求
|
||||
翻页时,一直重复请求第一页的数据
|
||||
翻页时,没有图片的内容有时候会引用有图片的内容
|
||||
12.截止时间
|
||||
组团活动超过截止时间之后,是否会显示停止报名。
|
||||
13.个人资料
|
||||
用户修改个人资料后资料是否进行保存,头像是否有变化。
|
||||
14.导航功能
|
||||
界面的各导航模块可以实现正确的导航,是否会出现导航错乱的现象。
|
||||
15.退出
|
||||
用户点击退出之后,是否会退出当前帐号,并回到登陆界面重新进行登录。
|
|
@ -0,0 +1,55 @@
|
|||
source 'https://rubygems.org'
|
||||
|
||||
gem 'rake'
|
||||
# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
|
||||
gem 'rails', '~> 5.0.0', '>= 5.0.0.1'
|
||||
# Use sqlite3 as the database for Active Record
|
||||
# Use Puma as the app server
|
||||
gem 'puma', '~> 3.0'
|
||||
# Use SCSS for stylesheets
|
||||
gem 'sass-rails', '~> 5.0'
|
||||
# Use Uglifier as compressor for JavaScript assets
|
||||
gem 'uglifier', '>= 1.3.0'
|
||||
# Use CoffeeScript for .coffee assets and views
|
||||
gem 'coffee-rails', '~> 4.2'
|
||||
# See https://github.com/rails/execjs#readme for more supported runtimes
|
||||
# gem 'therubyracer', platforms: :ruby
|
||||
|
||||
# Use jquery as the JavaScript library
|
||||
gem 'jquery-rails'
|
||||
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
|
||||
gem 'turbolinks', '~> 5'
|
||||
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
|
||||
gem 'jbuilder', '~> 2.5'
|
||||
# Use Redis adapter to run Action Cable in production
|
||||
# gem 'redis', '~> 3.0'
|
||||
# Use ActiveModel has_secure_password
|
||||
gem 'bcrypt', '~> 3.1.7'
|
||||
# will_paginate
|
||||
gem 'will_paginate', '~> 3.1.0'
|
||||
gem 'sendgrid-ruby'
|
||||
|
||||
# Use Capistrano for deployment
|
||||
# gem 'capistrano-rails', group: :development
|
||||
|
||||
group :development, :test do
|
||||
gem 'sqlite3'
|
||||
# Call 'byebug' anywhere in the code to stop execution and get a debugger console
|
||||
gem 'byebug', platform: :mri
|
||||
end
|
||||
|
||||
group :development do
|
||||
# Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
|
||||
gem 'web-console'
|
||||
gem 'listen', '~> 3.0.5'
|
||||
# Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
|
||||
gem 'spring'
|
||||
gem 'spring-watcher-listen', '~> 2.0.0'
|
||||
end
|
||||
|
||||
group :production do
|
||||
gem 'pg'
|
||||
end
|
||||
|
||||
# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
|
||||
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
|
|
@ -0,0 +1,194 @@
|
|||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
actioncable (5.0.0.1)
|
||||
actionpack (= 5.0.0.1)
|
||||
nio4r (~> 1.2)
|
||||
websocket-driver (~> 0.6.1)
|
||||
actionmailer (5.0.0.1)
|
||||
actionpack (= 5.0.0.1)
|
||||
actionview (= 5.0.0.1)
|
||||
activejob (= 5.0.0.1)
|
||||
mail (~> 2.5, >= 2.5.4)
|
||||
rails-dom-testing (~> 2.0)
|
||||
actionpack (5.0.0.1)
|
||||
actionview (= 5.0.0.1)
|
||||
activesupport (= 5.0.0.1)
|
||||
rack (~> 2.0)
|
||||
rack-test (~> 0.6.3)
|
||||
rails-dom-testing (~> 2.0)
|
||||
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
||||
actionview (5.0.0.1)
|
||||
activesupport (= 5.0.0.1)
|
||||
builder (~> 3.1)
|
||||
erubis (~> 2.7.0)
|
||||
rails-dom-testing (~> 2.0)
|
||||
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
||||
activejob (5.0.0.1)
|
||||
activesupport (= 5.0.0.1)
|
||||
globalid (>= 0.3.6)
|
||||
activemodel (5.0.0.1)
|
||||
activesupport (= 5.0.0.1)
|
||||
activerecord (5.0.0.1)
|
||||
activemodel (= 5.0.0.1)
|
||||
activesupport (= 5.0.0.1)
|
||||
arel (~> 7.0)
|
||||
activesupport (5.0.0.1)
|
||||
concurrent-ruby (~> 1.0, >= 1.0.2)
|
||||
i18n (~> 0.7)
|
||||
minitest (~> 5.1)
|
||||
tzinfo (~> 1.1)
|
||||
arel (7.1.4)
|
||||
bcrypt (3.1.11)
|
||||
bcrypt (3.1.11-x64-mingw32)
|
||||
builder (3.2.2)
|
||||
byebug (9.0.6)
|
||||
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)
|
||||
concurrent-ruby (1.0.2)
|
||||
debug_inspector (0.0.2)
|
||||
erubis (2.7.0)
|
||||
execjs (2.7.0)
|
||||
ffi (1.9.14)
|
||||
ffi (1.9.14-x64-mingw32)
|
||||
globalid (0.3.7)
|
||||
activesupport (>= 4.1.0)
|
||||
i18n (0.7.0)
|
||||
jbuilder (2.6.0)
|
||||
activesupport (>= 3.0.0, < 5.1)
|
||||
multi_json (~> 1.2)
|
||||
jquery-rails (4.2.1)
|
||||
rails-dom-testing (>= 1, < 3)
|
||||
railties (>= 4.2.0)
|
||||
thor (>= 0.14, < 2.0)
|
||||
listen (3.0.8)
|
||||
rb-fsevent (~> 0.9, >= 0.9.4)
|
||||
rb-inotify (~> 0.9, >= 0.9.7)
|
||||
loofah (2.0.3)
|
||||
nokogiri (>= 1.5.9)
|
||||
mail (2.6.4)
|
||||
mime-types (>= 1.16, < 4)
|
||||
method_source (0.8.2)
|
||||
mime-types (3.1)
|
||||
mime-types-data (~> 3.2015)
|
||||
mime-types-data (3.2016.0521)
|
||||
mini_portile2 (2.1.0)
|
||||
minitest (5.9.1)
|
||||
multi_json (1.12.1)
|
||||
nio4r (1.2.1)
|
||||
nokogiri (1.6.8.1)
|
||||
mini_portile2 (~> 2.1.0)
|
||||
nokogiri (1.6.8.1-x64-mingw32)
|
||||
mini_portile2 (~> 2.1.0)
|
||||
pg (0.19.0)
|
||||
pg (0.19.0-x64-mingw32)
|
||||
puma (3.6.2)
|
||||
rack (2.0.1)
|
||||
rack-test (0.6.3)
|
||||
rack (>= 1.0)
|
||||
rails (5.0.0.1)
|
||||
actioncable (= 5.0.0.1)
|
||||
actionmailer (= 5.0.0.1)
|
||||
actionpack (= 5.0.0.1)
|
||||
actionview (= 5.0.0.1)
|
||||
activejob (= 5.0.0.1)
|
||||
activemodel (= 5.0.0.1)
|
||||
activerecord (= 5.0.0.1)
|
||||
activesupport (= 5.0.0.1)
|
||||
bundler (>= 1.3.0, < 2.0)
|
||||
railties (= 5.0.0.1)
|
||||
sprockets-rails (>= 2.0.0)
|
||||
rails-dom-testing (2.0.1)
|
||||
activesupport (>= 4.2.0, < 6.0)
|
||||
nokogiri (~> 1.6.0)
|
||||
rails-html-sanitizer (1.0.3)
|
||||
loofah (~> 2.0)
|
||||
railties (5.0.0.1)
|
||||
actionpack (= 5.0.0.1)
|
||||
activesupport (= 5.0.0.1)
|
||||
method_source
|
||||
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)
|
||||
ruby_http_client (3.0.0)
|
||||
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)
|
||||
sendgrid-ruby (4.0.6)
|
||||
ruby_http_client (~> 3.0.0)
|
||||
spring (2.0.0)
|
||||
activesupport (>= 4.2)
|
||||
spring-watcher-listen (2.0.1)
|
||||
listen (>= 2.7, < 4.0)
|
||||
spring (>= 1.2, < 3.0)
|
||||
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)
|
||||
sqlite3 (1.3.12)
|
||||
sqlite3 (1.3.12-x64-mingw32)
|
||||
thor (0.19.1)
|
||||
thread_safe (0.3.5)
|
||||
tilt (2.0.5)
|
||||
turbolinks (5.0.1)
|
||||
turbolinks-source (~> 5)
|
||||
turbolinks-source (5.0.0)
|
||||
tzinfo (1.2.2)
|
||||
thread_safe (~> 0.1)
|
||||
tzinfo-data (1.2016.10)
|
||||
tzinfo (>= 1.0.0)
|
||||
uglifier (3.0.3)
|
||||
execjs (>= 0.3.0, < 3)
|
||||
web-console (3.4.0)
|
||||
actionview (>= 5.0)
|
||||
activemodel (>= 5.0)
|
||||
debug_inspector
|
||||
railties (>= 5.0)
|
||||
websocket-driver (0.6.4)
|
||||
websocket-extensions (>= 0.1.0)
|
||||
websocket-extensions (0.1.2)
|
||||
will_paginate (3.1.5)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
x64-mingw32
|
||||
|
||||
DEPENDENCIES
|
||||
bcrypt (~> 3.1.7)
|
||||
byebug
|
||||
coffee-rails (~> 4.2)
|
||||
jbuilder (~> 2.5)
|
||||
jquery-rails
|
||||
listen (~> 3.0.5)
|
||||
pg
|
||||
puma (~> 3.0)
|
||||
rails (~> 5.0.0, >= 5.0.0.1)
|
||||
rake
|
||||
sass-rails (~> 5.0)
|
||||
sendgrid-ruby
|
||||
spring
|
||||
spring-watcher-listen (~> 2.0.0)
|
||||
sqlite3
|
||||
turbolinks (~> 5)
|
||||
tzinfo-data
|
||||
uglifier (>= 1.3.0)
|
||||
web-console
|
||||
will_paginate (~> 3.1.0)
|
||||
|
||||
BUNDLED WITH
|
||||
1.13.6
|
|
@ -0,0 +1,178 @@
|
|||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
actioncable (5.0.0.1)
|
||||
actionpack (= 5.0.0.1)
|
||||
nio4r (~> 1.2)
|
||||
websocket-driver (~> 0.6.1)
|
||||
actionmailer (5.0.0.1)
|
||||
actionpack (= 5.0.0.1)
|
||||
actionview (= 5.0.0.1)
|
||||
activejob (= 5.0.0.1)
|
||||
mail (~> 2.5, >= 2.5.4)
|
||||
rails-dom-testing (~> 2.0)
|
||||
actionpack (5.0.0.1)
|
||||
actionview (= 5.0.0.1)
|
||||
activesupport (= 5.0.0.1)
|
||||
rack (~> 2.0)
|
||||
rack-test (~> 0.6.3)
|
||||
rails-dom-testing (~> 2.0)
|
||||
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
||||
actionview (5.0.0.1)
|
||||
activesupport (= 5.0.0.1)
|
||||
builder (~> 3.1)
|
||||
erubis (~> 2.7.0)
|
||||
rails-dom-testing (~> 2.0)
|
||||
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
||||
activejob (5.0.0.1)
|
||||
activesupport (= 5.0.0.1)
|
||||
globalid (>= 0.3.6)
|
||||
activemodel (5.0.0.1)
|
||||
activesupport (= 5.0.0.1)
|
||||
activerecord (5.0.0.1)
|
||||
activemodel (= 5.0.0.1)
|
||||
activesupport (= 5.0.0.1)
|
||||
arel (~> 7.0)
|
||||
activesupport (5.0.0.1)
|
||||
concurrent-ruby (~> 1.0, >= 1.0.2)
|
||||
i18n (~> 0.7)
|
||||
minitest (~> 5.1)
|
||||
tzinfo (~> 1.1)
|
||||
arel (7.1.4)
|
||||
bcrypt (3.1.11)
|
||||
builder (3.2.2)
|
||||
byebug (9.0.6)
|
||||
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)
|
||||
concurrent-ruby (1.0.2)
|
||||
debug_inspector (0.0.2)
|
||||
erubis (2.7.0)
|
||||
execjs (2.7.0)
|
||||
ffi (1.9.14)
|
||||
globalid (0.3.7)
|
||||
activesupport (>= 4.1.0)
|
||||
i18n (0.7.0)
|
||||
jbuilder (2.6.0)
|
||||
activesupport (>= 3.0.0, < 5.1)
|
||||
multi_json (~> 1.2)
|
||||
jquery-rails (4.2.1)
|
||||
rails-dom-testing (>= 1, < 3)
|
||||
railties (>= 4.2.0)
|
||||
thor (>= 0.14, < 2.0)
|
||||
listen (3.0.8)
|
||||
rb-fsevent (~> 0.9, >= 0.9.4)
|
||||
rb-inotify (~> 0.9, >= 0.9.7)
|
||||
loofah (2.0.3)
|
||||
nokogiri (>= 1.5.9)
|
||||
mail (2.6.4)
|
||||
mime-types (>= 1.16, < 4)
|
||||
method_source (0.8.2)
|
||||
mime-types (3.1)
|
||||
mime-types-data (~> 3.2015)
|
||||
mime-types-data (3.2016.0521)
|
||||
mini_portile2 (2.1.0)
|
||||
minitest (5.9.1)
|
||||
multi_json (1.12.1)
|
||||
nio4r (1.2.1)
|
||||
nokogiri (1.6.8.1)
|
||||
mini_portile2 (~> 2.1.0)
|
||||
pg (0.18.4)
|
||||
puma (3.6.2)
|
||||
rack (2.0.1)
|
||||
rack-test (0.6.3)
|
||||
rack (>= 1.0)
|
||||
rails (5.0.0.1)
|
||||
actioncable (= 5.0.0.1)
|
||||
actionmailer (= 5.0.0.1)
|
||||
actionpack (= 5.0.0.1)
|
||||
actionview (= 5.0.0.1)
|
||||
activejob (= 5.0.0.1)
|
||||
activemodel (= 5.0.0.1)
|
||||
activerecord (= 5.0.0.1)
|
||||
activesupport (= 5.0.0.1)
|
||||
bundler (>= 1.3.0, < 2.0)
|
||||
railties (= 5.0.0.1)
|
||||
sprockets-rails (>= 2.0.0)
|
||||
rails-dom-testing (2.0.1)
|
||||
activesupport (>= 4.2.0, < 6.0)
|
||||
nokogiri (~> 1.6.0)
|
||||
rails-html-sanitizer (1.0.3)
|
||||
loofah (~> 2.0)
|
||||
railties (5.0.0.1)
|
||||
actionpack (= 5.0.0.1)
|
||||
activesupport (= 5.0.0.1)
|
||||
method_source
|
||||
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)
|
||||
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)
|
||||
spring (2.0.0)
|
||||
activesupport (>= 4.2)
|
||||
spring-watcher-listen (2.0.1)
|
||||
listen (>= 2.7, < 4.0)
|
||||
spring (>= 1.2, < 3.0)
|
||||
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)
|
||||
sqlite3 (1.3.12)
|
||||
thor (0.19.1)
|
||||
thread_safe (0.3.5)
|
||||
tilt (2.0.5)
|
||||
turbolinks (5.0.1)
|
||||
turbolinks-source (~> 5)
|
||||
turbolinks-source (5.0.0)
|
||||
tzinfo (1.2.2)
|
||||
thread_safe (~> 0.1)
|
||||
uglifier (3.0.3)
|
||||
execjs (>= 0.3.0, < 3)
|
||||
web-console (3.4.0)
|
||||
actionview (>= 5.0)
|
||||
activemodel (>= 5.0)
|
||||
debug_inspector
|
||||
railties (>= 5.0)
|
||||
websocket-driver (0.6.4)
|
||||
websocket-extensions (>= 0.1.0)
|
||||
websocket-extensions (0.1.2)
|
||||
|
||||
PLATFORMS
|
||||
ruby
|
||||
|
||||
DEPENDENCIES
|
||||
bcrypt (~> 3.1.7)
|
||||
byebug
|
||||
coffee-rails (~> 4.2)
|
||||
jbuilder (~> 2.5)
|
||||
jquery-rails
|
||||
listen (~> 3.0.5)
|
||||
pg (~> 0.18.4)
|
||||
puma (~> 3.0)
|
||||
rails (~> 5.0.0, >= 5.0.0.1)
|
||||
sass-rails (~> 5.0)
|
||||
spring
|
||||
spring-watcher-listen (~> 2.0.0)
|
||||
sqlite3
|
||||
turbolinks (~> 5)
|
||||
tzinfo-data
|
||||
uglifier (>= 1.3.0)
|
||||
web-console
|
||||
|
||||
BUNDLED WITH
|
||||
1.13.6
|
|
@ -0,0 +1,24 @@
|
|||
# README
|
||||
|
||||
This README would normally document whatever steps are necessary to get the
|
||||
application up and running.
|
||||
|
||||
Things you may want to cover:
|
||||
|
||||
* Ruby version
|
||||
|
||||
* System dependencies
|
||||
|
||||
* Configuration
|
||||
|
||||
* Database creation
|
||||
|
||||
* Database initialization
|
||||
|
||||
* How to run the test suite
|
||||
|
||||
* Services (job queues, cache servers, search engines, etc.)
|
||||
|
||||
* Deployment instructions
|
||||
|
||||
* ...
|
|
@ -0,0 +1,6 @@
|
|||
# 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_relative 'config/application'
|
||||
|
||||
Rails.application.load_tasks
|
|
@ -0,0 +1,3 @@
|
|||
//= link_tree ../images
|
||||
//= link_directory ../javascripts .js
|
||||
//= link_directory ../stylesheets .css
|
|
@ -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 any plugin's vendor/assets/javascripts directory 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
|
||||
// compiled file. JavaScript code in this file should be added after the last require_* statement.
|
||||
//
|
||||
// Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details
|
||||
// about supported directives.
|
||||
//
|
||||
//= require jquery
|
||||
//= require jquery_ujs
|
||||
//= require turbolinks
|
||||
//= require_tree .
|
|
@ -0,0 +1,13 @@
|
|||
// Action Cable provides the framework to deal with WebSockets in Rails.
|
||||
// You can generate new channels where WebSocket features live using the rails generate channel command.
|
||||
//
|
||||
//= require action_cable
|
||||
//= require_self
|
||||
//= require_tree ./channels
|
||||
|
||||
(function() {
|
||||
this.App || (this.App = {});
|
||||
|
||||
App.cable = ActionCable.createConsumer();
|
||||
|
||||
}).call(this);
|
|
@ -0,0 +1,3 @@
|
|||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://coffeescript.org/
|
|
@ -0,0 +1,3 @@
|
|||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://coffeescript.org/
|
|
@ -0,0 +1,3 @@
|
|||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://coffeescript.org/
|
|
@ -0,0 +1,3 @@
|
|||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://coffeescript.org/
|
|
@ -0,0 +1,3 @@
|
|||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://coffeescript.org/
|
|
@ -0,0 +1,3 @@
|
|||
# Place all the behaviors and hooks related to the matching controller here.
|
||||
# All this logic will automatically be available in application.js.
|
||||
# You can use CoffeeScript in this file: http://coffeescript.org/
|
|
@ -0,0 +1,15 @@
|
|||
/*
|
||||
* 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 any plugin's vendor/assets/stylesheets directory 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 bottom of the
|
||||
* compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS
|
||||
* files in this directory. Styles in this file should be added after the last require_* statement.
|
||||
* It is generally better to create a new file per style scope.
|
||||
*
|
||||
*= require_tree .
|
||||
*= require_self
|
||||
*/
|
|
@ -0,0 +1,3 @@
|
|||
// Place all the styles related to the Chat controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
|
@ -0,0 +1,3 @@
|
|||
// Place all the styles related to the Comments controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
|
@ -0,0 +1,3 @@
|
|||
// Place all the styles related to the login controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
|
@ -0,0 +1,3 @@
|
|||
// Place all the styles related to the main controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
|
@ -0,0 +1,3 @@
|
|||
// Place all the styles related to the MicroPosts controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
|
@ -0,0 +1,3 @@
|
|||
// Place all the styles related to the users controller here.
|
||||
// They will automatically be included in application.css.
|
||||
// You can use Sass (SCSS) here: http://sass-lang.com/
|
|
@ -0,0 +1,4 @@
|
|||
module ApplicationCable
|
||||
class Channel < ActionCable::Channel::Base
|
||||
end
|
||||
end
|
|
@ -0,0 +1,4 @@
|
|||
module ApplicationCable
|
||||
class Connection < ActionCable::Connection::Base
|
||||
end
|
||||
end
|
|
@ -0,0 +1,16 @@
|
|||
class ApplicationController < ActionController::Base
|
||||
protect_from_forgery with: :exception
|
||||
|
||||
include ApplicationHelper
|
||||
include LoginHelper
|
||||
include UsersHelper
|
||||
|
||||
|
||||
# Confirms a logged-in user.
|
||||
def logged_in_user
|
||||
unless logged_in?
|
||||
flash[:danger] = "请先登录"
|
||||
redirect_to login_url
|
||||
end
|
||||
end
|
||||
end
|
|
@ -0,0 +1,100 @@
|
|||
class ChatController < ApplicationController
|
||||
before_action :logged_in_user
|
||||
|
||||
include ChatHelper
|
||||
|
||||
def index
|
||||
@user = current_user
|
||||
@current_chat_user_name = params[:chat_with]
|
||||
@chat_with_users = get_chat_with_users(@user)
|
||||
if !@current_chat_user_name.nil?
|
||||
@current_chat_user = User.find_by(name: @current_chat_user_name)
|
||||
if !@current_chat_user_name.nil?
|
||||
messages = process_messages(@user, @current_chat_user)
|
||||
render json: messages
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
def new
|
||||
# 用户发送新的消息
|
||||
|
||||
@user = current_user
|
||||
username = @user.name
|
||||
userpic = @user.picurl
|
||||
|
||||
msg = params[:msg]
|
||||
current_chat_user_name = params[:chat_with]
|
||||
current_chat_user = User.find_by(name: current_chat_user_name)
|
||||
save_time = DateTime.now
|
||||
msg_db = Message.new(content: msg, send_user: @user.id, recieve_user: current_chat_user.id,
|
||||
create_time: save_time, readed: false)
|
||||
|
||||
if msg_db.save
|
||||
render json: {username: username, userpic: userpic, content: msg, time: get_strftime(save_time)}
|
||||
else
|
||||
render json: {username: username, userpic: userpic, content: "error", time: get_strftime(save_time)}
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def notify
|
||||
# 获取未读短信数
|
||||
@user = current_user
|
||||
render json: {unreaded: unread_msg_num(@user)}
|
||||
end
|
||||
|
||||
|
||||
def online
|
||||
# # 获取未读短信和对对应的联系人
|
||||
@user = current_user
|
||||
results = unread_msg_users(@user)
|
||||
if results.empty?
|
||||
results = nil
|
||||
end
|
||||
render json: {users: results}
|
||||
end
|
||||
|
||||
def query
|
||||
# 添加新的联系人
|
||||
@user = current_user
|
||||
query_name = params[:username]
|
||||
all_user_names = params[:all]
|
||||
query_pic = String.new()
|
||||
|
||||
if all_user_names.nil?
|
||||
query_user = User.find_by(name: query_name)
|
||||
if query_user.nil?
|
||||
query_name = nil
|
||||
ok = false
|
||||
else
|
||||
if query_name == @user.name
|
||||
query_name = nil
|
||||
ok = false
|
||||
else
|
||||
query_name = query_user.name
|
||||
query_pic = query_user.picurl
|
||||
ok = true
|
||||
end
|
||||
end
|
||||
else
|
||||
if all_user_names.include? query_name or query_name == @user.name
|
||||
query_name = nil
|
||||
ok = false
|
||||
else
|
||||
query_user = User.find_by(name: query_name)
|
||||
if query_user.nil?
|
||||
query_name = nil
|
||||
ok = false
|
||||
else
|
||||
query_name = query_user.name
|
||||
query_pic = query_user.picurl
|
||||
ok = true
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
render json: {username: query_name, userpic: query_pic, ok: ok}
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,23 @@
|
|||
class CommentsController < ApplicationController
|
||||
include CommentsHelper
|
||||
|
||||
def get
|
||||
micropost_id = params["micropost_id"]
|
||||
micropost_comments = get_micropost_comments micropost_id
|
||||
render json: {comments: micropost_comments}
|
||||
end
|
||||
|
||||
def new
|
||||
@user = current_user
|
||||
username = @user.name
|
||||
userpic = @user.picurl
|
||||
content = params[:content].to_s
|
||||
micropost_id = params[:micropost_id]
|
||||
if !content.empty? and !micropost_id.nil?
|
||||
comments = @user.comments.new(content: content, micro_post_id: micropost_id, comment_time: DateTime.now)
|
||||
comments.save
|
||||
end
|
||||
render json: {username: username, userpic: userpic}
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,27 @@
|
|||
class LoginController < ApplicationController
|
||||
def init
|
||||
if logged_in?
|
||||
redirect_to main_path
|
||||
else
|
||||
render 'init'
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
def login
|
||||
user = User.find_by(email: params[:email].downcase)
|
||||
if user && user.authenticate(params[:password])
|
||||
log_in(user)
|
||||
redirect_to main_path
|
||||
else
|
||||
flash.now[:danger] = "用户名或者密码错误"
|
||||
render 'init'
|
||||
end
|
||||
end
|
||||
|
||||
def logout
|
||||
log_out
|
||||
redirect_to login_path
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,38 @@
|
|||
class MainController < ApplicationController
|
||||
include MainHelper
|
||||
before_action :logged_in_user
|
||||
|
||||
|
||||
def show
|
||||
@user = current_user
|
||||
page_num = params[:page]
|
||||
post_type = params[:type]
|
||||
|
||||
if !page_num
|
||||
page_num = 1
|
||||
end
|
||||
if !post_type
|
||||
post_type=[1, 2, 3]
|
||||
end
|
||||
|
||||
@posts = MicroPost.where(post_type: post_type).paginate(:page => page_num, :per_page => 10).order(post_time: :desc)
|
||||
@micro_posts_array = get_post(@posts)
|
||||
render 'main'
|
||||
|
||||
end
|
||||
|
||||
def activity
|
||||
@user = current_user
|
||||
micro_post_id = params[:micropost_id]
|
||||
join = params[:join].to_s
|
||||
|
||||
if join == "true"
|
||||
num, names = new_engaged_people(micro_post_id, current_user.name)
|
||||
else
|
||||
num, names = delete_engaged_people(micro_post_id, current_user.name)
|
||||
end
|
||||
|
||||
render json: {total_num: num, total_names: names}
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,49 @@
|
|||
class MicroPostsController < ApplicationController
|
||||
include MicroPostsHelper
|
||||
before_action :logged_in_user
|
||||
|
||||
|
||||
def show
|
||||
@user = current_user
|
||||
@micro_posts = read_each_post @user
|
||||
end
|
||||
|
||||
def new
|
||||
@user = current_user
|
||||
|
||||
post_type = params[:post_type].to_i
|
||||
title = params[:title].to_s
|
||||
content = params[:content].to_s
|
||||
pictures = params[:pictures]
|
||||
|
||||
if pictures
|
||||
pic_path = Array.new
|
||||
pictures.each do |pic|
|
||||
savename = savePicture(pic)
|
||||
pic_path << savename
|
||||
end
|
||||
pic_path = pic_path.join(',')
|
||||
end
|
||||
|
||||
if post_type >= 1 and post_type <= 3 and !title.empty? and !content.empty?
|
||||
micropost = @user.micro_posts.new(title: title, content: content, pic: pic_path,
|
||||
post_time: DateTime.now, post_type: post_type,
|
||||
engage_people: 1, engaged_people_names: current_user.name)
|
||||
micropost.save
|
||||
end
|
||||
redirect_to microposts_path
|
||||
end
|
||||
|
||||
def delete
|
||||
@user = current_user
|
||||
micropost_id = params[:micropost_id].to_i
|
||||
micropost_id = @user.micro_posts.find_by(id: micropost_id)
|
||||
if micropost_id
|
||||
micropost_id.destroy
|
||||
render json: {status:true}
|
||||
else
|
||||
render json: {status:false}
|
||||
end
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,148 @@
|
|||
class UsersController < ApplicationController
|
||||
|
||||
before_action :logged_in_user,except: [:new,:create,:forgetpasswd,:changepasswd]
|
||||
@@user_pics_dir = "public/userpics"
|
||||
|
||||
def new
|
||||
@user = User.new
|
||||
end
|
||||
|
||||
def create
|
||||
@user = User.new(user_params)
|
||||
if @user.save
|
||||
log_in @user
|
||||
redirect_to main_path
|
||||
else
|
||||
render 'new'
|
||||
end
|
||||
end
|
||||
|
||||
def edit
|
||||
@user = current_user
|
||||
render 'edit'
|
||||
end
|
||||
|
||||
|
||||
def update
|
||||
end
|
||||
|
||||
|
||||
def forgetpasswd
|
||||
useremail = params[:email]
|
||||
if useremail
|
||||
@user = User.find_by(email: useremail)
|
||||
if !@user.nil?
|
||||
send_code @user
|
||||
flash[:success] = "验证码已发送至您的邮箱"
|
||||
redirect_to changepasswd_path(email: @user.email)
|
||||
else
|
||||
flash[:danger] = "用户不存在"
|
||||
render 'forgetpasswd'
|
||||
end
|
||||
else
|
||||
render 'forgetpasswd'
|
||||
end
|
||||
end
|
||||
|
||||
def changepasswd
|
||||
if request.get?
|
||||
user_email = params[:email]
|
||||
if user_email
|
||||
@user = User.find_by(email: user_email)
|
||||
if !@user.nil?
|
||||
render 'changepasswd'
|
||||
else
|
||||
flash[:danger] = "用户不存在"
|
||||
redirect_to login_path
|
||||
end
|
||||
else
|
||||
redirect_to login_path
|
||||
end
|
||||
else
|
||||
result = check_change_params(params[:email], params[:verify_code], params[:password], params[:password_confirm])
|
||||
if result
|
||||
flash[:success]="密码更新成功"
|
||||
else
|
||||
flash[:danger]="密码更新失败"
|
||||
end
|
||||
redirect_to login_path
|
||||
end
|
||||
end
|
||||
|
||||
def changeprofile
|
||||
@user = current_user
|
||||
result, user, err_string = check_change_profile_params(params[:user])
|
||||
if result == false
|
||||
flash[:danger] = err_string
|
||||
else
|
||||
pic_url = save_user_pic params[:user][:pic]
|
||||
if pic_url.nil? == false
|
||||
user[:picurl] = pic_url
|
||||
end
|
||||
@user.update_attributes(user)
|
||||
end
|
||||
redirect_to profile_path
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def user_params
|
||||
params.require(:user).permit(:name, :email, :password,
|
||||
:password_confirmation)
|
||||
end
|
||||
|
||||
def check_change_profile_params user_params
|
||||
if user_params.nil?
|
||||
return false, nil, "修改参数为空"
|
||||
end
|
||||
if user_params[:username].length <= 0
|
||||
return false, nil, "姓名错误"
|
||||
end
|
||||
user = Hash.new
|
||||
user[:name] = user_params[:username]
|
||||
user[:profession] = user_params[:profession]
|
||||
user[:sexual] = user_params[:sexual]
|
||||
return true, user, nil
|
||||
end
|
||||
|
||||
def save_user_pic pic
|
||||
if pic.nil?
|
||||
return nil
|
||||
end
|
||||
if !(File.directory? @@user_pics_dir)
|
||||
FileUtils.mkdir_p(@@user_pics_dir)
|
||||
end
|
||||
ext = File.extname(pic.original_filename)
|
||||
timestamp = Time.now.to_s
|
||||
picname = Digest::MD5::hexdigest(pic.original_filename + timestamp) + ext
|
||||
File.open(File.join(@@user_pics_dir, picname), 'wb') { |f| f.write(pic.read) }
|
||||
save_name = File.join("userpics", picname)
|
||||
return save_name
|
||||
end
|
||||
|
||||
def send_code user
|
||||
verify_code = rand(999999).to_s
|
||||
result = UserMailer.send_verify_code(user.email, verify_code).deliver_now
|
||||
p result
|
||||
user.update_attribute(:verify_code, verify_code)
|
||||
end
|
||||
|
||||
def check_change_params(email, verify_code, password, password_confirmation)
|
||||
if password != password_confirmation
|
||||
return false
|
||||
end
|
||||
user = User.find_by(email: email)
|
||||
if user.nil?
|
||||
return false
|
||||
end
|
||||
if user.verify_code != verify_code
|
||||
return false
|
||||
end
|
||||
hold = Hash.new
|
||||
hold[:password] = password
|
||||
hold[:password_confirmation] = password_confirmation
|
||||
user.update_attributes(hold)
|
||||
return true
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,9 @@
|
|||
module ApplicationHelper
|
||||
|
||||
def get_strftime intime
|
||||
# 将数据库中的UTC时间转换为本地时间
|
||||
return intime.utc.in_time_zone('Beijing').strftime(format='%F %T')
|
||||
end
|
||||
|
||||
|
||||
end
|
|
@ -0,0 +1,78 @@
|
|||
module ChatHelper
|
||||
|
||||
|
||||
def get_chat_with_users user
|
||||
# 获得与当前用户有聊天记录的用户
|
||||
chat_with_users = {}
|
||||
|
||||
user.recieve_messages.where(readed: true).select(:send_user).distinct.each do |chat|
|
||||
temp_user_id = chat.send_user
|
||||
find_user = User.find(temp_user_id)
|
||||
user_name_sym = find_user.name.to_sym
|
||||
chat_with_users[user_name_sym] = true
|
||||
end
|
||||
|
||||
user.send_messages.select(:recieve_user).distinct.each do |chat|
|
||||
temp_user_id = chat.recieve_user
|
||||
find_user = User.find(temp_user_id)
|
||||
user_name_sym = find_user.name.to_sym
|
||||
chat_with_users[user_name_sym] = true
|
||||
end
|
||||
|
||||
user.recieve_messages.where(readed: false).select(:send_user).distinct.each do |chat|
|
||||
temp_user_id = chat.send_user
|
||||
find_user = User.find(temp_user_id)
|
||||
user_name_sym = find_user.name.to_sym
|
||||
chat_with_users[user_name_sym] = false
|
||||
end
|
||||
|
||||
return chat_with_users
|
||||
|
||||
end
|
||||
|
||||
def process_messages(user, chat_with)
|
||||
# 处理用户对话(消息)
|
||||
results = []
|
||||
|
||||
Message.transaction do
|
||||
messages = Message.lock.where(send_user: [user.id, chat_with.id],
|
||||
recieve_user: [user.id, chat_with.id])
|
||||
|
||||
if messages.length >= 1
|
||||
messages = messages.order(create_time: :asc)
|
||||
messages.each do |message|
|
||||
if message.send_user == user.id
|
||||
x = {issend: true, name: user.name, userpic: user.picurl,
|
||||
content: message.content, time: get_strftime(message.create_time)}
|
||||
else
|
||||
message.readed = true
|
||||
message.save
|
||||
x = {issend: false, name: chat_with.name, userpic: chat_with.picurl,
|
||||
content: message.content, time: get_strftime(message.create_time)}
|
||||
end
|
||||
results << x
|
||||
end
|
||||
end
|
||||
end
|
||||
results
|
||||
end
|
||||
|
||||
def unread_msg_num user
|
||||
# 未读消息数目
|
||||
user.recieve_messages.where(readed: false).count
|
||||
end
|
||||
|
||||
def unread_msg_users user
|
||||
# 未读消息的用户
|
||||
return_user_msg = {}
|
||||
results = user.recieve_messages.where(readed: false)
|
||||
if results.length != 0
|
||||
results.each do |result|
|
||||
username = User.find(result.send_user).name
|
||||
return_user_msg[username] = [];
|
||||
return_user_msg[username] <<result.content;
|
||||
end
|
||||
end
|
||||
return_user_msg
|
||||
end
|
||||
end
|
|
@ -0,0 +1,18 @@
|
|||
module CommentsHelper
|
||||
def get_micropost_comments micropost_id
|
||||
comments_array = Array.new()
|
||||
micropost = MicroPost.find_by(id: micropost_id)
|
||||
comments = micropost.comments.order(comment_time: :desc)
|
||||
if !comments.empty?
|
||||
comments.each do |com|
|
||||
temp = Hash.new()
|
||||
temp["username"] = com.user.name
|
||||
temp["userpic"] = com.user.picurl
|
||||
temp["content"] = com.content
|
||||
comments_array << temp
|
||||
end
|
||||
end
|
||||
return comments_array
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,29 @@
|
|||
module LoginHelper
|
||||
# Logs in the given user.
|
||||
def log_in(user)
|
||||
session[:user_id] = user.id
|
||||
end
|
||||
|
||||
# Returns true if the given user is the current user.
|
||||
def current_user?(user)
|
||||
user == current_user
|
||||
end
|
||||
|
||||
# Returns the user corresponding to the remember token cookie.
|
||||
def current_user
|
||||
user_id = session[:user_id]
|
||||
@current_user ||= User.find_by(id: user_id)
|
||||
end
|
||||
|
||||
# Returns true if the user is logged in, false otherwise.
|
||||
def logged_in?
|
||||
!current_user.nil?
|
||||
end
|
||||
|
||||
# Logs out the current user.
|
||||
def log_out
|
||||
session.delete(:user_id)
|
||||
@current_user = nil
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,97 @@
|
|||
module MainHelper
|
||||
|
||||
def get_post posts
|
||||
micro_posts_array = []
|
||||
if !posts.empty?
|
||||
posts.each do |micro_post|
|
||||
x = Hash.new()
|
||||
x["username"] = micro_post.user.name
|
||||
x["userpic"] = micro_post.user.picurl
|
||||
x["postid"] = micro_post.id
|
||||
x["title"] = micro_post.title
|
||||
x["content"] = micro_post.content
|
||||
case micro_post.post_type
|
||||
when 1
|
||||
x["type"] = "新鲜事"
|
||||
when 2
|
||||
x["type"] = "组团信息"
|
||||
when 3
|
||||
x["type"] = "失物招领"
|
||||
else
|
||||
x["type"] = "新鲜事"
|
||||
end
|
||||
x["time"] = get_strftime(micro_post.post_time)
|
||||
x["pics"] = micro_post.pic.split(',') if micro_post.pic
|
||||
x["peo_num"] = micro_post.engage_people
|
||||
micro_posts_array << x
|
||||
end
|
||||
end
|
||||
return micro_posts_array
|
||||
end
|
||||
|
||||
def get_engaged_people micropost_id
|
||||
# 获得参加活动的人数和姓名
|
||||
MicroPost.transaction do
|
||||
micropost = MicroPost.lock.find_by(id: micropost_id)
|
||||
engage_people = micropost.engage_people
|
||||
engage_people_name = micropost.engaged_people_names
|
||||
return engage_people, engage_people_name
|
||||
end
|
||||
end
|
||||
|
||||
def save_engaged_people(micropost_id, num, names)
|
||||
# 将参加活动的人数和姓名存入数据库中
|
||||
MicroPost.transaction do
|
||||
micropost = MicroPost.lock.find_by(id: micropost_id)
|
||||
micropost.engage_people = num
|
||||
micropost.engaged_people_names = names
|
||||
micropost.save
|
||||
end
|
||||
end
|
||||
|
||||
def new_engaged_people(micropost_id, name)
|
||||
# 新参加活动登记
|
||||
engage_people, engage_people_names = get_engaged_people micropost_id
|
||||
if engage_people_names.nil?
|
||||
engage_people += 1
|
||||
engage_people_names = name
|
||||
else
|
||||
engage_people_names = engage_people_names.split(',')
|
||||
if engage_people_names.include?(name) != true
|
||||
engage_people_names << name
|
||||
engage_people += 1
|
||||
end
|
||||
engage_people_names = engage_people_names.join(',')
|
||||
end
|
||||
save_engaged_people(micropost_id, engage_people, engage_people_names)
|
||||
return engage_people, engage_people_names
|
||||
end
|
||||
|
||||
def delete_engaged_people(micropost_id, name)
|
||||
# 退出活动登记
|
||||
engage_people, engage_people_names = get_engaged_people micropost_id
|
||||
engage_people_names = engage_people_names.split(',')
|
||||
if engage_people_names.delete(name)
|
||||
engage_people_names = engage_people_names.join(',')
|
||||
engage_people -= 1
|
||||
save_engaged_people(micropost_id, engage_people, engage_people_names)
|
||||
end
|
||||
return engage_people,engage_people_names
|
||||
end
|
||||
|
||||
def joinded_activity(micropost_id,name)
|
||||
engage_people, engage_people_names = get_engaged_people micropost_id
|
||||
if engage_people_names.nil?
|
||||
return false
|
||||
end
|
||||
engage_people_names = engage_people_names.split(',')
|
||||
return engage_people_names.include?(name)
|
||||
end
|
||||
|
||||
|
||||
def micro_post_belong_to_user(micropost_id,user)
|
||||
find_result = user.micro_posts.where(id: micropost_id)
|
||||
return !find_result.empty?
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,47 @@
|
|||
module MicroPostsHelper
|
||||
|
||||
require 'fileutils'
|
||||
@@micro_posts_dir = "public/data"
|
||||
|
||||
def read_each_post user
|
||||
micro_posts_array = []
|
||||
micro_posts = user.micro_posts.all.order(post_time: :desc)
|
||||
if !micro_posts.empty?
|
||||
micro_posts.each do |micro_post|
|
||||
x = Hash.new()
|
||||
x["postid"] = micro_post.id
|
||||
x["title"] = micro_post.title
|
||||
x["content"] = micro_post.content
|
||||
case micro_post.post_type
|
||||
when 1
|
||||
x["type"] = "新鲜事"
|
||||
when 2
|
||||
x["type"] = "组团信息"
|
||||
when 3
|
||||
x["type"] = "失物招领"
|
||||
else
|
||||
x["type"] = "新鲜事"
|
||||
end
|
||||
x["time"] = get_strftime(micro_post.post_time)
|
||||
x["pics"] = micro_post.pic.split(',') if micro_post.pic
|
||||
x["peo_num"] = micro_post.engage_people
|
||||
x["peo_names"] = micro_post.engaged_people_names
|
||||
x["comments"] = micro_post.comments
|
||||
micro_posts_array << x
|
||||
end
|
||||
end
|
||||
return micro_posts_array
|
||||
end
|
||||
|
||||
def savePicture pic
|
||||
if !(File.directory? @@micro_posts_dir)
|
||||
FileUtils.mkdir_p(@@micro_posts_dir)
|
||||
end
|
||||
ext = File.extname(pic.original_filename)
|
||||
timestamp = Time.now.to_s
|
||||
save_name = Digest::MD5::hexdigest(pic.original_filename + timestamp) + ext
|
||||
File.open(File.join(@@micro_posts_dir, save_name), 'wb') { |f| f.write(pic.read) }
|
||||
return save_name
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,11 @@
|
|||
module UsersHelper
|
||||
def get_user_name_from_id user_id
|
||||
user = User.find_by(id: user_id)
|
||||
return user.name if !user.nil?
|
||||
end
|
||||
|
||||
def get_user_sexual user
|
||||
user.sexual
|
||||
end
|
||||
end
|
||||
|
|
@ -0,0 +1,2 @@
|
|||
class ApplicationJob < ActiveJob::Base
|
||||
end
|
|
@ -0,0 +1,4 @@
|
|||
class ApplicationMailer < ActionMailer::Base
|
||||
default from: "ucasguoren@heroku.com"
|
||||
layout 'mailer'
|
||||
end
|
|
@ -0,0 +1,9 @@
|
|||
class UserMailer < ApplicationMailer
|
||||
default from: "ucasguoren@heroku.com"
|
||||
|
||||
def send_verify_code mail_address, code
|
||||
@verify_code = code
|
||||
mail(to: mail_address, subject: "验证码")
|
||||
end
|
||||
|
||||
end
|
|
@ -0,0 +1,3 @@
|
|||
class ApplicationRecord < ActiveRecord::Base
|
||||
self.abstract_class = true
|
||||
end
|
|
@ -0,0 +1,4 @@
|
|||
class Comment < ApplicationRecord
|
||||
belongs_to :user, class_name: 'User', foreign_key: 'user_id'
|
||||
belongs_to :micro_post, class_name: 'MicroPost', foreign_key: 'micro_post_id'
|
||||
end
|
|
@ -0,0 +1,4 @@
|
|||
class Message < ApplicationRecord
|
||||
belongs_to :sender, class_name: 'User', foreign_key: 'send_user'
|
||||
belongs_to :reciever, class_name: 'User', foreign_key: 'recieve_user'
|
||||
end
|
|
@ -0,0 +1,4 @@
|
|||
class MicroPost < ApplicationRecord
|
||||
belongs_to :user
|
||||
has_many :comments, class_name: 'Comment', foreign_key: 'micro_post_id', dependent: :destroy
|
||||
end
|
|
@ -0,0 +1,29 @@
|
|||
class User < ApplicationRecord
|
||||
before_save :default_values
|
||||
|
||||
def default_values
|
||||
if self.picurl.nil?
|
||||
self.picurl = 'images/avatars/default/avatar.png'
|
||||
end
|
||||
end
|
||||
|
||||
has_many :send_messages, class_name: 'Message', foreign_key: 'send_user', dependent: :destroy
|
||||
has_many :recieve_messages, class_name: 'Message', foreign_key: 'recieve_user', dependent: :destroy
|
||||
has_many :micro_posts, dependent: :destroy
|
||||
has_many :comments, class_name: 'Comment', foreign_key: 'user_id', dependent: :destroy
|
||||
|
||||
VALID_EMAIL_REGEX = /\A[\w+\-.]+@([a-z\d\-]+\.)+[a-z]+\z/i
|
||||
before_save { self.email = email.downcase }
|
||||
validates :name, presence: true, length: {maximum: 50}, uniqueness: {
|
||||
case_sensitive: false
|
||||
}
|
||||
validates :email, presence: true, length: {maximum: 255},
|
||||
format: {with: VALID_EMAIL_REGEX}, uniqueness: {
|
||||
case_sensitive: true
|
||||
}
|
||||
has_secure_password
|
||||
validates :password, presence: true, length: {minimum: 6}, allow_nil: true
|
||||
|
||||
|
||||
|
||||
end
|
|
@ -0,0 +1,262 @@
|
|||
<% provide(:title, @user.name) %>
|
||||
|
||||
<div class="modal-shiftfix">
|
||||
|
||||
<!-- Navigation -->
|
||||
<%= render 'layouts/nav' %>
|
||||
<!-- End Navigation -->
|
||||
|
||||
<div class="container-fluid main-content">
|
||||
<!-- Conversation -->
|
||||
<div class="widget-container scrollable chat chat-page row">
|
||||
<div class="contact-list">
|
||||
<div class="heading">
|
||||
我的联系人<i class="icon-plus pull-right" data-toggle="modal" data-target="#addUser"></i>
|
||||
</div>
|
||||
<ul id="contactlists">
|
||||
<% @chat_with_users.each do |name, readed| %>
|
||||
<% if readed == false %>
|
||||
<li class="user_entry">
|
||||
<a>
|
||||
<label class="user_name"><%= name.to_s %></label>
|
||||
<i class="icon-circle text-success">新短信</i>
|
||||
</a>
|
||||
</li>
|
||||
<% else %>
|
||||
<li class="user_entry">
|
||||
<a>
|
||||
<label class="user_name"><%= name.to_s %></label>
|
||||
</a>
|
||||
</li>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="heading">
|
||||
<i class="icon-comments"></i>
|
||||
<lable id="chatwith"></lable>
|
||||
</div>
|
||||
<div id="chatScroll" class="widget-content padded">
|
||||
<ul id="chatList">
|
||||
</ul>
|
||||
</div>
|
||||
<div class="post-message">
|
||||
<input id="msg" class="form-control" placeholder="新信息..." type="text">
|
||||
<input id="msgSubmit" type="submit" value="发送">
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="modal fade" id="addUser" tabindex="-1" role="dialog" aria-labelledby="adduser" aria-hidden="true">
|
||||
<div class="modal-dialog">
|
||||
<div class="modal-content">
|
||||
<div class="modal-header">
|
||||
<button type="button" class="close" data-dismiss="modal" aria-hidden="true">×</button>
|
||||
<h4 class="modal-title" id="myModalLabel">添加用户</h4>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<input id="query_user" type="text" class="form-control" placeholder="用户名称">
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
|
||||
<button id="query_submit" type="button" class="btn btn-primary">提交</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
|
||||
function insertSend(name, pic, content, time) {
|
||||
var from =
|
||||
'<li class=" current-user"> ' +
|
||||
'<img width="30" height="30" src="' +
|
||||
pic +
|
||||
'"/>' +
|
||||
'<div class="bubble">' +
|
||||
'<a class="user-name">' +
|
||||
name +
|
||||
'</a>' +
|
||||
'<p class="message">' +
|
||||
content +
|
||||
'</p> <p class="time">' +
|
||||
time +
|
||||
'</p> </div> </li>'
|
||||
;
|
||||
$("#chatList").append(from);
|
||||
|
||||
}
|
||||
|
||||
function insertRecieve(name, pic, content, time) {
|
||||
var from =
|
||||
'<li>' +
|
||||
'<img width="30" height="30" ' +
|
||||
'src="' +
|
||||
pic +
|
||||
'"/>' +
|
||||
'<div class="bubble">' +
|
||||
'<a class="user-name">' +
|
||||
name +
|
||||
'</a>' +
|
||||
'<p class="message">' +
|
||||
content +
|
||||
'</p>' +
|
||||
'<p class="time">' +
|
||||
time +
|
||||
'</p>' +
|
||||
'</div>' +
|
||||
'</li>';
|
||||
$("#chatList").append(from);
|
||||
}
|
||||
|
||||
function label_click() {
|
||||
name = $(this).find("label").text();
|
||||
$.ajax({
|
||||
type: 'get',
|
||||
dataType: 'json',
|
||||
data: {chat_with: name},
|
||||
url: '/chat',
|
||||
success: function (data, textStatus, jqXHR) {
|
||||
$("#chatList").empty();
|
||||
$('#chatwith').text(name);
|
||||
for (var i = 0; i < data.length; i++) {
|
||||
if (data[i]["issend"] == true) {
|
||||
insertSend(data[i]["name"], data[i]["userpic"], data[i]["content"], data[i]["time"])
|
||||
}
|
||||
else {
|
||||
insertRecieve(data[i]["name"], data[i]["userpic"], data[i]["content"], data[i]["time"]);
|
||||
}
|
||||
}
|
||||
notify();
|
||||
$("#msg").attr("disabled", false);
|
||||
$("#chatScroll").scrollTop($("#chatScroll")[0].scrollHeight);
|
||||
}
|
||||
});
|
||||
$(this).find("i").remove();
|
||||
}
|
||||
|
||||
|
||||
function sendMsg() {
|
||||
var text = $("#msg").val();
|
||||
if (text.length == 0) {
|
||||
return false;
|
||||
}
|
||||
var chat_with_user = $("#chatwith").text();
|
||||
$.ajax({
|
||||
type: 'post',
|
||||
data: {msg: text, chat_with: chat_with_user, authenticity_token: AUTH_TOKEN},
|
||||
dataType: 'json',
|
||||
url: '/newmsg',
|
||||
success: function (data, textStatus, jqXHR) {
|
||||
insertSend(data["username"], data["userpic"], data["content"], data["time"]);
|
||||
$("#chatScroll").scrollTop($("#chatScroll")[0].scrollHeight);
|
||||
}
|
||||
});
|
||||
$("#msg").val("");
|
||||
return true;
|
||||
}
|
||||
|
||||
$("#msgSubmit").click(function () {
|
||||
sendMsg();
|
||||
});
|
||||
|
||||
function append_user(name) {
|
||||
var append_div = '<li class="user_entry">' +
|
||||
'<a>' +
|
||||
'<label class="user_name">' +
|
||||
name +
|
||||
'</label>' +
|
||||
'</a>' +
|
||||
'</li>';
|
||||
|
||||
$("#contactlists").append(append_div)
|
||||
|
||||
}
|
||||
|
||||
function query_user(name) {
|
||||
var all_user_name = [];
|
||||
$(".user_entry label").each(function () {
|
||||
all_user_name.push($(this).text());
|
||||
});
|
||||
|
||||
if (all_user_name.indexOf(name) < 0) {
|
||||
console.log(all_user_name, name);
|
||||
$.ajax({
|
||||
type: 'get',
|
||||
data: {username: name, all: all_user_name},
|
||||
dataType: 'json',
|
||||
url: '/query',
|
||||
success: function (data, textStatus, jqXHR) {
|
||||
if (data["ok"] == true) {
|
||||
append_user(data["username"]);
|
||||
$('.user_entry').bind("click", label_click);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
$("#query_submit").click(function () {
|
||||
$('#addUser').modal("hide");
|
||||
var queryname = $("#query_user").val();
|
||||
if (queryname.length != 0) {
|
||||
console.log(queryname);
|
||||
query_user(queryname);
|
||||
$("#query_user").val("");
|
||||
}
|
||||
});
|
||||
|
||||
$(document).ready(function () {
|
||||
$('.user_entry').bind("click", label_click);
|
||||
});
|
||||
|
||||
|
||||
function addOnlineLable(uniquename) {
|
||||
var yuandian = '<i class="icon-circle text-success">新消息</i>';
|
||||
var results = $('.user_name:contains(' + uniquename + ')');
|
||||
for (var i = 0; i < results.length; i++) {
|
||||
if ($(results[i]).text() === uniquename) {
|
||||
if ($(results[i]).parent().find("i").length == 0) {
|
||||
$(results[i]).parent().append(yuandian);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function online() {
|
||||
$.ajax({
|
||||
type: 'get',
|
||||
dataType: 'json',
|
||||
url: '/online',
|
||||
success: function (data, textStatus, jqXHR) {
|
||||
if (data["users"] != null) {
|
||||
for (var key in data["users"]) {
|
||||
addOnlineLable(key);
|
||||
var current_chat_with = $("#chatwith").text();
|
||||
if (current_chat_with.length > 0 && current_chat_with == key) {
|
||||
$(".user_name").each(function () {
|
||||
if ($(this).text() == current_chat_with) {
|
||||
$(this).click();
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
setInterval('online()', 10000);
|
||||
|
||||
$("#msg").bind("keyup", function (e) {
|
||||
if (e.keyCode == "13") {
|
||||
sendMsg();
|
||||
}
|
||||
});
|
||||
|
||||
</script>
|
|
@ -0,0 +1,92 @@
|
|||
<div class="navbar navbar-fixed-top scroll-hide">
|
||||
<div class="container-fluid top-bar">
|
||||
<div class="pull-right">
|
||||
<ul class="nav navbar-nav pull-right">
|
||||
<li class="dropdown user hidden-xs"><a data-toggle="dropdown" class="dropdown-toggle" href="/logout">
|
||||
<img width="34" height="34" src="<%= @user.picurl %>"/><%= @user.name %><b class="caret"></b></a>
|
||||
<ul class="dropdown-menu">
|
||||
<li><a href="/profile">
|
||||
<i class="icon-user"></i>个人设置</a>
|
||||
</li>
|
||||
<li><a href="/logout">
|
||||
<i class="icon-signout"></i>退出</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
<a class="logo" href="/main"></a>
|
||||
<button class="navbar-toggle"><span class="icon-bar"></span><span class="icon-bar"></span><span
|
||||
class="icon-bar"></span></button>
|
||||
</div>
|
||||
<div class="container-fluid main-nav clearfix">
|
||||
<div class="nav-collapse">
|
||||
<ul class="nav">
|
||||
<li class="dropdown">
|
||||
<a data-toggle="dropdown" href="#">
|
||||
<span aria-hidden="true" class="se7en-star"></span>随便看看<b class="caret"></b>
|
||||
</a>
|
||||
<ul class="dropdown-menu">
|
||||
<li>
|
||||
<a href="/main">果仁动态</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/main?type=2">组团信息</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/main?type=3">失物信息</a>
|
||||
</li>
|
||||
</ul>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/microposts"><span aria-hidden="true" class="se7en-home"></span>我的动态</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/chat">
|
||||
<span aria-hidden="true" class="se7en-envelope"></span>
|
||||
私信
|
||||
<div id="msgNum" class="label label-info">0</div>
|
||||
</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/logout"><span aria-hidden="true" class="se7en-pages"></span>退出</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
|
||||
function addNotifyLable(uniquename) {
|
||||
var yuandian = '<i class="icon-circle text-success"></i>';
|
||||
var results = $('.user_name:contains(' + uniquename + ')');
|
||||
for (var i = 0; i < results.length; i++) {
|
||||
if ($(results[i]).text() === uniquename) {
|
||||
$(results[i]).parent().append(yuandian);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function notify() {
|
||||
$.ajax({
|
||||
type: 'get',
|
||||
dataType: 'json',
|
||||
url: '/notify',
|
||||
success: function (data, textStatus, jqXHR) {
|
||||
$("#msgNum"
|
||||
).text(data["unreaded"]);
|
||||
}
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
var notify_num_ticker;
|
||||
$(document).ready(function () {
|
||||
notify();
|
||||
notify_num_ticker = setInterval('notify()', 10000);
|
||||
$("#msg").attr("disabled", true);
|
||||
});
|
||||
|
||||
|
||||
</script>
|
|
@ -0,0 +1,76 @@
|
|||
|
||||
<!--引入文件-->
|
||||
<link href="stylesheets/bootstrap.min.css" media="all" rel="stylesheet" type="text/css"/>
|
||||
<link href="stylesheets/font-awesome.css" media="all" rel="stylesheet" type="text/css"/>
|
||||
<link href="stylesheets/se7en-font.css" media="all" rel="stylesheet" type="text/css"/>
|
||||
<link href="stylesheets/isotope.css" media="all" rel="stylesheet" type="text/css"/>
|
||||
<link href="stylesheets/jquery.fancybox.css" media="all" rel="stylesheet" type="text/css"/>
|
||||
<link href="stylesheets/fullcalendar.css" media="all" rel="stylesheet" type="text/css"/>
|
||||
<link href="stylesheets/wizard.css" media="all" rel="stylesheet" type="text/css"/>
|
||||
<link href="stylesheets/select2.css" media="all" rel="stylesheet" type="text/css"/>
|
||||
<link href="stylesheets/morris.css" media="all" rel="stylesheet" type="text/css"/>
|
||||
<link href="stylesheets/datatables.css" media="all" rel="stylesheet" type="text/css"/>
|
||||
<link href="stylesheets/datepicker.css" media="all" rel="stylesheet" type="text/css"/>
|
||||
<link href="stylesheets/timepicker.css" media="all" rel="stylesheet" type="text/css"/>
|
||||
<link href="stylesheets/colorpicker.css" media="all" rel="stylesheet" type="text/css"/>
|
||||
<link href="stylesheets/bootstrap-switch.css" media="all" rel="stylesheet" type="text/css"/>
|
||||
<link href="stylesheets/daterange-picker.css" media="all" rel="stylesheet" type="text/css"/>
|
||||
<link href="stylesheets/typeahead.css" media="all" rel="stylesheet" type="text/css"/>
|
||||
<link href="stylesheets/summernote.css" media="all" rel="stylesheet" type="text/css"/>
|
||||
<link href="stylesheets/pygments.css" media="all" rel="stylesheet" type="text/css"/>
|
||||
<link href="stylesheets/style.css" media="all" rel="stylesheet" type="text/css"/>
|
||||
<link href="stylesheets/color/green.css" media="all" rel="alternate stylesheet" title="green-theme"
|
||||
type="text/css"/>
|
||||
<link href="stylesheets/color/orange.css" media="all" rel="alternate stylesheet" title="orange-theme"
|
||||
type="text/css"/>
|
||||
<link href="stylesheets/color/magenta.css" media="all" rel="alternate stylesheet" title="magenta-theme"
|
||||
type="text/css"/>
|
||||
<link href="stylesheets/color/gray.css" media="all" rel="alternate stylesheet" title="gray-theme" type="text/css"/>
|
||||
<!--引入文件-->
|
||||
|
||||
<script src="javascripts/jquery.min.js" type="text/javascript"></script>
|
||||
<script src="javascripts/jquery-ui-1.12.1.min.js" type="text/javascript"></script>
|
||||
<script src="javascripts/bootstrap.min.js" type="text/javascript"></script>
|
||||
<script src="javascripts/raphael.min.js" type="text/javascript"></script>
|
||||
<script src="javascripts/selectivizr-min.js" type="text/javascript"></script>
|
||||
<script src="javascripts/jquery.mousewheel.js" type="text/javascript"></script>
|
||||
<script src="javascripts/jquery.vmap.min.js" type="text/javascript"></script>
|
||||
<script src="javascripts/jquery.vmap.sampledata.js" type="text/javascript"></script>
|
||||
<script src="javascripts/jquery.vmap.world.js" type="text/javascript"></script>
|
||||
<script src="javascripts/jquery.bootstrap.wizard.js" type="text/javascript"></script>
|
||||
<script src="javascripts/fullcalendar.min.js" type="text/javascript"></script>
|
||||
<script src="javascripts/gcal.js" type="text/javascript"></script>
|
||||
<script src="javascripts/jquery.dataTables.min.js" type="text/javascript"></script>
|
||||
<script src="javascripts/datatable-editable.js" type="text/javascript"></script>
|
||||
<script src="javascripts/jquery.easy-pie-chart.js" type="text/javascript"></script>
|
||||
<script src="javascripts/excanvas.min.js" type="text/javascript"></script>
|
||||
<script src="javascripts/jquery.isotope.min.js" type="text/javascript"></script>
|
||||
<script src="javascripts/isotope_extras.js" type="text/javascript"></script>
|
||||
<script src="javascripts/modernizr.custom.js" type="text/javascript"></script>
|
||||
<script src="javascripts/jquery.fancybox.pack.js" type="text/javascript"></script>
|
||||
<script src="javascripts/select2.js" type="text/javascript"></script>
|
||||
<script src="javascripts/styleswitcher.js" type="text/javascript"></script>
|
||||
<script src="javascripts/wysiwyg.js" type="text/javascript"></script>
|
||||
<script src="javascripts/summernote.min.js" type="text/javascript"></script>
|
||||
<script src="javascripts/jquery.inputmask.min.js" type="text/javascript"></script>
|
||||
<script src="javascripts/jquery.validate.js" type="text/javascript"></script>
|
||||
<script src="javascripts/bootstrap-fileupload.js" type="text/javascript"></script>
|
||||
<script src="javascripts/bootstrap-datepicker.js" type="text/javascript"></script>
|
||||
<script src="javascripts/bootstrap-timepicker.js" type="text/javascript"></script>
|
||||
<script src="javascripts/bootstrap-colorpicker.js" type="text/javascript"></script>
|
||||
<script src="javascripts/bootstrap-switch.min.js" type="text/javascript"></script>
|
||||
<script src="javascripts/typeahead.js" type="text/javascript"></script>
|
||||
<script src="javascripts/daterange-picker.js" type="text/javascript"></script>
|
||||
<script src="javascripts/date.js" type="text/javascript"></script>
|
||||
<script src="javascripts/morris.min.js" type="text/javascript"></script>
|
||||
<script src="javascripts/skycons.js" type="text/javascript"></script>
|
||||
<script src="javascripts/fitvids.js" type="text/javascript"></script>
|
||||
<script src="javascripts/jquery.sparkline.min.js" type="text/javascript"></script>
|
||||
<script src="javascripts/main.js" type="text/javascript"></script>
|
||||
<script src="javascripts/respond.js" type="text/javascript"></script>
|
||||
|
||||
<!--自定义CSS文件-->
|
||||
<link href="stylesheets/mystyle.css" media="all" rel="stylesheet" type="text/css"/>
|
||||
<!--自定义CSS文件-->
|
||||
|
||||
<meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" name="viewport">
|
|
@ -0,0 +1 @@
|
|||
<title> <%= yield(:title) %> | 果仁 </title>
|
|
@ -0,0 +1,19 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<%= render 'layouts/title' %>
|
||||
<%= javascript_tag "var AUTH_TOKEN = #{form_authenticity_token.inspect};" if protect_against_forgery? %>
|
||||
<%= render 'layouts/refer' %>
|
||||
</head>
|
||||
|
||||
<body class="<%= yield(:body_class) %>">
|
||||
<% flash.each do |message_type, message| %>
|
||||
<%= content_tag(:div, message, class: "alert alert-#{message_type}") %>
|
||||
<% end %>
|
||||
|
||||
<%= yield %>
|
||||
|
||||
<%= debug(params) if Rails.env.development? %>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,13 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<style>
|
||||
/* Email styles need to be inline */
|
||||
</style>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<%= yield %>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1 @@
|
|||
<%= yield %>
|
|
@ -0,0 +1,36 @@
|
|||
<% provide(:title, '登陆') %>
|
||||
<% provide(:body_class, 'login2') %>
|
||||
|
||||
<!-- Login Screen -->
|
||||
<div class="login-wrapper">
|
||||
<a href="#"><img width="210" height="70" src="images/logo/guoren.png"/></a>
|
||||
|
||||
<%= form_tag(controller: "login", action: "login", method: "post") do %>
|
||||
<div class="form-group">
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon"><i class="icon-user"></i></span><input class="form-control"
|
||||
placeholder="请输入登陆邮箱"
|
||||
name="email"
|
||||
type="text">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon"><i class="icon-lock"></i></span><input class="form-control"
|
||||
placeholder="请输入密码"
|
||||
name="password"
|
||||
type="password">
|
||||
</div>
|
||||
</div>
|
||||
<a class="pull-right" href="/forgetpasswd">忘记密码?</a>
|
||||
<!--<div class="text-left">-->
|
||||
<!--<label class="checkbox"><input type="checkbox" name="remember"><span>记住我</span></label>-->
|
||||
<!--</div>-->
|
||||
<input class="btn btn-lg btn-primary btn-block" type="submit" value="登陆">
|
||||
<% end %>
|
||||
<p>
|
||||
还没有果壳账号?
|
||||
</p>
|
||||
<%= link_to "注册新账户", signup_path, class: "btn btn-default-outline btn-block" %>
|
||||
</div>
|
||||
<!-- End Login Screen -->
|
|
@ -0,0 +1,205 @@
|
|||
<% provide(:title, @user.name) %>
|
||||
|
||||
<div class="modal-shiftfix">
|
||||
|
||||
<div class="container-fluid main-content">
|
||||
<%= render 'layouts/nav' %>
|
||||
<div class="row">
|
||||
<div class="col-lg-12">
|
||||
<% @micro_posts_array.each do |micro_post| %>
|
||||
<div class="social-wrapper">
|
||||
<div class="social-container">
|
||||
<div class="social-entry" id="postid_<%= micro_post["postid"] %>">
|
||||
<div class="widget-container fluid-height isotope-item">
|
||||
<div class="profile-info clearfix" style="padding: 20px 20px 0 20px">
|
||||
<img width="50" height="50" class="social-avatar pull-left"
|
||||
src="<%= micro_post["userpic"] %>">
|
||||
<a class="user-name"><i class="icon-user"></i><%= micro_post["username"] %></a><br>
|
||||
<div class="profile-details">
|
||||
<p>
|
||||
<label class="label label-info" style="margin: 0"><%= micro_post["type"] %></label>
|
||||
<i class="icon-time"><em><%= micro_post["time"] %></em></i>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
<div class="padded">
|
||||
<p class="content postcontent"><%= micro_post["content"] %></p>
|
||||
<% if micro_post["pics"] %>
|
||||
<div class="text-center">
|
||||
<% micro_post["pics"].each do |pic| %>
|
||||
<img width="250" class="social-content-media" src="<%= "data/" + pic %>"/>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
<% if micro_post_belong_to_user(micro_post["postid"], @user) == false %>
|
||||
<% if micro_post["type"] == "组团信息" %>
|
||||
<div class="social-button">
|
||||
<% if joinded_activity(micro_post["postid"], @user.name) %>
|
||||
<button class="btn btn-lg btn-success-outline activity">取消报名</button>
|
||||
<div class="activity-detail text-center"></div>
|
||||
<% else %>
|
||||
<button class="btn btn-lg btn-success-outline activity">报名参加</button>
|
||||
<div class="activity-detail text-center"></div>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
<% if micro_post["type"] == "失物招领" %>
|
||||
<div class="social-button">
|
||||
<button class="btn btn-success-outline lost">跟ta联系
|
||||
</button>
|
||||
</div>
|
||||
<% end %>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="comment-button">
|
||||
<button class="btn btn-block btn-default-outline showcomment">
|
||||
显示评论
|
||||
</button>
|
||||
</div>
|
||||
<div class="comments padded hidden">
|
||||
<input class="form-control makecomment" placeholder="写评论..." type="text">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<nav class="text-center">
|
||||
<%= will_paginate @posts, :page_links => false, :previous_label => "前一页", :next_label => "后一页" %>
|
||||
</nav>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script>
|
||||
|
||||
function comment_process(username, userpic, comment) {
|
||||
var commentElem = '<div class="comment">' +
|
||||
'<img width="40" height="40" class="social-avatars pull-left"' +
|
||||
'src=' +
|
||||
userpic +
|
||||
'/>' +
|
||||
'<a class="user-name">' +
|
||||
username +
|
||||
'</a>' +
|
||||
'<p>' +
|
||||
comment +
|
||||
'</p>' +
|
||||
'</div>';
|
||||
|
||||
return commentElem;
|
||||
}
|
||||
function getComments(id) {
|
||||
$.ajax({
|
||||
type: 'get',
|
||||
dataType: 'json',
|
||||
data: {micropost_id: id},
|
||||
url: '/comments',
|
||||
success: function (data, textStatus, jqXHR) {
|
||||
var micro_post_id = "#" + "postid_" + id;
|
||||
var comments = $(micro_post_id.toString()).parent().next();
|
||||
var comments = $(micro_post_id.toString()).find(".comments");
|
||||
comments.find(".comment").remove();
|
||||
comments.find("p").remove();
|
||||
if (data["comments"].length == 0) {
|
||||
comments.prepend("<p class='text-center'>无评论</p>");
|
||||
}
|
||||
else {
|
||||
var comments_array = data["comments"];
|
||||
for (var i = 0; i < comments_array.length; i++) {
|
||||
comments.prepend(comment_process(comments_array[i]["username"],
|
||||
comments_array[i]["userpic"], comments_array[i]["content"]))
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
$(".showcomment").bind("click", function () {
|
||||
var text = $(this).text();
|
||||
if (text == "隐藏评论") {
|
||||
$(this).parent().next(".comments").addClass("hidden");
|
||||
$(this).text("显示评论");
|
||||
}
|
||||
else {
|
||||
$(this).parent().next(".comments").removeClass("hidden");
|
||||
$(this).text("隐藏评论");
|
||||
var micropost_id = $(this).parent().parent().attr("id");
|
||||
if (micropost_id.indexOf('_') > 0) {
|
||||
var id = micropost_id.slice(micropost_id.indexOf('_') + 1);
|
||||
getComments(id);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$(".makecomment").bind("keyup", function (e) {
|
||||
var inputText = $(this).val();
|
||||
if (inputText.length <= 0) {
|
||||
return;
|
||||
}
|
||||
var username = "";
|
||||
var userpic = "";
|
||||
var enterObject = $(this);
|
||||
var micropost = $(this).parent().parent().attr("id");
|
||||
var micropost_id = micropost.slice(micropost.indexOf("_") + 1);
|
||||
if (e.keyCode == "13") {
|
||||
$.ajax({
|
||||
type: 'post',
|
||||
dataType: 'json',
|
||||
data: {micropost_id: micropost_id, content: inputText, authenticity_token: AUTH_TOKEN},
|
||||
url: '/newcomment',
|
||||
success: function (data, textStatus, jqXHR) {
|
||||
if (data["username"] && data["userpic"]) {
|
||||
enterObject.parent().children("p").remove();
|
||||
enterObject.before(comment_process(data["username"], data["userpic"], inputText));
|
||||
}
|
||||
$(".makecomment").val("");
|
||||
}
|
||||
});
|
||||
}
|
||||
});
|
||||
$(".activity").bind("click", function () {
|
||||
var activity = $(this);
|
||||
var text = activity.text().trim();
|
||||
var micropost = $(this).parent().parent().parent();
|
||||
var micropost_id = micropost.attr("id");
|
||||
if (micropost_id.indexOf('_') > 0) {
|
||||
var id = micropost_id.slice(micropost_id.indexOf('_') + 1);
|
||||
if (text == "报名参加") {
|
||||
$.ajax({
|
||||
type: 'get',
|
||||
dataType: 'json',
|
||||
data: {micropost_id: id, join: true},
|
||||
url: '/activity',
|
||||
success: function (data, textStatus, jqXHR) {
|
||||
//console.log(data["total_num"]);
|
||||
var engage_people = data["total_num"];
|
||||
var show_text = "已有" + engage_people + "人参加该活动" + '\n' + data["total_names"] + "参加了活动";
|
||||
activity.text("取消报名");
|
||||
micropost.find(".activity-detail").text(show_text);
|
||||
}
|
||||
});
|
||||
}
|
||||
else {
|
||||
$.ajax({
|
||||
type: 'get',
|
||||
dataType: 'json',
|
||||
data: {micropost_id: id, join: false},
|
||||
url: '/activity',
|
||||
success: function (data, textStatus, jqXHR) {
|
||||
activity.text("报名参加");
|
||||
micropost.find(".activity-detail").text("成功取消报名");
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$(".lost").bind("click", function () {
|
||||
window.open("/chat");
|
||||
});
|
||||
</script>
|
||||
|
||||
|
|
@ -0,0 +1,261 @@
|
|||
<% provide(:title, @user.name) %>
|
||||
|
||||
|
||||
<div class="modal-shiftfix">
|
||||
|
||||
<!-- Navigation -->
|
||||
<%= render 'layouts/nav' %>
|
||||
<!-- End Navigation -->
|
||||
|
||||
<div class="container-fluid main-content padded" id="user-page">
|
||||
<div class="row" id="new-post">
|
||||
<div class="widget-container fluid-height clearfix">
|
||||
<div class="heading">
|
||||
<i class="icon-reorder"></i>发布新信息
|
||||
</div>
|
||||
|
||||
<%= form_tag("/newpost", method: "post", class: "form-horizontal", enctype: "multipart/form-data") do %>
|
||||
|
||||
<div class="form-group ">
|
||||
<div class="col-md-2">
|
||||
<select class="form-control" name="post_type">
|
||||
<option value="1">新鲜事</option>
|
||||
<option value="2">组团信息</option>
|
||||
<option value="3">失物招领</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class="col-md-10">
|
||||
<input class="form-control" placeholder="标题" type="text" name="title">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-md-12">
|
||||
<textarea class="form-control" rows="3" name="content"></textarea>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-md-12">
|
||||
<div id="image-upload">
|
||||
<div id="total">当前选择上传0个图片</div>
|
||||
<input class="btn btn-default" type="button" value="添加图片" id="btnAdd" onclick="selectAttachment();">
|
||||
<input class="btn btn-default" type="button" value="清空图片" id="btnClear" style="display:none" onclick="clearAttachment();">
|
||||
<div id="attachmentList" style="display: none"></div>
|
||||
<div id="pics">
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-md-12 text-center">
|
||||
<button class="btn btn-primary" type="submit">发布</button>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="posts">
|
||||
<% @micro_posts.each do |micro_post| %>
|
||||
<div class="micro-post" id="<%= micro_post["postid"] %>">
|
||||
<button class="close delete-post" data-dismiss="alert" type="button">×</button>
|
||||
<div class="widget-container fluid-height padded">
|
||||
<div class="heading col-md-12">
|
||||
<i class="icon-tags"><%= micro_post["type"] %></i>
|
||||
<i class="icon-time"><%= micro_post["time"] %></i>
|
||||
</div>
|
||||
<div class="col-md-12">
|
||||
<p class="content"><%= micro_post["content"] %></p>
|
||||
<% if micro_post["pics"] %>
|
||||
<div class="text-center">
|
||||
<% micro_post["pics"].each do |pic| %>
|
||||
<img width="250" class="social-content-media" src="<%= "data/" + pic %>"/>
|
||||
<% end %>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
<div class="col-md-12">
|
||||
<div class="btn btn-default btn-block show-details">
|
||||
查看详情
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="activity-details" hidden>
|
||||
<% if micro_post["type"] == "组团信息" %>
|
||||
<div class="widget-container fluid-height">
|
||||
<div class="heading">
|
||||
<i class="icon-align-center"> 活动详情 </i>
|
||||
</div>
|
||||
<div class="widget-content padded">
|
||||
<h3 class="text-center">已有<%= micro_post["peo_num"] %>人参加活动</h3>
|
||||
<p><%= micro_post["peo_names"] %>参加了该活动</p>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
<% if !micro_post["comments"].empty? %>
|
||||
<div class="widget-container fluid-height scrollable list user-comments">
|
||||
<div class="heading">
|
||||
<i class="icon-mail-forward"> 评论 </i>
|
||||
</div>
|
||||
<div class="widget-content fluid-height">
|
||||
<ul>
|
||||
<% micro_post["comments"].each do |comment| %>
|
||||
<li>
|
||||
<div>
|
||||
<a class="user-name"><%= get_user_name_from_id(comment.user_id) %></a><em></em>
|
||||
</div>
|
||||
<div>
|
||||
<p><%= comment.content %></p>
|
||||
</div>
|
||||
</li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
<% else %>
|
||||
<p class="text-center alert-info">暂无评论</p>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
var pic_num = 0; // 用来动态生成span,upfile的id
|
||||
function addAttachmentToList() {
|
||||
if (findAttachment(event.srcElement.value)) return; //如果此文档已在图片列表中则不再添加
|
||||
if (extractFileName(event.srcElement.value)) {
|
||||
// 动态创建图片信息栏并添加到图片列表中
|
||||
var span = document.createElement('span');
|
||||
span.id = '_attachment' + pic_num;
|
||||
span.innerHTML = extractFileName(event.srcElement.value) +
|
||||
' <a href="javascript:delAttachment(' + (pic_num++) + ')">删除</a><br/>';
|
||||
span.title = event.srcElement.value;
|
||||
G('attachmentList').appendChild(span);
|
||||
}
|
||||
// 显示图片列表并变换添加图片按钮文本
|
||||
if (G('attachmentList').style.display == 'none') {
|
||||
G('btnAdd').value = '继续添加';
|
||||
G('attachmentList').style.display = '';
|
||||
G('btnClear').style.display = '';
|
||||
}
|
||||
|
||||
G('total').innerText = '当前选择上传' + G('attachmentList').childNodes.length + '个图片';
|
||||
}
|
||||
|
||||
function selectAttachment() {
|
||||
// 先清除无效动态生成的多余upfile
|
||||
cleanInvalidUpfile();
|
||||
|
||||
// 动态创建上传控件并与span对应
|
||||
var upfile = '<input type="file" style="display:none" multiple name="pictures[]" onchange="addAttachmentToList();" id="_upfile' + pic_num + '">';
|
||||
G('pics').insertAdjacentHTML('beforeEnd', upfile);
|
||||
G('_upfile' + pic_num).click();
|
||||
}
|
||||
|
||||
function extractFileName(fn) {
|
||||
var index = fn.substr(fn.lastIndexOf('.')).toLowerCase();
|
||||
if (index == '.png' || index == '.jpg' || index == '.jpeg') {
|
||||
return fn.substr(fn.lastIndexOf('\\') + 1);
|
||||
}
|
||||
else {
|
||||
alert('请上传.png或.jpg格式的图片!');
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
function findAttachment(fn) {
|
||||
var o = G('attachmentList').getElementsByTagName('span');
|
||||
for (var i = 0; i < o.length; i++)
|
||||
if (o[i].title == fn) return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
function delAttachment(id) {
|
||||
G('attachmentList').removeChild(G('_attachment' + id));
|
||||
G('pics').removeChild(G('_upfile' + id));
|
||||
|
||||
// 当图片列表为空则不显示并且变化添加图片按钮文本
|
||||
if (G('attachmentList').childNodes.length == 0) {
|
||||
G('btnAdd').value = '添加图片';
|
||||
G('attachmentList').style.display = 'none';
|
||||
G('btnClear').style.display = 'none';
|
||||
}
|
||||
|
||||
G('total').innerText = '当前选择上传' + G('attachmentList').childNodes.length + '个图片';
|
||||
}
|
||||
|
||||
function cleanInvalidUpfile() {
|
||||
var o = document.body.getElementsByTagName('input');
|
||||
for (var i = o.length - 1; i >= 0; i--)
|
||||
if (o[i].type == 'file' && o[i].id.indexOf('_upfile') == 0) {
|
||||
if (!G('_attachment' + o[i].id.substr(7)))
|
||||
G('pics').removeChild(o[i]);
|
||||
}
|
||||
}
|
||||
|
||||
function clearAttachment() {
|
||||
var o = G('attachmentList').childNodes;
|
||||
for (var i = o.length - 1; i >= 0; i--)
|
||||
G('attachmentList').removeChild(o[i]);
|
||||
|
||||
o = document.body.getElementsByTagName('input');
|
||||
for (var i = o.length - 1; i >= 0; i--)
|
||||
if (o[i].type == 'file' && o[i].id.indexOf('_upfile') == 0) {
|
||||
document.body.removeChild(o[i]);
|
||||
}
|
||||
|
||||
G('btnAdd').value = '添加图片';
|
||||
G('attachmentList').style.display = 'none';
|
||||
G('btnClear').style.display = 'none';
|
||||
G('total').innerText = '当前选择上传0个图片';
|
||||
|
||||
}
|
||||
|
||||
|
||||
function G(id) {
|
||||
return document.getElementById(id);
|
||||
}
|
||||
|
||||
|
||||
$(".delete-post").bind("click", function () {
|
||||
var errorhtml = '<div class="alert alert-danger">' +
|
||||
'<button class="close" data-dismiss="alert" type="button">×</button>删除失败</div>';
|
||||
var successhtml = '<div class="alert alert-success">' +
|
||||
'<button class="close" data-dismiss="alert" type="button">×</button>删除成功</div>';
|
||||
var micropost_id = $(this).parent().attr("id");
|
||||
$.ajax({
|
||||
type: 'get',
|
||||
dataType: 'json',
|
||||
data: {micropost_id: micropost_id},
|
||||
url: '/deletepost',
|
||||
success: function (data, textStatus, jqXHR) {
|
||||
if (data['status'] == true) {
|
||||
$('.posts').before(successhtml);
|
||||
}
|
||||
else {
|
||||
$('.posts').before(errorhtml);
|
||||
}
|
||||
}
|
||||
});
|
||||
});
|
||||
$('.show-details').bind("click", function () {
|
||||
var current_button = $(this);
|
||||
var micropost = current_button.parent().parent().parent();
|
||||
var text = current_button.text().trim();
|
||||
if (text == "查看详情") {
|
||||
micropost.find(".activity-details").show();
|
||||
current_button.text("隐藏详情");
|
||||
}
|
||||
else {
|
||||
micropost.find(".activity-details").hide();
|
||||
current_button.text("查看详情");
|
||||
}
|
||||
|
||||
})
|
||||
</script>
|
|
@ -0,0 +1,12 @@
|
|||
<% if object.errors.any? %>
|
||||
<div id="error_explanation">
|
||||
<div class="alert alert-danger">
|
||||
The form contains <%= pluralize(object.errors.count, "error") %>.
|
||||
</div>
|
||||
<ul>
|
||||
<% object.errors.full_messages.each do |msg| %>
|
||||
<li><%= msg %></li>
|
||||
<% end %>
|
||||
</ul>
|
||||
</div>
|
||||
<% end %>
|
|
@ -0,0 +1,25 @@
|
|||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<!-- 新 Bootstrap 核心 CSS 文件 -->
|
||||
<link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/3.3.0/css/bootstrap.min.css">
|
||||
|
||||
<!-- 可选的Bootstrap主题文件(一般不用引入) -->
|
||||
<link rel="stylesheet" href="http://cdn.bootcss.com/bootstrap/3.3.0/css/bootstrap-theme.min.css">
|
||||
|
||||
<!-- jQuery文件。务必在bootstrap.min.js 之前引入 -->
|
||||
<script src="http://cdn.bootcss.com/jquery/1.11.1/jquery.min.js"></script>
|
||||
|
||||
<!-- 最新的 Bootstrap 核心 JavaScript 文件 -->
|
||||
<script src="http://cdn.bootcss.com/bootstrap/3.3.0/js/bootstrap.min.js"></script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div class="container">
|
||||
您的验证码是: <%= @verify_code %>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
</html>
|
|
@ -0,0 +1,47 @@
|
|||
<% provide(:title, '忘记密码') %>
|
||||
<% provide(:body_class, 'login2') %>
|
||||
|
||||
<div class="login-wrapper">
|
||||
<a href="#"><img width="210" height="70" src="images/logo/guoren.png"/></a>
|
||||
|
||||
<%= form_tag("/changepasswd", method: "post") do %>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon"><i class="icon-envelope"></i></span><input class="form-control"
|
||||
placeholder="请输入邮箱地址"
|
||||
name="email"
|
||||
type="email">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon"><i class="icon-lock"></i></span><input class="form-control"
|
||||
placeholder="请输入邮箱验证码"
|
||||
name="verify_code"
|
||||
type="number">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon"><i class="icon-ok"></i></span><input class="form-control"
|
||||
placeholder="请输入新密码"
|
||||
name="password"
|
||||
type="password">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon"><i class="icon-ok"></i></span><input class="form-control"
|
||||
placeholder="请再次输入新密码"
|
||||
name="password_confirm"
|
||||
type="password">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%= submit_tag "重置密码", class: "btn btn-primary btn-block" %>
|
||||
<% end %>
|
||||
|
||||
</div>
|
|
@ -0,0 +1,97 @@
|
|||
<% provide(:title, @user.name) %>
|
||||
|
||||
<div class="modal-shiftfix">
|
||||
|
||||
<div id="profile-container" class="container-fluid main-content">
|
||||
|
||||
<%= render 'layouts/nav' %>
|
||||
|
||||
<%= form_tag("/changeprofile", method: "post", class: "form-horizontal", id: "profile", enctype: "multipart/form-data") do %>
|
||||
|
||||
<div class="row">
|
||||
<div class="widget-container">
|
||||
<div class="heading">
|
||||
<i class="icon-user"></i>个人设置
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="widget-container">
|
||||
<div class="heading">
|
||||
<i class="icon-user"></i>用户图像
|
||||
</div>
|
||||
<div class="col-md-12 text-center">
|
||||
<div class="fileupload fileupload-new" data-provides="fileupload">
|
||||
<div class="fileupload-new img-thumbnail" style="width: 200px; height: 200px;">
|
||||
<!--原照片-->
|
||||
<img src="<%= @user.picurl %>">
|
||||
</div>
|
||||
<div class="fileupload-preview fileupload-exists img-thumbnail"
|
||||
style="width: 200px; max-height: 200px">
|
||||
</div>
|
||||
<div class="padded">
|
||||
<span class="btn btn-default btn-file">
|
||||
<span
|
||||
class="fileupload-new">选择照片
|
||||
</span>
|
||||
<span
|
||||
class="fileupload-exists">
|
||||
重新选择
|
||||
</span>
|
||||
<input type="file" name="user[pic]">
|
||||
</span>
|
||||
<a class="btn btn-default fileupload-exists" data-dismiss="fileupload">清除照片</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="widget-container fluid-height clearfix">
|
||||
<div class="heading">
|
||||
<i class="icon-reorder"></i>基本信息
|
||||
</div>
|
||||
<div class="padded">
|
||||
<div class="form-group">
|
||||
<label class="control-label col-md-2">姓名</label>
|
||||
<div class="col-md-9">
|
||||
<input class="form-control" placeholder="请输入您的姓名" value="<%= @user.name %>"
|
||||
type="text" name="user[username]">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="control-label col-md-2">专业</label>
|
||||
<div class="col-md-9">
|
||||
<input class="form-control" placeholder="请输入您的专业" value="<%= @user.profession %>"
|
||||
type="text" name="user[profession]">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<label class="control-label col-md-2">性别</label>
|
||||
<div class="col-md-9">
|
||||
<label class="radio-inline"><input name="user[sexual]" type="radio" value="1"
|
||||
<% if get_user_sexual(@user) == true %>checked
|
||||
<% end %>
|
||||
><span>男</span></label>
|
||||
<label class="radio-inline"><input name="user[sexual]" type="radio" value="0"
|
||||
<% if get_user_sexual(@user) == false %>checked
|
||||
<% end %>
|
||||
><span>女</span></label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="col-md-12 text-center">
|
||||
<button class="btn btn-primary" type="submit">修改</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
</div>
|
||||
</div>
|
|
@ -0,0 +1,22 @@
|
|||
<% provide(:title, '忘记密码') %>
|
||||
<% provide(:body_class, 'login2') %>
|
||||
|
||||
<div class="login-wrapper">
|
||||
<a href="#"><img width="210" height="70" src="images/logo/guoren.png"/></a>
|
||||
|
||||
<%= form_tag("/forgetpasswd", method: "get") do %>
|
||||
|
||||
|
||||
<div class="form-group">
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon"><i class="icon-envelope"></i></span><input class="form-control"
|
||||
placeholder="请输入邮箱地址"
|
||||
name="email"
|
||||
type="email">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%= submit_tag "找回密码", class: "btn btn-primary btn-block" %>
|
||||
<% end %>
|
||||
|
||||
</div>
|
|
@ -0,0 +1,48 @@
|
|||
<% provide(:title, '用户注册') %>
|
||||
<% provide(:body_class, 'login2') %>
|
||||
|
||||
<div class="login-wrapper">
|
||||
<a href="#"><img width="210" height="70" src="images/logo/guoren.png"/></a>
|
||||
|
||||
|
||||
|
||||
<%= form_for(@user) do |f| %>
|
||||
<%= render 'shared/error_messages', object: f.object %>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon"><i class="icon-user"></i></span>
|
||||
<%= f.text_field :name, class: 'form-control', placeholder: "请输入名称" %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon"><i class="icon-envelope"></i></span>
|
||||
<%= f.email_field :email, class: 'form-control', placeholder: "请输入邮箱" %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon"><i class="icon-ok"></i></span>
|
||||
<%= f.password_field :password, class: 'form-control', placeholder: "请输入密码" %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon"><i class="icon-ok"></i></span>
|
||||
<%= f.password_field :password_confirmation, class: 'form-control',placeholder: "请再次输入密码" %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%= f.submit "注册", class: "btn btn-primary btn-block" %>
|
||||
<% end %>
|
||||
|
||||
<p>
|
||||
已经有果壳账号?
|
||||
</p>
|
||||
<%= link_to "登陆", login_path, class: "btn btn-default-outline btn-block" %>
|
||||
|
||||
</div>
|
|
@ -0,0 +1,3 @@
|
|||
#!/usr/bin/env ruby
|
||||
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
|
||||
load Gem.bin_path('bundler', 'bundle')
|
|
@ -0,0 +1,9 @@
|
|||
#!/usr/bin/env ruby
|
||||
begin
|
||||
load File.expand_path('../spring', __FILE__)
|
||||
rescue LoadError => e
|
||||
raise unless e.message.include?('spring')
|
||||
end
|
||||
APP_PATH = File.expand_path('../config/application', __dir__)
|
||||
require_relative '../config/boot'
|
||||
require 'rails/commands'
|
|
@ -0,0 +1,9 @@
|
|||
#!/usr/bin/env ruby
|
||||
begin
|
||||
load File.expand_path('../spring', __FILE__)
|
||||
rescue LoadError => e
|
||||
raise unless e.message.include?('spring')
|
||||
end
|
||||
require_relative '../config/boot'
|
||||
require 'rake'
|
||||
Rake.application.run
|
|
@ -0,0 +1,34 @@
|
|||
#!/usr/bin/env ruby
|
||||
require 'pathname'
|
||||
require 'fileutils'
|
||||
include FileUtils
|
||||
|
||||
# path to your application root.
|
||||
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
|
||||
|
||||
def system!(*args)
|
||||
system(*args) || abort("\n== Command #{args} failed ==")
|
||||
end
|
||||
|
||||
chdir APP_ROOT do
|
||||
# This script is a starting point to setup your application.
|
||||
# Add necessary setup steps to this file.
|
||||
|
||||
puts '== Installing dependencies =='
|
||||
system! 'gem install bundler --conservative'
|
||||
system('bundle check') || system!('bundle install')
|
||||
|
||||
# puts "\n== Copying sample files =="
|
||||
# unless File.exist?('config/database.yml')
|
||||
# cp 'config/database.yml.sample', 'config/database.yml'
|
||||
# end
|
||||
|
||||
puts "\n== Preparing database =="
|
||||
system! 'bin/rails db:setup'
|
||||
|
||||
puts "\n== Removing old logs and tempfiles =="
|
||||
system! 'bin/rails log:clear tmp:clear'
|
||||
|
||||
puts "\n== Restarting application server =="
|
||||
system! 'bin/rails restart'
|
||||
end
|
|
@ -0,0 +1,16 @@
|
|||
#!/usr/bin/env ruby
|
||||
|
||||
# This file loads spring without using Bundler, in order to be fast.
|
||||
# It gets overwritten when you run the `spring binstub` command.
|
||||
|
||||
unless defined?(Spring)
|
||||
require 'rubygems'
|
||||
require 'bundler'
|
||||
|
||||
lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read)
|
||||
if spring = lockfile.specs.detect { |spec| spec.name == "spring" }
|
||||
Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path
|
||||
gem 'spring', spring.version
|
||||
require 'spring/binstub'
|
||||
end
|
||||
end
|
|
@ -0,0 +1,29 @@
|
|||
#!/usr/bin/env ruby
|
||||
require 'pathname'
|
||||
require 'fileutils'
|
||||
include FileUtils
|
||||
|
||||
# path to your application root.
|
||||
APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
|
||||
|
||||
def system!(*args)
|
||||
system(*args) || abort("\n== Command #{args} failed ==")
|
||||
end
|
||||
|
||||
chdir APP_ROOT do
|
||||
# This script is a way to update your development environment automatically.
|
||||
# Add necessary update steps to this file.
|
||||
|
||||
puts '== Installing dependencies =='
|
||||
system! 'gem install bundler --conservative'
|
||||
system('bundle check') || system!('bundle install')
|
||||
|
||||
puts "\n== Updating database =="
|
||||
system! 'bin/rails db:migrate'
|
||||
|
||||
puts "\n== Removing old logs and tempfiles =="
|
||||
system! 'bin/rails log:clear tmp:clear'
|
||||
|
||||
puts "\n== Restarting application server =="
|
||||
system! 'bin/rails restart'
|
||||
end
|
|
@ -0,0 +1,33 @@
|
|||
<%= form_for @user, url: {action: "changepasswd"} do |f| %>
|
||||
<%= render 'shared/error_messages', object: f.object %>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon"><i class="icon-lock"></i></span>
|
||||
<input class="form-control" placeholder="请输入邮箱验证码" name="verify_code" type="text">
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon"><i class="icon-envelope"></i></span>
|
||||
<%= f.email_field :email, class: 'form-control', placeholder: "请输入邮箱" %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon"><i class="icon-ok"></i></span>
|
||||
<%= f.password_field :password, class: 'form-control', placeholder: "请输入密码" %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
<div class="input-group">
|
||||
<span class="input-group-addon"><i class="icon-ok"></i></span>
|
||||
<%= f.password_field :password_confirmation, class: 'form-control', placeholder: "请再次输入密码" %>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<%= f.submit "重置密码", class: "btn btn-primary btn-block" %>
|
||||
<% end %>
|
|
@ -0,0 +1,5 @@
|
|||
# This file is used by Rack-based servers to start the application.
|
||||
|
||||
require_relative 'config/environment'
|
||||
|
||||
run Rails.application
|
|
@ -0,0 +1,16 @@
|
|||
require_relative 'boot'
|
||||
|
||||
require 'rails/all'
|
||||
|
||||
# Require the gems listed in Gemfile, including any gems
|
||||
# you've limited to :test, :development, or :production.
|
||||
Bundler.require(*Rails.groups)
|
||||
|
||||
module GuorenPro
|
||||
class Application < Rails::Application
|
||||
# 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.
|
||||
config.time_zone = 'Beijing'
|
||||
end
|
||||
end
|
|
@ -0,0 +1,3 @@
|
|||
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
|
||||
|
||||
require 'bundler/setup' # Set up gems listed in the Gemfile.
|
|
@ -0,0 +1,9 @@
|
|||
development:
|
||||
adapter: async
|
||||
|
||||
test:
|
||||
adapter: async
|
||||
|
||||
production:
|
||||
adapter: redis
|
||||
url: redis://localhost:6379/1
|
|
@ -0,0 +1,25 @@
|
|||
# SQLite version 3.x
|
||||
# gem install sqlite3
|
||||
#
|
||||
# Ensure the SQLite 3 gem is defined in your Gemfile
|
||||
# gem 'sqlite3'
|
||||
#
|
||||
default: &default
|
||||
adapter: sqlite3
|
||||
pool: 5
|
||||
timeout: 5000
|
||||
|
||||
development:
|
||||
<<: *default
|
||||
database: db/development.sqlite3
|
||||
|
||||
# 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:
|
||||
<<: *default
|
||||
database: db/test.sqlite3
|
||||
|
||||
production:
|
||||
<<: *default
|
||||
database: db/production.sqlite3
|
|
@ -0,0 +1,5 @@
|
|||
# Load the Rails application.
|
||||
require_relative 'application'
|
||||
|
||||
# Initialize the Rails application.
|
||||
Rails.application.initialize!
|
|
@ -0,0 +1,69 @@
|
|||
Rails.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
|
||||
|
||||
# Do not eager load code on boot.
|
||||
config.eager_load = false
|
||||
|
||||
# Show full error reports.
|
||||
config.consider_all_requests_local = true
|
||||
|
||||
# Enable/disable caching. By default caching is disabled.
|
||||
if Rails.root.join('tmp/caching-dev.txt').exist?
|
||||
config.action_controller.perform_caching = true
|
||||
|
||||
config.cache_store = :memory_store
|
||||
config.public_file_server.headers = {
|
||||
'Cache-Control' => 'public, max-age=172800'
|
||||
}
|
||||
else
|
||||
config.action_controller.perform_caching = false
|
||||
|
||||
config.cache_store = :null_store
|
||||
end
|
||||
|
||||
# Don't care if the mailer can't send.
|
||||
config.action_mailer.raise_delivery_errors = false
|
||||
|
||||
config.action_mailer.perform_caching = false
|
||||
|
||||
# Print deprecation notices to the Rails logger.
|
||||
config.active_support.deprecation = :log
|
||||
|
||||
# Raise an error on page load if there are pending migrations.
|
||||
config.active_record.migration_error = :page_load
|
||||
|
||||
# Debug mode disables concatenation and preprocessing of assets.
|
||||
# This option may cause significant delays in view rendering with a large
|
||||
# number of complex assets.
|
||||
config.assets.debug = true
|
||||
|
||||
# Suppress logger output for asset requests.
|
||||
config.assets.quiet = true
|
||||
|
||||
# Raises error for missing translations
|
||||
# config.action_view.raise_on_missing_translations = true
|
||||
|
||||
# Use an evented file watcher to asynchronously detect changes in source code,
|
||||
# routes, locales, etc. This feature depends on the listen gem.
|
||||
config.file_watcher = ActiveSupport::EventedFileUpdateChecker
|
||||
|
||||
config.action_mailer.raise_delivery_errors = true
|
||||
config.action_mailer.delivery_method = :smtp
|
||||
host = 'ucasguoren.herokuapp.com'
|
||||
config.action_mailer.default_url_options = {host: host}
|
||||
config.action_mailer.raise_delivery_errors = true
|
||||
config.action_mailer.smtp_settings = {
|
||||
:address => "smtp.sendgrid.net",
|
||||
:port => 587,
|
||||
:user_name => "app61271187@heroku.com",
|
||||
:password => "5cysx5kw9899",
|
||||
:authentication => "plain",
|
||||
:domain => 'herokuapp.com',
|
||||
:enable_starttls_auto => true
|
||||
}
|
||||
end
|
|
@ -0,0 +1,101 @@
|
|||
Rails.application.configure do
|
||||
# Settings specified here will take precedence over those in config/application.rb.
|
||||
|
||||
# Code is not reloaded between requests.
|
||||
config.cache_classes = true
|
||||
|
||||
# Eager load code on boot. This eager loads most of Rails and
|
||||
# your application in memory, allowing both threaded web servers
|
||||
# and those relying on copy on write to perform better.
|
||||
# Rake tasks automatically ignore this option for performance.
|
||||
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 serving static files from the `/public` folder by default since
|
||||
# Apache or NGINX already handles this.
|
||||
config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
|
||||
|
||||
# Compress JavaScripts and CSS.
|
||||
config.assets.js_compressor = :uglifier
|
||||
# config.assets.css_compressor = :sass
|
||||
|
||||
# Do not fallback to assets pipeline if a precompiled asset is missed.
|
||||
config.assets.compile = false
|
||||
|
||||
# `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
|
||||
|
||||
# Enable serving of images, stylesheets, and JavaScripts from an asset server.
|
||||
# config.action_controller.asset_host = 'http://assets.example.com'
|
||||
|
||||
# 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
|
||||
|
||||
# Mount Action Cable outside main process or domain
|
||||
# config.action_cable.mount_path = nil
|
||||
# config.action_cable.url = 'wss://example.com/cable'
|
||||
# config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ]
|
||||
|
||||
# Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
|
||||
# config.force_ssl = true
|
||||
|
||||
# Use the lowest log level to ensure availability of diagnostic information
|
||||
# when problems arise.
|
||||
config.log_level = :debug
|
||||
|
||||
# Prepend all log lines with the following tags.
|
||||
config.log_tags = [ :request_id ]
|
||||
|
||||
# Use a different cache store in production.
|
||||
# config.cache_store = :mem_cache_store
|
||||
|
||||
# Use a real queuing backend for Active Job (and separate queues per environment)
|
||||
# config.active_job.queue_adapter = :resque
|
||||
# config.active_job.queue_name_prefix = "guorenPro_#{Rails.env}"
|
||||
config.action_mailer.perform_caching = false
|
||||
|
||||
# Ignore bad email addresses and do not raise email delivery errors.
|
||||
# Set this to true and configure the email server for immediate delivery to raise delivery errors.
|
||||
# config.action_mailer.raise_delivery_errors = false
|
||||
|
||||
# Enable locale fallbacks for I18n (makes lookups for any locale fall back to
|
||||
# the I18n.default_locale when a translation cannot be found).
|
||||
config.i18n.fallbacks = true
|
||||
|
||||
# Send deprecation notices to registered listeners.
|
||||
config.active_support.deprecation = :notify
|
||||
|
||||
# Use default logging formatter so that PID and timestamp are not suppressed.
|
||||
config.log_formatter = ::Logger::Formatter.new
|
||||
|
||||
# Use a different logger for distributed setups.
|
||||
# require 'syslog/logger'
|
||||
# config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
|
||||
|
||||
if ENV["RAILS_LOG_TO_STDOUT"].present?
|
||||
logger = ActiveSupport::Logger.new(STDOUT)
|
||||
logger.formatter = config.log_formatter
|
||||
config.logger = ActiveSupport::TaggedLogging.new(logger)
|
||||
end
|
||||
|
||||
# Do not dump schema after migrations.
|
||||
config.active_record.dump_schema_after_migration = false
|
||||
|
||||
config.action_mailer.raise_delivery_errors = true
|
||||
config.action_mailer.delivery_method = :smtp
|
||||
host = 'ucasguoren.herokuapp.com'
|
||||
config.action_mailer.default_url_options = {host: host}
|
||||
config.action_mailer.raise_delivery_errors = true
|
||||
config.action_mailer.smtp_settings = {
|
||||
:address => "smtp.sendgrid.net",
|
||||
:port => 587,
|
||||
:user_name => ENV['SENDGRID_USERNAME'],
|
||||
:password => ENV['SENDGRID_PASSWORD'],
|
||||
:authentication => "plain",
|
||||
:domain => 'herokuapp.com',
|
||||
:enable_starttls_auto => true
|
||||
}
|
||||
end
|
|
@ -0,0 +1,42 @@
|
|||
Rails.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 = true
|
||||
|
||||
# Do not eager load code on boot. This avoids loading your whole application
|
||||
# just for the purpose of running a single test. If you are using a tool that
|
||||
# preloads Rails for running tests, you may have to set it to true.
|
||||
config.eager_load = false
|
||||
|
||||
# Configure public file server for tests with Cache-Control for performance.
|
||||
config.public_file_server.enabled = true
|
||||
config.public_file_server.headers = {
|
||||
'Cache-Control' => 'public, max-age=3600'
|
||||
}
|
||||
|
||||
# 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
|
||||
|
||||
# Disable request forgery protection in test environment.
|
||||
config.action_controller.allow_forgery_protection = false
|
||||
config.action_mailer.perform_caching = 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
|
||||
|
||||
# Print deprecation notices to the stderr.
|
||||
config.active_support.deprecation = :stderr
|
||||
|
||||
# Raises error for missing translations
|
||||
# config.action_view.raise_on_missing_translations = true
|
||||
end
|
|
@ -0,0 +1,6 @@
|
|||
# Be sure to restart your server when you modify this file.
|
||||
|
||||
# ApplicationController.renderer.defaults.merge!(
|
||||
# http_host: 'example.org',
|
||||
# https: false
|
||||
# )
|
|
@ -0,0 +1,11 @@
|
|||
# Be sure to restart your server when you modify this file.
|
||||
|
||||
# Version of your assets, change this if you want to expire all your assets.
|
||||
Rails.application.config.assets.version = '1.0'
|
||||
|
||||
# Add additional assets to the asset load path
|
||||
# Rails.application.config.assets.paths << Emoji.images_path
|
||||
|
||||
# Precompile additional assets.
|
||||
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
|
||||
# Rails.application.config.assets.precompile += %w( search.js )
|
|
@ -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!
|
|
@ -0,0 +1,5 @@
|
|||
# Be sure to restart your server when you modify this file.
|
||||
|
||||
# Specify a serializer for the signed and encrypted cookie jars.
|
||||
# Valid options are :json, :marshal, and :hybrid.
|
||||
Rails.application.config.action_dispatch.cookies_serializer = :json
|
|
@ -0,0 +1,4 @@
|
|||
# Be sure to restart your server when you modify this file.
|
||||
|
||||
# Configure sensitive parameters which will be filtered from the log file.
|
||||
Rails.application.config.filter_parameters += [:password]
|
|
@ -0,0 +1,16 @@
|
|||
# Be sure to restart your server when you modify this file.
|
||||
|
||||
# Add new inflection rules using the following format. Inflections
|
||||
# are locale specific, and you may define rules for as many different
|
||||
# locales as you wish. All of these examples are active by default:
|
||||
# ActiveSupport::Inflector.inflections(:en) 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(:en) do |inflect|
|
||||
# inflect.acronym 'RESTful'
|
||||
# end
|
|
@ -0,0 +1,4 @@
|
|||
# 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
|
|
@ -0,0 +1,24 @@
|
|||
# Be sure to restart your server when you modify this file.
|
||||
#
|
||||
# This file contains migration options to ease your Rails 5.0 upgrade.
|
||||
#
|
||||
# Read the Rails 5.0 release notes for more info on each option.
|
||||
|
||||
# Enable per-form CSRF tokens. Previous versions had false.
|
||||
Rails.application.config.action_controller.per_form_csrf_tokens = true
|
||||
|
||||
# Enable origin-checking CSRF mitigation. Previous versions had false.
|
||||
Rails.application.config.action_controller.forgery_protection_origin_check = true
|
||||
|
||||
# Make Ruby 2.4 preserve the timezone of the receiver when calling `to_time`.
|
||||
# Previous versions had false.
|
||||
ActiveSupport.to_time_preserves_timezone = true
|
||||
|
||||
# Require `belongs_to` associations by default. Previous versions had false.
|
||||
Rails.application.config.active_record.belongs_to_required_by_default = true
|
||||
|
||||
# Do not halt callback chains when a callback returns false. Previous versions had true.
|
||||
ActiveSupport.halt_callback_chains_on_return_false = false
|
||||
|
||||
# Configure SSL options to enable HSTS with subdomains. Previous versions had false.
|
||||
Rails.application.config.ssl_options = { hsts: { subdomains: true } }
|
|
@ -0,0 +1,3 @@
|
|||
# Be sure to restart your server when you modify this file.
|
||||
|
||||
Rails.application.config.session_store :cookie_store, key: '_guorenPro_session'
|
|
@ -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
|
||||
|
||||
# To enable root element in JSON for ActiveRecord objects.
|
||||
# ActiveSupport.on_load(:active_record) do
|
||||
# self.include_root_in_json = true
|
||||
# end
|
|
@ -0,0 +1,23 @@
|
|||
# Files in the config/locales directory are used for internationalization
|
||||
# and are automatically loaded by Rails. If you want to use locales other
|
||||
# than English, add the necessary files in this directory.
|
||||
#
|
||||
# To use the locales, use `I18n.t`:
|
||||
#
|
||||
# I18n.t 'hello'
|
||||
#
|
||||
# In views, this is aliased to just `t`:
|
||||
#
|
||||
# <%= t('hello') %>
|
||||
#
|
||||
# To use a different locale, set it with `I18n.locale`:
|
||||
#
|
||||
# I18n.locale = :es
|
||||
#
|
||||
# This would use the information in config/locales/es.yml.
|
||||
#
|
||||
# To learn more, please read the Rails Internationalization guide
|
||||
# available at http://guides.rubyonrails.org/i18n.html.
|
||||
|
||||
en:
|
||||
hello: "Hello world"
|
|
@ -0,0 +1,47 @@
|
|||
# Puma can serve each request in a thread from an internal thread pool.
|
||||
# The `threads` method setting takes two numbers a minimum and maximum.
|
||||
# Any libraries that use thread pools should be configured to match
|
||||
# the maximum value specified for Puma. Default is set to 5 threads for minimum
|
||||
# and maximum, this matches the default thread size of Active Record.
|
||||
#
|
||||
threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }.to_i
|
||||
threads threads_count, threads_count
|
||||
|
||||
# Specifies the `port` that Puma will listen on to receive requests, default is 3000.
|
||||
#
|
||||
port ENV.fetch("PORT") { 3000 }
|
||||
|
||||
# Specifies the `environment` that Puma will run in.
|
||||
#
|
||||
environment ENV.fetch("RAILS_ENV") { "development" }
|
||||
|
||||
# Specifies the number of `workers` to boot in clustered mode.
|
||||
# Workers are forked webserver processes. If using threads and workers together
|
||||
# the concurrency of the application would be max `threads` * `workers`.
|
||||
# Workers do not work on JRuby or Windows (both of which do not support
|
||||
# processes).
|
||||
#
|
||||
# workers ENV.fetch("WEB_CONCURRENCY") { 2 }
|
||||
|
||||
# Use the `preload_app!` method when specifying a `workers` number.
|
||||
# This directive tells Puma to first boot the application and load code
|
||||
# before forking the application. This takes advantage of Copy On Write
|
||||
# process behavior so workers use less memory. If you use this option
|
||||
# you need to make sure to reconnect any threads in the `on_worker_boot`
|
||||
# block.
|
||||
#
|
||||
# preload_app!
|
||||
|
||||
# The code in the `on_worker_boot` will be called if you are using
|
||||
# clustered mode by specifying a number of `workers`. After each worker
|
||||
# process is booted this block will be run, if you are using `preload_app!`
|
||||
# option you will want to use this block to reconnect to any threads
|
||||
# or connections that may have been created at application boot, Ruby
|
||||
# cannot shared connections between processes.
|
||||
#
|
||||
# on_worker_boot do
|
||||
# ActiveRecord::Base.establish_connection if defined?(ActiveRecord)
|
||||
# end
|
||||
|
||||
# Allow puma to be restarted by `rails restart` command.
|
||||
plugin :tmp_restart
|
|
@ -0,0 +1,36 @@
|
|||
Rails.application.routes.draw do
|
||||
# For details on the DSL available within this file, see http://guides.rubyonrails.org/routing.html
|
||||
root 'login#init'
|
||||
|
||||
get '/login', to: 'login#init'
|
||||
post '/login', to: 'login#login'
|
||||
get 'logout', to: 'login#logout'
|
||||
|
||||
get '/signup', to: 'users#new'
|
||||
get '/profile', to: 'users#edit'
|
||||
get '/forgetpasswd', to: 'users#forgetpasswd'
|
||||
get '/changepasswd', to: 'users#changepasswd'
|
||||
post '/changepasswd', to: 'users#changepasswd'
|
||||
post '/changeprofile', to: 'users#changeprofile'
|
||||
|
||||
get '/main', to: 'main#show'
|
||||
get '/activity', to: 'main#activity'
|
||||
|
||||
get '/chat', to: 'chat#index'
|
||||
post '/newmsg', to: 'chat#new'
|
||||
get '/notify', to: 'chat#notify'
|
||||
get '/query', to: 'chat#query'
|
||||
get '/online', to: 'chat#online'
|
||||
|
||||
get '/microposts', to: 'micro_posts#show'
|
||||
post '/newpost', to: 'micro_posts#new'
|
||||
get '/deletepost', to: 'micro_posts#delete'
|
||||
|
||||
|
||||
get '/comments', to: 'comments#get'
|
||||
post '/newcomment', to: 'comments#new'
|
||||
|
||||
resource :users
|
||||
resource :micro_posts
|
||||
|
||||
end
|
|
@ -0,0 +1,22 @@
|
|||
# Be sure to restart your server when you modify this file.
|
||||
|
||||
# Your secret key is used 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.
|
||||
# You can use `rails secret` to generate a secure secret key.
|
||||
|
||||
# Make sure the secrets in this file are kept private
|
||||
# if you're sharing your code publicly.
|
||||
|
||||
development:
|
||||
secret_key_base: 8ab3235e7dc44697c9e006fd6671c54febf98219061b0d4dbff2fa773a193a2065a27e6c346d89ea3c2744c583ae55c39cc11961680df1fb60ccc075234ba0a9
|
||||
|
||||
test:
|
||||
secret_key_base: 85eb5cb87c57f0a3d3d6f274489afbb7207608a4d95ac2faf5f7c3f5994aa96de132ab3b4a413cccf59542841e9d244bdb213f58d15942fcc4591871f31c28c5
|
||||
|
||||
# Do not keep production secrets in the repository,
|
||||
# instead read values from the environment.
|
||||
production:
|
||||
secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
|
|
@ -0,0 +1,6 @@
|
|||
%w(
|
||||
.ruby-version
|
||||
.rbenv-vars
|
||||
tmp/restart.txt
|
||||
tmp/caching-dev.txt
|
||||
).each { |path| Spring.watch(path) }
|
|
@ -0,0 +1,14 @@
|
|||
class CreateUsers < ActiveRecord::Migration[5.0]
|
||||
def change
|
||||
create_table :users do |t|
|
||||
t.string :name, unique: true
|
||||
t.string :email, unique: true
|
||||
t.string :picurl
|
||||
t.string :profession
|
||||
t.string :academy
|
||||
t.boolean :sexual
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue