最新动态修改

chenlw_dev
Yiang Gan 9 years ago
commit f23c0e7602

@ -1,32 +1,32 @@
#coding=utf-8 #coding=utf-8
module Mobile module Mobile
module Apis module Apis
class Activities< Grape::API class Activities< Grape::API
resources :activities do resources :activities do
desc "get user activities" desc "get user activities"
get ':id' do get ':id' do
#uw = UserWechat.find params[:openid] #uw = UserWechat.find params[:openid]
user = User.find params[:id] user = User.find params[:id]
shield_project_ids = ShieldActivity.where("container_type='User' and container_id=#{user.id} and shield_type='Project'").map(&:shield_id) shield_project_ids = ShieldActivity.where("container_type='User' and container_id=#{user.id} and shield_type='Project'").map(&:shield_id)
shield_course_ids = ShieldActivity.where("container_type='User' and container_id=#{user.id} and shield_type='Course'").map(&:shield_id) shield_course_ids = ShieldActivity.where("container_type='User' and container_id=#{user.id} and shield_type='Course'").map(&:shield_id)
page = params[:page] ? params[:page].to_i + 1 : 0 page = params[:page] ? params[:page].to_i + 1 : 0
user_project_ids = (user.projects.visible.map{|project| project.id}-shield_project_ids).empty? ? "(-1)" : "(" + (user.projects.visible.map{|project| project.id}-shield_project_ids).join(",") + ")" user_project_ids = (user.projects.visible.map{|project| project.id}-shield_project_ids).empty? ? "(-1)" : "(" + (user.projects.visible.map{|project| project.id}-shield_project_ids).join(",") + ")"
user_course_ids = (user.courses.visible.map{|course| course.id}-shield_course_ids).empty? ? "(-1)" : "(" + (user.courses.visible.map{|course| course.id}-shield_course_ids).join(",") + ")" user_course_ids = (user.courses.visible.map{|course| course.id}-shield_course_ids).empty? ? "(-1)" : "(" + (user.courses.visible.map{|course| course.id}-shield_course_ids).join(",") + ")"
course_types = "('Message','News','HomeworkCommon','Poll','Course')" course_types = "('Message','News','HomeworkCommon','Poll','Course')"
project_types = "('Message','Issue','ProjectCreateInfo')" project_types = "('Message','Issue','ProjectCreateInfo')"
principal_types = "JournalsForMessage" principal_types = "JournalsForMessage"
blog_ids = "("+user.blog.id.to_s+","+((User.watched_by(user.id).count == 0 )? '0' :User.watched_by(user.id).map{|u| u.blog.id}.join(','))+")" blog_ids = "("+user.blog.id.to_s+","+((User.watched_by(user.id).count == 0 )? '0' :User.watched_by(user.id).map{|u| u.blog.id}.join(','))+")"
activities = UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types})" + activities = UserActivity.where("(container_type = 'Project' and container_id in #{user_project_ids} and act_type in #{project_types})" +
"or (container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types}) "+ "or (container_type = 'Course' and container_id in #{user_course_ids} and act_type in #{course_types}) "+
"or (container_type = 'Principal' and act_type= '#{principal_types}' and container_id = #{user.id}) " + "or (container_type = 'Principal' and act_type= '#{principal_types}' and container_id = #{user.id}) " +
"or (container_type = 'Blog' and act_type= 'BlogComment' and container_id in #{blog_ids})").order('updated_at desc').limit(10).offset(page * 10) "or (container_type = 'Blog' and act_type= 'BlogComment' and container_id in #{blog_ids})").order('updated_at desc').limit(10).offset(page * 10)
present :data, activities, with: Mobile::Entities::Activity present :data, activities, with: Mobile::Entities::Activity
present :status, 0 present :status, 0
end end
end end
end end
end end
end end

@ -1,17 +1,17 @@
#coding=utf-8 #coding=utf-8
module Mobile module Mobile
module Apis module Apis
class BlogComments< Grape::API class BlogComments< Grape::API
resources :blog_comments do resources :blog_comments do
desc "get special topic" desc "get special topic"
get ':id' do get ':id' do
blog = BlogComment.find params[:id] blog = BlogComment.find params[:id]
present :blog, message, with: Mobile::Entities::BlogComment present :blog, message, with: Mobile::Entities::BlogComment
present :status, 0 present :status, 0
end end
end end
end end
end end
end end

