Skip to content

Commit

Permalink
luci-app-squid: convert to JavaScript
Browse files Browse the repository at this point in the history
Assumption has been made that the config file is stored in /etc/squid
since the principal package limits the sysconfdir to this directory. If
that assumption is changed in the future we need to adjust the ACL.

Signed-off-by: Daniel Nilsson <dannil+github@protonmail.com>
  • Loading branch information
dannil committed Oct 10, 2024
1 parent f827219 commit 8068e97
Show file tree
Hide file tree
Showing 43 changed files with 303 additions and 300 deletions.
5 changes: 3 additions & 2 deletions applications/luci-app-squid/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
include $(TOPDIR)/rules.mk

LUCI_TITLE:=Squid LuCI Interface
LUCI_DEPENDS:=+luci-compat +luci-base +squid
LUCI_DEPENDS:=+luci-base +squid

PKG_MAINTAINER:=Marko Ratkaj <marko.ratkaj@sartura.hr>
PKG_MAINTAINER:=Marko Ratkaj <marko.ratkaj@sartura.hr>, \
Daniel Nilsson <dannil+github@protonmail.com>
PKG_LICENSE:=Apache-2.0

include ../../luci.mk
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
'use strict';

'require form';
'require fs';
'require uci';
'require ui';
'require view';

return view.extend({

load: function() {
return uci.load('squid')
.then(() => uci.get('squid', 'squid', 'config_file'));
},

render: function(config_file) {
var m, s, o;

m = new form.Map('squid', _('Squid'));

s = m.section(form.TypedSection, 'squid');
s.anonymous = true;
s.addremove = false;

s.tab('general', _('General Settings'));
s.tab('advanced', _('Advanced Settings'));

o = s.taboption('general', form.Value, 'http_port', _('Port'));
o.datatype = 'portrange';
o.placeholder = '0-65535';

o = s.taboption('general', form.Value, 'visible_hostname', _('Visible Hostname'));
o.datatype = 'string';
o.placeholder = 'OpenWrt';

o = s.taboption('general', form.Value, 'coredump_dir', _('Coredump files directory'));
o.datatype = 'string';
o.placeholder = '/tmp/squid';

o = s.taboption('advanced', form.TextValue, '_data');
o.wrap = false;
o.rows = 25;
o.rmempty = false;
o.cfgvalue = function(section_id) {
return fs.read(config_file);
};
o.write = function(section_id, value) {
if (value) {
var normalized = value.replaceAll('\r\n', '\n');
fs.write(config_file, normalized);
}
};

return m.render();
},

handleSaveApply: function (ev) {
this.handleSave()
.then(() => ui.changes.apply())
.then(() => fs.exec('/etc/init.d/squid', ['restart']));
}

});
67 changes: 0 additions & 67 deletions applications/luci-app-squid/luasrc/model/cbi/squid.lua

This file was deleted.

12 changes: 6 additions & 6 deletions applications/luci-app-squid/po/ar/squid.po
Original file line number Diff line number Diff line change
Expand Up @@ -11,31 +11,31 @@ msgstr ""
"&& n%100<=10 ? 3 : n%100>=11 ? 4 : 5;\n"
"X-Generator: Weblate 5.7-dev\n"

#: applications/luci-app-squid/luasrc/model/cbi/squid.lua:42
#: applications/luci-app-squid/htdocs/luci-static/resources/view/squid.js:26
msgid "Advanced Settings"
msgstr "إعدادات متقدمة"

#: applications/luci-app-squid/luasrc/model/cbi/squid.lua:38
#: applications/luci-app-squid/htdocs/luci-static/resources/view/squid.js:36
msgid "Coredump files directory"
msgstr "دليل ملفات Coredump"

#: applications/luci-app-squid/luasrc/model/cbi/squid.lua:28
#: applications/luci-app-squid/htdocs/luci-static/resources/view/squid.js:25
msgid "General Settings"
msgstr "الاعدادات العامة"

#: applications/luci-app-squid/root/usr/share/rpcd/acl.d/luci-app-squid.json:3
msgid "Grant UCI access for luci-app-squid"
msgstr "منح UCI حق الوصول إلى luci - app - squid"

#: applications/luci-app-squid/luasrc/model/cbi/squid.lua:30
#: applications/luci-app-squid/htdocs/luci-static/resources/view/squid.js:28
msgid "Port"
msgstr "المنفذ"

#: applications/luci-app-squid/luasrc/model/cbi/squid.lua:21
#: applications/luci-app-squid/htdocs/luci-static/resources/view/squid.js:19
#: applications/luci-app-squid/root/usr/share/luci/menu.d/luci-app-squid.json:3
msgid "Squid"
msgstr "حبار"

