Merge branch 'weixin_guange' of https://git.trustie.net/jacknudt/trustieforge into weixin_guange
This commit is contained in:
commit
85cfd542e6
|
@ -8,6 +8,8 @@ module Mobile
|
||||||
require_relative 'apis/homeworks'
|
require_relative 'apis/homeworks'
|
||||||
require_relative 'apis/comments'
|
require_relative 'apis/comments'
|
||||||
require_relative 'apis/issues'
|
require_relative 'apis/issues'
|
||||||
|
require_relative 'apis/activities'
|
||||||
|
require_relative 'apis/whomeworks'
|
||||||
|
|
||||||
class API < Grape::API
|
class API < Grape::API
|
||||||
version 'v1', using: :path
|
version 'v1', using: :path
|
||||||
|
@ -42,6 +44,8 @@ module Mobile
|
||||||
mount Apis::Homeworks
|
mount Apis::Homeworks
|
||||||
mount Apis::Comments
|
mount Apis::Comments
|
||||||
mount Apis::Issues
|
mount Apis::Issues
|
||||||
|
mount Apis::Activities
|
||||||
|
mount Apis::Whomeworks
|
||||||
|
|
||||||
#add_swagger_documentation ({api_version: 'v1', base_path: 'http://u06.shellinfo.cn/trustie/api'})
|
#add_swagger_documentation ({api_version: 'v1', base_path: 'http://u06.shellinfo.cn/trustie/api'})
|
||||||
#add_swagger_documentation ({api_version: 'v1', base_path: '/api'}) if Rails.env.development?
|
#add_swagger_documentation ({api_version: 'v1', base_path: '/api'}) if Rails.env.development?
|
||||||
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
#coding=utf-8
|
||||||
|
|
||||||
|
module Mobile
|
||||||
|
module Apis
|
||||||
|
class Activities< Grape::API
|
||||||
|
resources :activities do
|
||||||
|
|
||||||
|
desc "get user activities"
|
||||||
|
get ':id' do
|
||||||
|
#uw = UserWechat.find params[:openid]
|
||||||
|
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_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
|
||||||
|
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(",") + ")"
|
||||||
|
course_types = "('Message','News','HomeworkCommon','Poll','Course')"
|
||||||
|
project_types = "('Message','Issue','ProjectCreateInfo')"
|
||||||
|
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(','))+")"
|
||||||
|
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 = '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)
|
||||||
|
present :data, activities, with: Mobile::Entities::Activity
|
||||||
|
present :status, 0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,17 @@
|
||||||
|
#coding=utf-8
|
||||||
|
|
||||||
|
module Mobile
|
||||||
|
module Apis
|
||||||
|
class Whomeworks< Grape::API
|
||||||
|
resources :whomeworks do
|
||||||
|
|
||||||
|
desc "get one homework"
|
||||||
|
get ':id' do
|
||||||
|
homework = HomeworkCommon.find params[:id]
|
||||||
|
present :data, homework, with: Mobile::Entities::Whomework
|
||||||
|
present :status, 0
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,102 @@
|
||||||
|
# encoding: utf-8
|
||||||
|
module Mobile
|
||||||
|
module Entities
|
||||||
|
class Activity <Grape::Entity
|
||||||
|
include ApplicationHelper
|
||||||
|
include ApiHelper
|
||||||
|
def self.act_expose(f)
|
||||||
|
expose f do |ac,opt|
|
||||||
|
if ac.is_a?(Hash) && ac.key?(f)
|
||||||
|
ac[f]
|
||||||
|
elsif ac.is_a?(::UserActivity)
|
||||||
|
if ac.respond_to?(f)
|
||||||
|
ac.send(f)
|
||||||
|
else
|
||||||
|
case f
|
||||||
|
when :user_act
|
||||||
|
if ac.act_type == "ProjectCreateInfo"
|
||||||
|
ac unless ac.nil?
|
||||||
|
else
|
||||||
|
ac.act unless ac.nil? || ac.act.nil?
|
||||||
|
end
|
||||||
|
when :reply_num
|
||||||
|
if ac.act_type == "HomeworkCommon"
|
||||||
|
ac.nil? || ac.act.nil? ? 0 : ac.act.journals_for_messages.count
|
||||||
|
elsif ac.act_type == "News"
|
||||||
|
ac.nil? || ac.act.nil? ? 0 : ac.act.comments.count
|
||||||
|
elsif ac.act_type == "Message" || ac.act_type == "BlogComment" || ac.act_type == "JournalsForMessage"
|
||||||
|
ac.nil? || ac.act.nil? ? 0 : ac.act.children.count
|
||||||
|
elsif ac.act_type == "Issue"
|
||||||
|
ac.nil? || ac.act.nil? ? 0 : ac.act.journals.count
|
||||||
|
end
|
||||||
|
when :activity_praise_num
|
||||||
|
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)
|
||||||
|
end
|
||||||
|
when :homework_common_detail_manual
|
||||||
|
if ac.act_type == "HomeworkCommon"
|
||||||
|
ac.act.homework_detail_manual unless ac.nil? || ac.act.nil? || ac.act.homework_detail_manual.nil?
|
||||||
|
end
|
||||||
|
when :course_project_name
|
||||||
|
if ac.container_type == "Course"
|
||||||
|
name = (get_course(ac.container_id)).name
|
||||||
|
name
|
||||||
|
elsif ac.container_type == "Project"
|
||||||
|
name = (get_project(ac.container_id)).name
|
||||||
|
name
|
||||||
|
elsif ac.container_type == "Blog"
|
||||||
|
"发表博客"
|
||||||
|
end
|
||||||
|
when :activity_type_name
|
||||||
|
if ac.container_type == "Course"
|
||||||
|
case ac.act_type
|
||||||
|
when "HomeworkCommon"
|
||||||
|
"课程作业"
|
||||||
|
when "News"
|
||||||
|
"课程通知"
|
||||||
|
when "Message"
|
||||||
|
"课程问答区"
|
||||||
|
when "Poll"
|
||||||
|
"课程问卷"
|
||||||
|
when "Course"
|
||||||
|
"课程"
|
||||||
|
end
|
||||||
|
elsif ac.container_type == "Project"
|
||||||
|
case ac.act_type
|
||||||
|
when "Issue"
|
||||||
|
"项目缺陷"
|
||||||
|
when "Message"
|
||||||
|
"项目问答区"
|
||||||
|
when "ProjectCreateInfo"
|
||||||
|
"项目"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
expose :act_type
|
||||||
|
expose :container_type
|
||||||
|
expose :author, using: Mobile::Entities::User do |a, opt|
|
||||||
|
if a.is_a? ::UserActivity
|
||||||
|
if a.act_type == "ProjectCreateInfo"
|
||||||
|
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'
|
||||||
|
a.act.author
|
||||||
|
elsif a.act_type == 'HomeworkCommon' || a.act_type == 'Poll' || a.act_type == 'JournalsForMessage'
|
||||||
|
a.act.user
|
||||||
|
elsif a.act_type == 'Course'
|
||||||
|
a.act.teacher
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
act_expose :homework_common_detail_manual
|
||||||
|
act_expose :reply_num
|
||||||
|
act_expose :activity_praise_num
|
||||||
|
act_expose :user_act
|
||||||
|
act_expose :course_project_name
|
||||||
|
act_expose :activity_type_name
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -0,0 +1,53 @@
|
||||||
|
# encoding: utf-8
|
||||||
|
module Mobile
|
||||||
|
module Entities
|
||||||
|
class Whomework <Grape::Entity
|
||||||
|
include ApiHelper
|
||||||
|
include ApplicationHelper
|
||||||
|
include Redmine::I18n
|
||||||
|
def self.whomework_expose(f)
|
||||||
|
expose f do |wh, opt|
|
||||||
|
if wh.is_a?(Hash) && wh.key?(f)
|
||||||
|
if f == :created_at
|
||||||
|
format_time(wh[f])
|
||||||
|
else
|
||||||
|
wh[f]
|
||||||
|
end
|
||||||
|
elsif wh.is_a?(::HomeworkCommon)
|
||||||
|
if wh.respond_to?(f)
|
||||||
|
wh.send(f)
|
||||||
|
else
|
||||||
|
case f
|
||||||
|
when :absence_penalty
|
||||||
|
wh.nil? || wh.homework_detail_manual.nil? ? 0 : wh.homework_detail_manual.absence_penalty
|
||||||
|
when :evaluation_start
|
||||||
|
wh.nil? || wh.homework_detail_manual.nil? ? nil : convert_to_time(wh.homework_detail_manual.evaluation_start, 0)
|
||||||
|
when :evaluation_end
|
||||||
|
wh.nil? || wh.homework_detail_manual.nil? ? nil : convert_to_time(wh.homework_detail_manual.evaluation_end, 1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
expose :name
|
||||||
|
expose :description
|
||||||
|
expose :publish_time
|
||||||
|
expose :end_time
|
||||||
|
expose :homework_type
|
||||||
|
expose :late_penalty
|
||||||
|
expose :course_id
|
||||||
|
expose :anonymous_comment
|
||||||
|
expose :quotes
|
||||||
|
expose :is_open
|
||||||
|
whomework_expose :created_at
|
||||||
|
whomework_expose :absence_penalty
|
||||||
|
whomework_expose :evaluation_start
|
||||||
|
whomework_expose :evaluation_end
|
||||||
|
expose :author, using: Mobile::Entities::User do |w, opt|
|
||||||
|
if w.is_a?(::HomeworkCommon)
|
||||||
|
w.user
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
|
@ -201,5 +201,43 @@ module ApiHelper
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
|
#日期转换为时间
|
||||||
|
def convert_to_time date, num
|
||||||
|
if num == 0
|
||||||
|
date = date.to_s + " 00:00"
|
||||||
|
elsif num == 1
|
||||||
|
date = date.to_s + " 23:59"
|
||||||
|
end
|
||||||
|
return date
|
||||||
|
end
|
||||||
|
|
||||||
|
#获取用户
|
||||||
|
def get_user user_id
|
||||||
|
user = User.find user_id
|
||||||
|
user
|
||||||
|
end
|
||||||
|
|
||||||
|
#获取项目
|
||||||
|
def get_project project_id
|
||||||
|
project = Project.find project_id
|
||||||
|
project
|
||||||
|
end
|
||||||
|
|
||||||
|
#获取课程
|
||||||
|
def get_course course_id
|
||||||
|
course = Course.find course_id
|
||||||
|
course
|
||||||
|
end
|
||||||
|
|
||||||
|
#获取点赞数
|
||||||
|
def get_activity_praise_num(object)
|
||||||
|
obj_type = object.class
|
||||||
|
obj_id = object.id
|
||||||
|
record = PraiseTreadCache.find_by_object_id_and_object_type(obj_id,obj_type)
|
||||||
|
if record
|
||||||
|
return ((record.praise_num.nil? ? 0 : record.praise_num.to_i)-(record.tread_num.nil? ? 0 : record.tread_num.to_i))
|
||||||
|
else
|
||||||
|
return 0
|
||||||
|
end
|
||||||
|
end
|
||||||
end
|
end
|
|
@ -48,8 +48,10 @@ module RedmineApp
|
||||||
|
|
||||||
# The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
|
# 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.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
|
||||||
config.i18n.default_locale = :zh
|
#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.
|
# Configure the default encoding used in templates for Ruby 1.9.
|
||||||
config.encoding = "utf-8"
|
config.encoding = "utf-8"
|
||||||
|
|
||||||
|
|
16
db/schema.rb
16
db/schema.rb
|
@ -11,7 +11,7 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended to check this file into your version control system.
|
# It's strongly recommended to check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(:version => 20160225024759) do
|
ActiveRecord::Schema.define(:version => 20160317090350) do
|
||||||
|
|
||||||
create_table "activities", :force => true do |t|
|
create_table "activities", :force => true do |t|
|
||||||
t.integer "act_id", :null => false
|
t.integer "act_id", :null => false
|
||||||
|
@ -435,6 +435,8 @@ ActiveRecord::Schema.define(:version => 20160225024759) do
|
||||||
t.datetime "created_at", :null => false
|
t.datetime "created_at", :null => false
|
||||||
t.datetime "updated_at", :null => false
|
t.datetime "updated_at", :null => false
|
||||||
t.integer "total_score"
|
t.integer "total_score"
|
||||||
|
t.integer "homework_journal_num", :default => 0
|
||||||
|
t.integer "news_num", :default => 0
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "course_groups", :force => true do |t|
|
create_table "course_groups", :force => true do |t|
|
||||||
|
@ -506,6 +508,7 @@ ActiveRecord::Schema.define(:version => 20160225024759) do
|
||||||
t.integer "is_excellent", :default => 0
|
t.integer "is_excellent", :default => 0
|
||||||
t.integer "excellent_option", :default => 0
|
t.integer "excellent_option", :default => 0
|
||||||
t.integer "is_copy", :default => 0
|
t.integer "is_copy", :default => 0
|
||||||
|
t.integer "visits", :default => 0
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "custom_fields", :force => true do |t|
|
create_table "custom_fields", :force => true do |t|
|
||||||
|
@ -1282,6 +1285,7 @@ ActiveRecord::Schema.define(:version => 20160225024759) do
|
||||||
t.datetime "created_at", :null => false
|
t.datetime "created_at", :null => false
|
||||||
t.datetime "updated_at", :null => false
|
t.datetime "updated_at", :null => false
|
||||||
t.boolean "allow_guest_download", :default => true
|
t.boolean "allow_guest_download", :default => true
|
||||||
|
t.integer "visits", :default => 0
|
||||||
end
|
end
|
||||||
|
|
||||||
create_table "phone_app_versions", :force => true do |t|
|
create_table "phone_app_versions", :force => true do |t|
|
||||||
|
@ -1441,6 +1445,7 @@ ActiveRecord::Schema.define(:version => 20160225024759) do
|
||||||
t.integer "acts_count", :default => 0
|
t.integer "acts_count", :default => 0
|
||||||
t.integer "journals_count", :default => 0
|
t.integer "journals_count", :default => 0
|
||||||
t.integer "boards_reply_count", :default => 0
|
t.integer "boards_reply_count", :default => 0
|
||||||
|
t.integer "visits", :default => 0
|
||||||
end
|
end
|
||||||
|
|
||||||
add_index "projects", ["lft"], :name => "index_projects_on_lft"
|
add_index "projects", ["lft"], :name => "index_projects_on_lft"
|
||||||
|
@ -1777,6 +1782,14 @@ ActiveRecord::Schema.define(:version => 20160225024759) do
|
||||||
t.integer "fields_bits", :default => 0
|
t.integer "fields_bits", :default => 0
|
||||||
end
|
end
|
||||||
|
|
||||||
|
create_table "user_actions", :force => true do |t|
|
||||||
|
t.integer "user_id"
|
||||||
|
t.string "action_type"
|
||||||
|
t.integer "action_id"
|
||||||
|
t.datetime "created_at", :null => false
|
||||||
|
t.datetime "updated_at", :null => false
|
||||||
|
end
|
||||||
|
|
||||||
create_table "user_activities", :force => true do |t|
|
create_table "user_activities", :force => true do |t|
|
||||||
t.string "act_type"
|
t.string "act_type"
|
||||||
t.integer "act_id"
|
t.integer "act_id"
|
||||||
|
@ -1919,6 +1932,7 @@ ActiveRecord::Schema.define(:version => 20160225024759) do
|
||||||
t.string "mail_notification", :default => "", :null => false
|
t.string "mail_notification", :default => "", :null => false
|
||||||
t.string "salt", :limit => 64
|
t.string "salt", :limit => 64
|
||||||
t.integer "gid"
|
t.integer "gid"
|
||||||
|
t.integer "visits", :default => 0
|
||||||
end
|
end
|
||||||
|
|
||||||
add_index "users", ["auth_source_id"], :name => "index_users_on_auth_source_id"
|
add_index "users", ["auth_source_id"], :name => "index_users_on_auth_source_id"
|
||||||
|
|
|
@ -0,0 +1,221 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>react js</title>
|
||||||
|
<meta charset='utf-8' />
|
||||||
|
<meta name="keywords" content="" />
|
||||||
|
<meta name="description" content="" />
|
||||||
|
<meta name="apple-mobile-web-app-capable" content="no">
|
||||||
|
<meta content='True' name='HandheldFriendly' />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
|
||||||
|
|
||||||
|
<link type="text/css" rel="stylesheet" href="/stylesheets/weui/weixin.css" />
|
||||||
|
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="container"></div>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
<!-- 模板1开始,可以使用script(type设置为text/html)来存放模板片段,并且用id标示 -->
|
||||||
|
<script id="t:result-list" type="text/html">
|
||||||
|
<! for(var i =0; i <activities.length; ++i){ !>
|
||||||
|
<! var container_type = "course"; var act_type = "homework"; !>
|
||||||
|
<! if (container_type == "course") { !>
|
||||||
|
<! if (act_type == "homework") { !>
|
||||||
|
<!--homework -->
|
||||||
|
<div class="post-container">
|
||||||
|
<div class="post-wrapper">
|
||||||
|
<div class="post-main">
|
||||||
|
<div class="post-avatar fl"><img src="<!=activities[i].author.img_url!>" width="45" height="45" class="border-radius" /></div>
|
||||||
|
<div class="post-title hidden mb5"><span class="c-grey3 f15 fb"><!=activities[i].subject!></span></div>
|
||||||
|
<div class="post-title hidden"><a herf="javascript:void(0);" class="mr10"><!=activities[i].author.nickname!></a>to<a herf="javascript:void(0);" class="ml10">我的私有课程 | 课程作业</a></div>
|
||||||
|
<div class="cl"></div>
|
||||||
|
<div class="post-content c-grey2 mt10">
|
||||||
|
<div class="post-all-content"><!:=activities[i].description!><br />
|
||||||
|
<span class="mr15">迟交扣分:10分</span> 匿评开启时间:2016-03-14 00:00<br />
|
||||||
|
<span class="mr15">缺评扣分:5分/作品</span> 匿评关闭时间:2016-03-21 23:59</div>
|
||||||
|
</div>
|
||||||
|
<a herf="javascript:void(0);" class="link-blue f13 fl mt5 post-more undis" style="text-decoration:underline">点击展开</a>
|
||||||
|
<div class="cl"></div>
|
||||||
|
<span class="c-grey f13 mt10 fl"><!=activities[i].created_on!></span>
|
||||||
|
<div class="cl"></div>
|
||||||
|
</div>
|
||||||
|
<div class="post-interactive">
|
||||||
|
<div class="post-interactive-column c-grey2">回复<!=activities[i].reply_num!></div>
|
||||||
|
<div class="post-interactive-column c-grey2">赞<!=activities[i].praise_num!></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<! } else if (act_type == "news") { !>
|
||||||
|
<!-- course news -->
|
||||||
|
<div class="post-container">
|
||||||
|
<div class="post-wrapper">
|
||||||
|
<div class="post-main">
|
||||||
|
<div class="post-avatar fl"><img src="<!=activities[i].author.img_url!>" width="45" height="45" class="border-radius" /></div>
|
||||||
|
<div class="post-title hidden mb5"><span class="c-grey3 f15 fb"><!=activities[i].subject!></span></div>
|
||||||
|
<div class="post-title hidden"><a herf="javascript:void(0);" class="mr10"><!=activities[i].author.nickname!></a>to<a herf="javascript:void(0);" class="ml10">我的私有课程 | 课程讨论区</a></div>
|
||||||
|
<div class="cl"></div>
|
||||||
|
<div class="post-content c-grey2 mt10">
|
||||||
|
<div class="post-all-content"><!:=activities[i].description!></div>
|
||||||
|
</div>
|
||||||
|
<a herf="javascript:void(0);" class="link-blue f13 fl mt5 post-more undis" style="text-decoration:underline">点击展开</a>
|
||||||
|
<div class="cl"></div>
|
||||||
|
<span class="c-grey f13 mt10 fl"><!=activities[i].created_on!></span>
|
||||||
|
<div class="cl"></div>
|
||||||
|
</div>
|
||||||
|
<div class="post-interactive">
|
||||||
|
<div class="post-interactive-column c-grey2">回复</div>
|
||||||
|
<div class="post-interactive-column c-grey2">赞</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<! } else if (act_type == "messge") { !>
|
||||||
|
<!--course message -->
|
||||||
|
<div class="post-container">
|
||||||
|
<div class="post-wrapper">
|
||||||
|
<div class="post-main">
|
||||||
|
<div class="post-avatar fl"><img src="images/post-avatar.jpg" width="45" height="45" class="border-radius" /></div>
|
||||||
|
<div class="post-title fl mb10 hidden"><a herf="javascript:void(0);" class="mr10"><!=activities[i].author.nickname!></a> <span style="vertical-align:top;">给您留言了</span><br />
|
||||||
|
<span class="c-grey"><!=activities[i].created_on!></span> </div>
|
||||||
|
<div class="cl"></div>
|
||||||
|
<div class="post-content c-grey2 mt10">
|
||||||
|
<p class="post-all-content"><!:=activities[i].description!></p>
|
||||||
|
</div>
|
||||||
|
<a herf="javascript:void(0);" class="link-blue f13 fl mt5 post-more undis" style="text-decoration:underline;">点击展开</a>
|
||||||
|
<div class="cl"></div>
|
||||||
|
</div>
|
||||||
|
<div class="post-interactive">
|
||||||
|
<div class="post-interactive-column c-grey2">回复</div>
|
||||||
|
<div class="post-interactive-column c-grey2">赞</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<! } else if (act_type == "course") { !>
|
||||||
|
<div class="post-container">
|
||||||
|
<div class="post-wrapper">
|
||||||
|
<div class="post-main">
|
||||||
|
<div class="post-avatar fl"><img src="<!=activities[i].author.img_url!>" width="45" height="45" class="border-radius" /></div>
|
||||||
|
<div class="post-title hidden mb5"><span class="c-grey3 f15 fb"><!=activities[i].author.nickname!></span>创建了<span class="c-grey3 f15 fb">我的私有课程 | 课程</span></div>
|
||||||
|
<div class="post-title hidden"><a herf="javascript:void(0);" class="mr10"><!=activities[i].created_on!></a></div>
|
||||||
|
<div class="cl"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<! } !>
|
||||||
|
<! } else if (container_type == "project") { !>
|
||||||
|
<! if (act_type == "activities") { !>
|
||||||
|
<!-- activities -->
|
||||||
|
<div class="post-container">
|
||||||
|
<div class="post-wrapper">
|
||||||
|
<div class="post-main">
|
||||||
|
<div class="post-avatar fl"><img src="<!=activities[i].author.img_url!>" width="45" height="45" class="border-radius" /></div>
|
||||||
|
<div class="post-title hidden mb5"><span class="c-grey3 f15 fb"><!=activities[i].subject!></span></div>
|
||||||
|
<div class="post-title hidden"><a herf="javascript:void(0);" class="mr10"><!=activities[i].author.nickname!></a>to</div>
|
||||||
|
<div class="cl"></div>
|
||||||
|
<div class="post-content c-grey2 mt10">
|
||||||
|
<div class="post-all-content"><!:=activities[i].description!><br />
|
||||||
|
<span class="mr15">指派给:黄井泉</span> <span class="mr15">状态:新增</span> <span class="mr15">完成度:30%</span></div>
|
||||||
|
</div>
|
||||||
|
<a herf="javascript:void(0);" class="link-blue f13 fl mt5 post-more undis" style="text-decoration:underline">点击展开</a>
|
||||||
|
<div class="cl"></div>
|
||||||
|
<span class="c-grey f13 mt10 fl"><!=activities[i].created_on!></span>
|
||||||
|
<div class="cl"></div>
|
||||||
|
</div>
|
||||||
|
<div class="post-interactive">
|
||||||
|
<div class="post-interactive-column c-grey2">回复</div>
|
||||||
|
<div class="post-interactive-column c-grey2">赞</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<! } else if (act_type == "message") { !>
|
||||||
|
<!-- project news -->
|
||||||
|
<div class="post-container">
|
||||||
|
<div class="post-wrapper">
|
||||||
|
<div class="post-main">
|
||||||
|
<div class="post-avatar fl"><img src="<!=activities[i].author.img_url!>" width="45" height="45" class="border-radius" /></div>
|
||||||
|
<div class="post-title hidden mb5"><span class="c-grey3 f15 fb"><!=activities[i].subject!></span></div>
|
||||||
|
<div class="post-title hidden"><a herf="javascript:void(0);" class="mr10"><!=activities[i].author.nickname!></a>to<a herf="javascript:void(0);" class="ml10">我的私有课程 | 课程讨论区</a></div>
|
||||||
|
<div class="cl"></div>
|
||||||
|
<div class="post-content c-grey2 mt10">
|
||||||
|
<div class="post-all-content"><!:=activities[i].description!></div>
|
||||||
|
</div>
|
||||||
|
<a herf="javascript:void(0);" class="link-blue f13 fl mt5 post-more undis" style="text-decoration:underline">点击展开</a>
|
||||||
|
<div class="cl"></div>
|
||||||
|
<span class="c-grey f13 mt10 fl"><!=activities[i].created_on!></span>
|
||||||
|
<div class="cl"></div>
|
||||||
|
</div>
|
||||||
|
<div class="post-interactive">
|
||||||
|
<div class="post-interactive-column c-grey2">回复</div>
|
||||||
|
<div class="post-interactive-column c-grey2">赞</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<! } else if (act_type == "ProjectCreateInfo") { !>
|
||||||
|
<!-- project created -->
|
||||||
|
<div class="post-container">
|
||||||
|
<div class="post-wrapper">
|
||||||
|
<div class="post-main">
|
||||||
|
<div class="post-avatar fl"><img src="<!=activities[i].author.img_url!>" width="45" height="45" class="border-radius" /></div>
|
||||||
|
<div class="post-title hidden mb5"><span class="c-grey3 f15 fb"><!=activities[i].author.nickname!></span>创建了<span class="c-grey3 f15 fb">我的私有课程 | 课程</span></div>
|
||||||
|
<div class="post-title hidden"><a herf="javascript:void(0);" class="mr10"><!=activities[i].created_on!></a></div>
|
||||||
|
<div class="cl"></div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<! } !>
|
||||||
|
<! } else if (container_type == "Principal") { !>
|
||||||
|
<!--留言 -->
|
||||||
|
<div class="post-container">
|
||||||
|
<div class="post-wrapper">
|
||||||
|
<div class="post-main">
|
||||||
|
<div class="post-avatar fl"><img src="images/post-avatar.jpg" width="45" height="45" class="border-radius" /></div>
|
||||||
|
<div class="post-title fl mb10 hidden"><a herf="javascript:void(0);" class="mr10"><!=activities[i].author.nickname!></a> <span style="vertical-align:top;">给您留言了</span><br />
|
||||||
|
<span class="c-grey"><!=activities[i].created_on!></span> </div>
|
||||||
|
<div class="cl"></div>
|
||||||
|
<div class="post-content c-grey2 mt10">
|
||||||
|
<p class="post-all-content"><!:=activities[i].description!></p>
|
||||||
|
</div>
|
||||||
|
<a herf="javascript:void(0);" class="link-blue f13 fl mt5 post-more undis" style="text-decoration:underline;">点击展开</a>
|
||||||
|
<div class="cl"></div>
|
||||||
|
</div>
|
||||||
|
<div class="post-interactive">
|
||||||
|
<div class="post-interactive-column c-grey2">回复</div>
|
||||||
|
<div class="post-interactive-column c-grey2">赞</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<! } else if (container_type == "blog") { !>
|
||||||
|
<!--blog -->
|
||||||
|
<div class="post-container">
|
||||||
|
<div class="post-wrapper">
|
||||||
|
<div class="post-main">
|
||||||
|
<div class="post-avatar fl"><img src="<!=activities[i].author.img_url!>" width="45" height="45" class="border-radius" /></div>
|
||||||
|
<div class="post-title hidden mb5"><span class="c-grey3 f15 fb"><!=activities[i].subject!></span></div>
|
||||||
|
<div class="post-title hidden"><a herf="javascript:void(0);" class="mr10"><!=activities[i].author.nickname!></a>发表博客</div>
|
||||||
|
<div class="cl"></div>
|
||||||
|
<div class="post-content c-grey2 mt10">
|
||||||
|
<div class="post-all-content"><!:=activities[i].description!></div>
|
||||||
|
</div>
|
||||||
|
<a herf="javascript:void(0);" class="link-blue f13 fl mt5 post-more undis" style="text-decoration:underline">点击展开</a>
|
||||||
|
<div class="cl"></div>
|
||||||
|
<span class="c-grey f13 mt10 fl"><!=activities[i].created_on!></span>
|
||||||
|
<div class="cl"></div>
|
||||||
|
</div>
|
||||||
|
<div class="post-interactive">
|
||||||
|
<div class="post-interactive-column c-grey2">回复</div>
|
||||||
|
<div class="post-interactive-column c-grey2">赞</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
<! } !>
|
||||||
|
<! } !>
|
||||||
|
</script>
|
||||||
|
|
||||||
|
<script src="/javascripts/jquery-1.3.2.js"></script>
|
||||||
|
<script src="/javascripts/baiduTemplate.js"></script>
|
||||||
|
<script src="/javascripts/wechat/wechat-dev.js"></script>
|
||||||
|
<script src="/javascripts/wechat/auth.js"></script>
|
||||||
|
</body>
|
||||||
|
</html>
|
|
@ -18,7 +18,7 @@
|
||||||
<!-- 模板1开始,可以使用script(type设置为text/html)来存放模板片段,并且用id标示 -->
|
<!-- 模板1开始,可以使用script(type设置为text/html)来存放模板片段,并且用id标示 -->
|
||||||
<script id="t:result-list" type="text/html">
|
<script id="t:result-list" type="text/html">
|
||||||
|
|
||||||
<! for(var i =0; i <issues.length; ++i){ !>
|
<! for(var i =0; i < issues.length; ++i){ !>
|
||||||
<div class="post-container">
|
<div class="post-container">
|
||||||
<div class="post-wrapper">
|
<div class="post-wrapper">
|
||||||
<div class="post-main">
|
<div class="post-main">
|
||||||
|
|
|
@ -8,17 +8,19 @@ $(document).ready(function(){
|
||||||
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',{issues: data});
|
var html=bt('t:result-list',{activities: data});
|
||||||
$('#container').prepend(html);
|
$('#container').prepend(html);
|
||||||
}
|
descToggle();
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
var loadDataFromServer = function(id){
|
var loadDataFromServer = function(id){
|
||||||
getOpenId(function(openid){
|
//getOpenId(function(openid){
|
||||||
$.ajax({
|
$.ajax({
|
||||||
url: apiUrl + 'issues/' + id + "?openid="+openid,
|
url: apiUrl + 'activities/' + id,
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
success: function(data){
|
success: function(data){
|
||||||
setTemplate(data.data);
|
setTemplate(data.data);
|
||||||
|
@ -27,19 +29,17 @@ $(document).ready(function(){
|
||||||
console.log(err);
|
console.log(err);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
})
|
//})
|
||||||
|
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
loadDataFromServer(8686);
|
||||||
|
|
||||||
loadDataFromServer(299);
|
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){
|
||||||
|
@ -53,4 +53,13 @@ $(document).ready(function(){
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
var timeSpilt = function(){
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
/**
|
/**
|
||||||
* 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(){
|
||||||
|
@ -10,8 +11,6 @@ var Index = React.createClass({
|
||||||
|
|
||||||
var apiUrl = '/api/v1/';
|
var apiUrl = '/api/v1/';
|
||||||
|
|
||||||
var converter = new Showdown.converter();
|
|
||||||
|
|
||||||
var PostContainer = React.createClass({
|
var PostContainer = React.createClass({
|
||||||
loadDataFromServer: function(){
|
loadDataFromServer: function(){
|
||||||
$.ajax({
|
$.ajax({
|
||||||
|
@ -34,7 +33,7 @@ var PostContainer = React.createClass({
|
||||||
render: function(){
|
render: function(){
|
||||||
return (
|
return (
|
||||||
<PostView data={this.state.data}/>
|
<PostView data={this.state.data}/>
|
||||||
)issues
|
)
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -95,3 +94,4 @@ var routes = (
|
||||||
React.render(routes, document.getElementById("container"));
|
React.render(routes, document.getElementById("container"));
|
||||||
|
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
Loading…
Reference in New Issue