@ -1,17 +1,17 @@
#coding=utf-8 #coding=utf-8
module Mobile module Mobile
module Apis module Apis
class Issues< Grape::API class Issues< Grape::API
resources :issues do resources :issues do
desc "get special issuse" desc "get special issuse"
get ':id' do get ':id' do
issue = Issue.find params[:id] issue = Issue.find params[:id]
present :data, issue, with: Mobile::Entities::Issue present :data, issue, with: Mobile::Entities::Issue
present :status, 0 present :status, 0
end end
end end
end end
end end
end end

@ -1,17 +1,17 @@
#coding=utf-8 #coding=utf-8
module Mobile module Mobile
module Apis module Apis
class JournalForMessages< Grape::API class JournalForMessages< Grape::API
resources :journal_for_messages do resources :journal_for_messages do
desc "get special journal" desc "get special journal"
get ':id' do get ':id' do
jour = JournalsForMessage.find params[:id] jour = JournalsForMessage.find params[:id]
present :data, jour, with: Mobile::Entities::Jours present :data, jour, with: Mobile::Entities::Jours
present :status, 0 present :status, 0
end end
end end
end end
end end
end end

@ -1,17 +1,17 @@
#coding=utf-8 #coding=utf-8
module Mobile module Mobile
module Apis module Apis
class Messages< Grape::API class Messages< Grape::API
resources :messages do resources :messages do
desc "get special topic" desc "get special topic"
get ':id' do get ':id' do
message = Message.find params[:id] message = Message.find params[:id]
present :data, message, with: Mobile::Entities::Message present :data, message, with: Mobile::Entities::Message
present :status, 0 present :status, 0
end end
end end
end end
end end
end end

@ -1,17 +1,17 @@
#coding=utf-8 #coding=utf-8
module Mobile module Mobile
module Apis module Apis
class Newss< Grape::API class Newss< Grape::API
resources :newss do resources :newss do
desc "get special news" desc "get special news"
get ':id' do get ':id' do
news = News.find params[:id] news = News.find params[:id]
present :data, news, with: Mobile::Entities::News present :data, news, with: Mobile::Entities::News
present :status, 0 present :status, 0
end end
end end
end end
end end
end end

@ -1,17 +1,17 @@
#coding=utf-8 #coding=utf-8
module Mobile module Mobile
module Apis module Apis
class Whomeworks< Grape::API class Whomeworks< Grape::API
resources :whomeworks do resources :whomeworks do
desc "get one homework" desc "get one homework"
get ':id' do get ':id' do
homework = HomeworkCommon.find params[:id] homework = HomeworkCommon.find params[:id]
present :data, homework, with: Mobile::Entities::Whomework present :data, homework, with: Mobile::Entities::Whomework
present :status, 0 present :status, 0
end end
end end
end end
end end
end end

