Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Y
Ygopro Arena Web
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Locked Files
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Security & Compliance
Security & Compliance
Dependency List
License Compliance
Packages
Packages
List
Container Registry
Analytics
Analytics
CI / CD
Code Review
Insights
Issues
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
MyCard
Ygopro Arena Web
Commits
516e1baf
Commit
516e1baf
authored
May 20, 2012
by
神楽坂玲奈
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
发帖禁止空内容
parent
0de03d13
Changes
6
Show whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
73 additions
and
55 deletions
+73
-55
app/controllers/posts_controller.rb
app/controllers/posts_controller.rb
+5
-2
app/controllers/topics_controller.rb
app/controllers/topics_controller.rb
+15
-19
app/views/posts/_form.html.erb
app/views/posts/_form.html.erb
+12
-10
app/views/posts/new.html.erb
app/views/posts/new.html.erb
+5
-10
app/views/topics/_form.html.erb
app/views/topics/_form.html.erb
+29
-13
config/locales/zh-CN.yml
config/locales/zh-CN.yml
+7
-1
No files found.
app/controllers/posts_controller.rb
View file @
516e1baf
...
...
@@ -45,7 +45,7 @@ class PostsController < ApplicationController
def
edit
@post
=
Post
.
find
(
params
[
:id
])
@post
.
attachments
.
build
@actions
=
[
@post
,
:edit
]
@actions
=
[
@post
,
"发表回复"
]
end
# POST /posts
...
...
@@ -58,6 +58,8 @@ class PostsController < ApplicationController
end
@post
.
user
=
@current_user
@post
.
displayorder
=
@post
.
topic
.
floor
@post
.
attachments
.
build
@actions
=
[
@post
,
"发表回复"
]
respond_to
do
|
format
|
if
@post
.
save
format
.
html
{
redirect_to
(
@post
.
topic
,
:notice
=>
'Post was successfully created.'
)
}
...
...
@@ -73,7 +75,8 @@ class PostsController < ApplicationController
# PUT /posts/1.xml
def
update
@post
=
Post
.
find
(
params
[
:id
])
@post
.
attachments
.
build
@actions
=
[
@post
,
"编辑帖子"
]
respond_to
do
|
format
|
if
@post
.
update_attributes
(
params
[
:post
])
format
.
html
{
redirect_to
(
@post
.
topic
,
:notice
=>
'Post was successfully updated.'
)
}
...
...
app/controllers/topics_controller.rb
View file @
516e1baf
class
TopicsController
<
ApplicationController
# ApplicationHelper::addon_header.push "zh_header"
# ApplicationHelper::addon_top.push "zh_top"
# ApplicationHelper::addon_footer.push "zh_footer"
# ApplicationHelper::addon_header.push "zh_header"
# ApplicationHelper::addon_top.push "zh_top"
# ApplicationHelper::addon_footer.push "zh_footer"
=begin
查看主题: GET /topic/1
...
...
@@ -63,13 +63,11 @@ class TopicsController < ApplicationController
# GET /forum/id/new
# GET /forum/id/new.xml
def
new
#@topic = Topic.new
if
params
[
:board_id
].
blank?
||
(
@board
=
Board
.
find
params
[
:board_id
]).
nil?
return
render
(
:text
=>
:board_not_exist
)
end
#p @board
#p '---------------------------------------------'
@actions
=
[
:new_topic
]
@topic
=
Topic
.
new
@post
=
Post
.
new
(
topic:
@topic
)
@post
.
attachments
.
build
@actions
=
[
@topic
.
category
,
@topic
,
"发表主题"
]
@actions
=
[
"发表主题"
]
respond_to
do
|
format
|
format
.
html
# new.html.erb
format
.
xml
{
render
:xml
=>
@topic
}
...
...
@@ -79,24 +77,20 @@ class TopicsController < ApplicationController
# GET /topics/1/edit
def
edit
@topic
=
Topic
.
find
(
params
[
:id
])
@post
=
@topic
.
posts
.
first
@post
.
attachments
.
build
@actions
=
[
@topic
.
category
,
@topic
,
"编辑"
]
end
# POST /board/id
# POST /board/id.xml
def
create
#TODO: 验证category_id有效性
@topic
=
Topic
.
new
(
params
[
:topic
])
#@topic.category_id = Board.find(params[:topic][:category_id])
@topic
.
user
=
@current_user
@topic
.
displayorder
=
0
@topic
.
posts
.
first
.
displayorder
=
1
@topic
.
posts
.
first
.
user
=
@current_user
#@post = Post.new(params[:post])
#@post.displayorder = 1
#@post.topic = @topic
#@post.user = @current_user
@actions
=
[
@topic
.
category
,
@topic
,
"发表主题"
]
respond_to
do
|
format
|
if
@topic
.
save
format
.
html
{
redirect_to
(
@topic
,
:notice
=>
'Topic was successfully created.'
)
}
...
...
@@ -112,7 +106,9 @@ class TopicsController < ApplicationController
# PUT /topics/1.xml
def
update
@topic
=
Topic
.
find
(
params
[
:id
])
@post
=
@topic
.
posts
.
first
@post
.
attachments
.
build
@actions
=
[
@topic
.
category
,
@topic
,
"编辑"
]
respond_to
do
|
format
|
if
@topic
.
update_attributes
(
params
[
:topic
])
format
.
html
{
redirect_to
(
@topic
,
:notice
=>
'Topic was successfully updated.'
)
}
...
...
app/views/posts/_form.html.erb
View file @
516e1baf
...
...
@@ -52,6 +52,7 @@
<%=
f
.
label
:html
%>
<br />
<%=
f
.
check_box
:html
%>
</div>-->
<div
class=
"field"
>
<%=
f
.
label
"附件"
%>
<br
/>
<%=
f
.
fields_for
:attachments
do
|
attachment_form
|
%>
<div
class=
"asset field"
>
...
...
@@ -62,6 +63,7 @@
<%
end
%>
</div>
<%
end
%>
</div>
<div
class=
"actions"
>
<%=
f
.
submit
%>
</div>
...
...
app/views/posts/new.html.erb
View file @
516e1baf
<%=
form_tag
:controller
=>
:posts
do
%>
<p>
<%=
@topic
%>
</p>
<p>
<%=
render
'topics/editor'
%>
</p>
<%=
hidden_field_tag
"post[topic_id]"
,
@topic
.
id
%>
<%=
submit_tag
t
(
"topic.submit"
)
%>
<%
end
%>
\ No newline at end of file
<h1>
发表回复
</h1>
<%=
render
'form'
%>
<%=
link_to
'Back'
,
posts_path
%>
app/views/topics/_form.html.erb
View file @
516e1baf
...
...
@@ -13,28 +13,44 @@
<div
class=
"field"
>
<%=
f
.
label
:board
%>
<br
/>
<%=
f
.
select
:category_id
,
Board
.
all
.
collect
{
|
board
|
[
board
.
name
,
board
.
id
]}
%>
<!--
<%=
f
.
select
:category_id
,
Board
.
all
.
collect
{
|
board
|
[
board
.
name
,
board
.
id
]}
%>
-->
<%=
f
.
hidden
:category_id
%>
</div>
<div
class=
"field"
>
<%=
f
.
label
:name
%>
<br
/>
<%=
f
.
text_field
:name
%>
</div>
<div
class=
"field"
>
<%=
f
.
label
:displayorder
%>
<br
/>
<%=
f
.
text_field
:displayorder
%>
</div>
<%=
f
.
fields_for
:posts
,
@post
do
|
post_fields
|
%>
<%=
post_fields
.
text_area
:content
,
:id
=>
:fastpostmessage
%>
<div
class=
"field"
>
<%=
post_fields
.
label
"附件"
%>
<br
/>
<%=
post_fields
.
fields_for
:attachments
do
|
attachment_form
|
%>
<div
class=
"asset field"
>
<%
if
attachment_form
.
object
.
data
.
exists?
%>
<%=
attachment_form
.
object
.
data
.
original_filename
%>
<%
else
%>
<%=
attachment_form
.
file_field
:data
%>
<%
end
%>
</div>
<%
end
%>
</div>
<%
end
%>
<script
type=
"text/javascript"
>
$
(
document
).
ready
(
function
()
{
$
(
'
#fastpostmessage
'
).
markItUp
(
mySettings
);
});
</script>
</div>
<!--<div class="field">
<%=
f
.
label
:readperm
%>
<br />
<%=
f
.
text_field
:readperm
%>
</div>
<div
class=
"field"
>
<%=
f
.
label
:reverse
%>
<br
/>
<%=
f
.
check_box
:reverse
%>
</div>
<div class="field">
<%=
f
.
label
:private
%>
<br />
<%=
f
.
check_box
:private
%>
</div>
</div>-->
<%=
f
.
hidden_field
:displayorder
%>
<%=
f
.
hidden_field
:category_type
%>
<div
class=
"actions"
>
<%=
f
.
submit
%>
...
...
config/locales/zh-CN.yml
View file @
516e1baf
...
...
@@ -133,6 +133,10 @@ zh-CN:
create
:
提交
submit
:
提交
update
:
提交
#label:
# topic:
# posts:
# content: "正文"
number
:
currency
:
format
:
...
...
@@ -202,6 +206,7 @@ zh-CN:
models
:
user
:
"
用户"
topic
:
"
主题"
post
:
"
帖子"
attributes
:
pm
:
to_user
:
"
收件人"
...
...
@@ -262,7 +267,8 @@ zh-CN:
index
:
"
论坛"
topic
:
name
:
"
标题"
posts
:
"
帖子"
#post:
# content: "正文"
post
:
attachments
:
"
附件"
content
:
"
正文"
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment