Explorer

html-ui.secret-form

description
(en) The form to enter the value of a secret part. literal is the arguments of the secret literal as a JSON array [id, label, allowed URL prefixes]
type
Fn(language: String, literal: String) -> List<@html.node>
expression
fn(language$990, literal$0) =>
  match @definy.parse-json(text: $0) {
    #ok(json$1) =>
      let items$2 = match $1 {
          #array(items$3) =>
            $3,
          _ =>
            []
        };
      let id$4 = match @core.list-get(list: $2, index: 0) {
          #some(item$5) =>
            match $5 {
              #string(text$6) =>
                $6,
              _ =>
                ""
            },
          #none(_) =>
            ""
        };
      let label$7 = match @core.list-get(list: $2, index: 1) {
          #some(item$8) =>
            match $8 {
              #string(text$9) =>
                $9,
              _ =>
                ""
            },
          #none(_) =>
            ""
        };
      let prefixes$10 = match @core.list-get(list: $2, index: 2) {
          #some(item$11) =>
            @definy.json-to-string(value: $11),
          #none(_) =>
            "[]"
        };
      @core.list-concat(
        left: [
          @html-ui.text-element(
            name: "h2",
            text: @html-ui.text(
              language: $990,
              en: "Value of the secret",
              ja: "シークレットの値",
              eo: "Valoro de la sekreto"
            )
          ),
          @html.element(
            name: "p",
            attributes: [],
            children: @html-ui.text-nodes(
              language: $990,
              en: [
                @html.text(text: "The value is kept only in "),
                @html-ui.text-element(name: "code", text: "secrets.json"),
                @html.text(
                  text: " in the data folder of this server, and never appears in events or MCP. Allowed destinations: "
                ),
                @html-ui.text-element(name: "code", text: $10),
                @html.text(text: " ("),
                @html.element(
                  name: "a",
                  attributes: [{name: "href", value: "/secrets"}],
                  children: [@html.text(text: "Stored secrets")]
                ),
                @html.text(text: ")")
              ],
              ja: [
                @html.text(text: "値はこのサーバーのデータフォルダの "),
                @html-ui.text-element(name: "code", text: "secrets.json"),
                @html.text(
                  text: " にだけ保存し, イベントにも MCP にも出しません。送ってよい宛先: "
                ),
                @html-ui.text-element(name: "code", text: $10),
                @html.text(text: " ("),
                @html.element(
                  name: "a",
                  attributes: [{name: "href", value: "/secrets"}],
                  children: [@html.text(text: "入れてあるシークレット")]
                ),
                @html.text(text: ")")
              ],
              eo: [
                @html.text(text: "La valoro estas konservata nur en "),
                @html-ui.text-element(name: "code", text: "secrets.json"),
                @html.text(
                  text: " en la datuma dosierujo de ĉi tiu servilo, kaj neniam aperas en eventoj aŭ MCP. Permesitaj celoj: "
                ),
                @html-ui.text-element(name: "code", text: $10),
                @html.text(text: " ("),
                @html.element(
                  name: "a",
                  attributes: [{name: "href", value: "/secrets"}],
                  children: [@html.text(text: "Konservitaj sekretoj")]
                ),
                @html.text(text: ")")
              ]
            )
          )
        ],
        right: @html-ui.tool-form(
          tool: "secret",
          then: "",
          confirm: "",
          fields: [
            @html-ui.hidden(name: "id", value: $4),
            @html-ui.hidden(name: "label", value: $7),
            @html-ui.hidden-json(name: "allowed_url_prefixes", value: $10),
            @html.element(
              name: "input",
              attributes: [
                {name: "type", value: "password"},
                {name: "name", value: "value"},
                {name: "data-keep-empty", value: ""},
                {name: "autocomplete", value: "off"},
                {
                  name: "placeholder",
                  value: @core.string-concat(
                    left: $7,
                    right: @html-ui.text(
                      language: $990,
                      en: " (save it empty to delete it)",
                      ja: " (空にして保存すると消します)",
                      eo: " (konservu malplena por forigi ĝin)"
                    )
                  )
                }
              ],
              children: []
            )
          ],
          button: @html-ui.text(language: $990, en: "Save the value", ja: "値を保存", eo: "Konservi la valoron")
        )
      ),
    #error(_) =>
      []
  }
visibility
public
html-ui.secret-form (project html-ui, branch main, snapshot Daaw3vbJhY15cDW6JsA4JuXvffjj_qFyxoZQMUM8hvQ)
id: WaHkA457QqgV3zPOHzyveO_vwDRw4CcZuNM5X3PZLfw
content hash: frgTEOSMLL2ETDKcZCCQd1UDcxUg9Xp4esQhPM-FYTo