@ -1,132 +1,132 @@
# encoding: utf-8 # encoding: utf-8
module Mobile module Mobile
module Entities module Entities
class Activity <Grape::Entity class Activity <Grape::Entity
include ApplicationHelper include ApplicationHelper
include ApiHelper include ApiHelper
def self.act_expose(f) def self.act_expose(f)
expose f do |ac,opt| expose f do |ac,opt|
if ac.is_a?(Hash) && ac.key?(f) if ac.is_a?(Hash) && ac.key?(f)
ac[f] ac[f]
elsif ac.is_a?(::UserActivity) elsif ac.is_a?(::UserActivity)
if ac.respond_to?(f) if ac.respond_to?(f)
ac.send(f) ac.send(f)
else else
case f case f
when :user_act when :user_act
if ac.act_type == "ProjectCreateInfo" if ac.act_type == "ProjectCreateInfo"
ac unless ac.nil? ac unless ac.nil?
else else
ac.act unless ac.nil? || ac.act.nil? ac.act unless ac.nil? || ac.act.nil?
end end
when :reply_count when :reply_count
if ac.act_type == "HomeworkCommon" if ac.act_type == "HomeworkCommon"
ac.nil? || ac.act.nil? ? 0 : ac.act.journals_for_messages.count ac.nil? || ac.act.nil? ? 0 : ac.act.journals_for_messages.count
elsif ac.act_type == "News" elsif ac.act_type == "News"
ac.nil? || ac.act.nil? ? 0 : ac.act.comments.count ac.nil? || ac.act.nil? ? 0 : ac.act.comments.count
elsif ac.act_type == "Message" || ac.act_type == "BlogComment" || ac.act_type == "JournalsForMessage" elsif ac.act_type == "Message" || ac.act_type == "BlogComment" || ac.act_type == "JournalsForMessage"
ac.nil? || ac.act.nil? ? 0 : ac.act.children.count ac.nil? || ac.act.nil? ? 0 : ac.act.children.count
elsif ac.act_type == "Issue" elsif ac.act_type == "Issue"
ac.nil? || ac.act.nil? ? 0 : ac.act.journals.count ac.nil? || ac.act.nil? ? 0 : ac.act.journals.count
end end
when :subject when :subject
if ac.act_type == "HomeworkCommon" if ac.act_type == "HomeworkCommon"
ac.act.name unless ac.nil? || ac.act.nil? ac.act.name unless ac.nil? || ac.act.nil?
elsif ac.act_type == "News" || ac.act_type == "BlogComment" elsif ac.act_type == "News" || ac.act_type == "BlogComment"
ac.act.title unless ac.nil? || ac.act.nil? ac.act.title unless ac.nil? || ac.act.nil?
elsif ac.act_type == "Message" || ac.act_type == "Issue" elsif ac.act_type == "Message" || ac.act_type == "Issue"
ac.act.subject unless ac.nil? || ac.act.nil? ac.act.subject unless ac.nil? || ac.act.nil?
elsif ac.act_type == "JournalsForMessage" elsif ac.act_type == "JournalsForMessage"
ac.act.private == 0 ? "留言" : "私信" ac.act.private == 0 ? "留言" : "私信"
end end
when :description when :description
if ac.act_type == "HomeworkCommon" || ac.act_type == "Issue" || ac.act_type == "News" if ac.act_type == "HomeworkCommon" || ac.act_type == "Issue" || ac.act_type == "News"
ac.act.description unless ac.nil? || ac.act.nil? ac.act.description unless ac.nil? || ac.act.nil?
elsif ac.act_type == "Message" || ac.act_type == "BlogComment" elsif ac.act_type == "Message" || ac.act_type == "BlogComment"
ac.act.content unless ac.nil? || ac.act.nil? ac.act.content unless ac.nil? || ac.act.nil?
end end
when :latest_update when :latest_update
time_from_now ac.updated_at unless ac.nil? time_from_now ac.updated_at unless ac.nil?
when :activity_praise_count when :activity_praise_count
if ac.act_type == "HomeworkCommon" || ac.act_type == "News" || ac.act_type == "Message" || ac.act_type == "BlogComment" || ac.act_type == "JournalsForMessage" || ac.act_type == "Issue" if ac.act_type == "HomeworkCommon" || ac.act_type == "News" || ac.act_type == "Message" || ac.act_type == "BlogComment" || ac.act_type == "JournalsForMessage" || ac.act_type == "Issue"
ac.nil? || ac.act.nil? ? 0 : get_activity_praise_num(ac.act) ac.nil? || ac.act.nil? ? 0 : get_activity_praise_num(ac.act)
end end
#when :homework_common_detail_manual #when :homework_common_detail_manual
# if ac.act_type == "HomeworkCommon" # if ac.act_type == "HomeworkCommon"
# ac.act.homework_detail_manual unless ac.nil? || ac.act.nil? || ac.act.homework_detail_manual.nil? # ac.act.homework_detail_manual unless ac.nil? || ac.act.nil? || ac.act.homework_detail_manual.nil?
# end # end
when :course_project_name when :course_project_name
if ac.container_type == "Course" if ac.container_type == "Course"
name = (get_course(ac.container_id)).name name = (get_course(ac.container_id)).name
name name
elsif ac.container_type == "Project" elsif ac.container_type == "Project"
name = (get_project(ac.container_id)).name name = (get_project(ac.container_id)).name
name name
elsif ac.container_type == "Blog" elsif ac.container_type == "Blog"
"发表博客" "发表博客"
end end
when :activity_type_name when :activity_type_name
if ac.container_type == "Course" if ac.container_type == "Course"
case ac.act_type case ac.act_type
when "HomeworkCommon" when "HomeworkCommon"
"课程作业" "课程作业"
when "News" when "News"
"课程通知" "课程通知"
when "Message" when "Message"
"课程问答区" "课程问答区"
when "Poll" when "Poll"
"课程问卷" "课程问卷"
when "Course" when "Course"
"课程" "课程"
end end
elsif ac.container_type == "Project" elsif ac.container_type == "Project"
case ac.act_type case ac.act_type
when "Issue" when "Issue"
"项目缺陷" "项目缺陷"
when "Message" when "Message"
"项目问答区" "项目问答区"
when "ProjectCreateInfo" when "ProjectCreateInfo"
"项目" "项目"
end end
end end
end end
end end
end end
end end
end end
expose :act_type #缺陷/作业/讨论区/留言等类型 expose :act_type #缺陷/作业/讨论区/留言等类型
expose :container_type #课程/项目/博客/个人 expose :container_type #课程/项目/博客/个人
expose :author, using: Mobile::Entities::User do |a, opt| #用户信息 expose :author, using: Mobile::Entities::User do |a, opt| #用户信息
if a.is_a? ::UserActivity if a.is_a? ::UserActivity
if a.act_type == "ProjectCreateInfo" if a.act_type == "ProjectCreateInfo"
get_user(get_project(a.act_id).user_id) get_user(get_project(a.act_id).user_id)
elsif a.act_type == 'Issue' || a.act_type == 'News' || a.act_type == 'Message' || a.act_type == 'BlogComment' elsif a.act_type == 'Issue' || a.act_type == 'News' || a.act_type == 'Message' || a.act_type == 'BlogComment'
a.act.author a.act.author
elsif a.act_type == 'HomeworkCommon' || a.act_type == 'Poll' || a.act_type == 'JournalsForMessage' elsif a.act_type == 'HomeworkCommon' || a.act_type == 'Poll' || a.act_type == 'JournalsForMessage'
a.act.user a.act.user
elsif a.act_type == 'Course' elsif a.act_type == 'Course'
a.act.teacher a.act.teacher
end end
end end
end end
expose :homework_common_detail , using: Mobile::Entities::Whomework do |a, opt| #作业相关信息 expose :homework_common_detail , using: Mobile::Entities::Whomework do |a, opt| #作业相关信息
if a.act_type == "HomeworkCommon" if a.act_type == "HomeworkCommon"
a.act a.act
end end
end end
expose :issue_detail, using: Mobile::Entities::Issue do |a, opt| #缺陷信息 expose :issue_detail, using: Mobile::Entities::Issue do |a, opt| #缺陷信息
if a.act_type == "Issue" if a.act_type == "Issue"
a.act a.act
end end
end end
act_expose :reply_count #回复数 act_expose :reply_count #回复数
act_expose :activity_praise_count #点赞数 act_expose :activity_praise_count #点赞数
#act_expose :user_act #某个动态 #act_expose :user_act #某个动态
act_expose :subject #标题 act_expose :subject #标题
act_expose :description #描述 act_expose :description #描述
act_expose :latest_update #最新更新时间 act_expose :latest_update #最新更新时间
act_expose :course_project_name #课程/项目名字 act_expose :course_project_name #课程/项目名字
act_expose :activity_type_name #课程问答区/项目缺陷等 act_expose :activity_type_name #课程问答区/项目缺陷等
end end
end end
end end

