Skip to content

Commit

Permalink
feat: generate plist for ipa
Browse files Browse the repository at this point in the history
  • Loading branch information
xhofe committed Aug 28, 2022
1 parent 74007a1 commit 5ab5cc3
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 0 deletions.
69 changes: 69 additions & 0 deletions server/handles/helper.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
package handles

import (
"fmt"
"github.com/alist-org/alist/v3/internal/conf"
"github.com/alist-org/alist/v3/internal/setting"
"github.com/alist-org/alist/v3/server/common"
"github.com/gin-gonic/gin"
log "github.com/sirupsen/logrus"
"net/url"
"strings"
)

func Favicon(c *gin.Context) {
c.Redirect(302, setting.GetByKey(conf.Favicon))
}

func Plist(c *gin.Context) {
link := c.Param("link")
u, err := url.PathUnescape(link)
if err != nil {
common.ErrorResp(c, err, 500)
return
}
uUrl, err := url.Parse(u)
if err != nil {
common.ErrorResp(c, err, 500)
return
}
name := c.Param("name")
log.Debug("name", name)
u = uUrl.String()
name = strings.TrimSuffix(name, ".plist")
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 version="1.0">
<dict>
<key>items</key>
<array>
<dict>
<key>assets</key>
<array>
<dict>
<key>kind</key>
<string>software-package</string>
<key>url</key>
<string>%s</string>
</dict>
</array>
<key>metadata</key>
<dict>
<key>bundle-identifier</key>
<string>ci.nn.%s</string>
<key>bundle-version</key>
<string>4.4</string>
<key>kind</key>
<string>software</string>
<key>title</key>
<string>%s</string>
</dict>
</dict>
</array>
</dict>
</plist>`, u, url.PathEscape(name), name)
c.Header("Content-Type", "application/xml;charset=utf-8")
c.Status(200)
_, _ = c.Writer.WriteString(plist)
}
2 changes: 2 additions & 0 deletions server/router.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ func Init(r *gin.Engine) {
r.Use(middlewares.StoragesLoaded)
WebDav(r)

r.GET("/favicon.ico", handles.Favicon)
r.GET("/i/:link/:name", handles.Plist)
r.GET("/d/*path", middlewares.Down, handles.Down)
r.GET("/p/*path", middlewares.Down, handles.Proxy)

Expand Down

0 comments on commit 5ab5cc3

Please sign in to comment.