This repository has been archived by the owner on Jun 26, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
18 changed files
with
132 additions
and
54 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
- 编写测试用例 | ||
- 管理后台 | ||
- API | ||
- 权限 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
require 'will_paginate' | ||
require 'will_paginate/active_record' | ||
|
||
module Homeland | ||
module Concerns | ||
module Pagination | ||
extend ActiveSupport::Concern | ||
|
||
included do | ||
self.per_page = Homeland.config.per_page | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -25,4 +25,6 @@ | |
<% end %> | ||
</tbody> | ||
</table> | ||
|
||
<%= homeland_paginate @topics %> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
module Homeland | ||
module ActionView | ||
module TagHelpers | ||
DEFAULT_AVATAR = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAPAAAADwCAMAAAAJixmgAAAAFVBMVEWkpKSnp6eqqqq3t7fS0tLV1dXZ2dmshcKEAAAAtklEQVR4Ae3XsRGAAAjAQFRk/5HtqaTz5H+DlInvAQAAAAAAAAAAAAAAAAAAAACymiveO6o7BQsWLFiwYMGCBS8PFixYsGDBggULFixYsGDBggULFixYsGDBggULFixYsGDBc4IFCxYsWLBgwYIFC14ZfOeAPRQ8IliwYMGCBQsWLFiwYMGCBQsWLFiwYMGCBQsWLFiwYMGCBQsWLFiwYMGCBQv+JQAAAAAAAAAAAAAAAAAAAOAB4KJfdHmj+kwAAAAASUVORK5CYII=' | ||
|
||
def homeland_render_errors(target) | ||
if target.errors.present? | ||
render partial: '/homeland/shared/error_messages', locals: { target: target } | ||
end | ||
end | ||
|
||
def homeland_timeago(time, options = {}) | ||
options[:class] ||= "timeago" | ||
content_tag(:abbr, time.to_s, options.merge(:title => time.getutc.iso8601)) if time | ||
end | ||
|
||
def homeland_node_tag(node) | ||
return '' if node.blank? | ||
|
||
label = [node.badge_html, content_tag(:span, node.name, class: 'name')].join(' ') | ||
|
||
link_to raw(label), homeland.node_topics_path(node.id), class: 'node' | ||
end | ||
|
||
def homeland_user_name_tag(obj) | ||
return '' if obj.blank? | ||
return '' if obj.user_name.blank? | ||
|
||
link_to obj.user_name, obj.user_profile_url, class: 'user-name' | ||
end | ||
|
||
def homeland_user_avatar_tag(obj, opts = {}) | ||
default = image_tag(DEFAULT_AVATAR, class: 'avatar media-object') | ||
return default if obj.blank? | ||
if obj.user_avatar_url.blank? | ||
img = default | ||
else | ||
img = image_tag(obj.user_avatar_url, class: 'avatar media-object') | ||
end | ||
|
||
link_to img, obj.user_profile_url, title: obj.user_name, class: 'user-avatar' | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
require 'will_paginate/view_helpers/action_view' | ||
|
||
module Homeland | ||
module ActionView | ||
module WillPaginate | ||
def homeland_paginate(collection = nil, options = {}) | ||
options, collection = collection, nil if collection.is_a? Hash | ||
# Taken from original will_paginate code to handle if the helper is not passed a collection object. | ||
collection ||= infer_collection_from_controller | ||
options[:renderer] ||= BootstrapLinkRenderer | ||
options[:inner_window] ||= 2 | ||
will_paginate(collection, options).try :html_safe | ||
end | ||
|
||
class BootstrapLinkRenderer < ::WillPaginate::ActionView::LinkRenderer | ||
protected | ||
|
||
def html_container(html) | ||
container_attributes[:class] = 'pagination' | ||
tag(:ul, html, container_attributes) | ||
end | ||
|
||
def page_number(page) | ||
tag :li, link(page, page, rel: rel_value(page), class: 'page-link'), class: (page == current_page ? 'page-item active' : 'page-item') | ||
end | ||
|
||
def gap | ||
tag :li, link('…'.html_safe, '#'), class: 'page-item disabled' | ||
end | ||
|
||
def previous_or_next_page(page, text, classname) | ||
tag :li, link(text, page || '#', class: 'page-link'), | ||
class: [(classname[0..3] if @options[:page_links]), ("page-item #{classname}" if @options[:page_links]), ('page-item disabled' unless page)].join(' ') | ||
end | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,3 @@ | ||
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) | ||
ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__) | ||
|
||
require 'bundler/setup' # Set up gems listed in the Gemfile. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters