Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
sbwml committed Sep 15, 2022
2 parents 5fefc62 + fb48d47 commit c62b63a
Show file tree
Hide file tree
Showing 17 changed files with 240 additions and 155 deletions.
22 changes: 12 additions & 10 deletions alist/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
include $(TOPDIR)/rules.mk

PKG_NAME:=alist
PKG_VERSION:=2.6.4
PKG_WEB_VERSION:=2.6.4
PKG_VERSION:=3.0.0-rc.0
PKG_WEB_VERSION:=3.0.0-rc.0
PKG_RELEASE:=1

PKG_SOURCE:=$(PKG_NAME)-$(PKG_VERSION).tar.gz
PKG_SOURCE_URL:=https://codeload.github.com/alist-org/alist/tar.gz/v$(PKG_VERSION)?
PKG_HASH:=3860f5cec5d809159c55498874c472386cd6142a932a5e7bbfb3b0f569e3e12b
PKG_HASH:=659ddabc87ceca834a09320c6dd87ab24b16247b992d297b12d9ea4771bed9bf

PKG_LICENSE:=GPL-3.0
PKG_LICENSE_FILE:=LICENSE
Expand All @@ -22,8 +22,8 @@ PKG_MAINTAINER:=sbwml <[email protected]>
define Download/$(PKG_NAME)-web
FILE:=$(PKG_NAME)-web-$(PKG_WEB_VERSION).tar.gz
URL_FILE:=dist.tar.gz
URL:=https://github.com/alist-org/web-v2/releases/download/$(PKG_WEB_VERSION)/
HASH:=4189ce3c523e6b8f6bba55faefabc926f6ef793c8755c5c2a2d3f75532fb2243
URL:=https://github.com/alist-org/alist-web/releases/download/$(PKG_WEB_VERSION)/
HASH:=55ad8bf4e39e48ff1a0a503783c4e6922e102810cae6dcdf99cec91263c79414
endef

PKG_CONFIG_DEPENDS:=CONFIG_ALIST_COMPRESS_UPX
Expand All @@ -32,10 +32,12 @@ PKG_BUILD_DEPENDS:=golang/host
PKG_BUILD_PARALLEL:=1
PKG_USE_MIPS16:=0

GO_PKG:=github.com/Xhofe/alist
ALIST_PKG:=github.com/Xhofe/alist/conf
PKG_ALIST:=github.com/alist-org/alist/v3/internal/conf
GO_PKG:=github.com/alist-org/alist
GO_PKG_LDFLAGS:=-w -s
GO_PKG_LDFLAGS_X:=$(ALIST_PKG).GitTag=v$(PKG_VERSION)-$(ARCH)
GO_PKG_LDFLAGS_X:= \
$(PKG_ALIST).Version=v$(PKG_VERSION)-$(ARCH) \
$(PKG_ALIST).WebVersion=$(PKG_WEB_VERSION)

include $(INCLUDE_DIR)/package.mk
include $(TOPDIR)/feeds/packages/lang/golang/golang-package.mk
Expand Down Expand Up @@ -66,8 +68,8 @@ endef
define Build/Prepare
$(call Build/Prepare/Default)
$(eval $(call Download,$(PKG_NAME)-web))
$(TAR) --strip-components=1 -C $(PKG_BUILD_DIR)/public -xzf $(DL_DIR)/$(PKG_NAME)-web-$(PKG_WEB_VERSION).tar.gz
$(CP) ./files/assets/. $(PKG_BUILD_DIR)/public/assets/
$(TAR) --strip-components=1 -C $(PKG_BUILD_DIR)/public/dist -xzf $(DL_DIR)/$(PKG_NAME)-web-$(PKG_WEB_VERSION).tar.gz
$(CP) ./files/assets/. $(PKG_BUILD_DIR)/public/dist/assets/
endef

define Build/Compile
Expand Down
10 changes: 0 additions & 10 deletions alist/files/assets/circle_center.svg

This file was deleted.

10 changes: 0 additions & 10 deletions alist/files/assets/http_can_circle.svg

This file was deleted.

