Skip to content

Commit

Permalink
change article view , modify tag list view and comment view
Browse files Browse the repository at this point in the history
  • Loading branch information
liwh committed Jul 16, 2011
1 parent b2c1705 commit fd68b56
Show file tree
Hide file tree
Showing 18 changed files with 126 additions and 65 deletions.
8 changes: 4 additions & 4 deletions app/coffeescripts/controllers/articles.coffee
@@ -1,9 +1,9 @@
App.Controllers.Articles = Backbone.Controller.extend

initialize: ->
#标签
$('#tag-list a').click ->
$(this).toggleClass('active')
$(this).toggleClass('active-tag')
tags = StringUtils.to_a($('#article_tags_text').val())
tag = $(this).text()
if tag not in tags
Expand All @@ -16,9 +16,9 @@ App.Controllers.Articles = Backbone.Controller.extend
tags = StringUtils.to_a($('#article_tags_text').val())
$('#tag-list a').each ->
if $(this).text() in tags
$(this).addClass('active')
$(this).addClass('active-tag')
else
$(this).removeClass('active')
$(this).removeClass('active-tag')
.keyup()

$('#article-show,#article-edit-link,.cancel').click ->
Expand Down
2 changes: 2 additions & 0 deletions app/controllers/pages_controller.rb
Expand Up @@ -7,6 +7,8 @@ class PagesController < ApplicationController
expose(:page)

expose(:blogs) { current_user.shop.blogs }
expose(:blog)
expose(:articles)

def create
page.save
Expand Down
21 changes: 12 additions & 9 deletions app/views/articles/_article.html.haml
@@ -1,12 +1,15 @@
%tr(class="#{cycle(:odd, :event)}")
%td
=link_to article.title,blog_article_path(blog,article)
%span.description{:style => "margin: 0 0 0 4px;"}
%span.hint==由#{article.user.name}
==发表于:#{distance_of_time_in_words(article.updated_at,Time.now)}
%td.date{:style => "text-align: right"}
=article.created_at.to_s(:with_year)
%td.date{:style => "text-align: right"}
=article.updated_at.to_s(:with_year)
%td{:style => "text-align: center"}
=link_to article.title,blog_article_path(blog,article)
%td
%span.comment-number 0
%td
%ul.tag-list
%li
-article.tags.each do |tag|
=link_to tag.name, blog_path(blog,tag: tag.name),class: 'active-tag'
%td=article.author
%td
%span.note=article.updated_at.to_s(:with_year)
%td.r
= link_to image_tag('admin/icons/trash.gif'), blog_article_path(blog,article), remote: true, method: :delete, confirm: '您确定要删除?', title: '删除它', class: :del
50 changes: 37 additions & 13 deletions app/views/articles/_comments.html.haml
@@ -1,16 +1,40 @@
-if blog.commentable == 'no'
-if blog.commentable == 'no'
%p.description.highlight(style="text-align: center")
==此博客评论已被禁用,你可以#{link_to "启用评论",edit_blog_path(blog)}
-else
%p#comment-counts.info.c.st
==这篇文章共有#{article.comments.size}条评论
|
%span#comment_published_count.status_tag.published
=link_to "#{article.published_comments.size}条公开评论",comments_path(article_id:article.id,blog_id:blog.id,status:"published"),title:"显示所有公开评论"
|
%span#comment_unapproved_count.status_tag.unapproved
=link_to "#{article.unapproved_comments.size}条待审核评论",comments_path(article_id:article.id,blog_id:blog.id,status:"unapproved"),title:"显示所有待审核评论"
|
%span#comment_removed_count.status_tag.removed
=link_to "#{article.removed_comments.size}条已删除评论",comments_path(article_id:article.id,blog_id:blog.id,status:"removed"),title:"显示所有已删除评论"

