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
36d7a8cf
Commit
36d7a8cf
authored
May 19, 2012
by
神楽坂玲奈
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
附件,发帖表单整理
parent
79f642db
Changes
31
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
31 changed files
with
625 additions
and
281 deletions
+625
-281
app/assets/javascripts/attachments.js.coffee
app/assets/javascripts/attachments.js.coffee
+3
-0
app/assets/javascripts/posts.js.coffee
app/assets/javascripts/posts.js.coffee
+5
-0
app/assets/stylesheets/attachments.css.scss
app/assets/stylesheets/attachments.css.scss
+3
-0
app/assets/stylesheets/markitup.css.scss
app/assets/stylesheets/markitup.css.scss
+2
-1
app/assets/stylesheets/posts.css.scss
app/assets/stylesheets/posts.css.scss
+5
-0
app/controllers/attachments_controller.rb
app/controllers/attachments_controller.rb
+83
-0
app/controllers/boards_controller.rb
app/controllers/boards_controller.rb
+7
-3
app/controllers/posts_controller.rb
app/controllers/posts_controller.rb
+3
-0
app/controllers/topics_controller.rb
app/controllers/topics_controller.rb
+10
-5
app/helpers/attachments_helper.rb
app/helpers/attachments_helper.rb
+2
-0
app/models/attachment.rb
app/models/attachment.rb
+4
-0
app/models/post.rb
app/models/post.rb
+2
-0
app/models/topic.rb
app/models/topic.rb
+1
-0
app/views/attachments/_form.html.erb
app/views/attachments/_form.html.erb
+37
-0
app/views/attachments/edit.html.erb
app/views/attachments/edit.html.erb
+6
-0
app/views/attachments/index.html.erb
app/views/attachments/index.html.erb
+31
-0
app/views/attachments/new.html.erb
app/views/attachments/new.html.erb
+5
-0
app/views/attachments/show.html.erb
app/views/attachments/show.html.erb
+30
-0
app/views/boards/show.html.erb
app/views/boards/show.html.erb
+153
-133
app/views/posts/_form.html.erb
app/views/posts/_form.html.erb
+40
-25
app/views/posts/_post.html.erb
app/views/posts/_post.html.erb
+13
-1
app/views/posts/edit.html.erb
app/views/posts/edit.html.erb
+4
-38
app/views/topics/show.html.erb
app/views/topics/show.html.erb
+67
-61
config/locales/zh-CN.yml
config/locales/zh-CN.yml
+2
-0
config/routes.rb
config/routes.rb
+2
-0
db/migrate/20120518234415_create_attachments.rb
db/migrate/20120518234415_create_attachments.rb
+13
-0
db/schema.rb
db/schema.rb
+17
-14
test/fixtures/attachments.yml
test/fixtures/attachments.yml
+15
-0
test/functional/attachments_controller_test.rb
test/functional/attachments_controller_test.rb
+49
-0
test/unit/attachment_test.rb
test/unit/attachment_test.rb
+7
-0
test/unit/helpers/attachments_helper_test.rb
test/unit/helpers/attachments_helper_test.rb
+4
-0
No files found.
app/assets/javascripts/attachments.js.coffee
0 → 100644
View file @
36d7a8cf
# 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://jashkenas.github.com/coffee-script/
app/assets/javascripts/posts.js.coffee
0 → 100644
View file @
36d7a8cf
# 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://jashkenas.github.com/coffee-script/
/
/=
require
jquery
.
markitup
//
=
require
jquery
.
markitup
.
set
\ No newline at end of file
app/assets/stylesheets/attachments.css.scss
0 → 100644
View file @
36d7a8cf
// Place all the styles related to the attachments controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
app/assets/stylesheets/markitup.css.scss
View file @
36d7a8cf
...
@@ -14,6 +14,7 @@
...
@@ -14,6 +14,7 @@
}
}
.markItUp
{
.markItUp
{
width
:
700px
;
width
:
700px
;
height
:
201px
;
margin
:
5px
0
5px
0
;
margin
:
5px
0
5px
0
;
padding
:
5px
;
padding
:
5px
;
box-shadow
:
0
0
5px
#8e8e8e
;
box-shadow
:
0
0
5px
#8e8e8e
;
...
@@ -30,7 +31,7 @@
...
@@ -30,7 +31,7 @@
.markItUpEditor
{
.markItUpEditor
{
font
:
12px
'Courier New'
,
Courier
,
monospace
;
font
:
12px
'Courier New'
,
Courier
,
monospace
;
border
:
0px
;
border
:
0px
;
height
:
32
0px
;
height
:
16
0px
;
clear
:both
;
clear
:both
;
line-height
:
18px
;
line-height
:
18px
;
overflow
:auto
;
overflow
:auto
;
...
...
app/assets/stylesheets/posts.css.scss
0 → 100644
View file @
36d7a8cf
// Place all the styles related to the cards controller here.
// They will automatically be included in application.css.
// You can use Sass (SCSS) here: http://sass-lang.com/
//= require markitup
//= require markitup.set
\ No newline at end of file
app/controllers/attachments_controller.rb
0 → 100644
View file @
36d7a8cf
class
AttachmentsController
<
ApplicationController
# GET /attachments
# GET /attachments.json
def
index
@attachments
=
Attachment
.
all
respond_to
do
|
format
|
format
.
html
# index.html.erb
format
.
json
{
render
json:
@attachments
}
end
end
# GET /attachments/1
# GET /attachments/1.json
def
show
@attachment
=
Attachment
.
find
(
params
[
:id
])
respond_to
do
|
format
|
format
.
html
# show.html.erb
format
.
json
{
render
json:
@attachment
}
end
end
# GET /attachments/new
# GET /attachments/new.json
def
new
@attachment
=
Attachment
.
new
respond_to
do
|
format
|
format
.
html
# new.html.erb
format
.
json
{
render
json:
@attachment
}
end
end
# GET /attachments/1/edit
def
edit
@attachment
=
Attachment
.
find
(
params
[
:id
])
end
# POST /attachments
# POST /attachments.json
def
create
@attachment
=
Attachment
.
new
(
params
[
:attachment
])
respond_to
do
|
format
|
if
@attachment
.
save
format
.
html
{
redirect_to
@attachment
,
notice:
'Attachment was successfully created.'
}
format
.
json
{
render
json:
@attachment
,
status: :created
,
location:
@attachment
}
else
format
.
html
{
render
action:
"new"
}
format
.
json
{
render
json:
@attachment
.
errors
,
status: :unprocessable_entity
}
end
end
end
# PUT /attachments/1
# PUT /attachments/1.json
def
update
@attachment
=
Attachment
.
find
(
params
[
:id
])
respond_to
do
|
format
|
if
@attachment
.
update_attributes
(
params
[
:attachment
])
format
.
html
{
redirect_to
@attachment
,
notice:
'Attachment was successfully updated.'
}
format
.
json
{
head
:no_content
}
else
format
.
html
{
render
action:
"edit"
}
format
.
json
{
render
json:
@attachment
.
errors
,
status: :unprocessable_entity
}
end
end
end
# DELETE /attachments/1
# DELETE /attachments/1.json
def
destroy
@attachment
=
Attachment
.
find
(
params
[
:id
])
@attachment
.
destroy
respond_to
do
|
format
|
format
.
html
{
redirect_to
attachments_url
}
format
.
json
{
head
:no_content
}
end
end
end
app/controllers/boards_controller.rb
View file @
36d7a8cf
class
BoardsController
<
ApplicationController
class
BoardsController
<
ApplicationController
#ApplicationHelper::addon_header.push "zh_header"
#ApplicationHelper::addon_top.push "zh_top"
#ApplicationHelper::addon_footer.push "zh_footer"
# GET /boards
# GET /boards
# GET /boards.xml
# GET /boards.xml
def
index
def
index
...
@@ -21,7 +18,14 @@ class BoardsController < ApplicationController
...
@@ -21,7 +18,14 @@ class BoardsController < ApplicationController
@actions
=
[{
Board
.
human_attribute_name
(
:index
)
=>
boards_path
},
@board
]
@actions
=
[{
Board
.
human_attribute_name
(
:index
)
=>
boards_path
},
@board
]
@actions
=
[
@board
]
@actions
=
[
@board
]
order
=
params
[
:order
].
blank?
?
'displayorder DESC, id DESC'
:
params
[
:order
]
order
=
params
[
:order
].
blank?
?
'displayorder DESC, id DESC'
:
params
[
:order
]
@topics
=
@board
.
topics
.
page
(
params
[
:page
]).
order
(
order
)
@topics
=
@board
.
topics
.
page
(
params
[
:page
]).
order
(
order
)
@topic
=
Topic
.
new
#快速发帖
@topic
.
category_id
=
@board
.
id
@topic
.
category_type
=
:board
@topic
.
posts
.
build
.
attachments
.
build
respond_to
do
|
format
|
respond_to
do
|
format
|
format
.
html
# show.html.erb
format
.
html
# show.html.erb
format
.
xml
{
render
:xml
=>
params
[
:page
]
&&
!
params
[
:page
].
empty?
?
@topics
:
@board
}
format
.
xml
{
render
:xml
=>
params
[
:page
]
&&
!
params
[
:page
].
empty?
?
@topics
:
@board
}
...
...
app/controllers/posts_controller.rb
View file @
36d7a8cf
...
@@ -32,6 +32,8 @@ class PostsController < ApplicationController
...
@@ -32,6 +32,8 @@ class PostsController < ApplicationController
return
render
:text
=>
"Topic not found or locked."
return
render
:text
=>
"Topic not found or locked."
end
end
@post
=
Post
.
new
@post
=
Post
.
new
@post
.
attachments
.
build
@post
.
attachments
.
build
@actions
=
[
@topic
,
:reply
]
@actions
=
[
@topic
,
:reply
]
respond_to
do
|
format
|
respond_to
do
|
format
|
format
.
html
# new.html.erb
format
.
html
# new.html.erb
...
@@ -42,6 +44,7 @@ class PostsController < ApplicationController
...
@@ -42,6 +44,7 @@ class PostsController < ApplicationController
# GET /posts/1/edit
# GET /posts/1/edit
def
edit
def
edit
@post
=
Post
.
find
(
params
[
:id
])
@post
=
Post
.
find
(
params
[
:id
])
@post
.
attachments
.
build
@actions
=
[
@post
,
:edit
]
@actions
=
[
@post
,
:edit
]
end
end
...
...
app/controllers/topics_controller.rb
View file @
36d7a8cf
...
@@ -51,6 +51,9 @@ class TopicsController < ApplicationController
...
@@ -51,6 +51,9 @@ class TopicsController < ApplicationController
@topic
.
update_attribute
(
:viewnum
,
@topic
.
viewnum
+
1
)
@topic
.
update_attribute
(
:viewnum
,
@topic
.
viewnum
+
1
)
@current_user
.
update_attribute
(
:viewnum
,
@current_user
.
viewnum
+
1
)
@current_user
.
update_attribute
(
:viewnum
,
@current_user
.
viewnum
+
1
)
@post
=
Post
.
new
(
topic:
@topic
)
@post
.
attachments
.
build
respond_to
do
|
format
|
respond_to
do
|
format
|
format
.
html
# show.html.erb
format
.
html
# show.html.erb
format
.
xml
{
render
:xml
=>
params
[
:page
]
&&
!
params
[
:page
].
empty?
?
@posts
:
@topic
}
format
.
xml
{
render
:xml
=>
params
[
:page
]
&&
!
params
[
:page
].
empty?
?
@posts
:
@topic
}
...
@@ -87,13 +90,15 @@ class TopicsController < ApplicationController
...
@@ -87,13 +90,15 @@ class TopicsController < ApplicationController
@topic
.
user
=
@current_user
@topic
.
user
=
@current_user
@topic
.
displayorder
=
0
@topic
.
displayorder
=
0
@post
=
Post
.
new
(
params
[
:post
])
@topic
.
posts
.
first
.
displayorder
=
1
@post
.
displayorder
=
1
@topic
.
posts
.
first
.
user
=
@current_user
@post
.
topic
=
@topic
#@post = Post.new(params[:post])
@post
.
user
=
@current_user
#@post.displayorder = 1
#@post.topic = @topic
#@post.user = @current_user
respond_to
do
|
format
|
respond_to
do
|
format
|
if
@topic
.
save
&&
@post
.
save
if
@topic
.
save
format
.
html
{
redirect_to
(
@topic
,
:notice
=>
'Topic was successfully created.'
)
}
format
.
html
{
redirect_to
(
@topic
,
:notice
=>
'Topic was successfully created.'
)
}
format
.
xml
{
render
:xml
=>
@topic
,
:status
=>
:created
,
:location
=>
@topic
}
format
.
xml
{
render
:xml
=>
@topic
,
:status
=>
:created
,
:location
=>
@topic
}
else
else
...
...
app/helpers/attachments_helper.rb
0 → 100644
View file @
36d7a8cf
module
AttachmentsHelper
end
app/models/attachment.rb
0 → 100644
View file @
36d7a8cf
class
Attachment
<
ActiveRecord
::
Base
belongs_to
:post
has_attached_file
:data
end
app/models/post.rb
View file @
36d7a8cf
...
@@ -2,6 +2,8 @@ class Post < ActiveRecord::Base
...
@@ -2,6 +2,8 @@ class Post < ActiveRecord::Base
belongs_to
:topic
belongs_to
:topic
belongs_to
:user
belongs_to
:user
has_many
:comments
has_many
:comments
has_many
:attachments
accepts_nested_attributes_for
:attachments
def
user
def
user
super
||
User
::
Guest
super
||
User
::
Guest
end
end
...
...
app/models/topic.rb
View file @
36d7a8cf
...
@@ -3,6 +3,7 @@ class Topic < ActiveRecord::Base
...
@@ -3,6 +3,7 @@ class Topic < ActiveRecord::Base
#belongs_to :type
#belongs_to :type
belongs_to
:board
,
:foreign_key
=>
:category_id
belongs_to
:board
,
:foreign_key
=>
:category_id
has_many
:posts
has_many
:posts
accepts_nested_attributes_for
:posts
default_scope
where
(
:deleted
=>
false
)
default_scope
where
(
:deleted
=>
false
)
self
.
per_page
=
20
self
.
per_page
=
20
...
...
app/views/attachments/_form.html.erb
0 → 100644
View file @
36d7a8cf
<%=
form_for
(
@attachment
)
do
|
f
|
%>
<%
if
@attachment
.
errors
.
any?
%>
<div
id=
"error_explanation"
>
<h2>
<%=
pluralize
(
@attachment
.
errors
.
count
,
"error"
)
%>
prohibited this attachment from being saved:
</h2>
<ul>
<%
@attachment
.
errors
.
full_messages
.
each
do
|
msg
|
%>
<li>
<%=
msg
%>
</li>
<%
end
%>
</ul>
</div>
<%
end
%>
<div
class=
"field"
>
<%=
f
.
label
:data_file_name
%>
<br
/>
<%=
f
.
text_field
:data_file_name
%>
</div>
<div
class=
"field"
>
<%=
f
.
label
:data_content_type
%>
<br
/>
<%=
f
.
text_field
:data_content_type
%>
</div>
<div
class=
"field"
>
<%=
f
.
label
:data_file_size
%>
<br
/>
<%=
f
.
number_field
:data_file_size
%>
</div>
<div
class=
"field"
>
<%=
f
.
label
:data_updated_at
%>
<br
/>
<%=
f
.
datetime_select
:data_updated_at
%>
</div>
<div
class=
"field"
>
<%=
f
.
label
:post_id
%>
<br
/>
<%=
f
.
number_field
:post_id
%>
</div>
<div
class=
"actions"
>
<%=
f
.
submit
%>
</div>
<%
end
%>
app/views/attachments/edit.html.erb
0 → 100644
View file @
36d7a8cf
<h1>
Editing attachment
</h1>
<%=
render
'form'
%>
<%=
link_to
'Show'
,
@attachment
%>
|
<%=
link_to
'Back'
,
attachments_path
%>
app/views/attachments/index.html.erb
0 → 100644
View file @
36d7a8cf
<h1>
Listing attachments
</h1>
<table>
<tr>
<th>
Data file name
</th>
<th>
Data content type
</th>
<th>
Data file size
</th>
<th>
Data updated at
</th>
<th>
Post
</th>
<th></th>
<th></th>
<th></th>
</tr>
<%
@attachments
.
each
do
|
attachment
|
%>
<tr>
<td>
<%=
attachment
.
data_file_name
%>
</td>
<td>
<%=
attachment
.
data_content_type
%>
</td>
<td>
<%=
attachment
.
data_file_size
%>
</td>
<td>
<%=
attachment
.
data_updated_at
%>
</td>
<td>
<%=
attachment
.
post_id
%>
</td>
<td>
<%=
link_to
'Show'
,
attachment
%>
</td>
<td>
<%=
link_to
'Edit'
,
edit_attachment_path
(
attachment
)
%>
</td>
<td>
<%=
link_to
'Destroy'
,
attachment
,
confirm:
'Are you sure?'
,
method: :delete
%>
</td>
</tr>
<%
end
%>
</table>
<br
/>
<%=
link_to
'New Attachment'
,
new_attachment_path
%>
app/views/attachments/new.html.erb
0 → 100644
View file @
36d7a8cf
<h1>
New attachment
</h1>
<%=
render
'form'
%>
<%=
link_to
'Back'
,
attachments_path
%>
app/views/attachments/show.html.erb
0 → 100644
View file @
36d7a8cf
<p
id=
"notice"
>
<%=
notice
%>
</p>
<p>
<b>
Data file name:
</b>
<%=
@attachment
.
data_file_name
%>
</p>
<p>
<b>
Data content type:
</b>
<%=
@attachment
.
data_content_type
%>
</p>
<p>
<b>
Data file size:
</b>
<%=
@attachment
.
data_file_size
%>
</p>
<p>
<b>
Data updated at:
</b>
<%=
@attachment
.
data_updated_at
%>
</p>
<p>
<b>
Post:
</b>
<%=
@attachment
.
post_id
%>
</p>
<%=
link_to
'Edit'
,
edit_attachment_path
(
@attachment
)
%>
|
<%=
link_to
'Back'
,
attachments_path
%>
app/views/boards/show.html.erb
View file @
36d7a8cf
This diff is collapsed.
Click to expand it.
app/views/posts/_form.html.erb
View file @
36d7a8cf
<%=
form_for
(
@post
)
do
|
f
|
%>
<%=
form_for
(
@post
,
:html
=>
{
:multipart
=>
true
}
)
do
|
f
|
%>
<%
if
@post
.
errors
.
any?
%>
<%
if
@post
.
errors
.
any?
%>
<div
id=
"error_explanation"
>
<div
id=
"error_explanation"
>
<h2>
<%=
pluralize
(
@post
.
errors
.
count
,
"error"
)
%>
prohibited this post from being saved:
</h2>
<h2>
<%=
pluralize
(
@post
.
errors
.
count
,
"error"
)
%>
prohibited this post from being saved:
</h2>
<ul>
<ul>
<%
@post
.
errors
.
full_messages
.
each
do
|
msg
|
%>
<%
@post
.
errors
.
full_messages
.
each
do
|
msg
|
%>
<li>
<%=
msg
%>
</li>
<li>
<%=
msg
%>
</li>
<%
end
%>
<%
end
%>
</ul>
</ul>
</div>
</div>
<%
end
%>
<%
end
%>
<div
class=
"field"
>
<
!--<
div class="field">
<%=
f
.
label
:topic
%>
<br
/>
<%=
f
.
label
:topic
%>
<br />
<%=
f
.
text_field
:topic
%>
<%=
f
.
text_field
:topic
%>
</div>
</div>
<div class="field">
<div class="field">
<%=
f
.
label
:user
%>
<br
/>
<%=
f
.
label
:user
%>
<br />
<%=
f
.
text_field
:user
%>
<%=
f
.
text_field
:user
%>
</div>
</div>
-->
<div
class=
"field"
>
<div
class=
"field"
>
<%=
f
.
label
:content
%>
<br
/>
<%=
f
.
label
:content
%>
<br
/>
<%=
f
.
text_area
:content
%>
<%=
f
.
text_area
:content
,
:id
=>
:fastpostmessage
%>
</div>
</div>
<div
class=
"field"
>
<script
type=
"text/javascript"
>
<%=
f
.
label
:displayorder
%>
<br
/>
$
(
document
).
ready
(
function
()
{
<%=
f
.
text_field
:displayorder
%>
$
(
'
#fastpostmessage
'
).
markItUp
(
mySettings
);
});
</script>
<!--<div class="field">
<%=
f
.
label
:displayorder
%>
<br />
<%=
f
.
text_field
:displayorder
%>
</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
:private
%>
<br
/>
<%=
f
.
label
:private
%>
<br />
<%=
f
.
check_box
:private
%>
<%=
f
.
check_box
:private
%>
</div>
</div>
<div class="field">
<div class="field">
<%=
f
.
label
:anonymous
%>
<br
/>
<%=
f
.
label
:anonymous
%>
<br />
<%=
f
.
check_box
:anonymous
%>
<%=
f
.
check_box
:anonymous
%>
</div>
</div>
<div class="field">
<div class="field">
<%=
f
.
label
:ubb
%>
<br
/>
<%=
f
.
label
:ubb
%>
<br />
<%=
f
.
check_box
:ubb
%>
<%=
f
.
check_box
:ubb
%>
</div>
</div>
<div class="field">
<div class="field">
<%=
f
.
label
:html
%>
<br
/>
<%=
f
.
label
:html
%>
<br />
<%=
f
.
check_box
:html
%>
<%=
f
.
check_box
:html
%>
</div>
</div>-->
<%=
f
.
label
"附件"
%>
<br
/>
<%=
f
.
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
class=
"actions"
>
<div
class=
"actions"
>
<%=
f
.
submit
%>
<%=
f
.
submit
%>
</div>
</div>
...
...
app/views/posts/_post.html.erb
View file @
36d7a8cf
...
@@ -52,7 +52,19 @@
...
@@ -52,7 +52,19 @@
<div
class=
"t_msgfontfix"
>
<div
class=
"t_msgfontfix"
>
<table
cellspacing=
"0"
cellpadding=
"0"
><tbody><tr><td
class=
"t_msgfont"
id=
"postmessage_751931"
>
<%=
post
.
content
.
bbcode_to_html
.
html_safe
%>
</td></tr></tbody></table>
<table
cellspacing=
"0"
cellpadding=
"0"
><tbody><tr><td
class=
"t_msgfont"
id=
"postmessage_751931"
>
<%=
post
.
content
.
bbcode_to_html
.
html_safe
%>
</td></tr></tbody></table>
</div>
</div>
<%
if
!
post
.
attachments
.
empty?
%>
<p>
<b>
<%=
post
.
attachments
.
size
%>
个附件:
</b>
<ul>
<%
post
.
attachments
.
each
do
|
attachment
|
%>
<li>
<%=
link_to
attachment
.
data
.
original_filename
,
attachment
.
data
.
url
%>
</li>
<%
if
attachment
.
data
.
content_type
[
0
,
5
]
==
"image"
%>
<%=
image_tag
attachment
.
data
.
url
%>
<%
end
%>
<%
end
%>
</ul>
</p>
<%
end
%>
<div
id=
"post_rate_div_751931"
></div>
<div
id=
"post_rate_div_751931"
></div>
</div>
</div>
...
...
app/views/posts/edit.html.erb
View file @
36d7a8cf
<%=
form_for
(
@post
)
do
|
f
|
%>
<h1>
Editing post
</h1>
<%
if
@post
.
errors
.
any?
%>
<div
id=
"error_explanation"
>
<h2>
<%=
pluralize
(
@post
.
errors
.
count
,
"error"
)
%>
prohibited this post from being saved:
</h2>
<ul>
<%=
render
'form'
%>
<%
@post
.
errors
.
full_messages
.
each
do
|
msg
|
%>
<li>
<%=
msg
%>
</li>
<%
end
%>
</ul>
</div>
<%
end
%>
<!--<div class="field">
<%=
link_to
'Show'
,
@post
%>
|
<%=
f
.
label
:topic
%>
<br />
<%=
link_to
'Back'
,
posts_path
%>
<%=
f
.
text_field
:topic
%>
</div>-->
<div
class=
"field"
>
<%=
render
'topics/editor'
,
:content
=>
@post
.
content
%>
</div>
<div
class=
"field"
>
<%=
f
.
label
t
'post.private'
%>
<br
/>
<%=
f
.
check_box
:private
%>
</div>
<div
class=
"field"
>
<%=
f
.
label
t
'post.anonymous'
%>
<br
/>
<%=
f
.
check_box
:anonymous
%>
</div>
<!--<div class="field">
<%=
f
.
label
:ubb
%>
<br />
<%=
f
.
check_box
:ubb
%>
</div>
<div class="field">
<%=
f
.
label
:html
%>
<br />
<%=
f
.
check_box
:html
%>
</div>-->
<div
class=
"actions"
>
<%=
f
.
submit
t
'post.submit'
%>
</div>
<%
end
%>
app/views/topics/show.html.erb
View file @
36d7a8cf
This diff is collapsed.
Click to expand it.
config/locales/zh-CN.yml
View file @
36d7a8cf
...
@@ -259,6 +259,8 @@ zh-CN:
...
@@ -259,6 +259,8 @@ zh-CN:
top_traps
:
"
热门陷阱"
top_traps
:
"
热门陷阱"
board
:
board
:
index
:
"
论坛"
index
:
"
论坛"
post
:
attachments
:
"
附件"
mycard
:
mycard
:
download
:
"
立即下载"
download
:
"
立即下载"
battlenet
:
"
YGO战网"
battlenet
:
"
YGO战网"
...
...
config/routes.rb
View file @
36d7a8cf
MycardServerHttp
::
Application
.
routes
.
draw
do
MycardServerHttp
::
Application
.
routes
.
draw
do
resources
:attachments
resources
:moderators
resources
:moderators
resources
:servers
resources
:servers
...
...
db/migrate/20120518234415_create_attachments.rb
0 → 100644
View file @
36d7a8cf
class
CreateAttachments
<
ActiveRecord
::
Migration
def
change
create_table
:attachments
do
|
t
|
t
.
string
:data_file_name
t
.
string
:data_content_type
t
.
integer
:data_file_size
t
.
datetime
:data_updated_at
t
.
integer
:post_id
t
.
timestamps
end
end
end
db/schema.rb
View file @
36d7a8cf
...
@@ -11,7 +11,17 @@
...
@@ -11,7 +11,17 @@
#
#
# It's strongly recommended to check this file into your version control system.
# It's strongly recommended to check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
:version
=>
20120510085131
)
do
ActiveRecord
::
Schema
.
define
(
:version
=>
20120518234415
)
do
create_table
"attachments"
,
:force
=>
true
do
|
t
|
t
.
string
"data_file_name"
t
.
string
"data_content_type"
t
.
integer
"data_file_size"
t
.
datetime
"data_updated_at"
t
.
integer
"post_id"
t
.
datetime
"created_at"
,
:null
=>
false
t
.
datetime
"updated_at"
,
:null
=>
false
end
create_table
"boards"
,
:force
=>
true
do
|
t
|
create_table
"boards"
,
:force
=>
true
do
|
t
|
t
.
string
"name"
,
:default
=>
""
,
:null
=>
false
t
.
string
"name"
,
:default
=>
""
,
:null
=>
false
...
@@ -76,8 +86,11 @@ ActiveRecord::Schema.define(:version => 20120510085131) do
...
@@ -76,8 +86,11 @@ ActiveRecord::Schema.define(:version => 20120510085131) do
t
.
string
"replay"
t
.
string
"replay"
t
.
integer
"user1_credits"
t
.
integer
"user1_credits"
t
.
integer
"user2_credits"
t
.
integer
"user2_credits"
t
.
datetime
"created_at"
,
:null
=>
false
t
.
integer
"version"
t
.
datetime
"updated_at"
,
:null
=>
false
t
.
datetime
"created_at"
,
:null
=>
false
t
.
datetime
"updated_at"
,
:null
=>
false
t
.
boolean
"user1_public"
,
:default
=>
true
,
:null
=>
false
t
.
boolean
"user2_public"
,
:default
=>
true
,
:null
=>
false
end
end
add_index
"duels"
,
[
"user1_id"
],
:name
=>
"index_duels_on_user1_id"
add_index
"duels"
,
[
"user1_id"
],
:name
=>
"index_duels_on_user1_id"
...
@@ -195,16 +208,6 @@ ActiveRecord::Schema.define(:version => 20120510085131) do
...
@@ -195,16 +208,6 @@ ActiveRecord::Schema.define(:version => 20120510085131) do
t
.
datetime
"updated_at"
,
:null
=>
false
t
.
datetime
"updated_at"
,
:null
=>
false
end
end
create_table
"sessions"
,
:force
=>
true
do
|
t
|
t
.
string
"session_id"
,
:null
=>
false
t
.
text
"data"
t
.
datetime
"created_at"
,
:null
=>
false
t
.
datetime
"updated_at"
,
:null
=>
false
end
add_index
"sessions"
,
[
"session_id"
],
:name
=>
"index_sessions_on_session_id"
add_index
"sessions"
,
[
"updated_at"
],
:name
=>
"index_sessions_on_updated_at"
create_table
"settings"
,
:primary_key
=>
"name"
,
:force
=>
true
do
|
t
|
create_table
"settings"
,
:primary_key
=>
"name"
,
:force
=>
true
do
|
t
|
t
.
text
"value"
t
.
text
"value"
end
end
...
@@ -231,7 +234,7 @@ ActiveRecord::Schema.define(:version => 20120510085131) do
...
@@ -231,7 +234,7 @@ ActiveRecord::Schema.define(:version => 20120510085131) do
create_table
"users"
,
:force
=>
true
do
|
t
|
create_table
"users"
,
:force
=>
true
do
|
t
|
t
.
string
"name"
,
:null
=>
false
t
.
string
"name"
,
:null
=>
false
t
.
string
"password"
t
.
string
"password"
t
.
string
"email"
t
.
string
"email"
,
:default
=>
""
,
:null
=>
false
t
.
string
"nickname"
,
:default
=>
""
,
:null
=>
false
t
.
string
"nickname"
,
:default
=>
""
,
:null
=>
false
t
.
text
"signature"
t
.
text
"signature"
t
.
integer
"credits"
,
:default
=>
0
,
:null
=>
false
t
.
integer
"credits"
,
:default
=>
0
,
:null
=>
false
...
...
test/fixtures/attachments.yml
0 → 100644
View file @
36d7a8cf
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/Fixtures.html
one
:
data_file_name
:
MyString
data_content_type
:
MyString
data_file_size
:
1
data_updated_at
:
2012-05-19 07:44:15
post_id
:
1
two
:
data_file_name
:
MyString
data_content_type
:
MyString
data_file_size
:
1
data_updated_at
:
2012-05-19 07:44:15
post_id
:
1
test/functional/attachments_controller_test.rb
0 → 100644
View file @
36d7a8cf
require
'test_helper'
class
AttachmentsControllerTest
<
ActionController
::
TestCase
setup
do
@attachment
=
attachments
(
:one
)
end
test
"should get index"
do
get
:index
assert_response
:success
assert_not_nil
assigns
(
:attachments
)
end
test
"should get new"
do
get
:new
assert_response
:success
end
test
"should create attachment"
do
assert_difference
(
'Attachment.count'
)
do
post
:create
,
attachment:
@attachment
.
attributes
end
assert_redirected_to
attachment_path
(
assigns
(
:attachment
))
end
test
"should show attachment"
do
get
:show
,
id:
@attachment
assert_response
:success
end
test
"should get edit"
do
get
:edit
,
id:
@attachment
assert_response
:success
end
test
"should update attachment"
do
put
:update
,
id:
@attachment
,
attachment:
@attachment
.
attributes
assert_redirected_to
attachment_path
(
assigns
(
:attachment
))
end
test
"should destroy attachment"
do
assert_difference
(
'Attachment.count'
,
-
1
)
do
delete
:destroy
,
id:
@attachment
end
assert_redirected_to
attachments_path
end
end
test/unit/attachment_test.rb
0 → 100644
View file @
36d7a8cf
require
'test_helper'
class
AttachmentTest
<
ActiveSupport
::
TestCase
# test "the truth" do
# assert true
# end
end
test/unit/helpers/attachments_helper_test.rb
0 → 100644
View file @
36d7a8cf
require
'test_helper'
class
AttachmentsHelperTest
<
ActionView
::
TestCase
end
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