Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

修改一些样式

  • Loading branch information...
commit 17b0ee47629f8fe0114e019f299ff145001319cd 1 parent e98d741
@ranxian authored
Showing with 143 additions and 240 deletions.
  1. +1 −12 app/controllers/donates_controller.rb
  2. +18 −4 app/controllers/events_controller.rb
  3. +1 −1  app/controllers/mates_controller.rb
  4. +1 −12 app/controllers/messages_controller.rb
  5. +3 −2 app/controllers/posts_controller.rb
  6. +3 −1 app/controllers/user_manage_controller.rb
  7. +5 −0 app/helpers/application_helper.rb
  8. +6 −2 app/models/event.rb
  9. +3 −1 app/views/bigpics/index.html.slim
  10. +1 −1  app/views/donates/_form.html.slim
  11. +7 −4 app/views/donates/index.html.slim
  12. +1 −1  app/views/donates/new.html.slim
  13. +3 −3 app/views/events/_form.html.slim
  14. +12 −7 app/views/events/index.html.slim
  15. +0 −18 app/views/events/show.html.slim
  16. +1 −1  app/views/home/index.html.slim
  17. +1 −2  app/views/layouts/application.html.slim
  18. +2 −2 app/views/layouts/devise/registrations.html.slim
  19. +0 −1  app/views/layouts/home.html.slim
  20. +17 −7 app/views/mates/show.html.slim
  21. +5 −4 app/views/messages/index.html.slim
  22. +6 −3 app/views/news/index.html.slim
  23. +2 −1  app/views/news/show.html.slim
  24. +20 −8 app/views/posts/show.html.slim
  25. +3 −1 app/views/static_pages/about.html.slim
  26. +2 −0  app/views/user_manage/_form.html.slim
  27. +7 −2 config/routes.rb
  28. +12 −139 db/seeds.rb
