Explorar el Código

live cast now support real id and default cast content.

master
Patrick Peng Sun hace 8 años
padre
commit
cc7ef3da4f
Se han modificado 2 ficheros con 40 adiciones y 16 borrados
  1. +38
    -14
      livecast.go
  2. +2
    -2
      spa/livecast.html

+ 38
- 14
livecast.go Ver fichero

@@ -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)
}

+ 2
- 2
spa/livecast.html Ver fichero

@@ -3,7 +3,7 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0" />
<title>{{.Title}}</title>
<title>{{.Name}}</title>
<!-- CSS -->
<link href="https://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
<link href="materialize/css/materialize.css" type="text/css" rel="stylesheet" media="screen,projection" />
@@ -14,7 +14,7 @@
<div class="container">
<br>
<br>
<h5 class="header center orange-text">{{.Title}}</h5>
<h5 class="header center orange-text">{{.Name}}</h5>
<div id="videowraper" class="row center videoWrapper">
<iframe width="560" height="315" src="{{.Youtube}}" frameborder="0" allowfullscreen></iframe>
</div>

Cargando…
Cancelar
Guardar