From 30a4c8d40b4684fb3faf30de70460bb9c155b9f6 Mon Sep 17 00:00:00 2001 From: sbwml Date: Sun, 23 Jan 2022 01:04:29 +0800 Subject: [PATCH] LuCI support for alist --- luci-app-alist/Makefile | 17 ++++++++ luci-app-alist/luasrc/controller/alist.lua | 25 ++++++++++++ luci-app-alist/luasrc/model/cbi/alist.lua | 21 ++++++++++ luci-app-alist/luasrc/view/alist_status.htm | 27 +++++++++++++ luci-app-alist/po/zh_Hans/alist.po | 39 +++++++++++++++++++ .../root/etc/uci-defaults/50_luci-alist | 4 ++ 6 files changed, 133 insertions(+) create mode 100644 luci-app-alist/Makefile create mode 100644 luci-app-alist/luasrc/controller/alist.lua create mode 100644 luci-app-alist/luasrc/model/cbi/alist.lua create mode 100644 luci-app-alist/luasrc/view/alist_status.htm create mode 100644 luci-app-alist/po/zh_Hans/alist.po create mode 100755 luci-app-alist/root/etc/uci-defaults/50_luci-alist diff --git a/luci-app-alist/Makefile b/luci-app-alist/Makefile new file mode 100644 index 0000000..723705a --- /dev/null +++ b/luci-app-alist/Makefile @@ -0,0 +1,17 @@ +# Copyright (C) 2016 Openwrt.org +# +# This is free software, licensed under the Apache License, Version 2.0 . +# + +include $(TOPDIR)/rules.mk + +LUCI_TITLE:=LuCI support for alist +LUCI_DEPENDS:=+alist +LUCI_PKGARCH:=all +PKG_VERSION:=1.0.2 +PKG_RELEASE:=1 + +include $(TOPDIR)/feeds/luci/luci.mk + +# call BuildPackage - OpenWrt buildroot signature + diff --git a/luci-app-alist/luasrc/controller/alist.lua b/luci-app-alist/luasrc/controller/alist.lua new file mode 100644 index 0000000..a54982f --- /dev/null +++ b/luci-app-alist/luasrc/controller/alist.lua @@ -0,0 +1,25 @@ +module("luci.controller.alist", package.seeall) + +function index() + if not nixio.fs.access("/etc/config/alist") then + return + end + + entry({"admin", "nas", "alist"}, cbi("alist"), _("Alist"), 20).dependent = true + + entry({"admin", "nas", "alist_status"}, call("alist_status")) +end + +function alist_status() + local sys = require "luci.sys" + local uci = require "luci.model.uci".cursor() + local port = tonumber(uci:get_first("alist", "alist", "port")) + + local status = { + running = (sys.call("pidof alist >/dev/null") == 0), + port = (port or 5244) + } + + luci.http.prepare_content("application/json") + luci.http.write_json(status) +end diff --git a/luci-app-alist/luasrc/model/cbi/alist.lua b/luci-app-alist/luasrc/model/cbi/alist.lua new file mode 100644 index 0000000..08ddd9c --- /dev/null +++ b/luci-app-alist/luasrc/model/cbi/alist.lua @@ -0,0 +1,21 @@ +local m, s + +m = Map("alist", translate("Alist"), translate("Alist is an file list program that supports multiple storage. Default password: alist")) + +m:section(SimpleSection).template = "alist_status" + +s=m:section(TypedSection, "alist", translate("Global settings")) +s.addremove=false +s.anonymous=true + +s:option(Flag, "enabled", translate("Enable")).rmempty=false +s:option(Value, "port", translate("Port")).rmempty=false + +s=m:section(TypedSection, "alist", translate("Cache settings")) +s.addremove=false +s.anonymous=true + +s:option(Value, "expiration", translate("Cache invalidation time (unit: minutes)")).rmempty=false +s:option(Value, "cleanup_interval", translate("Clear the invalidation cache interval")).rmempty=false + +return m diff --git a/luci-app-alist/luasrc/view/alist_status.htm b/luci-app-alist/luasrc/view/alist_status.htm new file mode 100644 index 0000000..b4bc25e --- /dev/null +++ b/luci-app-alist/luasrc/view/alist_status.htm @@ -0,0 +1,27 @@ + + +
+ <%:Alist Status%> +

+ <%:Collecting data...%> +

+
diff --git a/luci-app-alist/po/zh_Hans/alist.po b/luci-app-alist/po/zh_Hans/alist.po new file mode 100644 index 0000000..d25c0cd --- /dev/null +++ b/luci-app-alist/po/zh_Hans/alist.po @@ -0,0 +1,39 @@ +msgid "Alist" +msgstr "Alist 文件列表" + +msgid "Running state" +msgstr "运行状态" + +msgid "Click to open Alist" +msgstr "点击打开 Alist" + +msgid "Alist is an file list program that supports multiple storage. Default password: alist" +msgstr "Alist 是一个支持多存储的文件列表程序。默认密码:alist" + +msgid "Global settings" +msgstr "全局设置" + +msgid "Port" +msgstr "端口" + +msgid "Cache settings" +msgstr "缓存设置" + +msgid "Cache invalidation time (unit: minutes)" +msgstr "缓存失效时间(分钟)" + +msgid "Clear the invalidation cache interval" +msgstr "清理失效缓存间隔" + +msgid "The Alist service is running." +msgstr "Alist 服务已启动" + +msgid "The Alist service is not running." +msgstr "Alist 服务未启动" + +msgid "Alist Status" +msgstr "Alist 服务状态" + +msgid "Collecting data..." +msgstr "收集数据..." + diff --git a/luci-app-alist/root/etc/uci-defaults/50_luci-alist b/luci-app-alist/root/etc/uci-defaults/50_luci-alist new file mode 100755 index 0000000..e0aedf7 --- /dev/null +++ b/luci-app-alist/root/etc/uci-defaults/50_luci-alist @@ -0,0 +1,4 @@ +#!/bin/sh + +rm -f /tmp/luci-indexcache* +exit 0