#: applications/luci-app-squid/luasrc/model/cbi/squid.lua:34
#: applications/luci-app-squid/htdocs/luci-static/resources/view/squid.js:32
msgid "Visible Hostname"
msgstr "اسم المضيف المرئي"
12 changes: 6 additions & 6 deletions applications/luci-app-squid/po/bg/squid.po
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,31 @@ msgstr ""
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 5.5-dev\n"

#: applications/luci-app-squid/luasrc/model/cbi/squid.lua:42
#: applications/luci-app-squid/htdocs/luci-static/resources/view/squid.js:26
msgid "Advanced Settings"
msgstr "Разширени настройки"

#: applications/luci-app-squid/luasrc/model/cbi/squid.lua:38
#: applications/luci-app-squid/htdocs/luci-static/resources/view/squid.js:36
msgid "Coredump files directory"
msgstr ""

#: applications/luci-app-squid/luasrc/model/cbi/squid.lua:28
#: applications/luci-app-squid/htdocs/luci-static/resources/view/squid.js:25
msgid "General Settings"
msgstr "Общи настройки"

#: applications/luci-app-squid/root/usr/share/rpcd/acl.d/luci-app-squid.json:3
msgid "Grant UCI access for luci-app-squid"
msgstr ""

#: applications/luci-app-squid/luasrc/model/cbi/squid.lua:30
#: applications/luci-app-squid/htdocs/luci-static/resources/view/squid.js:28
msgid "Port"
msgstr "Порт"

#: applications/luci-app-squid/luasrc/model/cbi/squid.lua:21
#: applications/luci-app-squid/htdocs/luci-static/resources/view/squid.js:19
#: applications/luci-app-squid/root/usr/share/luci/menu.d/luci-app-squid.json:3
msgid "Squid"
msgstr ""

#: applications/luci-app-squid/luasrc/model/cbi/squid.lua:34
#: applications/luci-app-squid/htdocs/luci-static/resources/view/squid.js:32
msgid "Visible Hostname"
msgstr ""
12 changes: 6 additions & 6 deletions applications/luci-app-squid/po/bn_BD/squid.po
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,31 @@ msgstr ""
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.9-dev\n"

#: applications/luci-app-squid/luasrc/model/cbi/squid.lua:42
#: applications/luci-app-squid/htdocs/luci-static/resources/view/squid.js:26
msgid "Advanced Settings"
msgstr "উন্নত সেটিংস"

#: applications/luci-app-squid/luasrc/model/cbi/squid.lua:38
#: applications/luci-app-squid/htdocs/luci-static/resources/view/squid.js:36
msgid "Coredump files directory"
msgstr ""

#: applications/luci-app-squid/luasrc/model/cbi/squid.lua:28
#: applications/luci-app-squid/htdocs/luci-static/resources/view/squid.js:25
msgid "General Settings"
msgstr "সাধারণ সেটিংস"

#: applications/luci-app-squid/root/usr/share/rpcd/acl.d/luci-app-squid.json:3
msgid "Grant UCI access for luci-app-squid"
msgstr ""

#: applications/luci-app-squid/luasrc/model/cbi/squid.lua:30
#: applications/luci-app-squid/htdocs/luci-static/resources/view/squid.js:28
msgid "Port"
msgstr "পোর্ট"

#: applications/luci-app-squid/luasrc/model/cbi/squid.lua:21
#: applications/luci-app-squid/htdocs/luci-static/resources/view/squid.js:19
#: applications/luci-app-squid/root/usr/share/luci/menu.d/luci-app-squid.json:3
msgid "Squid"
msgstr ""

#: applications/luci-app-squid/luasrc/model/cbi/squid.lua:34
#: applications/luci-app-squid/htdocs/luci-static/resources/view/squid.js:32
msgid "Visible Hostname"
msgstr ""
12 changes: 6 additions & 6 deletions applications/luci-app-squid/po/ca/squid.po
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,31 @@ msgstr ""
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 4.5.2-dev\n"

#: applications/luci-app-squid/luasrc/model/cbi/squid.lua:42
#: applications/luci-app-squid/htdocs/luci-static/resources/view/squid.js:26
msgid "Advanced Settings"
msgstr "Configuració avançada"

#: applications/luci-app-squid/luasrc/model/cbi/squid.lua:38
#: applications/luci-app-squid/htdocs/luci-static/resources/view/squid.js:36
msgid "Coredump files directory"
msgstr ""

#: applications/luci-app-squid/luasrc/model/cbi/squid.lua:28
#: applications/luci-app-squid/htdocs/luci-static/resources/view/squid.js:25
msgid "General Settings"
msgstr "Paràmetres generals"

#: applications/luci-app-squid/root/usr/share/rpcd/acl.d/luci-app-squid.json:3
msgid "Grant UCI access for luci-app-squid"
msgstr ""