#comments
%h4==文章#{article.title}的评论
%p.description
These are comments for this article, you can view and manage all your
%a{:href => "/admin/comments"} comments here
%form#batch-form{"accept-charset" => "UTF-8", :action => "/admin/articles/set", :method => "post"}
%table#comments-list.standard-table.hide_checkboxes{:cellpadding => "0", :cellspacing => "0"}
%thead
%tr
%th.checkbox{:width => "5%"}
%input#select-all{:type => "checkbox"}/
%th{:width => "17%"} From
%th{:width => "55%"} Comment
%th{:width => "22%"} &nbsp;
%tbody
/ Required arguments: comment, parent
%tr#comment_19083422.odd
%td.checkbox
%input#checkbox-19083422.selector{:name => "comments[]", :type => "checkbox", :value => "19083422"}/
%td
jj
%a.email{:href => "mailto:jj@gmail.com"} jj@gmail.com
%span.note 12 Jul 23:12
%td
%p fasffas
%span.posted-on
Posted in
%a{:href => "/admin/blogs/941902/articles/3200602"} aaa
from the blog
%a{:href => "/admin/blogs/941902"} aaa
%td.r
%span.comment-actions
%span#comment_19083422_actions
%a.action.btn{"data-method" => "post", "data-remote" => "true", :href => "/admin/comments/19083422/spam", :loading => "var action = $('comment_19083422_actions'); action.update('marking as spam...'); action.addClassName('hint');", :rel => "nofollow", :title => "Spam this comment"} spam
%a.action{"data-confirm" => "Are you sure you want to delete this comment?", "data-method" => "post", "data-remote" => "true", :href => "/admin/comments/19083422/remove", :loading => "var action = $('comment_19083422_actions'); action.update('removing...'); action.addClassName('hint');", :rel => "nofollow", :title => "Remove this comment"}
%img{:alt => "Trash", :src => "https://cdn.shopify.com/s/images/admin/icons/trash.gif?19b2f7c9ac918121a1eed4f4e75712320f420f18"}/
5 changes: 3 additions & 2 deletions app/views/articles/_form.html.haml
@@ -1,3 +1,5 @@
%dt=f.label :author
%dd=f.select :author, shop.users.map(&:name)
%dt=f.label :title
%dd=f.text_field :title,class:"big"
%dt.sst=f.label :body_html
Expand All @@ -8,8 +10,7 @@
%p
=f.text_field :tags_text, size:50
%p.note{:style => "clear: both"} 最近使用过的标签,单击增加。
%ul#tag-list.clearfix.nobull.st
%ul#tag-list.tag-list.clearfix.nobull.st
-tags.each do |tag|
%li
%a(href="#")=tag.name

