Explorer

html-ui.project-text

description
Read the parts of a branch as text (definy.mcp-project-text) for the project page. json is the settings of the module (html-ui.module-info), or {descriptions} of the project (from the latest snapshot) when module is empty
type
Fn(
  project: String,
  branch: String,
  module: String,
  all: Boolean,
  start: Number,
  then: Fn(response: @html-ui.response) -> @definy.service-io
) -> @definy.service-io
expression
fn(project$0, branch$1, module$2, all$3, start$9, then$4) =>
  @definy.read-branch-snapshot(
    project: $0,
    branch: $1,
    then: fn(commit$5, commits$6) =>
      match $5 {
        #none(_) =>
          $4(
            response: {
              status: 404,
              text: @core.string-join(items: ["Branch ", $1, " of project ", $0, " was not found"], separator: ""),
              json: #null<@definy.json>
            }
          ),
        #some(found$7) =>
          let module_parts$10 = @definy.snapshot-parts(modules: @html-ui.modules-named(modules: $7.commit.modules, name: $2, index: 0), index: 0);
          @definy.read-part-contents(
            parts: match $3 {
              true =>
                @definy.snapshot-parts(modules: $7.commit.modules, index: 0),
              false =>
                @std.list-range(
                  T: @definy.stored-snapshot-part,
                  list: $10,
                  start: $9,
                  end: @std.min(a: @core.plus(left: $9, right: 100), b: @core.list-length(value: $10))
                )
            },
            then: fn(parts$8) =>
              let text$11 = @definy.mcp-project-text(
                  commit: $7,
                  parts: $8,
                  names: @definy.snapshot-part-names(commits: @core.list-concat(left: [$7], right: @definy.latest-main-snapshots(commits: $6)))
                );
              match @core.equal(left: $2, right: "") {
                true =>
                  @definy.read-snapshot-content(
                    event_hash: $7.event_hash,
                    then: fn(commit$12) =>
                      $4(
                        response: {
                          status: 200,
                          text: $11,
                          json: #object<@definy.json>([
                            {
                              key: "descriptions",
                              value: @html-ui.descriptions-json(
                                texts: match $12 {
                                  #some(content$13) =>
                                    $13.project_description,
                                  #none(_) =>
                                    []
                                }
                              )
                            }
                          ])
                        }
                      )
                  ),
                false =>
                  $4(
                    response: {
                      status: 200,
                      text: $11,
                      json: @html-ui.module-info(
                        modules: @html-ui.modules-named(modules: $7.commit.modules, name: $2, index: 0),
                        count: @core.list-length(value: $10)
                      )
                    }
                  )
              }
          )
      }
  )
visibility
public
html-ui.project-text (project html-ui, branch main, snapshot Daaw3vbJhY15cDW6JsA4JuXvffjj_qFyxoZQMUM8hvQ)
id: 2qreyZrqDJSTv3GHQ-tBPDEgsrnPDuceti3fOzxZRwo
content hash: zVhtlqKyHHyd2FjoocMeANwHaAj5WfmUDktoikSS3RQ