Skip to content

Commit

Permalink
Add Twitter Bootstrap for html and css
Browse files Browse the repository at this point in the history
  • Loading branch information
huacnlee committed Oct 10, 2011
1 parent 6fbf2ad commit 3b3d1d3
Show file tree
Hide file tree
Showing 54 changed files with 3,252 additions and 634 deletions.
3 changes: 3 additions & 0 deletions app/controllers/cpanel/replies_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ def index
# GET /replies/1.xml
def show
@reply = Reply.find(params[:id])
if @reply.topic.blank?
redirect_to cpanel_replies_path, :alert => "帖子已经不存在"
end

respond_to do |format|
format.html # show.html.erb
Expand Down
2 changes: 1 addition & 1 deletion app/controllers/notes_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class NotesController < ApplicationController
# GET /notes
# GET /notes.xml
def index
@notes = current_user.notes
@notes = current_user.notes.paginate(:page => params[:page], :per_page => 20)
set_seo_meta("记事本")
end

Expand Down
29 changes: 28 additions & 1 deletion app/helpers/application_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module ApplicationHelper
# return the formatted flash[:notice] html
def notice_message()
if flash[:notice]
result = '<div id="success_message">'+flash[:notice]+'</div>'
result = '<div class="alert-message success"><a href="#" class="close">x</a>'+flash[:notice]+'</div>'
else
result = ''
end
Expand All @@ -26,4 +26,31 @@ def timeago(time, options = {})
options[:class] ||= "timeago"
content_tag(:abbr, time.to_s, options.merge(:title => time.getutc.iso8601)) if time
end

class BootstrapLinkRenderer < ::WillPaginate::ViewHelpers::LinkRenderer
protected
def html_container(html)
tag :div, tag(:ul, html), container_attributes
end

def page_number(page)
tag :li, link(page, page, :rel => rel_value(page)), :class =>
('active' if page == current_page)
end

def gap
tag :li, link(super, '#'), :class => 'disabled'
end

def previous_or_next_page(page, text, classname)
tag :li, link(text, page || '#'), :class => [classname[0..3],
classname, ('disabled' unless page)].join(' ')
end
end

def will_paginate1(pages)
will_paginate(pages, :class => 'pagination', :inner_window => 2,
:outer_window => 0, :renderer => BootstrapLinkRenderer, :previous_label =>
'上一页'.html_safe, :next_label => '下一页'.html_safe)
end
end
2 changes: 1 addition & 1 deletion app/helpers/users_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def user_name_tag(user,options = {})


def user_avatar_tag(user,size = :normal, opts = {})
link = opts[:link] || false
link = opts[:link] || true
hash = Digest::MD5.hexdigest(user.email)
width = 48
case size
Expand Down
49 changes: 28 additions & 21 deletions app/views/cpanel/nodes/_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,23 +1,30 @@
<%= form_for([:cpanel,@node]) do |f| %>
<%= render 'shared/error_messages', :target => @node %>

<div class="field">
<%= f.label :name %><br />
<%= f.text_field :name %>
</div>
<div class="field">
<%= f.label :section_id %><br />
<%= f.select :section_id, Section.all.collect { |s| [s.name,s.id] } %>
</div>
<div class="field">
<%= f.label :sort %><br />
<%= f.text_field :sort %>
</div>
<div class="field">
<%= f.label :summary %><br />
<%= f.text_area :summary, :class => "middle",:style => "height:80px;" %>
</div>
<div class="actions">
<button class="button submit">保存</button> <%= link_to 'Back', cpanel_nodes_path %>
</div>
<fieldset>
<legend></legend>
<%= render 'shared/error_messages', :target => @node %>
<div class="clearfix">
<%= f.label :name %>
<div class="input">
<%= f.text_field :name %></div>
</div>
<div class="clearfix">
<%= f.label :section_id %>
<div class="input">
<%= f.select :section_id, Section.all.collect { |s| [s.name,s.id] } %></div>
</div>
<div class="clearfix">
<%= f.label :sort %>
<div class="input">
<%= f.text_field :sort %></div>
</div>
<div class="clearfix">
<%= f.label :summary %>
<div class="input">
<%= f.text_area :summary, :class => "xxlarge",:style => "height:80px;" %>
</div>
</div>
<div class="actions">
<button class="btn primary">保存</button> <%= link_to 'Back', cpanel_nodes_path %>
</div>
</fieldset>
<% end %>
16 changes: 9 additions & 7 deletions app/views/cpanel/photos/_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
<%= form_for([:cpanel,@photo] , :html => { :enctype => "multipart/form-data" }) do |f| %>
<fieldset>
<legend></legend>
<%= render 'shared/error_messages', :target => @photo %>

