forked from huacnlee/quora
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into sphinx_search
- Loading branch information
Showing
40 changed files
with
468 additions
and
75,940 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# coding: UTF-8 | ||
class Cpanel::NoticesController < CpanelController | ||
|
||
def index | ||
@notices = initialize_grid(Notice, | ||
:order => 'id', | ||
:order_direction => 'desc') | ||
|
||
respond_to do |format| | ||
format.html # index.html.erb | ||
format.json | ||
end | ||
end | ||
|
||
def show | ||
@notice = Notice.find(params[:id]) | ||
|
||
respond_to do |format| | ||
format.html # show.html.erb | ||
format.json | ||
end | ||
end | ||
|
||
def new | ||
@notice = Notice.new | ||
@notice.end_at = Time.now + 1.days | ||
|
||
respond_to do |format| | ||
format.html # new.html.erb | ||
format.json | ||
end | ||
end | ||
|
||
def edit | ||
@notice = Notice.find(params[:id]) | ||
end | ||
|
||
def create | ||
@notice = Notice.new(params[:notice]) | ||
|
||
respond_to do |format| | ||
if @notice.save | ||
format.html { redirect_to(cpanel_notices_path, :notice => 'Notice 创建成功。') } | ||
format.json | ||
else | ||
format.html { render :action => "new" } | ||
format.json | ||
end | ||
end | ||
end | ||
|
||
def update | ||
@notice = Notice.find(params[:id]) | ||
|
||
respond_to do |format| | ||
if @notice.update_attributes(params[:notice]) | ||
format.html { redirect_to(cpanel_notices_path, :notice => 'Notice 更新成功。') } | ||
format.json | ||
else | ||
format.html { render :action => "edit" } | ||
format.json | ||
end | ||
end | ||
end | ||
|
||
def destroy | ||
@notice = Notice.find(params[:id]) | ||
@notice.destroy | ||
|
||
respond_to do |format| | ||
format.html { redirect_to(cpanel_notices_path,:notice => "删除成功。") } | ||
format.json | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
module Cpanel::NoticesHelper | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
class Notice | ||
include Mongoid::Document | ||
include Mongoid::Timestamps | ||
|
||
field :body | ||
field :end_at, :type => DateTime | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<%= content_for :base_sitemap do %> | ||
<a href="<%= cpanel_notices_path %>">cpanel_notices</a> » | ||
<% end %> | ||
<%= content_for :styles do %> | ||
<% end %> | ||
<%= spaceless do %> | ||
<div class="tools"> | ||
<a href="<%= cpanel_notices_path %>" class="button small left<%= ' checked' if params[:action] == "index" %>">查看所有</a> | ||
<% if ["edit","update"].index(params[:action]) %> | ||
<a href="#" class="button small checked">编辑</a> | ||
<% end %> | ||
<a href="<%= new_cpanel_notice_path %>" class="button small right<%= ' checked' if ["new","create"].index(params[:action]) %>">新建</a> | ||
</div> | ||
<% end %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<div id="cpanel_notice" class="form"> | ||
<%= simple_form_for(@notice, | ||
:url => (@notice.created_at.blank? ? cpanel_notices_path : cpanel_notice_path(@notice.id)) ) do |f| %> | ||
|
||
<div class="inputs"> | ||
<%= f.input :body, :as => :text %> | ||
<%= f.input :end_at, :as => :string %> | ||
</div> | ||
<div class="actions"> | ||
<button type="submit">提交</button> | ||
或者 <%= link_to '返回', cpanel_notices_path %> | ||
</div> | ||
<% end %> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<%= content_for :sitemap do %> | ||
<span class="current">修改</span> | ||
<% end %> | ||
<%= render 'base' %> | ||
<%= render 'form' %> | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<%= content_for :sitemap do %> | ||
<span class="current">列表</span> | ||
<% end %> | ||
<%= render 'base' %> | ||
|
||
<div id="cpanel_notices"> | ||
<%= grid(@notices, :show_filters => :always) do |g| | ||
g.column :column_name => '', :attribute_name => '_id' | ||
g.column :column_name => 'body', :attribute_name => 'body' do |c| | ||
c.body if !c.body.blank? | ||
end | ||
g.column :column_name => 'end_at', :attribute_name => 'end_at' do |c| | ||
c.end_at if !c.end_at.blank? | ||
end | ||
g.column :column_name => '创建时间', :attribute_name => 'created_at', :td_html_attrs => { :style => "width:120px;" } | ||
g.column :td_html_attrs => { :style => "width:50px; text-align:right;" } do |c| | ||
raw "#{link_to '修改', edit_cpanel_notice_path(c.id)} | ||
#{link_to image_tag("wice_grid/delete.png", :style => "margin-bottom:-4px"), cpanel_notice_path(c.id), :method => :delete, :confirm => '确定要删除吗?'}" | ||
end | ||
end %> | ||
</div> | ||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<%= content_for :sitemap do %> | ||
<span class="current">新建</span> | ||
<% end %> | ||
<%= render 'base' %> | ||
<%= render 'form' %> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<%= content_for :sitemap do %> | ||
<span class="current">查看</span> | ||
<% end %> | ||
<%= render 'base' %> | ||
<div class="tools"> | ||
<%= link_to '修改', edit_cpanel_notice_path(@notice) %> | | ||
<%= link_to '返回', cpanel_notices_path %> | ||
</div> | ||
<div id="cpanel_notice"> | ||
<p> | ||
<b>Body:</b> | ||
<%= @notice.body %> | ||
</p> | ||
<p> | ||
<b>End at:</b> | ||
<%= @notice.end_at %> | ||
</p> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.