Explorer

html-ui.handle-request

description
type
Fn(language: String, config: @html-ui.config, path: String, query: String) -> @definy.service-io
expression
fn(language$990, config$13, path$0, query$1) =>
  let segments$2 = @core.string-split(text: $0, separator: "/");
  let first$3 = @html-ui.segment(segments: $2, index: 1);
  let project$4 = @html-ui.segment(segments: $2, index: 2);
  let branch$5 = @html-ui.segment(segments: $2, index: 3);
  let rest$6 = @html-ui.segment(segments: $2, index: 4);
  match @core.and(left: $13.editable, right: @core.equal(left: $3, right: "batch")) {
    true =>
      @html-ui.batch-page(
        language: $990,
        project: $4,
        branch: match @core.equal(left: $5, right: "") {
          true =>
            "main",
          false =>
            $5
        }
      ),
    false =>
      match @core.or(left: @core.equal(left: $3, right: "about"), right: @core.equal(left: $3, right: "docs")) {
        true =>
          match @core.equal(left: $3, right: "docs") {
            true =>
              @html-ui.docs-page(language: $990, name: $4),
            false =>
              @html-ui.about-page(language: $990)
          },
        false =>
          match @core.equal(left: $3, right: "lang") {
            true =>
              @html-ui.set-language(request: $13.request, code: $4),
            false =>
              match @core.equal(left: $3, right: "p") {
                false =>
                  match @core.equal(left: $3, right: "") {
                    true =>
                      @html-ui.rpc(
                        config: $13,
                        method: "EventService/GetProjectBranches",
                        request: "{}",
                        then: fn(response$7) =>
                          @html-ui.rpc(
                            config: $13,
                            method: "definy_list_accounts",
                            request: "{}",
                            then: fn(response$18) =>
                              match $13.editable {
                                true =>
                                  @html-ui.rpc(
                                    config: $13,
                                    method: "definy_whoami",
                                    request: "{}",
                                    then: fn(response$17) =>
                                      @html-ui.home-page(
                                        language: $990,
                                        editable: true,
                                        me: @html-ui.after-prefix(
                                          line: @html-ui.segment(segments: @core.string-split(text: $17.text, separator: "\n"), index: 0),
                                          prefix: "account id: "
                                        ),
                                        accounts: $18.text,
                                        response: $7
                                      )
                                  ),
                                false =>
                                  @html-ui.home-page(language: $990, editable: false, me: "", accounts: $18.text, response: $7)
                              }
                          )
                      ),
                    false =>
                      match @core.and(
                          left: @core.equal(left: $3, right: "part"),
                          right: @core.not(value: @core.equal(left: $4, right: ""))
                        ) {
                        true =>
                          @html-ui.rpc(
                            config: $13,
                            method: "definy_get_part",
                            request: @core.string-join(items: ["{\"part\":", @definy.json-string-literal(value: $4), "}"], separator: ""),
                            then: fn(response$8) =>
                              @html-ui.part-page(
                                language: $990,
                                editable: false,
                                project: "",
                                branch: "",
                                part: $4,
                                commit: "",
                                references: "",
                                response: $8
                              )
                          ),
                        false =>
                          match @core.and(left: $13.editable, right: @core.equal(left: $3, right: "edit")) {
                            true =>
                              let edit_part$11 = match @core.equal(left: $6, right: "") {
                                  true =>
                                    @html-ui.query-param(query: $1, name: "part"),
                                  false =>
                                    $6
                                };
                              @html-ui.rpc(
                                config: $13,
                                method: "definy_get_part",
                                request: @core.string-join(
                                  items: [
                                    "{\"project\":",
                                    @definy.json-string-literal(value: $4),
                                    ",\"branch\":",
                                    @definy.json-string-literal(value: $5),
                                    ",\"part\":",
                                    @definy.json-string-literal(value: $11),
                                    "}"
                                  ],
                                  separator: ""
                                ),
                                then: fn(response$12) =>
                                  @html-ui.edit-page(language: $990, project: $4, branch: $5, part: $11, response: $12)
                              ),
                            false =>
                              match @core.and(
                                  left: @core.equal(left: $3, right: "h"),
                                  right: @core.not(value: @core.equal(left: $4, right: ""))
                                ) {
                                true =>
                                  let history_branch$14 = match @core.equal(left: $5, right: "") {
                                      true =>
                                        "main",
                                      false =>
                                        $5
                                    };
                                  let limit$15 = match @core.equal(
                                        left: @html-ui.parse-count(text: @html-ui.query-param(query: $1, name: "limit"), index: 0, acc: 0),
                                        right: 0
                                      ) {
                                      true =>
                                        20,
                                      false =>
                                        @html-ui.parse-count(text: @html-ui.query-param(query: $1, name: "limit"), index: 0, acc: 0)
                                    };
                                  @html-ui.rpc(
                                    config: $13,
                                    method: "definy_get_history",
                                    request: @core.string-join(
                                      items: [
                                        "{\"project\":",
                                        @definy.json-string-literal(value: $4),
                                        ",\"branch\":",
                                        @definy.json-string-literal(value: $14),
                                        ",\"limit\":",
                                        @std.number-to-string(value: $15),
                                        "}"
                                      ],
                                      separator: ""
                                    ),
                                    then: fn(response$16) =>
                                      @html-ui.history-page(language: $990, project: $4, branch: $14, limit: $15, response: $16)
                                  ),
                                false =>
                                  @html-ui.handle-more(language: $990, config: $13, first: $3, second: $4, path: $0, query: $1)
                              }
                          }
                      }
                  },
                true =>
                  match @std.string-contains(value: $6, pattern: ".") {
                    false =>
                      @html-ui.project-text(
                        project: $4,
                        branch: $5,
                        module: $6,
                        all: @core.and(
                          left: @core.equal(left: $6, right: ""),
                          right: @core.not(value: @core.equal(left: @html-ui.query-param(query: $1, name: "q"), right: ""))
                        ),
                        start: @html-ui.parse-count(text: @html-ui.query-param(query: $1, name: "start"), index: 0, acc: 0),
                        then: fn(response$9) =>
                          @html-ui.project-page(
                            language: $990,
                            editable: $13.editable,
                            project: $4,
                            branch: $5,
                            module: $6,
                            search: @html-ui.query-param(query: $1, name: "q"),
                            start: @html-ui.parse-count(text: @html-ui.query-param(query: $1, name: "start"), index: 0, acc: 0),
                            response: $9
                          )
                      ),
                    true =>
                      @html-ui.rpc(
                        config: $13,
                        method: "definy_get_part",
                        request: @core.string-join(
                          items: [
                            "{\"project\":",
                            @definy.json-string-literal(value: $4),
                            ",\"branch\":",
                            @definy.json-string-literal(value: $5),
                            ",\"part\":",
                            @definy.json-string-literal(value: $6),
                            match @core.equal(left: @html-ui.query-param(query: $1, name: "commit"), right: "") {
                              true =>
                                "",
                              false =>
                                @core.string-concat(
                                  left: ",\"commit\":",
                                  right: @definy.json-string-literal(value: @html-ui.query-param(query: $1, name: "commit"))
                                )
                            },
                            "}"
                          ],
                          separator: ""
                        ),
                        then: fn(response$10) =>
                          @html-ui.part-route(
                            language: $990,
                            config: $13,
                            project: $4,
                            branch: $5,
                            part: $6,
                            commit: @html-ui.query-param(query: $1, name: "commit"),
                            response: $10
                          )
                      )
                  }
              }
          }
      }
  }
visibility
public
html-ui.handle-request (project html-ui, branch docs, snapshot gs1l1UTtuqXPo94f28PvN-A1-mCpo3N7OfWdGmKcOS8)
id: R5G4pR4yXUKSS8OfT4LoNAsgIkSJ136twb1kevgfOC4
content hash: 1Q1VtJWsJQ1ffPegEp3BVoahe65qOB0W-sTfXYXopno