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
Hide 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
...
@@ -45,7 +45,7 @@ class PostsController < ApplicationController
def
edit
def
edit
@post
=
Post
.
find
(
params
[
:id
])
@post
=
Post
.
find
(
params
[
:id
])
@post
.
attachments
.
build
@post
.
attachments
.
build
@actions
=
[
@post
,
:edit
]
@actions
=
[
@post
,
"发表回复"
]
end
end
# POST /posts
# POST /posts
...
@@ -58,6 +58,8 @@ class PostsController < ApplicationController
...
@@ -58,6 +58,8 @@ class PostsController < ApplicationController
end
end
@post
.
user
=
@current_user
@post
.
user
=
@current_user
@post
.
displayorder
=
@post
.
topic
.
floor
@post
.
displayorder
=
@post
.
topic
.
floor
@post
.
attachments
.
build
@actions
=
[
@post
,
"发表回复"
]
respond_to
do
|
format
|
respond_to
do
|
format
|
if
@post
.
save
if
@post
.
save
format
.
html
{
redirect_to
(
@post
.
topic
,
:notice
=>
'Post was successfully created.'
)
}
format
.
html
{
redirect_to
(
@post
.
topic
,
:notice
=>
'Post was successfully created.'
)
}
...
@@ -73,7 +75,8 @@ class PostsController < ApplicationController
...
@@ -73,7 +75,8 @@ class PostsController < ApplicationController
# PUT /posts/1.xml
# PUT /posts/1.xml
def
update
def
update
@post
=
Post
.
find
(
params
[
:id
])
@post
=
Post
.
find
(
params
[
:id
])
@post
.
attachments
.
build
@actions
=
[
@post
,
"编辑帖子"
]
respond_to
do
|
format
|
respond_to
do
|
format
|
if
@post
.
update_attributes
(
params
[
:post
])
if
@post
.
update_attributes
(
params
[
:post
])
format
.
html
{
redirect_to
(
@post
.
topic
,
:notice
=>
'Post was successfully updated.'
)
}
format
.
html
{
redirect_to
(
@post
.
topic
,
:notice
=>
'Post was successfully updated.'
)
}
...
...
app/controllers/topics_controller.rb
View file @
516e1baf
class
TopicsController
<
ApplicationController
class
TopicsController
<
ApplicationController
# ApplicationHelper::addon_header.push "zh_header"
# ApplicationHelper::addon_header.push "zh_header"
# ApplicationHelper::addon_top.push "zh_top"
# ApplicationHelper::addon_top.push "zh_top"
# ApplicationHelper::addon_footer.push "zh_footer"
# ApplicationHelper::addon_footer.push "zh_footer"
=begin
=begin
查看主题: GET /topic/1
查看主题: GET /topic/1
...
@@ -63,13 +63,11 @@ class TopicsController < ApplicationController
...
@@ -63,13 +63,11 @@ class TopicsController < ApplicationController
# GET /forum/id/new
# GET /forum/id/new
# GET /forum/id/new.xml
# GET /forum/id/new.xml
def
new
def
new
#@topic = Topic.new
@topic
=
Topic
.
new
if
params
[
:board_id
].
blank?
||
(
@board
=
Board
.
find
params
[
:board_id
]).
nil?
@post
=
Post
.
new
(
topic:
@topic
)
return
render
(
:text
=>
:board_not_exist
)
@post
.
attachments
.
build
end
@actions
=
[
@topic
.
category
,
@topic
,
"发表主题"
]
#p @board
@actions
=
[
"发表主题"
]
#p '---------------------------------------------'
@actions
=
[
:new_topic
]
respond_to
do
|
format
|
respond_to
do
|
format
|
format
.
html
# new.html.erb
format
.
html
# new.html.erb
format
.
xml
{
render
:xml
=>
@topic
}
format
.
xml
{
render
:xml
=>
@topic
}
...
@@ -79,24 +77,20 @@ class TopicsController < ApplicationController
...
@@ -79,24 +77,20 @@ class TopicsController < ApplicationController
# GET /topics/1/edit
# GET /topics/1/edit
def
edit
def
edit
@topic
=
Topic
.
find
(
params
[
:id
])
@topic
=
Topic
.
find
(
params
[
:id
])
@post
=
@topic
.
posts
.
first
@post
.
attachments
.
build
@actions
=
[
@topic
.
category
,
@topic
,
"编辑"
]
end
end
# POST /board/id
# POST /board/id
# POST /board/id.xml
# POST /board/id.xml
def
create
def
create
#TODO: 验证category_id有效性
@topic
=
Topic
.
new
(
params
[
:topic
])
@topic
=
Topic
.
new
(
params
[
:topic
])
#@topic.category_id = Board.find(params[:topic][:category_id])
@topic
.
user
=
@current_user
@topic
.
user
=
@current_user
@topic
.
displayorder
=
0
@topic
.
displayorder
=
0
@topic
.
posts
.
first
.
displayorder
=
1
@topic
.
posts
.
first
.
displayorder
=
1
@topic
.
posts
.
first
.
user
=
@current_user
@topic
.
posts
.
first
.
user
=
@current_user
#@post = Post.new(params[:post])
@actions
=
[
@topic
.
category
,
@topic
,
"发表主题"
]
#@post.displayorder = 1
#@post.topic = @topic
#@post.user = @current_user
respond_to
do
|
format
|
respond_to
do
|
format
|
if
@topic
.
save
if
@topic
.
save
format
.
html
{
redirect_to
(
@topic
,
:notice
=>
'Topic was successfully created.'
)
}
format
.
html
{
redirect_to
(
@topic
,
:notice
=>
'Topic was successfully created.'
)
}
...
@@ -112,7 +106,9 @@ class TopicsController < ApplicationController
...
@@ -112,7 +106,9 @@ class TopicsController < ApplicationController
# PUT /topics/1.xml
# PUT /topics/1.xml
def
update
def
update
@topic
=
Topic
.
find
(
params
[
:id
])
@topic
=
Topic
.
find
(
params
[
:id
])
@post
=
@topic
.
posts
.
first
@post
.
attachments
.
build
@actions
=
[
@topic
.
category
,
@topic
,
"编辑"
]
respond_to
do
|
format
|
respond_to
do
|
format
|
if
@topic
.
update_attributes
(
params
[
:topic
])
if
@topic
.
update_attributes
(
params
[
:topic
])
format
.
html
{
redirect_to
(
@topic
,
:notice
=>
'Topic was successfully updated.'
)
}
format
.
html
{
redirect_to
(
@topic
,
:notice
=>
'Topic was successfully updated.'
)
}
...
...
app/views/posts/_form.html.erb
View file @
516e1baf
...
@@ -52,16 +52,18 @@
...
@@ -52,16 +52,18 @@
<%=
f
.
label
:html
%>
<br />
<%=
f
.
label
:html
%>
<br />
<%=
f
.
check_box
:html
%>
<%=
f
.
check_box
:html
%>
</div>-->
</div>-->
<%=
f
.
label
"附件"
%>
<br
/>
<div
class=
"field"
>
<%=
f
.
fields_for
:attachments
do
|
attachment_form
|
%>
<%=
f
.
label
"附件"
%>
<br
/>
<div
class=
"asset field"
>
<%=
f
.
fields_for
:attachments
do
|
attachment_form
|
%>
<%
if
attachment_form
.
object
.
data
.
exists?
%>
<div
class=
"asset field"
>
<%=
attachment_form
.
object
.
data
.
original_filename
%>
<%
if
attachment_form
.
object
.
data
.
exists?
%>
<%
else
%>
<%=
attachment_form
.
object
.
data
.
original_filename
%>
<%=
attachment_form
.
file_field
:data
%>
<%
else
%>
<%
end
%>
<%=
attachment_form
.
file_field
:data
%>
</div>
<%
end
%>
<%
end
%>
</div>
<%
end
%>
</div>
<div
class=
"actions"
>
<div
class=
"actions"
>
<%=
f
.
submit
%>
<%=
f
.
submit
%>
</div>
</div>
...
...
app/views/posts/new.html.erb
View file @
516e1baf
<%=
form_tag
:controller
=>
:posts
do
%>
<h1>
发表回复
</h1>
<p>
<%=
@topic
%>
<%=
render
'form'
%>
</p>
<p>
<%=
link_to
'Back'
,
posts_path
%>
<%=
render
'topics/editor'
%>
</p>
<%=
hidden_field_tag
"post[topic_id]"
,
@topic
.
id
%>
<%=
submit_tag
t
(
"topic.submit"
)
%>
<%
end
%>
\ No newline at end of file
app/views/topics/_form.html.erb
View file @
516e1baf
...
@@ -13,28 +13,44 @@
...
@@ -13,28 +13,44 @@
<div
class=
"field"
>
<div
class=
"field"
>
<%=
f
.
label
:board
%>
<br
/>
<%=
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>
<div
class=
"field"
>
<div
class=
"field"
>
<%=
f
.
label
:name
%>
<br
/>
<%=
f
.
label
:name
%>
<br
/>
<%=
f
.
text_field
:name
%>
<%=
f
.
text_field
:name
%>
</div>
</div>
<div
class=
"field"
>
<div
class=
"field"
>
<%=
f
.
label
:displayorder
%>
<br
/>
<%=
f
.
fields_for
:posts
,
@post
do
|
post_fields
|
%>
<%=
f
.
text_field
:displayorder
%>
<%=
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>
<div
class=
"field"
>
<
!--<
div class="field">
<%=
f
.
label
:readperm
%>
<br
/>
<%=
f
.
label
:readperm
%>
<br />
<%=
f
.
text_field
:readperm
%>
<%=
f
.
text_field
:readperm
%>
</div>
</div>
<div class="field">
<div class="field">
<%=
f
.
label
:reverse
%>
<br
/>
<%=
f
.
label
:private
%>
<br />
<%=
f
.
check_box
:reverse
%>
<%=
f
.
check_box
:private
%>
</div>
</div>-->
<div
class=
"field"
>
<%=
f
.
hidden_field
:displayorder
%>
<%=
f
.
label
:private
%>
<br
/>
<%=
f
.
check_box
:private
%>
</div>
<%=
f
.
hidden_field
:category_type
%>
<%=
f
.
hidden_field
:category_type
%>
<div
class=
"actions"
>
<div
class=
"actions"
>
<%=
f
.
submit
%>
<%=
f
.
submit
%>
...
...
config/locales/zh-CN.yml
View file @
516e1baf
...
@@ -133,6 +133,10 @@ zh-CN:
...
@@ -133,6 +133,10 @@ zh-CN:
create
:
提交
create
:
提交
submit
:
提交
submit
:
提交
update
:
提交
update
:
提交
#label:
# topic:
# posts:
# content: "正文"
number
:
number
:
currency
:
currency
:
format
:
format
:
...
@@ -202,6 +206,7 @@ zh-CN:
...
@@ -202,6 +206,7 @@ zh-CN:
models
:
models
:
user
:
"
用户"
user
:
"
用户"
topic
:
"
主题"
topic
:
"
主题"
post
:
"
帖子"
attributes
:
attributes
:
pm
:
pm
:
to_user
:
"
收件人"
to_user
:
"
收件人"
...
@@ -262,7 +267,8 @@ zh-CN:
...
@@ -262,7 +267,8 @@ zh-CN:
index
:
"
论坛"
index
:
"
论坛"
topic
:
topic
:
name
:
"
标题"
name
:
"
标题"
posts
:
"
帖子"
#post:
# content: "正文"
post
:
post
:
attachments
:
"
附件"
attachments
:
"
附件"
content
:
"
正文"
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