mirror of https://github.com/Xhofe/alist
feat: support custom `bundle-identifier` by filename
parent
09564102e7
commit
b74b55fa4a
|
@ -10,7 +10,6 @@ import (
|
||||||
"github.com/alist-org/alist/v3/internal/setting"
|
"github.com/alist-org/alist/v3/internal/setting"
|
||||||
"github.com/alist-org/alist/v3/server/common"
|
"github.com/alist-org/alist/v3/server/common"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
log "github.com/sirupsen/logrus"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func Favicon(c *gin.Context) {
|
func Favicon(c *gin.Context) {
|
||||||
|
@ -38,10 +37,18 @@ func Plist(c *gin.Context) {
|
||||||
common.ErrorResp(c, err, 500)
|
common.ErrorResp(c, err, 500)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
name := c.Param("name")
|
fullName := c.Param("name")
|
||||||
log.Debug("name", name)
|
|
||||||
Url := uUrl.String()
|
Url := uUrl.String()
|
||||||
name = strings.TrimSuffix(name, ".plist")
|
fullName = strings.TrimSuffix(fullName, ".plist")
|
||||||
|
name := fullName
|
||||||
|
identifier := fmt.Sprintf("ci.nn.%s", url.PathEscape(fullName))
|
||||||
|
|
||||||
|
if strings.Contains(fullName, "_") {
|
||||||
|
ss := strings.Split(fullName, "_")
|
||||||
|
name = strings.Join(ss[:len(ss)-1], "_")
|
||||||
|
identifier = ss[len(ss)-1]
|
||||||
|
}
|
||||||
|
|
||||||
name = strings.ReplaceAll(name, "<", "[")
|
name = strings.ReplaceAll(name, "<", "[")
|
||||||
name = strings.ReplaceAll(name, ">", "]")
|
name = strings.ReplaceAll(name, ">", "]")
|
||||||
plist := fmt.Sprintf(`<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
plist := fmt.Sprintf(`<?xml version="1.0" encoding="UTF-8"?><!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||||
|
@ -56,13 +63,13 @@ func Plist(c *gin.Context) {
|
||||||
<key>kind</key>
|
<key>kind</key>
|
||||||
<string>software-package</string>
|
<string>software-package</string>
|
||||||
<key>url</key>
|
<key>url</key>
|
||||||
<string>%s</string>
|
<string><![CDATA[%s]]></string>
|
||||||
</dict>
|
</dict>
|
||||||
</array>
|
</array>
|
||||||
<key>metadata</key>
|
<key>metadata</key>
|
||||||
<dict>
|
<dict>
|
||||||
<key>bundle-identifier</key>
|
<key>bundle-identifier</key>
|
||||||
<string>ci.nn.%s</string>
|
<string>%s</string>
|
||||||
<key>bundle-version</key>
|
<key>bundle-version</key>
|
||||||
<string>4.4</string>
|
<string>4.4</string>
|
||||||
<key>kind</key>
|
<key>kind</key>
|
||||||
|
@ -73,7 +80,7 @@ func Plist(c *gin.Context) {
|
||||||
</dict>
|
</dict>
|
||||||
</array>
|
</array>
|
||||||
</dict>
|
</dict>
|
||||||
</plist>`, Url, url.PathEscape(name), name)
|
</plist>`, Url, identifier, name)
|
||||||
c.Header("Content-Type", "application/xml;charset=utf-8")
|
c.Header("Content-Type", "application/xml;charset=utf-8")
|
||||||
c.Status(200)
|
c.Status(200)
|
||||||
_, _ = c.Writer.WriteString(plist)
|
_, _ = c.Writer.WriteString(plist)
|
||||||
|
|
Loading…
Reference in New Issue