@ -1,46 +1,46 @@
module Mobile module Mobile
module Entities module Entities
class BlogComment < Grape::Entity class BlogComment < Grape::Entity
include ApplicationHelper include ApplicationHelper
include ApiHelper include ApiHelper
def self.blog_comment_expose(f) def self.blog_comment_expose(f)
expose f do |u,opt| expose f do |u,opt|
if u.is_a?(Hash) && u.key?(f) if u.is_a?(Hash) && u.key?(f)
u[f] u[f]
elsif u.is_a?(::BlogComment) elsif u.is_a?(::BlogComment)
if u.respond_to?(f) if u.respond_to?(f)
if f == :created_at if f == :created_at
format_time( u.send(f)) format_time( u.send(f))
else else
u.send(f) u.send(f)
end end
else else
# case f # case f
# when :xx # when :xx
# # # #
# end # end
end end
end end
end end
end end
expose :user, using: Mobile::Entities::User do |c, opt| expose :user, using: Mobile::Entities::User do |c, opt|
if c.is_a?(::BlogComment) if c.is_a?(::BlogComment)
c.author c.author
end end
end end
blog_comment_expose :blog_id blog_comment_expose :blog_id
blog_comment_expose :title blog_comment_expose :title
blog_comment_expose :content blog_comment_expose :content
blog_comment_expose :comments_count blog_comment_expose :comments_count
blog_comment_expose :created_at blog_comment_expose :created_at
blog_comment_expose :id blog_comment_expose :id
expose :blog_comment_children, using:Mobile::Entities::BlogComment do |c,opt| expose :blog_comment_children, using:Mobile::Entities::BlogComment do |c,opt|
if c.is_a? (::BlogComment) if c.is_a? (::BlogComment)
c.children c.children
end end
end end
end end
end end
end end