#: applications/luci-app-squid/luasrc/model/cbi/squid.lua:30
#: applications/luci-app-squid/htdocs/luci-static/resources/view/squid.js:28
msgid "Port"
msgstr "Port"

#: applications/luci-app-squid/luasrc/model/cbi/squid.lua:21
#: applications/luci-app-squid/htdocs/luci-static/resources/view/squid.js:19
#: applications/luci-app-squid/root/usr/share/luci/menu.d/luci-app-squid.json:3
msgid "Squid"
msgstr ""

#: applications/luci-app-squid/luasrc/model/cbi/squid.lua:34
#: applications/luci-app-squid/htdocs/luci-static/resources/view/squid.js:32
msgid "Visible Hostname"
msgstr ""
12 changes: 6 additions & 6 deletions applications/luci-app-squid/po/cs/squid.po
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,31 @@ msgstr ""
"Plural-Forms: nplurals=3; plural=(n==1) ? 0 : (n>=2 && n<=4) ? 1 : 2;\n"
"X-Generator: Weblate 5.0.2\n"

#: applications/luci-app-squid/luasrc/model/cbi/squid.lua:42
#: applications/luci-app-squid/htdocs/luci-static/resources/view/squid.js:26
msgid "Advanced Settings"
msgstr "Pokročilá nastavení"

#: applications/luci-app-squid/luasrc/model/cbi/squid.lua:38
#: applications/luci-app-squid/htdocs/luci-static/resources/view/squid.js:36
msgid "Coredump files directory"
msgstr "Adresář se soubory výpisu paměti (coredump)"

#: applications/luci-app-squid/luasrc/model/cbi/squid.lua:28
#: applications/luci-app-squid/htdocs/luci-static/resources/view/squid.js:25
msgid "General Settings"
msgstr "Obecná nastavení"

#: applications/luci-app-squid/root/usr/share/rpcd/acl.d/luci-app-squid.json:3
msgid "Grant UCI access for luci-app-squid"
msgstr "Udělit oprávnění k UCI pro luci-app-shairplay"

#: applications/luci-app-squid/luasrc/model/cbi/squid.lua:30
#: applications/luci-app-squid/htdocs/luci-static/resources/view/squid.js:28
msgid "Port"
msgstr "Port"

#: applications/luci-app-squid/luasrc/model/cbi/squid.lua:21
#: applications/luci-app-squid/htdocs/luci-static/resources/view/squid.js:19
#: applications/luci-app-squid/root/usr/share/luci/menu.d/luci-app-squid.json:3
msgid "Squid"
msgstr "Squid"

#: applications/luci-app-squid/luasrc/model/cbi/squid.lua:34
#: applications/luci-app-squid/htdocs/luci-static/resources/view/squid.js:32
msgid "Visible Hostname"
msgstr "Viditelný název hostitele"
12 changes: 6 additions & 6 deletions applications/luci-app-squid/po/da/squid.po
Original file line number Diff line number Diff line change
Expand Up @@ -10,31 +10,31 @@ msgstr ""
"Plural-Forms: nplurals=2; plural=n != 1;\n"
"X-Generator: Weblate 5.4-dev\n"

#: applications/luci-app-squid/luasrc/model/cbi/squid.lua:42
#: applications/luci-app-squid/htdocs/luci-static/resources/view/squid.js:26
msgid "Advanced Settings"
msgstr "Avancerede indstillinger"

#: applications/luci-app-squid/luasrc/model/cbi/squid.lua:38
#: applications/luci-app-squid/htdocs/luci-static/resources/view/squid.js:36
msgid "Coredump files directory"
msgstr "Coredump filer mappe"

#: applications/luci-app-squid/luasrc/model/cbi/squid.lua:28
#: applications/luci-app-squid/htdocs/luci-static/resources/view/squid.js:25
msgid "General Settings"
msgstr "Generelle indstillinger"

#: applications/luci-app-squid/root/usr/share/rpcd/acl.d/luci-app-squid.json:3
msgid "Grant UCI access for luci-app-squid"
msgstr "Giv UCI-adgang til luci-app-squid"

#: applications/luci-app-squid/luasrc/model/cbi/squid.lua:30
#: applications/luci-app-squid/htdocs/luci-static/resources/view/squid.js:28
msgid "Port"
msgstr "Port"

#: applications/luci-app-squid/luasrc/model/cbi/squid.lua:21
#: applications/luci-app-squid/htdocs/luci-static/resources/view/squid.js:19
#: applications/luci-app-squid/root/usr/share/luci/menu.d/luci-app-squid.json:3
msgid "Squid"
msgstr "Squid"

#: applications/luci-app-squid/luasrc/model/cbi/squid.lua:34
#: applications/luci-app-squid/htdocs/luci-static/resources/view/squid.js:32
msgid "Visible Hostname"
msgstr "Synligt værtsnavn"
Loading

0 comments on commit 8068e97

Please sign in to comment.