diff --git a/livecast.go b/livecast.go index 2ec8d7b..e33112f 100644 --- a/livecast.go +++ b/livecast.go @@ -6,30 +6,43 @@ import ( "io/ioutil" "log" "net/http" + "net/url" ) -type liveCast struct { - Youtube string - Title string - Description string +type crmdLiveCast struct { + crmdEntityBase + Youtube string `json:"youtube,omitempty"` + Description string `json:"description,omitempty"` } func liveCastHandler(w http.ResponseWriter, r *http.Request) { - cast := liveCast{} - cast.Youtube = "https://www.youtube.com/embed/T3-ueqivO0g" - cast.Title = "大学联盟活动日" - cast.Description = ` -当地时间7月12日,伊利诺伊州中部地区联邦检察官办公室发布公告称,综合各种证据,负责调查案件的执法人员相信章莹颖已经死亡。 + castID := "" + q, err := url.ParseQuery(r.URL.RawQuery) + if err == nil { + castIDs, ok := q["id"] + if ok { + castID = castIDs[0] + } + } - 美国司法部网站12日发布消息,美国联邦大陪审团当天正式起诉涉嫌绑架中国访问学者章莹颖的嫌疑人布伦特·克里斯滕森(Brendt Christensen),原定14日进行的预审取消,提审日期待定。 - 如罪名成立,嫌疑人布伦特·克里斯滕森将面临终身监禁的最高刑罚。目前美国警方仍在就此案进行调查。 + if castID == "" { + responseDefaultLiveCast(w) + return + } - 伊利诺伊州乌尔班纳(Urbana)的一个联邦大陪审团星期三决定起诉涉嫌绑架中国学者章莹颖的一名男子。` + //castID = "5967812b87eb10564" + entity, err := crmFindEntityByID("Livecast", castID) + if err != nil || entity == nil { + response404Handler(w) + return + } - cast.youtubeVideo(w, r) + cast := entity.(crmdLiveCast) + + cast.youtubeVideo(w) } -func (m liveCast) youtubeVideo(w http.ResponseWriter, r *http.Request) { +func (m crmdLiveCast) youtubeVideo(w http.ResponseWriter) { tTest := template.New("livecast") str, err := ioutil.ReadFile("spa/livecast.html") if err != nil { @@ -51,3 +64,14 @@ func (m liveCast) youtubeVideo(w http.ResponseWriter, r *http.Request) { log.Println("ERROR: Template execution on spa/Edit, failed \n" + err.Error()) } } + +func responseDefaultLiveCast(w http.ResponseWriter) { + cast := crmdLiveCast{} + + cast.Youtube = "https://www.youtube.com/embed/8r9zR27Kzho" + cast.Name = "暂无直播" + cast.Description = ` + 直播活动,和校友会活动息息相关,方便在不同地域的校友积极参加,同时留下宝贵的影响资料,供后来的校友们参考。在没有直播的情况下, 校友会随机选取哈工大的宣传片,校友们的个人简介,以及校友会的宣传片放映。 + ` + cast.youtubeVideo(w) +} diff --git a/spa/livecast.html b/spa/livecast.html index 592d1a9..e36861b 100644 --- a/spa/livecast.html +++ b/spa/livecast.html @@ -3,7 +3,7 @@
-