Compare commits
9 Commits
renovate/g
...
v2.6.3
Author | SHA1 | Date | |
---|---|---|---|
1d3b86985f | |||
c711ba53a3 | |||
532a326ad6 | |||
917ad07ab7 | |||
50fd7de045 | |||
f6527f1c4c | |||
a3ef3d1416 | |||
89b05021f8 | |||
7e40acad3f |
18
.github/workflows/release.yml
vendored
18
.github/workflows/release.yml
vendored
@ -14,23 +14,9 @@ jobs:
|
|||||||
uses: actions/checkout@v2
|
uses: actions/checkout@v2
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0
|
fetch-depth: 0
|
||||||
- name: Changelog
|
- run: npx changelogithub # or changelogithub@0.12 if ensure the stable result
|
||||||
uses: Bullrich/generate-release-changelog@master
|
|
||||||
id: Changelog
|
|
||||||
env:
|
env:
|
||||||
REPO: ${{ github.repository }}
|
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
|
||||||
- name: Create Release
|
|
||||||
id: create_release
|
|
||||||
uses: actions/create-release@latest
|
|
||||||
env:
|
|
||||||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions, you do not need to create your own token
|
|
||||||
with:
|
|
||||||
tag_name: ${{ github.ref }}
|
|
||||||
release_name: Release ${{ github.ref }}
|
|
||||||
body: |
|
|
||||||
${{ steps.Changelog.outputs.changelog }}
|
|
||||||
draft: false
|
|
||||||
prerelease: false
|
|
||||||
release:
|
release:
|
||||||
needs: changelog
|
needs: changelog
|
||||||
strategy:
|
strategy:
|
||||||
|
@ -72,7 +72,8 @@ Available at: <https://alist.nn.ci>.
|
|||||||
<https://alist-doc.nn.ci/en/>
|
<https://alist-doc.nn.ci/en/>
|
||||||
|
|
||||||
## Special sponsors
|
## Special sponsors
|
||||||
- [Find Resources - Aliyundrive Resource Search Engine](https://zhaoziyuan.la/)
|
- [找资源 - 阿里云盘资源搜索引擎](https://zhaoziyuan.la/)
|
||||||
|
- [KinhDown 百度云盘不限速下载!永久免费!以稳定运行3年!非常可靠!](https://kinhdown.com/?Type=Tutorials)
|
||||||
- [JetBrains: Essential tools for software developers and teams](https://www.jetbrains.com/)
|
- [JetBrains: Essential tools for software developers and teams](https://www.jetbrains.com/)
|
||||||
|
|
||||||
## License
|
## License
|
||||||
|
@ -73,6 +73,7 @@
|
|||||||
|
|
||||||
## 特别赞助
|
## 特别赞助
|
||||||
- [找资源 - 阿里云盘资源搜索引擎](https://zhaoziyuan.la/)
|
- [找资源 - 阿里云盘资源搜索引擎](https://zhaoziyuan.la/)
|
||||||
|
- [KinhDown 百度云盘不限速下载!永久免费!以稳定运行3年!非常可靠!](https://kinhdown.com/?Type=Tutorials)
|
||||||
- [JetBrains: Essential tools for software developers and teams](https://www.jetbrains.com/)
|
- [JetBrains: Essential tools for software developers and teams](https://www.jetbrains.com/)
|
||||||
|
|
||||||
## 许可
|
## 许可
|
||||||
|
14
build.sh
14
build.sh
@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
# 构建前端,在当前目录产生一个dist文件夹
|
# 构建前端,在当前目录产生一个dist文件夹
|
||||||
BUILD_WEB() {
|
BUILD_WEB() {
|
||||||
git clone https://github.com/alist-org/alist-web.git
|
git clone https://github.com/alist-org/web-v2.git
|
||||||
cd alist-web
|
cd web-v2
|
||||||
yarn
|
yarn
|
||||||
yarn build
|
yarn build
|
||||||
sed -i -e "s/\/CDN_URL\//\//g" dist/index.html
|
sed -i -e "s/\/CDN_URL\//\//g" dist/index.html
|
||||||
@ -11,11 +11,11 @@ BUILD_WEB() {
|
|||||||
rm -f dist/index.html-e
|
rm -f dist/index.html-e
|
||||||
mv dist ..
|
mv dist ..
|
||||||
cd .. || exit
|
cd .. || exit
|
||||||
rm -rf alist-web
|
rm -rf web-v2
|
||||||
}
|
}
|
||||||
|
|
||||||
CDN_WEB() {
|
CDN_WEB() {
|
||||||
curl -L https://github.com/alist-org/alist-web/releases/latest/download/dist.tar.gz -o dist.tar.gz
|
curl -L https://github.com/alist-org/web-v2/releases/latest/download/dist.tar.gz -o dist.tar.gz
|
||||||
tar -zxvf dist.tar.gz
|
tar -zxvf dist.tar.gz
|
||||||
rm -f dist.tar.gz
|
rm -f dist.tar.gz
|
||||||
}
|
}
|
||||||
@ -28,7 +28,7 @@ BUILD_DOCKER() {
|
|||||||
gitAuthor=$(git show -s --format='format:%aN <%ae>' HEAD)
|
gitAuthor=$(git show -s --format='format:%aN <%ae>' HEAD)
|
||||||
gitCommit=$(git log --pretty=format:"%h" -1)
|
gitCommit=$(git log --pretty=format:"%h" -1)
|
||||||
gitTag=$(git describe --long --tags --dirty --always)
|
gitTag=$(git describe --long --tags --dirty --always)
|
||||||
webTag=$(wget -qO- -t1 -T2 "https://api.github.com/repos/alist-org/alist-web/releases/latest" | grep "tag_name" | head -n 1 | awk -F ":" '{print $2}' | sed 's/\"//g;s/,//g;s/ //g')
|
webTag=$(wget -qO- -t1 -T2 "https://api.github.com/repos/alist-org/web-v2/releases/latest" | grep "tag_name" | head -n 1 | awk -F ":" '{print $2}' | sed 's/\"//g;s/,//g;s/ //g')
|
||||||
ldflags="\
|
ldflags="\
|
||||||
-w -s \
|
-w -s \
|
||||||
-X 'github.com/Xhofe/alist/conf.BuiltAt=$builtAt' \
|
-X 'github.com/Xhofe/alist/conf.BuiltAt=$builtAt' \
|
||||||
@ -49,7 +49,7 @@ BUILD() {
|
|||||||
gitAuthor=$(git show -s --format='format:%aN <%ae>' HEAD)
|
gitAuthor=$(git show -s --format='format:%aN <%ae>' HEAD)
|
||||||
gitCommit=$(git log --pretty=format:"%h" -1)
|
gitCommit=$(git log --pretty=format:"%h" -1)
|
||||||
gitTag=$(git describe --long --tags --dirty --always)
|
gitTag=$(git describe --long --tags --dirty --always)
|
||||||
webTag=$(wget -qO- -t1 -T2 "https://api.github.com/repos/alist-org/alist-web/releases/latest" | grep "tag_name" | head -n 1 | awk -F ":" '{print $2}' | sed 's/\"//g;s/,//g;s/ //g')
|
webTag=$(wget -qO- -t1 -T2 "https://api.github.com/repos/alist-org/web-v2/releases/latest" | grep "tag_name" | head -n 1 | awk -F ":" '{print $2}' | sed 's/\"//g;s/,//g;s/ //g')
|
||||||
echo "build version: $gitTag"
|
echo "build version: $gitTag"
|
||||||
|
|
||||||
ldflags="\
|
ldflags="\
|
||||||
@ -95,7 +95,7 @@ BUILD_MUSL() {
|
|||||||
gitAuthor=$(git show -s --format='format:%aN <%ae>' HEAD)
|
gitAuthor=$(git show -s --format='format:%aN <%ae>' HEAD)
|
||||||
gitCommit=$(git log --pretty=format:"%h" -1)
|
gitCommit=$(git log --pretty=format:"%h" -1)
|
||||||
gitTag=$(git describe --long --tags --dirty --always)
|
gitTag=$(git describe --long --tags --dirty --always)
|
||||||
webTag=$(wget -qO- -t1 -T2 "https://api.github.com/repos/alist-org/alist-web/releases/latest" | grep "tag_name" | head -n 1 | awk -F ":" '{print $2}' | sed 's/\"//g;s/,//g;s/ //g')
|
webTag=$(wget -qO- -t1 -T2 "https://api.github.com/repos/alist-org/web-v2/releases/latest" | grep "tag_name" | head -n 1 | awk -F ":" '{print $2}' | sed 's/\"//g;s/,//g;s/ //g')
|
||||||
ldflags="\
|
ldflags="\
|
||||||
-w -s --extldflags '-static -fpic' \
|
-w -s --extldflags '-static -fpic' \
|
||||||
-X 'github.com/Xhofe/alist/conf.BuiltAt=$builtAt' \
|
-X 'github.com/Xhofe/alist/conf.BuiltAt=$builtAt' \
|
||||||
|
@ -24,22 +24,26 @@ type CacheConfig struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Force bool `json:"force"`
|
Force bool `json:"force"`
|
||||||
Address string `json:"address" env:"ADDR"`
|
Address string `json:"address" env:"ADDR"`
|
||||||
Port int `json:"port" env:"PORT"`
|
Port int `json:"port" env:"PORT"`
|
||||||
Assets string `json:"assets" env:"ASSETS"`
|
Assets string `json:"assets" env:"ASSETS"`
|
||||||
Database Database `json:"database"`
|
LocalAssets string `json:"local_assets" env:"LOCAL_ASSETS"`
|
||||||
Scheme Scheme `json:"scheme"`
|
SubFolder string `json:"sub_folder" env:"SUB_FOLDER"`
|
||||||
Cache CacheConfig `json:"cache"`
|
Database Database `json:"database"`
|
||||||
TempDir string `json:"temp_dir" env:"TEMP_DIR"`
|
Scheme Scheme `json:"scheme"`
|
||||||
|
Cache CacheConfig `json:"cache"`
|
||||||
|
TempDir string `json:"temp_dir" env:"TEMP_DIR"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func DefaultConfig() *Config {
|
func DefaultConfig() *Config {
|
||||||
return &Config{
|
return &Config{
|
||||||
Address: "0.0.0.0",
|
Address: "0.0.0.0",
|
||||||
Port: 5244,
|
Port: 5244,
|
||||||
Assets: "https://npm.elemecdn.com/alist-web@$version/dist",
|
Assets: "/",
|
||||||
TempDir: "data/temp",
|
SubFolder: "",
|
||||||
|
LocalAssets: "",
|
||||||
|
TempDir: "data/temp",
|
||||||
Database: Database{
|
Database: Database{
|
||||||
Type: "sqlite3",
|
Type: "sqlite3",
|
||||||
Port: 0,
|
Port: 0,
|
||||||
|
@ -176,7 +176,7 @@ func (driver Pan123) Link(args base.Args, account *model.Account) (*base.Link, e
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
u_ := fmt.Sprintf("https://%s%s", u.Host, u.Path)
|
u_ := fmt.Sprintf("https://%s%s", u.Host, u.Path)
|
||||||
res, err := base.NoRedirectClient.R().SetQueryParamsFromValues(u.Query()).Get(u_)
|
res, err := base.NoRedirectClient.R().SetQueryParamsFromValues(u.Query()).Head(u_)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
@ -184,6 +184,7 @@ func (driver Pan123) Link(args base.Args, account *model.Account) (*base.Link, e
|
|||||||
link := base.Link{
|
link := base.Link{
|
||||||
Url: resp.Data.DownloadUrl,
|
Url: resp.Data.DownloadUrl,
|
||||||
}
|
}
|
||||||
|
log.Debugln("res code: ", res.StatusCode())
|
||||||
if res.StatusCode() == 302 {
|
if res.StatusCode() == 302 {
|
||||||
link.Url = res.Header().Get("location")
|
link.Url = res.Header().Get("location")
|
||||||
}
|
}
|
||||||
|
@ -270,7 +270,7 @@ func (driver Cloud139) Rename(src string, dst string, account *model.Account) er
|
|||||||
"accountType": 1,
|
"accountType": 1,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
pathname = "/orchestration/personalCloud/catalog/v1.0/updateContentInfo"
|
pathname = "/orchestration/personalCloud/content/v1.0/updateContentInfo"
|
||||||
}
|
}
|
||||||
_, err = driver.Post(pathname, data, nil, account)
|
_, err = driver.Post(pathname, data, nil, account)
|
||||||
return err
|
return err
|
||||||
|
@ -113,7 +113,7 @@ func (driver Alist) Link(args base.Args, account *model.Account) (*base.Link, er
|
|||||||
flag = "p"
|
flag = "p"
|
||||||
}
|
}
|
||||||
link := base.Link{}
|
link := base.Link{}
|
||||||
link.Url = fmt.Sprintf("%s/%s%s?sign=%s", account.SiteUrl, flag, path, utils.SignWithToken(name, conf.Token))
|
link.Url = fmt.Sprintf("%s/%s%s?sign=%s", account.SiteUrl, flag, utils.Join(utils.ParsePath(account.RootFolder), path), utils.SignWithToken(name, conf.Token))
|
||||||
return &link, nil
|
return &link, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,11 +2,14 @@ package server
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"io/fs"
|
"io/fs"
|
||||||
|
"os"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/pprof"
|
"net/http/pprof"
|
||||||
"strings"
|
"strings"
|
||||||
|
"path/filepath"
|
||||||
|
|
||||||
|
"github.com/Xhofe/alist/utils"
|
||||||
"github.com/Xhofe/alist/conf"
|
"github.com/Xhofe/alist/conf"
|
||||||
"github.com/Xhofe/alist/public"
|
"github.com/Xhofe/alist/public"
|
||||||
"github.com/gin-gonic/gin"
|
"github.com/gin-gonic/gin"
|
||||||
@ -19,31 +22,65 @@ func InitIndex() {
|
|||||||
if !strings.Contains(conf.Conf.Assets, "/") {
|
if !strings.Contains(conf.Conf.Assets, "/") {
|
||||||
conf.Conf.Assets = conf.DefaultConfig().Assets
|
conf.Conf.Assets = conf.DefaultConfig().Assets
|
||||||
}
|
}
|
||||||
index, err = public.Public.Open("index.html")
|
// if LocalAssets is local path, read local index.html.
|
||||||
|
if (utils.IsDir(filepath.Dir(conf.Conf.LocalAssets))) && utils.Exists(filepath.Join(conf.Conf.LocalAssets, "index.html")) {
|
||||||
|
index, err = os.Open(filepath.Join(conf.Conf.LocalAssets, "index.html"))
|
||||||
|
defer index.Close()
|
||||||
|
log.Infof("used local index.html")
|
||||||
|
} else {
|
||||||
|
index, err = public.Public.Open("index.html")
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal(err.Error())
|
log.Fatal(err.Error())
|
||||||
}
|
}
|
||||||
data, _ := ioutil.ReadAll(index)
|
data, _ := ioutil.ReadAll(index)
|
||||||
|
conf.RawIndexHtml = string(data)
|
||||||
|
// if exist SUB_FOLDER, replace it by config: SubFolder
|
||||||
|
subfolder := strings.Trim(conf.Conf.SubFolder, "/")
|
||||||
|
if strings.Contains(conf.RawIndexHtml, "SUB_FOLDER") {
|
||||||
|
conf.RawIndexHtml = strings.ReplaceAll(conf.RawIndexHtml, "SUB_FOLDER", subfolder)
|
||||||
|
}
|
||||||
cdnUrl := strings.ReplaceAll(conf.Conf.Assets, "$version", conf.WebTag)
|
cdnUrl := strings.ReplaceAll(conf.Conf.Assets, "$version", conf.WebTag)
|
||||||
cdnUrl = strings.TrimRight(cdnUrl, "/")
|
cdnUrl = strings.TrimRight(cdnUrl, "/")
|
||||||
conf.RawIndexHtml = string(data)
|
|
||||||
if strings.Contains(conf.RawIndexHtml, "CDN_URL") {
|
if strings.Contains(conf.RawIndexHtml, "CDN_URL") {
|
||||||
conf.RawIndexHtml = strings.ReplaceAll(conf.RawIndexHtml, "/CDN_URL", cdnUrl)
|
if (cdnUrl == "") && (subfolder != "") {
|
||||||
conf.RawIndexHtml = strings.ReplaceAll(conf.RawIndexHtml, "assets/", cdnUrl+"/assets/")
|
conf.RawIndexHtml = strings.ReplaceAll(conf.RawIndexHtml, "CDN_URL", subfolder)
|
||||||
|
conf.RawIndexHtml = strings.ReplaceAll(conf.RawIndexHtml, "assets/", "/" + subfolder+"/assets/")
|
||||||
|
} else {
|
||||||
|
conf.RawIndexHtml = strings.ReplaceAll(conf.RawIndexHtml, "/CDN_URL", cdnUrl)
|
||||||
|
conf.RawIndexHtml = strings.ReplaceAll(conf.RawIndexHtml, "assets/", cdnUrl+"/assets/")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func Static(r *gin.Engine) {
|
func Static(r *gin.Engine) {
|
||||||
|
var assets fs.FS
|
||||||
|
var pub fs.FS
|
||||||
|
var err error
|
||||||
|
var fsys fs.FS
|
||||||
//InitIndex()
|
//InitIndex()
|
||||||
assets, err := fs.Sub(public.Public, "assets")
|
// if LocalAssets is local path, read local assets.
|
||||||
|
fsys = os.DirFS(conf.Conf.LocalAssets)
|
||||||
|
if (utils.IsDir(filepath.Dir(conf.Conf.LocalAssets))) && utils.Exists(filepath.Join(conf.Conf.LocalAssets, "assets")) {
|
||||||
|
assets, err = fs.Sub(fsys, "assets")
|
||||||
|
log.Infof("used local assets")
|
||||||
|
} else {
|
||||||
|
assets, err = fs.Sub(public.Public, "assets")
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("can't find assets folder")
|
log.Fatalf("can't find assets folder")
|
||||||
}
|
}
|
||||||
pub, err := fs.Sub(public.Public, "public")
|
r.StaticFS("/assets/", http.FS(assets))
|
||||||
|
// if LocalAssets is local path, read local assets.
|
||||||
|
if (utils.IsDir(filepath.Dir(conf.Conf.LocalAssets))) && utils.Exists(filepath.Join(conf.Conf.LocalAssets, "public")) {
|
||||||
|
pub, err = fs.Sub(fsys, "public")
|
||||||
|
log.Infof("used local public")
|
||||||
|
} else {
|
||||||
|
pub, err = fs.Sub(public.Public, "public")
|
||||||
|
}
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatalf("can't find public folder")
|
log.Fatalf("can't find public folder")
|
||||||
}
|
}
|
||||||
r.StaticFS("/assets/", http.FS(assets))
|
|
||||||
r.StaticFS("/public/", http.FS(pub))
|
r.StaticFS("/public/", http.FS(pub))
|
||||||
r.NoRoute(func(c *gin.Context) {
|
r.NoRoute(func(c *gin.Context) {
|
||||||
c.Header("Content-Type", "text/html")
|
c.Header("Content-Type", "text/html")
|
||||||
|
Reference in New Issue
Block a user