38 changes: 0 additions & 38 deletions alist/patches/0001-Revert-feat-clear-temp-file-while-start.patch

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
--- a/internal/bootstrap/config.go
+++ b/internal/bootstrap/config.go
@@ -55,11 +55,7 @@ func InitConfig() {
}
conf.Conf.TempDir = absPath
}
- err := os.RemoveAll(filepath.Join(conf.Conf.TempDir))
- if err != nil {
- log.Errorln("failed delete temp file:", err)
- }
- err = os.MkdirAll(conf.Conf.TempDir, 0700)
+ err := os.MkdirAll(conf.Conf.TempDir, 0700)
if err != nil {
log.Fatalf("create temp dir error: %+v", err)
}
2 changes: 1 addition & 1 deletion luci-app-alist/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
include $(TOPDIR)/rules.mk

PKG_NAME:=luci-app-alist
PKG_VERSION:=1.0.4
PKG_VERSION:=1.0.5
PKG_RELEASE:=1

LUCI_TITLE:=LuCI support for alist
Expand Down
28 changes: 26 additions & 2 deletions luci-app-alist/luasrc/controller/alist.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,17 @@ function index()
return
end

local page = entry({"admin", "nas", "alist"}, alias("admin", "nas", "alist", "basic"), _("Alist"), 20)
page.dependent = true
page.acl_depends = { "luci-app-alist" }

entry({"admin", "nas"}, firstchild(), "NAS", 44).dependent = false
entry({"admin", "nas", "alist"}, cbi("alist"), _("Alist"), 20).dependent = true
entry({"admin", "nas", "alist_status"}, call("alist_status"))
entry({"admin", "nas", "alist", "basic"}, cbi("alist/basic"), _("Basic Setting"), 1).leaf = true
entry({"admin", "nas", "alist", "log"}, cbi("alist/log"), _("Logs"), 2).leaf = true
entry({"admin", "nas", "alist", "alist_status"}, call("alist_status")).leaf = true
entry({"admin", "nas", "alist", "get_log"}, call("get_log")).leaf = true
entry({"admin", "nas", "alist", "clear_log"}, call("clear_log")).leaf = true
entry({"admin", "nas", "alist", "admin_info"}, call("admin_info")).leaf = true
end

function alist_status()
Expand All @@ -23,3 +31,19 @@ function alist_status()
luci.http.prepare_content("application/json")
luci.http.write_json(status)
end

function get_log()
luci.http.write(luci.sys.exec("cat $(uci -q get alist.@alist[0].temp_dir)/alist.log"))
end

function clear_log()
luci.sys.call("cat /dev/null > $(uci -q get alist.@alist[0].temp_dir)/alist.log")
end

function admin_info()
local username = luci.sys.exec("/usr/bin/alist --conf /etc/alist/config.json password 2>&1 | tail -2 | awk 'NR==1 {print $2}'")
local password = luci.sys.exec("/usr/bin/alist --conf /etc/alist/config.json password 2>&1 | tail -2 | awk 'NR==2 {print $2}'")

luci.http.prepare_content("application/json")
luci.http.write_json({username = username, password = password})
end
53 changes: 0 additions & 53 deletions luci-app-alist/luasrc/model/cbi/alist.lua

This file was deleted.

45 changes: 45 additions & 0 deletions luci-app-alist/luasrc/model/cbi/alist/basic.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
local m, s

m = Map("alist", translate("Alist"), translate("A file list program that supports multiple storage.") .. "<br/>" .. [[<a href="https://alist.nn.ci/zh/guide/drivers/local.html" target="_blank">]] .. translate("User Manual") .. [[</a>]])

m:section(SimpleSection).template = "alist/alist_status"

s = m:section(TypedSection, "alist")
s.addremove = false
s.anonymous = true

o = s:option(Flag, "enabled", translate("Enable"))
o.rmempty = false

o = s:option(Value, "port", translate("Port"))
o.datatype = "and(port,min(1))"
o.rmempty = false

o = s:option(Flag, "log", translate("Enable Logs"))
o.default = 1
o.rmempty = false

o = s:option(Flag, "ssl", translate("Enable SSL"))
o.rmempty=false

o = s:option(Value,"ssl_cert", translate("SSL cert"), translate("SSL certificate file path"))
o.datatype = "file"
o:depends("ssl", "1")

o = s:option(Value,"ssl_key", translate("SSL key"), translate("SSL key file path"))
o.datatype = "file"
o:depends("ssl", "1")

o = s:option(Flag, "allow_wan", translate("Allow Access From Internet"))
o.rmempty = false