@ -1,35 +1,35 @@
module Mobile module Mobile
module Entities module Entities
class Issue <Grape::Entity class Issue <Grape::Entity
include ApiHelper include ApiHelper
include Redmine::I18n include Redmine::I18n
def self.issue_expose(f) def self.issue_expose(f)
expose f do |issue, opt| expose f do |issue, opt|
if issue.is_a?(Hash) && issue.key?(f) if issue.is_a?(Hash) && issue.key?(f)
issue[f] issue[f]
elsif issue.is_a?(::Issue) elsif issue.is_a?(::Issue)
if issue.respond_to?(f) if issue.respond_to?(f)
issue.send(f) issue.send(f)
else else
case f case f
when :issue_priority when :issue_priority
get_issue_priority_api issue.priority_id get_issue_priority_api issue.priority_id
when :issue_assigned_to when :issue_assigned_to
(get_user(issue.assigned_to_id)).login (get_user(issue.assigned_to_id)).login
when :issue_status when :issue_status
IssueStatus.find(issue.status_id).name IssueStatus.find(issue.status_id).name
end end
end end
end end
end end
end end
expose :subject expose :subject
expose :description expose :description
expose :author, using: Mobile::Entities::User expose :author, using: Mobile::Entities::User
expose :done_ratio expose :done_ratio
issue_expose :issue_priority issue_expose :issue_priority
issue_expose :issue_assigned_to issue_expose :issue_assigned_to
issue_expose :issue_status issue_expose :issue_status
end end
end end
end end

@ -1,66 +1,66 @@
# encoding: utf-8 # encoding: utf-8
module Mobile module Mobile
module Entities module Entities
class Whomework <Grape::Entity class Whomework <Grape::Entity
include ApiHelper include ApiHelper
include ApplicationHelper include ApplicationHelper
include Redmine::I18n include Redmine::I18n
def self.whomework_expose(f) def self.whomework_expose(f)
expose f do |wh, opt| expose f do |wh, opt|
if wh.is_a?(Hash) && wh.key?(f) if wh.is_a?(Hash) && wh.key?(f)
if f == :created_at if f == :created_at
format_time(wh[f]) format_time(wh[f])
else else
wh[f] wh[f]
end end
elsif wh.is_a?(::HomeworkCommon) elsif wh.is_a?(::HomeworkCommon)
if wh.respond_to?(f) if wh.respond_to?(f)
wh.send(f) wh.send(f)
else else
case f case f
when :absence_penalty when :absence_penalty
wh.nil? || wh.homework_detail_manual.nil? ? 0 : wh.homework_detail_manual.absence_penalty wh.nil? || wh.homework_detail_manual.nil? ? 0 : wh.homework_detail_manual.absence_penalty
when :evaluation_start when :evaluation_start
wh.nil? || wh.homework_detail_manual.nil? ? nil : convert_to_time(wh.homework_detail_manual.evaluation_start, 0) wh.nil? || wh.homework_detail_manual.nil? ? nil : convert_to_time(wh.homework_detail_manual.evaluation_start, 0)
when :evaluation_end when :evaluation_end
wh.nil? || wh.homework_detail_manual.nil? ? nil : convert_to_time(wh.homework_detail_manual.evaluation_end, 1) wh.nil? || wh.homework_detail_manual.nil? ? nil : convert_to_time(wh.homework_detail_manual.evaluation_end, 1)
when :whomework_praise_count when :whomework_praise_count
get_activity_praise_num(wh) get_activity_praise_num(wh)
when :whomework_journal_count when :whomework_journal_count
wh.journals_for_messages.count wh.journals_for_messages.count
end end
end end
end end
end end
end end
expose :author, using: Mobile::Entities::User do |w, opt| expose :author, using: Mobile::Entities::User do |w, opt|
if w.is_a?(::HomeworkCommon) if w.is_a?(::HomeworkCommon)
w.user w.user
end end
end end
expose :name expose :name
expose :description expose :description
expose :publish_time expose :publish_time
expose :end_time expose :end_time
expose :homework_type expose :homework_type
expose :late_penalty expose :late_penalty
expose :course_id expose :course_id
expose :anonymous_comment expose :anonymous_comment
expose :quotes expose :quotes
expose :is_open expose :is_open
whomework_expose :created_at whomework_expose :created_at
whomework_expose :absence_penalty whomework_expose :absence_penalty
whomework_expose :evaluation_start whomework_expose :evaluation_start
whomework_expose :evaluation_end whomework_expose :evaluation_end
whomework_expose :whomework_praise_count whomework_expose :whomework_praise_count
whomework_expose :whomework_journal_count whomework_expose :whomework_journal_count
expose :journals_for_messages, using: Mobile::Entities::Jours do |f, opt| expose :journals_for_messages, using: Mobile::Entities::Jours do |f, opt|
#f[:journals_for_messages] if f.is_a?(Hash) && f.key?(:journals_for_messages) #f[:journals_for_messages] if f.is_a?(Hash) && f.key?(:journals_for_messages)
if f.is_a?(::HomeworkCommon) if f.is_a?(::HomeworkCommon)
f.journals_for_messages f.journals_for_messages
end end
end end
end end
end end
end end