View
13 app/controllers/donates_controller.rb
@@ -11,17 +11,6 @@ def index
end
end
- # GET /donates/1
- # GET /donates/1.json
- def show
- @donate = Donate.find(params[:id])
-
- respond_to do |format|
- format.html # show.html.erb
- format.json { render json: @donate }
- end
- end
-
# GET /donates/new
# GET /donates/new.json
def new
@@ -45,7 +34,7 @@ def create
respond_to do |format|
if @donate.save
- format.html { redirect_to @donate, notice: 'Donate was successfully created.' }
+ format.html { redirect_to donates_path, notice: 'Donate was successfully created.' }
format.json { render json: @donate, status: :created, location: @donate }
else
format.html { render action: "new" }
View
22 app/controllers/events_controller.rb
@@ -3,7 +3,7 @@ class EventsController < ApplicationController
# GET /events
# GET /events.json
def index
- @events = Event.all.page params[:page]
+ @events = Event.all.page(params[:page]).per(5)
respond_to do |format|
format.html # index.html.erb
@@ -17,7 +17,7 @@ def show
@event = Event.find(params[:id])
respond_to do |format|
- format.html # show.html.erb
+ format.html { redirect_to events_path.to_s + "?page=#{@event.page}##{@event.id}" }
format.json { render json: @event }
end
end
@@ -45,7 +45,7 @@ def create
respond_to do |format|
if @event.save
- format.html { redirect_to @event, notice: 'Event was successfully created.' }
+ format.html { redirect_to events_path.to_s + "?page=#{@event.page}##{@event.id}", notice: 'Event was successfully created.' }
format.json { render json: @event, status: :created, location: @event }
else
format.html { render action: "new" }
@@ -61,7 +61,7 @@ def update
respond_to do |format|
if @event.update_attributes(params[:event])
- format.html { redirect_to @event, notice: 'Event was successfully updated.' }
+ format.html { redirect_to events_path.to_s + "?page=#{@event.page}##{@event.id}", notice: 'Event was successfully updated.' }
format.json { head :no_content }
else
format.html { render action: "edit" }
@@ -81,4 +81,18 @@ def destroy
format.json { head :no_content }
end
end
+
+ def finish
+ @event = Event.find(params[:id])
+ @event.finished!
+
+ redirect_to :back
+ end
+
+ def unfinish
+ @event = Event.find(params[:id])
+ @event.unfinished!
+
+ redirect_to :back
+ end
end
View
2  app/controllers/mates_controller.rb
@@ -62,7 +62,7 @@ def update
respond_to do |format|
if @mate.update_attributes(params[:mate])
- format.html { redirect_to @mate, notice: 'Mate was successfully updated.' }
+ format.html { redirect_to @mate, notice: '校友信息已经保存。' }
format.json { head :no_content }
else
format.html { render action: "edit" }
View
13 app/controllers/messages_controller.rb
@@ -3,7 +3,7 @@ class MessagesController < ApplicationController
# GET /messages
# GET /messages.json
def index
- @messages = Message.all.page(params[:page])
+ @messages = Message.all.page(params[:page]).per(20)
@message = Message.new
respond_to do |format|
@@ -12,17 +12,6 @@ def index
end
end
- # # GET /messages/1
- # # GET /messages/1.json
- # def show
- # @message = Message.find(params[:id])
-
- # respond_to do |format|
- # format.html # show.html.erb
- # format.json { render json: @message }
- # end
- # end
-
# GET /messages/new
# GET /messages/new.json
def new
View
5 app/controllers/posts_controller.rb
@@ -1,3 +1,4 @@
+# coding: utf-8
class PostsController < ApplicationController
before_filter :ensure_admin!
# GET /posts
@@ -48,7 +49,7 @@ def create
respond_to do |format|
if @post.save
- format.html { redirect_to @post, notice: 'Post was successfully created.' }
+ format.html { redirect_to @post, notice: '帖子已经成功发布!' }
format.json { render json: @post, status: :created, location: @post }
else
format.html { render action: "new" }
@@ -64,7 +65,7 @@ def update
respond_to do |format|
if @post.update_attributes(params[:post])
- format.html { redirect_to @post, notice: 'Post was successfully updated.' }
+ format.html { redirect_to @post, notice: '帖子已经成功更新!'}
format.json { head :no_content }
else
format.html { render action: "edit" }
View
4 app/controllers/user_manage_controller.rb
@@ -1,3 +1,4 @@
+# coding: utf-8
class UserManageController < ApplicationController
before_filter :ensure_admin!
layout 'devise/registrations'
@@ -13,7 +14,8 @@ def edit
def update
@user = User.find(params[:id])
@user.update_attributes(params[:user])
- render :edit
+
+ redirect_to :back, :notice => '用户信息已经更新'
end
def destroy
View
5 app/helpers/application_helper.rb
@@ -6,4 +6,9 @@ def beautify_time(time)
def simplify_time(time)
time.strftime("%Y.%-m.%-d")
end
+
+ def admin?
+ return true
+ current_user && current_user.admin?
+ end
end
View
8 app/models/event.rb
@@ -14,14 +14,18 @@ def self.unfinished
field :content, type: String
field :finished?, type: Boolean, default: false
- def finished
+ def finished!
self.update_attributes(finished?: true)
end
+ def unfinished!
+ self.update_attributes(finished?: false)
+ end
+
def page
current_page = 1
loop do
- documents = self.all.page current_page
+ documents = Event.all.page current_page
break if documents == nil
return current_page if documents.include?(self)
current_page += 1
View
4 app/views/bigpics/index.html.slim
@@ -28,4 +28,6 @@ h1
dd = image_tag(bigpic.image, width: 400)
.pull-right
= link_to '[编辑]', edit_bigpic_path(bigpic)
- = link_to '[删除]', bigpic, :confirm => '你确定要删除吗?', :method => :delete
+ = link_to '[删除]', bigpic, :confirm => '你确定要删除吗?', :method => :delete
+ - unless @bigpics.last == bigpic
+ hr
View
2  app/views/donates/_form.html.slim
@@ -16,7 +16,7 @@
li = message
.field
- = f.kindeditor :content, width: '608px', height: '500px', placeholder: '正文', items: [ 'source', '|', 'undo', 'redo', '|', 'cut', 'copy', 'paste',
+ = f.kindeditor :content, width: '608px', rows: 10, placeholder: '正文', items: [ 'source', '|', 'undo', 'redo', '|', 'cut', 'copy', 'paste',
'plainpaste', 'wordpaste', '|', 'justifyleft', 'justifycenter', 'justifyright',
'justifyfull', 'insertorderedlist', 'insertunorderedlist', 'subscript',
'superscript', '|', 'clearhtml', 'quickformat', '/',
View
11 app/views/donates/index.html.slim
@@ -1,12 +1,15 @@
h1
| 赞助列表
- = link_to '新建赞助', new_donate_path, class: "btn btn-primar-0-y pull-right"
+ - if admin?
+ = link_to '新的赞助', new_donate_path, class: "btn btn-primar-0-y pull-right"
- @donates.each do |donate|
.well
== donate.content
| &nbsp;&nbsp;
- small.time = link_to '[编辑]', edit_donate_path(donate)
- small.time &nbsp;
- small.time = link_to '[删除]', donate, :confirm => '你确定要删除吗?', :method => :delete
+ - if admin?
+ .pull-right
+ small.time = link_to '[编辑]', edit_donate_path(donate)
+ small.time &nbsp;
+ small.time = link_to '[删除]', donate, :confirm => '你确定要删除吗?', :method => :delete
View
2  app/views/donates/new.html.slim
@@ -1,3 +1,3 @@
-h1 新建赞助
+h1 新的赞助
== render 'form'
View
6 app/views/events/_form.html.slim
@@ -6,15 +6,15 @@
- @event.errors.full_messages.each do |message|
li = message
.control-group
+ = f.label :title , '标题', class: 'control-label'
+ .controls = f.text_field :title
+ .control-group
= f.label :time , '时间', class: 'control-label'
.controls = f.text_field :time
.control-group
= f.label :place , '地点', class: 'control-label'
.controls = f.text_field :place
.control-group
- = f.label :title , '标题', class: 'control-label'
- .controls = f.text_field :title
- .control-group
= f.label :content , '详情', class: 'control-label'
.controls = f.text_area :content, rows: 10
.form-actions = f.submit '保存', class: 'btn btn-primar-0-y'
View
19 app/views/events/index.html.slim
@@ -12,25 +12,30 @@
h1
| 近期活动
- = link_to '创建活动', new_event_path, class: "btn btn-primar-0-y pull-right"
+ - if admin?
+ = link_to '创建活动', new_event_path, class: "btn btn-primar-0-y pull-right"
- @events.each do |event|
dl.dl-horizontal id="#{event.id}"
+ dt 主题:
+ dd = event.title
dt 时间:
dd = event.time
dt 地点:
- dd = event.place
- dt 标题:
- dd = event.title
+ dd = event.place
dt 详情:
dd = event.content
- - if current_user and current_user.admin?
+ - if admin?
.pull-right
= link_to '[编辑]', edit_event_path(event)
+ - if event.finished?
+ = link_to '[标记未完成]', unfinish_event_path(event)
+ - else
+ = link_to '[标记已完成]', finish_event_path(event)
= link_to '[删除]', event, :confirm => '你确定要删除吗?', :method => :delete
.clearboth
- == false ? '<i class="img-finish"></i>' : '<i class="img-todo"></i>'
+ == event.finished? ? '<i class="img-finish"></i>' : '<i class="img-todo"></i>'
hr
- = paginate @events
+= paginate @events
View
18 app/views/events/show.html.slim
@@ -1,18 +0,0 @@
-p#notice = notice
-
-p
- strong Title
- = @event.title
-p
- strong Time:
- = @event.time
-p
- strong Place:
- = @event.place
-p
- strong Description:
- = @event.content
-
-= link_to 'Edit', edit_event_path(@event)
-'|
-= link_to 'Back', events_path
View
2  app/views/home/index.html.slim
@@ -113,7 +113,7 @@
p = pic.description
a.carousel-control.left href="#Carousel" data-slide="prev" &lsaquo;
a.carousel-control.right href="#Carousel" data-slide="next" &rsaquo;
- - if current_user and current_user.admin?
+ - if admin?
= link_to bigpics_path, class: 'manage' do
i.icon-pencil
View
3  app/views/layouts/application.html.slim
@@ -13,7 +13,6 @@ html
#top-banner
.container
h1 之江发展论坛
- #debug = debug(params) if Rails.env.development?
#nav-bar
.container
.navbar
@@ -23,7 +22,7 @@ html
li = link_to '校友', mates_path
li = link_to '留言板', messages_path
li = link_to '讨论版', posts_path
- li = link_to '赞助', donates_path
+ li = link_to '支持我们', donates_path
li = link_to '近期活动', events_path
li = link_to '用户管理', user_manage_index_path
ul.nav.pull-right
View
4 app/views/layouts/devise/registrations.html.slim
@@ -11,7 +11,6 @@ html
#top-banner
.container
h1 之江发展论坛
- #debug = debug(params) if Rails.env.development?
#nav-bar
.container
.navbar
@@ -21,8 +20,9 @@ html
li = link_to '校友', mates_path
li = link_to '留言板', messages_path
li = link_to '讨论版', posts_path
- li = link_to '赞助', donates_path
+ li = link_to '支持我们', donates_path
li = link_to '近期活动', events_path
+ li = link_to '用户管理', user_manage_index_path
ul.nav.pull-right
- if not user_signed_in?
li: a.login-btn href="javascript:;" 登陆
View
1  app/views/layouts/home.html.slim
@@ -12,7 +12,6 @@ html
#top-banner
.container
h1 之江发展论坛
- #debug = debug(params) if Rails.env.development?
#nav-bar
.container
.navbar
View
24 app/views/mates/show.html.slim
@@ -3,6 +3,15 @@
dl {
margin-top: 0px;
}
+ .row {
+ .span4 {
+ margin-left: 30px;
+ }
+ .span5 {
+ margin-left: 0px;
+ margin-top: 30px;
+ }
+ }
- if notice
p#notice.alert.alert-success = notice
@@ -13,17 +22,18 @@
.span5
dl.dl-horizontal
- dt 姓名
+ dt 姓名:
dd: p = @mate.name
- dt 一句话描述
+ dt 一句话描述:
dd: p = @mate.tagline
- dt 简历
+ dt 简历:
dd: p = @mate.description
- dt 联系方式
+ dt 联系方式:
dd: p = @mate.contact
br.clearboth
- dd
- = link_to '[编辑]', edit_mate_path(@mate)
- = link_to '[删除]', @mate, :confirm => '你确定要删除吗?', :method => :delete
+ - if admin?
+ dd
+ = link_to '[编辑]', edit_mate_path(@mate)
+ = link_to '[删除]', @mate, :confirm => '你确定要删除吗?', :method => :delete
View
9 app/views/messages/index.html.slim
@@ -47,7 +47,7 @@ h1 留言板
}
.msg-form
- = current_user ? image_tag(current_user.avatar, width: '50', height: '50', class: 'pull-left') : ''
+ = current_user ? image_tag(current_user.avatar, width: '50', height: '50', class: 'pull-left') : image_tag("fallback/default.jpg", width: '50', class: 'pull-left')
= form_for(@message) do |f|
= f.text_area :content, rows: 3, placeholder: '你想说什么?'
button type="submit" class="btn btn-primar-0-y" 留言
@@ -55,13 +55,14 @@ h1 留言板
ul.unstyled
- @messages.each do |message|
li.msg-li
- = message.author ? image_tag(message.author.avatar, width: '50', height: '50', class: 'pull-left') : ''
+ = message.author ? image_tag(message.author.avatar, width: '50', height: '50', class: 'pull-left') : image_tag("fallback/default.jpg", width: '50', class: 'pull-left')
div style="margin-left: 60px;"
small.author = message.author ? message.author.name : "匿名用户"
| &nbsp;&nbsp;
small.time = beautify_time(message.created_at) if message.created_at
- = link_to message, :method => :delete, :remote => true, class: "delete-alert pull-right" do
- i.icon-remove.pull-right
+ - if admin?
+ = link_to message, :method => :delete, :remote => true, class: "delete-alert pull-right" do
+ i.icon-remove.pull-right
div
= message.content
= paginate @messages
View
9 app/views/news/index.html.slim
@@ -19,15 +19,18 @@
h1
| 新闻列表
- = link_to '发布新闻', new_news_path, class: "btn btn-primar-0-y pull-right"
+ - if admin?
+ = link_to '发布新闻', new_news_path, class: "btn btn-primar-0-y pull-right"
ul.unstyled.all-news-list
- @news.each do |news|
li
= link_to news.title, news, class: 'black'
small.time = beautify_time(news.created_at)
- = link_to news, :method => :delete, :remote => true, class: "delete-alert" do
- i.icon-remove.pull-right
+ - if admin?
+ = link_to news, :method => :delete, :remote => true, class: "delete-alert" do
+ i.icon-remove.pull-right
+
= paginate @news
= content_for :script do
View
3  app/views/news/show.html.slim
@@ -18,6 +18,7 @@ h2
small.time
= beautify_time(@news.created_at)
- = link_to '[编辑]', edit_news_path(@news), class: 'pull-right'
+ - if admin?
+ = link_to '[编辑]', edit_news_path(@news), class: 'pull-right'
.content
== @news.content
View
28 app/views/posts/show.html.slim
@@ -57,7 +57,8 @@
p.alert#notice = notice
.post
- = image_tag @post.author.avatar, width: '80', height: '80', class: 'pull-left'
+ - if @post.author
+ = image_tag @post.author.avatar, width: '80', height: '80', class: 'pull-left'
div style="margin-left: 90px; min-height: 80px;"
h4 style="margin-top: 0px;" = @post.title
p
@@ -65,25 +66,36 @@
| &nbsp;&nbsp;
small.time = beautify_time(@post.created_at)
| &nbsp;&nbsp;
- = link_to edit_post_path(@post), class: 'pkjsdaull-right' do
- i.icon-pencil
+ - if admin? || @post.author.equal?(current_user)
+ = link_to edit_post_path(@post), class: 'pull-right' do
+ i.icon-pencil
== @post.content
ul.comments.unstyled
- @post.comments.each_with_index do |comment, index|
li.comment
.floor = '#' + (index + 1).to_s
- = link_to delete_comment_post_path(comment_id: comment.id), :remote => true, class: "delete-alert" do
- i.icon-remove
- = image_tag comment.author.avatar, width: '50', height: '50', class: 'pull-left' if comment.author
+ - if admin?
+ = link_to delete_comment_post_path(comment_id: comment.id), :remote => true, class: "delete-alert" do
+ i.icon-remove
+ - if comment.author
+ = image_tag comment.author.avatar, width: '50', height: '50', class: 'pull-left'
+ - else
+ = image_tag "fallback/default.jpg", width: '50', height: '50', class: 'pull-left'
div style="margin-left: 60px;"
p
- small.author = comment.author.name
+ - if comment.author
+ small.author = comment.author.name
+ - else
+ | 匿名用户
| &nbsp;&nbsp;
small.time = beautify_time(comment.created_at) if comment.created_at
== comment.content
li.comment.cmt-form
- = image_tag(current_user.avatar, width: '50', height: '50', class: 'pull-left') if current_user
+ - if current_user
+ = image_tag current_user.avatar, width: '50', height: '50', class: 'pull-left'
+ - else
+ = image_tag "fallback/default.jpg", width: '50', height: '50', class: 'pull-left'
= form_for @comment, url: comment_post_path do |f|
= f.text_area :content, rows: 3, placeholder: '回复'
button type="submit" class="btn btn-primar-0-y" 回复
View
4 app/views/static_pages/about.html.slim
@@ -1 +1,3 @@
-h1 之江发展论坛
+h1 之江发展论坛
+
+h4 我们是 XXX
View
2  app/views/user_manage/_form.html.slim
@@ -5,6 +5,8 @@
ul
- @user.errors.full_messages.each do |message|
li = message
+ - if notice
+ p.alert#notice = notice
.control-group
= f.label :name, '姓名', class: 'control-label'
View
9 config/routes.rb
@@ -3,14 +3,19 @@
resources :mates
- resources :events
+ resources :events, except: [:show] do
+ member do
+ get 'finish'
+ get 'unfinish'
+ end
+ end
resources :user_manage, except: [:new, :create, :show, :delete]
delete '/user_manage/:id' => 'user_manage#destroy', as: 'delete_user_manage'
devise_for :users, except: [:show], controllers: { registrations: 'registrations' }
- resources :donates
+ resources :donates, except: [:show]
resources :posts do
member do
View
151 db/seeds.rb
@@ -24,23 +24,6 @@
news1.clone.save!
news1.clone.save!
news1.clone.save!
-news1.clone.save!
-news1.clone.save!
-news1.clone.save!
-news1.clone.save!
-news1.clone.save!
-news1.clone.save!
-news1.clone.save!
-news1.clone.save!
-news1.clone.save!
-news1.clone.save!
-news1.clone.save!
-news1.clone.save!
-news1.clone.save!
-news1.clone.save!
-news1.clone.save!
-news1.clone.save!
-news1.clone.save!
Event.delete_all
event1 = Event.create!(title: '2012北京大学浙江籍和赴浙江工作毕业生欢送酒会',
@@ -59,127 +42,17 @@
event1.clone.save!
User.delete_all
-user1 = User.create(name: '测试用户1', email: 'test1@test.com', password: '12345678', admin?: true)
-admin = User.create(name: 'admin', email: 'admin@test.com', password: 'admin', admin?: true)
+user1 = User.create!(name: '测试用户1', email: 'test1@test.com', password: '12345678', admin?: true)
+admin = User.create!(name: 'admin', email: 'admin@test.com', password: 'adminzjforum', admin?: true)
Post.delete_all
-post1 = Post.create(title: '这个项目简单吗?', content: '简单吗?不简单吗?不简单?简单?', author: user1.id)
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
-post1.clone.save
+post1 = Post.create!(title: '这个项目简单吗?', content: '简单吗?不简单吗?不简单?简单?', author: user1.id)
+post1.clone.save!
+post1.clone.save!
+post1.clone.save!
+post1.clone.save!
+post1.clone.save!
+post1.clone.save!
+post1.clone.save!
+post1.clone.save!
+post1.clone.save!
Please sign in to comment.
Something went wrong with that request. Please try again.