Explorer

html-ui.search-page

description
The page /search?q=: the parts and modules of the main branch of every project whose name (module.name) contains the query (at most 300). Instead of the command palette of the React UI
type
Fn(language: String, query: String) -> @definy.service-io
expression
fn(language$990, query$0) =>
  @definy.read-snapshots(
    then: fn(commits$1) =>
      let found$2 = match @core.equal(left: $0, right: "") {
          true =>
            [],
          false =>
            @core.list-fold(
              T: @definy.event-snapshot,
              A: List<Record{project: String, part: String}>,
              reducer: fn(acc$3, item$4) =>
                @core.list-fold(
                  T: @definy.stored-snapshot-part,
                  A: List<Record{project: String, part: String}>,
                  reducer: fn(acc$5, item$6) =>
                    match @core.and(
                        left: @std.string-contains(value: $6.name, pattern: $0),
                        right: @core.less-than(left: @core.list-length(value: $5), right: 300)
                      ) {
                      true =>
                        @core.list-append(list: $5, item: {project: $4.commit.project_name, part: $6.name}),
                      false =>
                        $5
                    },
                  init: $3,
                  xs: @definy.snapshot-parts(modules: $4.commit.modules, index: 0)
                ),
              init: [],
              xs: @definy.latest-main-snapshots(commits: $1)
            )
        };
      @html-ui.page(
        language: $990,
        title: @html-ui.text(language: $990, en: "Search", ja: "探す", eo: "Serĉi"),
        body: [
          @html.element(
            name: "h1",
            attributes: [],
            children: [
              @html.text(
                text: @html-ui.text(language: $990, en: "Search parts", ja: "パーツを探す", eo: "Serĉi partojn")
              )
            ]
          ),
          @html.element(
            name: "form",
            attributes: [{name: "method", value: "get"}, {name: "action", value: "/search"}],
            children: [
              @html.element(
                name: "input",
                attributes: [
                  {name: "type", value: "search"},
                  {name: "name", value: "q"},
                  {name: "autofocus", value: ""},
                  {name: "value", value: $0},
                  {
                    name: "placeholder",
                    value: @html-ui.text(
                      language: $990,
                      en: "module.name or a part of it",
                      ja: "モジュール.名前 か その一部",
                      eo: "modulo.nomo aŭ parto de ĝi"
                    )
                  }
                ],
                children: []
              ),
              @html.text(text: " "),
              @html.element(
                name: "button",
                attributes: [],
                children: [@html.text(text: @html-ui.text(language: $990, en: "Search", ja: "探す", eo: "Serĉi"))]
              )
            ]
          ),
          @html.element(
            name: "p",
            attributes: [{name: "class", value: "muted"}],
            children: [
              @html.text(
                text: @html-ui.text(
                  language: $990,
                  en: "Searches the names of the parts in the main branch of every project.",
                  ja: "全てのプロジェクトの main ブランチのパーツの名前から探します。",
                  eo: "Serĉas en la nomoj de la partoj de la ĉefa branĉo de ĉiu projekto."
                )
              ),
              @html.text(
                text: match @core.equal(left: $0, right: "") {
                  true =>
                    "",
                  false =>
                    @core.string-join(
                      items: [
                        " ",
                        @std.number-to-string(value: @core.list-length(value: $2)),
                        @html-ui.text(language: $990, en: " found.", ja: " 個見つかりました。", eo: " trovitaj.")
                      ],
                      separator: ""
                    )
                }
              )
            ]
          ),
          @html.element(
            name: "ul",
            attributes: [],
            children: @core.list-map(
              T: Record{project: String, part: String},
              U: @html.node,
              f: fn(item$7) =>
                @html.element(
                  name: "li",
                  attributes: [],
                  children: [
                    @html.element(
                      name: "a",
                      attributes: [
                        {
                          name: "href",
                          value: @core.string-join(items: ["/p/", $7.project, "/main/", $7.part], separator: "")
                        }
                      ],
                      children: [@html.element(name: "code", attributes: [], children: [@html.text(text: $7.part)])]
                    ),
                    @html.text(text: " "),
                    @html.element(
                      name: "span",
                      attributes: [{name: "class", value: "muted"}],
                      children: [@html.text(text: $7.project)]
                    )
                  ]
                ),
              xs: $2
            )
          )
        ]
      )
  )
visibility
public
html-ui.search-page (project html-ui, branch main, snapshot Daaw3vbJhY15cDW6JsA4JuXvffjj_qFyxoZQMUM8hvQ)
id: vbg4FzsXgv31fDcoF0f7ZstaUSkJBTg1mvww5cQtF0U
content hash: 55ensQs9F_ZjRSTlaPX9vdMeXeuT_YA4uKjrES052pI