forked from soulteary/flare
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
package deprecated | ||
|
||
import ( | ||
"net/http" | ||
|
||
"github.com/gin-gonic/gin" | ||
|
||
FlareState "github.com/soulteary/flare/state" | ||
) | ||
|
||
// TODO:样式优化 | ||
func makeLandingPage(originURL string, currentURL string, delay string) []byte { | ||
tpl := `<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<meta http-equiv="X-UA-Compatible" content="IE=edge"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<meta http-equiv="Refresh" content="` + delay + `; url='` + currentURL + `'" /> | ||
<title>URL Deprecated</title> | ||
</head> | ||
<body> | ||
<p>由于程序升级,<a href="` + currentURL + `"><code>` + originURL + `</code></a>变更为<a href="` + currentURL + `"><code>` + currentURL + `</code></a>,页面将在` + delay + `秒后自动跳转。</p> | ||
<p>你也可以直接点击<a href="` + currentURL + `"><code>这里</code></a>,前往新的页面</p> | ||
</body> | ||
</html>` | ||
return []byte(tpl) | ||
} | ||
|
||
// 展示临时的落地页,在几个版本后,彻底取消路由 | ||
func RegisterRouting(router *gin.Engine) { | ||
const urlMDI = "/resources/mdi-cheat-sheets/" | ||
router.GET(urlMDI, func(c *gin.Context) { | ||
if FlareState.AppFlags.EnableDeprecatedNotice { | ||
c.Data(http.StatusOK, "text/html; charset=utf-8", makeLandingPage(urlMDI, FlareState.RegularPages.Icons.Path, "5")) | ||
} else { | ||
c.Redirect(http.StatusTemporaryRedirect, FlareState.RegularPages.Icons.Path) | ||
} | ||
c.Abort() | ||
}) | ||
} |