@ -1,3 +1,4 @@
<<<<<<< HEAD
require File.expand_path('../boot', __FILE__) require File.expand_path('../boot', __FILE__)
require 'rails/all' require 'rails/all'
@ -94,3 +95,101 @@ module RedmineApp
end end
end end
=======
require File.expand_path('../boot', __FILE__)
require 'rails/all'
require 'sprockets/railtie'
require 'elasticsearch/model'
if defined?(Bundler)
# If you precompile assets before deploying to production, use this line
Bundler.require(*Rails.groups(:assets => %w(development test)))
# If you want your assets lazily compiled in production, use this line
# Bundler.require(:default, :assets, Rails.env)
end
module RedmineApp
class Application < Rails::Application
# Settings in config/environments/* take precedence over those specified here.
# Application configuration should go into files in config/initializers
# -- all .rb files in that directory are automatically loaded.
#verifier if email is real
config.generators do |g|
g.test_framework :rspec,
fixtures: true,
view_specs: false,
helper_specs: false,
routing_specs: false,
controller_specs: true,
request_specs: false
g.fixture_replacement :factory_girl, dir: "spec/factories"
end
# Custom directories with classes and modules you want to be autoloadable.
config.autoload_paths += %W(#{config.root}/lib)
config.autoload_paths += %w(#{RAILS_ROOT}/app/sweepers)
# Only load the plugins named here, in the order given (default is alphabetical).
# :all can be used as a placeholder for all plugins not explicitly named.
# config.plugins = [ :exception_notification, :ssl_requirement, :all ]
# Activate observers that should always be running.
config.active_record.observers = :journals_for_message_observer, :issue_observer, :journal_observer, :wiki_content_observer
config.active_record.store_full_sti_class = true
config.active_record.default_timezone = :local
config.time_zone = 'Beijing'
# Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
# Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
# config.time_zone = 'Central Time (US & Canada)'
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
# config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
config.i18n.default_locale = :zh
#config.i18n.enforce_available_locales = true
#I18n.config.enforce_available_locales = true
# Configure the default encoding used in templates for Ruby 1.9.
config.encoding = "utf-8"
# Configure sensitive parameters which will be filtered from the log file.
config.filter_parameters += [:password]
# Enable the asset pipeline
config.assets.enabled = false
# Version of your assets, change this if you want to expire all your assets
config.assets.version = '1.0'
config.action_mailer.perform_deliveries = false
# Do not include all helpers
config.action_controller.include_all_helpers = false
config.action_view.sanitized_allowed_tags = 'div', 'p', 'span', 'img', 'embed'
config.before_initialize do
end
config.after_initialize do
if RbConfig::CONFIG['target_os'] == 'mingw32'
Elasticsearch::Client.new hosts: ['localhost:9200'], retry_on_failure: true,log:true
elsif RbConfig::CONFIG['target_os'] == 'linux' && ["fast76"].include?(`hostname`.gsub("\n",""))
Elasticsearch::Client.new hosts: ['localhost:9200'], retry_on_failure: true,log:true
elsif RbConfig::CONFIG['target_os'] == 'linux' && ["testtrustie11","agent12"].include?(`hostname`.gsub("\n",""))
Elasticsearch::Client.new hosts: ['localhost:9200','192.168.80.11:9200','192.168.80.12:9200'], retry_on_failure: true
elsif RbConfig::CONFIG['target_os'] == 'linux' && ["trustie168","trustieserver14","trustieserver16","Trustie18"].include?(`hostname`.gsub("\n",""))
Elasticsearch::Client.new hosts: ['localhost:9200','192.168.80.168:9200'], retry_on_failure: true
else
Elasticsearch::Client.new hosts: ['localhost:9200'], retry_on_failure: true
end
end
if File.exists?(File.join(File.dirname(__FILE__), 'additional_environment.rb'))
instance_eval File.read(File.join(File.dirname(__FILE__), 'additional_environment.rb'))
end
end
end
>>>>>>> 77e11fe0fec7f8f0537940863e78c4d7d483aff1

File diff suppressed because it is too large Load Diff

@ -1,65 +1,65 @@
/** /**
* Created by root on 3/25/16. * Created by root on 3/25/16.
*/ */
$(document).ready(function(){ $(document).ready(function(){
var bt=baidu.template; var bt=baidu.template;
bt.LEFT_DELIMITER='<!'; bt.LEFT_DELIMITER='<!';
bt.RIGHT_DELIMITER='!>'; bt.RIGHT_DELIMITER='!>';
var apiUrl = '/api/v1/'; var apiUrl = '/api/v1/';
var setTemplate = function(data){ var setTemplate = function(data){
console.log(data); console.log(data);
var html=bt('t:result-list',{activities: data}); var html=bt('t:result-list',{activities: data});
$('#container').prepend(html); $('#container').prepend(html);
descToggle(); descToggle();
}; };
var loadDataFromServer = function(id){ var loadDataFromServer = function(id){
//getOpenId(function(openid){ //getOpenId(function(openid){
$.ajax({ $.ajax({
url: apiUrl + 'activities/' + id, url: apiUrl + 'activities/' + id,
dataType: 'json', dataType: 'json',
success: function(data){ success: function(data){
setTemplate(data.data); setTemplate(data.data);
}, },
error: function(xhr,status,err){ error: function(xhr,status,err){
console.log(err); console.log(err);
} }
}); });
//}) //})
}; };
loadDataFromServer(8686); loadDataFromServer(8686);
var descToggle = function(){ var descToggle = function(){
var postWidth = $(".post-wrapper").width(); var postWidth = $(".post-wrapper").width();
var titleWidth = postWidth - 80; var titleWidth = postWidth - 80;
$(".post-title").css("maxWidth",titleWidth); $(".post-title").css("maxWidth",titleWidth);
$(".post-all-content").each(function(){ $(".post-all-content").each(function(){
var postHeight = $(this).height(); var postHeight = $(this).height();
if (postHeight > 90){ if (postHeight > 90){
$(this).parent().next().css("display","block"); $(this).parent().next().css("display","block");
$(this).parent().next().toggle(function(){ $(this).parent().next().toggle(function(){
$(this).text("点击隐藏"); $(this).text("点击隐藏");
$(this).prev().css("height",postHeight); $(this).prev().css("height",postHeight);
},function(){ },function(){
$(this).text("点击展开"); $(this).text("点击展开");
$(this).prev().css("height",90); $(this).prev().css("height",90);
}); });
} }
}); });
} }
var timeSpilt = function(){ var timeSpilt = function(){
} }
}); });

@ -1,97 +1,97 @@
/** /**
* Created by guange on 16/3/21. * Created by guange on 16/3/21.
*//* *//*
var Index = React.createClass({ var Index = React.createClass({
render: function(){ render: function(){
return (<div>index page</div>); return (<div>index page</div>);
} }
}); });
var apiUrl = '/api/v1/'; var apiUrl = '/api/v1/';
var PostContainer = React.createClass({ var PostContainer = React.createClass({
loadDataFromServer: function(){ loadDataFromServer: function(){
$.ajax({ $.ajax({
url: apiUrl + 'issues/' + this.props.params.id, url: apiUrl + 'issues/' + this.props.params.id,
dataType: 'json', dataType: 'json',
success: function(data){ success: function(data){
this.setState({data: data.data}); this.setState({data: data.data});
}.bind(this), }.bind(this),
error: function(xhr,status,err){ error: function(xhr,status,err){
console.log(err); console.log(err);
}.bind(this) }.bind(this)
}) })
}, },
componentDidMount: function(){ componentDidMount: function(){
this.loadDataFromServer(); this.loadDataFromServer();
}, },
getInitialState: function(){ getInitialState: function(){
return {data: null}; return {data: null};
}, },
render: function(){ render: function(){
return ( return (
<PostView data={this.state.data}/> <PostView data={this.state.data}/>
) )
} }
}); });
var PostView = React.createClass({ var PostView = React.createClass({
testClick: function(){ testClick: function(){
console.log("123123"); console.log("123123");
}, },
render: function(){ render: function(){
if(!this.props.data){ if(!this.props.data){
return <div></div> return <div></div>
} }
var issueEach = this.props.data.map(function(issue){ var issueEach = this.props.data.map(function(issue){
var descMarkup = converter.makeHtml(issue.description.toString()); var descMarkup = converter.makeHtml(issue.description.toString());
return ( return (
<div className="post-container"> <div className="post-container">
<div className="post-wrapper"> <div className="post-wrapper">
<div className="post-main"> <div className="post-main">
<div className="post-avatar fl"><img src={issue.author.img_url} width="45" height="45" className="border-radius" /></div> <div className="post-avatar fl"><img src={issue.author.img_url} width="45" height="45" className="border-radius" /></div>
<div className="post-title hidden mb5"><span className="c-grey3 f15 fb">{issue.subject}</span></div> <div className="post-title hidden mb5"><span className="c-grey3 f15 fb">{issue.subject}</span></div>
<div className="post-title hidden"><a herf="javascript:void(0);" className="mr10">{issue.author.nickname}</a>项目问题</div> <div className="post-title hidden"><a herf="javascript:void(0);" className="mr10">{issue.author.nickname}</a>项目问题</div>
<div className="cl"></div> <div className="cl"></div>
<div className="post-content c-grey2 mt10"> <div className="post-content c-grey2 mt10">
<div className="post-all-content" dangerouslySetInnerHTML={{__html: descMarkup}}></div> <div className="post-all-content" dangerouslySetInnerHTML={{__html: descMarkup}}></div>
</div> </div>
<a herf="javascript:void(0);" className="link-blue f13 fl mt5 post-more " style={{textDecoration: 'underline'}}>点击展开</a> <a herf="javascript:void(0);" className="link-blue f13 fl mt5 post-more " style={{textDecoration: 'underline'}}>点击展开</a>
<div className="cl"></div> <div className="cl"></div>
<span onClick={this.testClick} className="c-grey f13 mt10 fl">{issue.created_on}</span> <span onClick={this.testClick} className="c-grey f13 mt10 fl">{issue.created_on}</span>
<div className="cl"></div> <div className="cl"></div>
</div> </div>
</div> </div>
</div> </div>
) )
}); });
return( return(
<div>{issueEach}</div> <div>{issueEach}</div>
); );
} }
}); });
var Route = ReactRouter.Route; var Route = ReactRouter.Route;
var Router = ReactRouter.Router; var Router = ReactRouter.Router;
var routes = ( var routes = (
<Router> <Router>
<Route path="/" component={Index}/> <Route path="/" component={Index}/>
<Route path="issue/:id" component={PostContainer} /> <Route path="issue/:id" component={PostContainer} />
</Router> </Router>
); );
React.render(routes, document.getElementById("container")); React.render(routes, document.getElementById("container"));
*/ */

@ -1 +0,0 @@
just test
Loading…
Cancel
Save