<div class="field">
<%= f.label :title %><br />
<%= f.text_field :title %>
<div class="clearfix">
<%= f.label :title %><div class="input">
<%= f.text_field :title %></div>
</div>
<div class="field">
<%= f.label :image %><br />
<%= f.file_field :image %>
<div class="clearfix">
<%= f.label :image %><div class="input">
<%= f.file_field :image %></div>
</div>
<div class="actions">
<button type="submit" class="button submit">上传</button>
<button type="submit" class="btn primary">上传</button> or <%= link_to 'Back', photos_path %>
</div>
<% end %>
3 changes: 0 additions & 3 deletions app/views/cpanel/photos/edit.html.erb
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
<h1>Editing photo</h1>

<%= render 'form' %>
<%= link_to 'Show', @photo %> |
<%= link_to 'Back', photos_path %>
2 changes: 1 addition & 1 deletion app/views/cpanel/photos/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
</tr>
<% end %>
</table>
<%= will_paginate @photos %>
<%= will_paginate1 @photos %>
<br />

<%= link_to 'New Photo', new_cpanel_photo_path %>
2 changes: 1 addition & 1 deletion app/views/cpanel/photos/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@

<%= render 'form' %>

<%= link_to 'Back', photos_path %>

44 changes: 17 additions & 27 deletions app/views/cpanel/replies/_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,36 +1,26 @@
<%= form_for(@reply, :url => (@reply.id.blank? ? cpanel_replies_path : cpanel_reply_path(@reply.id))) do |f| %>
<% if @reply.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@reply.errors.count, "error") %> prohibited this reply from being saved:</h2>
<fieldset>
<legend></legend>
<%= render 'shared/error_messages', :target => @reply %>

<ul>
<% @reply.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
<div class="clearfix">
<%= f.label :body %>
<div class="input">
<%= f.text_area :body, :class => "long", :style => "height:400px" %>
</div>
<% end %>

<div class="field">
<%= @topic.title %>
</div>
<div class="field">
<%= f.label :body %><br />
<%= f.text_area :body, :class => "long", :style => "height:400px" %>
</div>
<div class="field">
<%= f.label :user_id %><br />
<%= f.text_field :user_id %> <%= @topic.user.name %>
</div>
<div class="field">
<%= f.label :state %><br />
<%= f.text_field :state, Reply::STATE %>
<div class="clearfix">
<%= f.label :user_id %>
<div class="input">
<%= f.text_field :user_id %> <%= @reply.user.name %>
</div>
</div>
<div class="field">
<%= f.label :source %><br />
<%= f.text_field :source %>
<div class="clearfix">
<%= f.label :source %><div class="input">
<%= f.text_field :source %></div>
</div>
<div class="actions">
<button class="submit">保存</button>
<button type="submit" class="btn primary">保存</button> or
<%= link_to 'Back', cpanel_replies_path %>
</div>
<% end %>
5 changes: 1 addition & 4 deletions app/views/cpanel/replies/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,4 @@
<a href="<%= cpanel_replies_path %>">回复</a> &gt; <span class="current">修改</span>
<% end %>
<h1>Editing reply</h1>

