<%+header%> <% local http = require("luci.http") local core = require("substore.core") -- meta.error 是语言中立的 msgid(可能是组合消息),翻译在视图侧做 —— -- 后端模块不能 require("luci.i18n"),见 msg.lua 的文件头。 local msg = require("substore.msg") local function tmsg(s) return msg.translate(s, luci.i18n.translate) end local id = http.formvalue("id") or "" local it = id ~= "" and core.get(id) or nil local is_edit = it ~= nil local rules_enabled = it and (it.rules_enable == true or it.rules_enable == "1") or false local ki = (it and it.keyword_include) or "" local ke = (it and it.keyword_exclude) or "" local dedup = it and (it.dedup == "1" or it.dedup == true) -- 协议筛选 / 重命名:控制器一直在读这两项(read_rules_fields),但此前三个表单 -- 都没有提交它们的控件 —— 字段永远写空,且每次保存会把 UCI 里已有的值重置为 ""。 local proto_sel = {} for p in ((it and it.proto_filter) or ""):gmatch("[^,]+") do proto_sel[p:match("^%s*(.-)%s*$")] = true end local rm = (it and it.rename_map) or "" local local_mode = (it and it.local_mode) or "text" local content = (it and it.raw_content) or "" -- 注入 JS 的初始内容:JSON 字符串字面量,把全部 "<" 转成 <, -- 同时挡住 "

<%=is_edit and luci.i18n.translate("Edit local subscription") or luci.i18n.translate("Add local subscription")%>

<% if is_edit then %><% end %>
"/>
">
<%:Paste a node list here — one format at a time (URI / Base64 / YAML / JSON / WireGuard .conf); protocols may be mixed within that format.%>
">
<%:Add nodes via form below. Each node will be saved as JSON and parsed on save.%>
/>
onchange="var r=document.getElementById('rules_row');if(r)r.style.display=this.checked?'block':'none';"/> <%:When enabled, apply keyword include/exclude and dedup rules to nodes%>
">
/>
<% for _, p in ipairs(core.RULE_PROTOS) do %> /> <% end %>
<%:Separate multiple keywords with commas (e.g. HK,US,JP); include = keep if any matches, exclude = drop if any matches.%>
<%:Protocol filter: with none ticked no filtering is applied.%>
<%:Rename: one rule per line (# starts a comment); rules apply top to bottom and are chained. The three forms differ in scope:%>
<%:OLD=NEW — exact match: renames only nodes named exactly OLD.%>
<%:PATTERN -> REPLACEMENT — regex: replaces matches in the name of every node (Lua patterns, not PCRE; $1 for captures).%>
<%:{server}_{port}_{proto} — placeholder template: renames every node unconditionally.%>
<%:Placeholders: {server} {port} {proto} {name} {uuid} {password} {group}.%>
<% if is_edit and it.last_update then %>
<%:Nodes:%> <%=it.node_count or 0%> | <%:Last updated:%> <%=os.date("%Y-%m-%d %H:%M", it.last_update)%> <% if it.error and it.error ~= "" then %> | <%=luci.util.pcdata(tmsg(it.error))%><% end %>
<% end %>
<%+footer%>