14 changes: 14 additions & 0 deletions app/views/blogs/_blog.html.haml
@@ -0,0 +1,14 @@
%table.standard-table.ssb{:cellspacing => "0", :style => "margin-bottom: 40px"}
%thead
%tr
%th{:width => "20%"}==#{blog.title} 文章
%th{:width => "10%"} 评论
%th{:width => "17%"} 标签
%th{:width => "13%"} 作者
%th{:width => "8%"} 更新时间
%th{:width => "5%"} &nbsp;
%tbody
-articles = blog.articles
=render partial: 'articles/article' , collection: articles, locals: {blog: blog}
%tr.last-article
%td{:colspan => "6"}=link_to "管理 #{blog.title}", blog_path(blog),class: 'view-all-articles'
52 changes: 36 additions & 16 deletions app/views/blogs/_comments.html.haml
Expand Up @@ -2,19 +2,39 @@
%p.description.highlight(style="text-align: center")
==此博客评论已被禁用,你可以#{link_to "启用评论",edit_blog_path(blog)}
-else
%p#comment-counts.info.c.st
-total = blog.articles.map(&:comments).map(&:size).inject(0){|sum,v| sum += v}
-published = blog.articles.map(&:published_comments).map(&:size).inject(0){|sum,v| sum += v}
-unapproved = blog.articles.map(&:unapproved_comments).map(&:size).inject(0){|sum,v| sum += v}
-removed = total - published - unapproved
==这篇博客共有
=link_to "#{total}条评论", comments_path(blog_id:blog.id)
|
%span#comment_published_count.status_tag.published
=link_to "#{published}条公开评论", comments_path(blog_id:blog.id,status:"published")
|
%span#comment_unapproved_count.status_tag.unapproved
=link_to "#{unapproved}条待审核评论", comments_path(blog_id:blog.id,status:"unapproved")
|
%span#comment_removed_count.status_tag.removed
=link_to "#{removed}条已删除评论", comments_path(blog_id:blog.id,status:"removed")
#comments
%h4==文章#{article.title}的评论
%p.description
下面是该文章的评论, 您可以在这里查看并管理
%a{:href => "/admin/comments"} 所有的评论
%form#batch-form{"accept-charset" => "UTF-8", :action => "/admin/articles/set", :method => "post"}
%table#comments-list.standard-table.hide_checkboxes{:cellpadding => "0", :cellspacing => "0"}
%thead
%tr
%th.checkbox{:width => "5%"}
%input#select-all{:type => "checkbox"}/
%th{:width => "17%"} From
%th{:width => "55%"} Comment
%th{:width => "22%"} &nbsp;
%tbody
/ Required arguments: comment, parent
%tr#comment_19083422.odd
%td.checkbox
%input#checkbox-19083422.selector{:name => "comments[]", :type => "checkbox", :value => "19083422"}/
%td
jj
%a.email{:href => "mailto:jj@gmail.com"} jj@gmail.com
%span.note 12 Jul 23:12
%td
%p fasffas
%span.posted-on
Posted in
%a{:href => "/admin/blogs/941902/articles/3200602"} aaa
from the blog
%a{:href => "/admin/blogs/941902"} aaa
%td.r
%span.comment-actions
%span#comment_19083422_actions
%a.action.btn{"data-method" => "post", "data-remote" => "true", :href => "/admin/comments/19083422/spam", :loading => "var action = $('comment_19083422_actions'); action.update('marking as spam...'); action.addClassName('hint');", :rel => "nofollow", :title => "Spam this comment"} spam
%a.action{"data-confirm" => "Are you sure you want to delete this comment?", "data-method" => "post", "data-remote" => "true", :href => "/admin/comments/19083422/remove", :loading => "var action = $('comment_19083422_actions'); action.update('removing...'); action.addClassName('hint');", :rel => "nofollow", :title => "Remove this comment"}
%img{:alt => "Trash", :src => "https://cdn.shopify.com/s/images/admin/icons/trash.gif?19b2f7c9ac918121a1eed4f4e75712320f420f18"}/
11 changes: 1 addition & 10 deletions app/views/blogs/_index.html.haml
@@ -1,15 +1,6 @@
/
Required arguments: blogs, comment_counts
#blogs
%h4 博客
%p.description
博客是经常更新的一系列文章。
您的客户可以订阅博客,及时看到新的文章。
%table.data.blogs-table{ :cellspacing => "0", :cellpadding => "0" }
%thead
%tr
%th{ :scope => "col" } 标题
%th{ :scope => "col", :style => "width: 50px" } &nbsp;
%tbody
-blogs.each do |blog|
=render partial:"blogs/blogs",locals:{blog:blog}
=render blogs
16 changes: 9 additions & 7 deletions app/views/blogs/show.html.haml
Expand Up @@ -14,16 +14,18 @@
==此博客有#{articles.size}篇文章
#articles
#page-list{:style => ""}
%table.data.row-space{:cellpadding => "0", :cellspacing => "0"}
%table.standard-table.ssb{:cellspacing => "0"}
%thead
%tr
%th{:scope => "col"} 标题
%th{:scope => "col", :style => "width: 150px; text-align: right; padding-right: 0"} 创建时间
%th{:scope => "col", :style => "width: 150px; text-align: right; padding-right: 0"} 最后更新时间
%th{:scope => "col", :style => "width: 50px"} &nbsp;
%th{:width => "20%"}==文章
%th{:width => "10%"} 评论
%th{:width => "17%"} 标签
%th{:width => "13%"} 作者
%th{:width => "8%"} 更新时间
%th{:width => "5%"} &nbsp;
%tbody=render articles
/ PAGINATION LINKS
#btm-nav.act-screen
#pagination
#pagination
/ Required arguments: parent, counts
=render partial:"comments"
-#=render partial:"comments"
5 changes: 2 additions & 3 deletions app/views/pages/_page.html.haml
Expand Up @@ -3,6 +3,5 @@
=link_to page.title, page_path(page), :title => "handle: #{page.title}"
-if page.published?
%span.status-hidden 隐藏
%td.date(style="text-align: right")=page.updated_at.to_s(:db)
%td(style="text-align: center")
= link_to image_tag('admin/icons/trash.gif'), page_path(page), remote: true, method: :delete, confirm: '您确定要删除?', title: '删除它', class: :del
%td.date=page.updated_at.to_s(:db)
%td(style="text-align: center")=link_to image_tag('admin/icons/trash.gif'), page_path(page), remote: true, method: :delete, confirm: '您确定要删除?', title: '删除它', class: :del
3 changes: 2 additions & 1 deletion app/views/pages/index.html.haml
Expand Up @@ -3,6 +3,7 @@
%ul
%li#create-page= link_to "新增页面", new_page_path
%li#create-blog= link_to "新增博客", new_blog_path
%li#create-article= link_to "新增博客", new_article_path
#pages
%h4 页面
%p.description
Expand All @@ -14,7 +15,7 @@
%thead
%tr
%th(scope="col") 标题
%th(scope="col" style="width: 114px; text-align: right; padding-right: 0") 更新时间
%th(scope="col" style="width: 150px;") 更新时间
%th(scope="col" style="width: 50px") &nbsp;
%tbody= render pages
/ PAGINATION LINKS
Expand Down
1 change: 1 addition & 0 deletions config/locales/cn.yml
Expand Up @@ -74,6 +74,7 @@ cn:
title: 标题
article:
title: 标题
author: 作者
body_html: 内容
tags: 标签
custom_collection:
Expand Down
1 change: 1 addition & 0 deletions config/routes.rb
Expand Up @@ -124,6 +124,7 @@
end

resources :pages, except: :edit
resources :articles, only: [:new,:create]

resources :blogs do
resources :articles
Expand Down
1 change: 1 addition & 0 deletions db/migrate/20110511132245_create_blogs.rb
Expand Up @@ -17,6 +17,7 @@ def self.up
t.text :body_html , comment: '内容'
t.boolean :published, comment: '是否可见' , default: true
t.integer :user_id , comment: '更新人'
t.string :author , comment: '作者'
t.boolean :delta , comment: "ts全文检索增量更新标记" , default: true, null: false

t.timestamps
Expand Down
1 change: 1 addition & 0 deletions db/schema.rb
Expand Up @@ -19,6 +19,7 @@
t.text "body_html"
t.boolean "published", :default => true
t.integer "user_id"
t.string "author"
t.boolean "delta", :default => true, :null => false
t.datetime "created_at"
t.datetime "updated_at"
Expand Down
Binary file added public/images/admin/btns/bg-tags.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/admin/icons/book-edit.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added public/images/admin/icons/book.png
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit fd68b56

Please sign in to comment.