<%= render 'form' %>
<%= link_to 'Back', cpanel_replies_path %>
<%= render 'form' %>
2 changes: 1 addition & 1 deletion app/views/cpanel/replies/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@
</tr>
<% end %>
</table>
<%= will_paginate @replies %>
<%= will_paginate1 @replies %>

21 changes: 14 additions & 7 deletions app/views/cpanel/sections/_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,15 +1,22 @@
<%= form_for([:cpanel,@section]) do |f| %>
<fieldset>
<legend></legend>
<%= render 'shared/error_messages', :target => @section %>

<div class="field">
<%= f.label :name %><br />
<%= f.text_field :name %>
<div class="clearfix">
<%= f.label :name %>
<div class="input">
<%= f.text_field :name %>
</div>
</div>
<div class="field">
<%= f.label :sort %><br />
<%= f.text_field :sort %>
<div class="clearfix">
<%= f.label :sort %>
<div class="input">
<%= f.text_field :sort %>
</div>
</div>
<div class="actions">
<button class="button submit">保存</button> <%= link_to 'Back', cpanel_sections_path %>
<button class="btn primary">保存</button> <%= link_to 'Back', cpanel_sections_path %>
</div>
</fieldset>
<% end %>
45 changes: 30 additions & 15 deletions app/views/cpanel/topics/_form.html.erb
Original file line number Diff line number Diff line change
@@ -1,31 +1,46 @@
<%= form_for([:cpanel,@topic]) do |f| %>
<fieldset>
<legend></legend>
<%= render 'shared/error_messages', :target => @topic %>

<div class="field">
<%= f.label :title %><br />
<%= f.text_field :title, :class => "middle" %>
<div class="clearfix">
<%= f.label :title %>
<div class="input">
<%= f.text_field :title, :class => "span10" %>
</div>
</div>
<div class="field">
<%= f.label :node_id %><br />
<div class="clearfix">
<%= f.label :node_id %>
<div class="input">
<%= f.select :node_id, Node.all.collect { |n| [n.name,n.id] } %>
</div>
</div>
<div class="field">
<%= f.label :body %><br />
<%= f.text_area :body, :class => "long", :style => "height:400px" %>
<div class="clearfix">
<%= f.label :body %>
<div class="input">
<%= f.text_area :body, :class => "span13", :style => "height:400px" %>
</div>
</div>
<div class="field">
<%= f.label :user_id %><br />
<div class="clearfix">
<%= f.label :user_id %>
<div class="input">
<%= f.text_field :user_id %> <%= @topic.user.name if @topic.user %>
</div>
</div>
<div class="field">
<%= f.label :last_reply_user_id %><br />
<div class="clearfix">
<%= f.label :last_reply_user_id %>
<div class="input">
<%= f.text_field :last_reply_user_id %>
</div>
</div>
<div class="field">
<%= f.label :source %><br />
<div class="clearfix">
<%= f.label :source %>
<div class="input">
<%= f.text_field :source %>
</div>
</div>
<div class="actions">
<button class="submit">保存</button>
<button class="btn primary">保存</button> or
<%= link_to 'Back', cpanel_topics_path %>
</div>
<% end %>
2 changes: 1 addition & 1 deletion app/views/cpanel/topics/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@

<%= render 'form' %>

<%= link_to 'Back', cpanel_topics_path %>

2 changes: 1 addition & 1 deletion app/views/cpanel/topics/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
</tr>
<% end %>
</table>
<%= will_paginate @topics %>
<%= will_paginate1 @topics %>
<br />

<%= link_to 'New Topic', new_cpanel_topic_path %>
2 changes: 0 additions & 2 deletions app/views/cpanel/topics/new.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,3 @@
<h1>New topic</h1>

<%= render 'form' %>
<%= link_to 'Back', cpanel_topics_path %>
Loading

0 comments on commit 3b3d1d3

Please sign in to comment.