Skip to content

Commit 06b21e2

Browse files
committedFeb 21, 2013
admin console: upload user logo, modify user profile.
1 parent 1726573 commit 06b21e2

File tree

7 files changed

+63
-12
lines changed

7 files changed

+63
-12
lines changed
 

‎TODO

+5
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
- Now
2+
* upload logo
3+
* comment box tips: markdown style
4+
* upload attachment and delete immediately
5+
16
- Backend
27
* Editor Tab
38
* admin panel:

‎app/controllers/admin.rb

+1
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,7 @@
108108
@account = Account.find params[:id]
109109
if @account.update_attributes(params[:account])
110110
flash[:notice] = '修改个人设置成功'
111+
redirect_to url(:admin, :edit_profile, :id => @account.id)
111112
else
112113
render 'admin/edit_profile'
113114
end

‎app/views/admin/_form.erb

+5-5
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@
55

66
<table class="content">
77
<tr>
8-
<th valign="top">Title</th>
8+
<th valign="top">文章标题</th>
99
<td><%= form.text_field :title, :class => 'title' %></td>
1010
</tr>
1111

1212
<tr>
13-
<th valign="top">Content</th>
13+
<th valign="top">文章内容</th>
1414
<td>
1515
<div>
1616
<a id="show_blog_content_editor" href="#">Editor</a>
@@ -28,7 +28,7 @@
2828
</tr>
2929

3030
<tr>
31-
<th valign="top">Category</th>
31+
<th valign="top">文章分类</th>
3232
<td>
3333
<label><%= form.radio_button :category, :value => 'blog' %> 博客文章(blog)</label>
3434
<label><%= form.radio_button :category, :value => 'note' %> 学习笔记(note)</label>
@@ -66,14 +66,14 @@
6666
</tr>
6767

6868
<tr>
69-
<th valign="top">URL</th>
69+
<th valign="top">URL后缀</th>
7070
<td>
7171
<%= form.text_field :slug_url, :placeholder => '填写URL英文关键词,用-连接' %>
7272
</td>
7373
</tr>
7474

7575
<tr>
76-
<th valign="top">Comment</th>
76+
<th valign="top">允许评论</th>
7777
<td>
7878
<%= form.check_box :commentable, :style => 'display:inline;' %>
7979
<div id="form-error-info"></div>

‎app/views/admin/edit_profile.erb

+43-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,43 @@
1-
edit <%= @account.name %> profile
1+
<div class="publish">
2+
<div class="con">
3+
<% form_for @account, url(:admin, :profile, :id => @account.id), :method => :put, :multipart => true do |form| %>
4+
<div class="title">修改用户信息</div>
5+
<table class="content">
6+
<tr>
7+
<th valign="top">用户名字</th>
8+
<td><%= form.text_field :name, :class => 'title' %></td>
9+
</tr>
10+
11+
<tr>
12+
<th valign="top">Email地址</th>
13+
<td><%= form.text_field :email, :class => 'title' %></td>
14+
</tr>
15+
16+
<tr>
17+
<th valign="top">修改密码</th>
18+
<td><%= form.password_field :password, :class => 'title' %></td>
19+
</tr>
20+
21+
<tr>
22+
<th valign="top">确认密码</th>
23+
<td><%= form.password_field :password_confirmation, :class => 'title' %></td>
24+
</tr>
25+
26+
<tr>
27+
<th valign="top">头像</th>
28+
<td>
29+
<p><%= image_tag(@account.logo.url) %></p>
30+
<%= form.file_field :logo %>
31+
</td>
32+
</tr>
33+
34+
<tr>
35+
<th>&nbsp;</th>
36+
<td align="center">
37+
<%= form.submit '', :class => 'submit' %>
38+
</td>
39+
</tr>
40+
</table>
41+
<% end %>
42+
</div>
43+
</div>

‎app/views/admin/index.erb

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@
66
</div>
77

88
<p>
9-
admin
9+
admin console.
1010
</p>

‎lib/avatar_uploader.rb

+7-4
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,20 @@ class AvatarUploader < CarrierWave::Uploader::Base
22
include CarrierWave::MiniMagick
33
storage :file
44

5+
process :resize_to_fit => [80, 80]
6+
process :convert => 'png'
7+
8+
def filename
9+
"logo.#{model.logo.file.extension}" if original_filename
10+
end
11+
512
def store_dir
613
"uploads/#{model.class.to_s.underscore}/#{mounted_as}/#{model.id}"
714
end
815

916
def default_url
1017
"/images/default_logo.jpg"
1118
end
12-
13-
version :normal do
14-
process :resize_to_fill => [80, 80]
15-
end
1619

1720
def extension_white_list
1821
%w(jpg jpeg gif png)

‎public/skins/default/content.css

+1-1
Original file line numberDiff line numberDiff line change
@@ -216,4 +216,4 @@ body{ background:#bebebe url(bg.gif);}
216216
div#flash-notice{ width:100px;height:24px;text-align:center;position:fixed;background-color:red;color:#fff;top:0px;right:0px;display:none;}
217217
div#comment-error-info{ width:120px;height:24px;text-align:center;float:left;position:relative;background-color:red;color:#fff;display:none;}
218218
div#form-error-info{ width:100%;height:20px;text-align:left;display:block;color:red;}
219-
div#form-error-info span{padding:0 5px;}
219+
div#form-error-info span{padding:0 5px;}

0 commit comments

Comments
 (0)
Please sign in to comment.