MCPcopy Index your code
hub / github.com/TruthHun/BookStack / QrCode

Method QrCode

controllers/DocumentController.go:1388–1419  ·  view source on GitHub ↗

生成书籍访问的二维码.

()

Source from the content-addressed store, hash-verified

1386//生成书籍访问的二维码.
1387
1388func (this *DocumentController) QrCode() {
1389 this.Prepare()
1390 identify := this.GetString(":key")
1391
1392 book, err := models.NewBook().FindByIdentify(identify)
1393
1394 if err != nil || book.BookId <= 0 {
1395 this.Abort("404")
1396 }
1397
1398 uri := this.BaseUrl() + beego.URLFor("DocumentController.Index", ":key", identify)
1399 code, err := qr.Encode(uri, qr.L, qr.Unicode)
1400 if err != nil {
1401 beego.Error(err)
1402 this.Abort("404")
1403 }
1404 code, err = barcode.Scale(code, 150, 150)
1405
1406 if err != nil {
1407 beego.Error(err)
1408 this.Abort("404")
1409 }
1410 this.Ctx.ResponseWriter.Header().Set("Content-Type", "image/png")
1411
1412 //imgpath := filepath.Join("cache","qrcode",identify + ".png")
1413
1414 err = png.Encode(this.Ctx.ResponseWriter, code)
1415 if err != nil {
1416 beego.Error(err)
1417 this.Abort("404")
1418 }
1419}
1420
1421// 书籍内搜索.
1422func (this *DocumentController) Search() {

Callers

nothing calls this directly

Calls 5

NewBookFunction · 0.92
BaseUrlMethod · 0.80
SetMethod · 0.80
PrepareMethod · 0.45
FindByIdentifyMethod · 0.45

Tested by

no test coverage detected