o = s:option(Value, "temp_dir", translate("Cache directory"))
o.datatype = "string"
o.default = "/tmp/alist"
o.rmempty = false

o = s:option(Button, "admin_info", translate("View Password"))
o.rawhtml = true
o.template = "alist/admin_info"

return m
5 changes: 5 additions & 0 deletions luci-app-alist/luasrc/model/cbi/alist/log.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
m = Map("alist")

m:append(Template("alist/alist_log"))

return m
26 changes: 26 additions & 0 deletions luci-app-alist/luasrc/view/alist/admin_info.htm
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<%+cbi/valueheader%>
<script type="text/javascript">//<![CDATA[
function admin_info(btn)
{
btn.disabled = true;
btn.value = '<%:Reading...%>';
XHR.get('<%=luci.dispatcher.build_url("admin", "nas", "alist", "admin_info")%>',
null,
function(x,rv)
{
var tb = document.getElementById('<%=self.option%>-status');
if (tb)
{
tb.innerHTML = "<%:Username:%>" + "<font color='green'>" + rv.username + "</font>";
tb.innerHTML += "<%:Password:%>" + "<font color='green'>" + rv.password + "</font>";
}
btn.disabled = false;
btn.value = '<%:Read%>';
}
);
return false;
}
//]]></script>
<input type="button" class="btn cbi-button cbi-button-apply" value="<%:Read%>" onclick="return admin_info(this)" />
<span id="<%=self.option%>-status"><em><%=self.value%></em></span>
<%+cbi/valuefooter%>
29 changes: 29 additions & 0 deletions luci-app-alist/luasrc/view/alist/alist_log.htm
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<script type="text/javascript">
//<![CDATA[
function clear_log(btn) {
XHR.get('<%=url([[admin]], [[nas]], [[alist]], [[clear_log]])%>', null,
function(x, data) {
if(x && x.status == 200) {
var log_textarea = document.getElementById('log_textarea');
log_textarea.innerHTML = "";
log_textarea.scrollTop = log_textarea.scrollHeight;
}
location.reload();
}
);
}
XHR.poll(2, '<%=url([[admin]], [[nas]], [[alist]], [[get_log]])%>', null,
function(x, data) {
if(x && x.status == 200) {
var log_textarea = document.getElementById('log_textarea');
log_textarea.innerHTML = x.responseText;
log_textarea.scrollTop = log_textarea.scrollHeight;
}
}
);
//]]>
</script>
<fieldset class="cbi-section" id="_log_fieldset">
<input class="cbi-button cbi-input-remove" type="button" onclick="clear_log()" value="<%:Clear logs%>" style="margin-left: 10px; margin-top: 10px;">
<textarea id="log_textarea" class="cbi-input-textarea" style="width: calc(100% - 20px); height: 500px; margin: 10px;" data-update="change" rows="5" wrap="off" readonly="readonly"></textarea>
</fieldset>
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@
%>

<script type="text/javascript">//<![CDATA[
XHR.poll(5, '<%=url("admin/nas/alist_status")%>', null,
XHR.poll(5, '<%=url("admin/nas/alist/alist_status")%>', null,
function(x, st)
{
var tb = document.getElementById('alist_status');
if (st && tb)
{
if (st.running)
{
tb.innerHTML = '<em style=\"color:green\"><b><%:The Alist service is running.%></b></em>' + "<input class=\"cbi-button-reload mar-10\" type=\"button\" value=\" <%:Click to open Alist%> \" onclick=\"window.open('<%=protocol%>" + window.location.hostname + ":" + st.port + "/')\"/>";
tb.innerHTML = '<em style=\"color:green\"><b>Alist <%:RUNNING%></b></em>' + "<input class=\"cbi-button-reload mar-10\" type=\"button\" value=\" <%:Open Web Interface%> \" onclick=\"window.open('<%=protocol%>" + window.location.hostname + ":" + st.port + "/')\"/>";
}
else
{
tb.innerHTML = '<em style=\"color:red\"><b><%:The Alist service is not running.%></b></em>';
tb.innerHTML = '<em style=\"color:red\"><b>Alist <%:NOT RUNNING%></b></em>';
}
}
}
Expand Down
Loading

0 comments on commit c62b63a

Please sign in to comment.