diff --git a/docs/package/gluon-config-mode-contact-info.rst b/docs/package/gluon-config-mode-contact-info.rst new file mode 100644 index 0000000000000000000000000000000000000000..a38cc0a5a6b35356f22936d3f631e6706063a6c3 --- /dev/null +++ b/docs/package/gluon-config-mode-contact-info.rst @@ -0,0 +1,28 @@ +gluon-config-mode-contact-info +============================== + +This package allows the user to provide contact information within config mode to be +distributed in the mesh. You can define whether the owner contact field is +obligatory or not in your site.conf. + +site.conf +--------- + +config_mode.owner.obligatory : this whole section is optional + - ``true`` field is obligatory: gluon-node-info.@owner[0].contact may not be empty + - ``false`` field is optional: gluon-node-info.@owner[0].contact may be empty + - defaults to ``false`` + +# example: + + config_mode = { + geo_location = { + show_altitude = true, + }, + owner = { + obligatory = true + }, + }, + + + \ No newline at end of file diff --git a/docs/site-example/site.conf b/docs/site-example/site.conf index 964324df77be910246192ac844c2f9f090e8e383..6dee6df2a510f526795201204c34eee2b7f4ef8d 100644 --- a/docs/site-example/site.conf +++ b/docs/site-example/site.conf @@ -192,10 +192,15 @@ -- skip = true, -- }, - -- Show/hide the altitude field -- config_mode = { - -- geo_location = { - -- show_altitude = false, - -- }, + -- Show/hide the altitude field + -- geo_location = { + -- show_altitude = false, + -- }, + -- define if the contact field is obligatory (optional) + -- owner = { + -- obligatory = true + -- }, -- }, + } diff --git a/package/gluon-config-mode-contact-info/Makefile b/package/gluon-config-mode-contact-info/Makefile index 801fad61e49f9e7c2d471af8a3fa933d7bf94546..3ac8a0b3cde41ab943d91902ba5cb78aafdaecdb 100644 --- a/package/gluon-config-mode-contact-info/Makefile +++ b/package/gluon-config-mode-contact-info/Makefile @@ -13,10 +13,15 @@ PKG_CONFIG_DEPENDS += $(GLUON_I18N_CONFIG) define Package/gluon-config-mode-contact-info SECTION:=gluon CATEGORY:=Gluon - TITLE:=Set a custom string that will be distributed in the mesh. + TITLE:=Allows the user to provide contact information to be distributed in the mesh DEPENDS:=gluon-config-mode-core-virtual +gluon-node-info endef +define Package/gluon-config-mode-contact-info/description + Allows the user to provide contact information to be distributed in the mesh. + Can be made obligatory in site.conf +endef + define Build/Prepare mkdir -p $(PKG_BUILD_DIR) endef @@ -34,4 +39,9 @@ define Package/gluon-config-mode-contact-info/install $(call GluonInstallI18N,gluon-config-mode-contact-info,$(1)) endef +define Package/gluon-config-mode-contact-info/postinst +#!/bin/sh +$(call GluonCheckSite,check_site.lua) +endef + $(eval $(call BuildPackage,gluon-config-mode-contact-info)) diff --git a/package/gluon-config-mode-contact-info/check_site.lua b/package/gluon-config-mode-contact-info/check_site.lua new file mode 100644 index 0000000000000000000000000000000000000000..fe818616dd69315ce16cc0e0cbebe7330990e568 --- /dev/null +++ b/package/gluon-config-mode-contact-info/check_site.lua @@ -0,0 +1,3 @@ +if need_table('config_mode', nil, false) and need_table('config_mode.owner', nil, false) then + need_boolean('config_mode.owner.obligatory', false) +end diff --git a/package/gluon-config-mode-contact-info/i18n/de.po b/package/gluon-config-mode-contact-info/i18n/de.po index 719246f44724bf695a492bc7183b493dedc949c9..35f0ee9551322f6d14c54cc1714325a3c28dc869 100644 --- a/package/gluon-config-mode-contact-info/i18n/de.po +++ b/package/gluon-config-mode-contact-info/i18n/de.po @@ -14,13 +14,13 @@ msgid "Contact info" msgstr "Kontakt" msgid "" -"You can provide your contact information here to allow others to contact " -"you. Please note that this information will be visible <em>publicly</em> on " +"Please provide your contact information here to allow others to contact " +"you. Note that this information will be visible <em>publicly</em> on " "the internet together with your node's coordinates." msgstr "" -"Hier kannst du einen <em>öffentlichen</em> Hinweis hinterlegen, um anderen " -"zu ermöglichen, Kontakt mit dir aufzunehmen. Bitte beachte, dass " -"dieser Hinweis auch öffentlich im Internet, zusammen mit den Koordinaten " +"Bitte hinterlege hier einen Hinweis, um anderen zu ermöglichen, " +"Kontakt mit dir aufzunehmen. Beachte, dass dieser Hinweis auch " +"<em>öffentlich</em> im Internet, zusammen mit den Koordinaten " "deines Knotens, einsehbar sein wird." msgid "e.g. E-mail or phone number" diff --git a/package/gluon-config-mode-contact-info/i18n/fr.po b/package/gluon-config-mode-contact-info/i18n/fr.po index 779e15fe1d7de630a10773757c80f34e6b785877..624b18640f4dedaecf933f247606f88b217ed978 100644 --- a/package/gluon-config-mode-contact-info/i18n/fr.po +++ b/package/gluon-config-mode-contact-info/i18n/fr.po @@ -14,11 +14,12 @@ msgid "Contact info" msgstr "Informations de Contact" msgid "" -"You can provide your contact information here to allow others to contact " -"you. Please note that this information will be visible <em>publicly</em> on " +"Please provide your contact information here to allow others to contact " +"you. Note that this information will be visible <em>publicly</em> on " "the internet together with your node's coordinates." msgstr "" -"Ici vous pouvez donner des informations <em>publiques</em> pour permettre aux autres de vous contacter. " +"S'il vous plaît entrez ici des informations <em>publiques</em> pour " +"permettre aux autres de vous contacter. " "Ces informations seront affichées en ligne, avec les coordonnées du nœud." msgid "e.g. E-mail or phone number" diff --git a/package/gluon-config-mode-contact-info/i18n/gluon-config-mode-contact-info.pot b/package/gluon-config-mode-contact-info/i18n/gluon-config-mode-contact-info.pot index 63939a8384ada32a7512259d986f945467ff15f4..9dcaf9ecd8d7f49d886cef8601a4cccb9a146bea 100644 --- a/package/gluon-config-mode-contact-info/i18n/gluon-config-mode-contact-info.pot +++ b/package/gluon-config-mode-contact-info/i18n/gluon-config-mode-contact-info.pot @@ -5,8 +5,8 @@ msgid "Contact info" msgstr "" msgid "" -"You can provide your contact information here to allow others to contact " -"you. Please note that this information will be visible <em>publicly</em> on " +"Please provide your contact information here to allow others to contact " +"you. Note that this information will be visible <em>publicly</em> on " "the internet together with your node's coordinates." msgstr "" diff --git a/package/gluon-config-mode-contact-info/luasrc/lib/gluon/config-mode/wizard/0500-contact-info.lua b/package/gluon-config-mode-contact-info/luasrc/lib/gluon/config-mode/wizard/0500-contact-info.lua index a2182f95966d6608cfdd657c04383b020014c857..46ff45677b3bc0d0899009a063ee1ad01142059e 100644 --- a/package/gluon-config-mode-contact-info/luasrc/lib/gluon/config-mode/wizard/0500-contact-info.lua +++ b/package/gluon-config-mode-contact-info/luasrc/lib/gluon/config-mode/wizard/0500-contact-info.lua @@ -1,13 +1,14 @@ local cbi = require "luci.cbi" local i18n = require "luci.i18n" local uci = luci.model.uci.cursor() +local site = require 'gluon.site_config' local M = {} function M.section(form) local s = form:section(cbi.SimpleSection, nil, i18n.translate( - 'You can provide your contact information here to ' - .. 'allow others to contact you. Please note that ' + 'Please provide your contact information here to ' + .. 'allow others to contact you. Note that ' .. 'this information will be visible <em>publicly</em> ' .. 'on the internet together with your node\'s coordinates.' ) @@ -15,7 +16,7 @@ function M.section(form) local o = s:option(cbi.Value, "_contact", i18n.translate("Contact info")) o.default = uci:get_first("gluon-node-info", "owner", "contact", "") - o.rmempty = true + o.rmempty = not ((site.config_mode or {}).owner or {}).obligatory o.datatype = "string" o.description = i18n.translate("e.g. E-mail or phone number") o.maxlen = 140