ATProto Browser

ATProto Browser

Experimental browser for the Atmosphere

Record data

{
  "uri": "at://did:plc:qfpnj4og54vl56wngdriaxug/sh.tangled.repo.pull/3lmma3w6e2e22",
  "cid": "bafyreihqetndpbwy3j5v354ntkqieccovj2mtimtkgvr2qxknb35ftf7bm",
  "value": {
    "$type": "sh.tangled.repo.pull",
    "patch": "diff --git a/appview/pages/templates/fragments/diff.html b/appview/pages/templates/fragments/diff.html\nindex 0e4fd835185e78629bb76e62bb7716aec032459a..50e2940b4204afbcf5946ff744987b56ac756ca5 100644\n--- a/appview/pages/templates/fragments/diff.html\n+++ b/appview/pages/templates/fragments/diff.html\n@@ -8,6 +8,26 @@\n   {{ $this := $commit.This }}\n   {{ $parent := $commit.Parent }}\n \n+  <section class=\"mt-6 p-6 border border-gray-200 dark:border-gray-700 w-full mx-auto rounded bg-white dark:bg-gray-800 drop-shadow-sm\">\n+    <div class=\"diff-stat\">\n+      <div class=\"flex gap-2 items-center\">\n+        <strong class=\"text-sm uppercase dark:text-gray-200\">Changed files</strong>\n+        {{ block \"statPill\" $stat }} {{ end }}\n+      </div>\n+      <div class=\"overflow-x-auto\">\n+        {{ range $diff }}\n+        <ul class=\"dark:text-gray-200\">\n+          {{ if .IsDelete }}\n+          <li><a href=\"#file-{{ .Name.Old }}\" class=\"dark:hover:text-gray-300\">{{ .Name.Old }}</a></li>\n+          {{ else }}\n+          <li><a href=\"#file-{{ .Name.New }}\" class=\"dark:hover:text-gray-300\">{{ .Name.New }}</a></li>\n+          {{ end }}\n+        </ul>\n+        {{ end }}\n+      </div>\n+    </div>\n+  </section>\n+\n   {{ $last := sub (len $diff) 1 }}\n   {{ range $idx, $hunk := $diff }}\n   {{ with $hunk }}\n@@ -32,6 +52,8 @@                 <span class=\"bg-gray-100 text-gray-700 dark:bg-gray-700 dark:text-gray-300 {{ $markerstyle }}\">RENAMED</span>\n                 {{ else }}\n                 <span class=\"bg-gray-100 text-gray-700 dark:bg-gray-700 dark:text-gray-300 {{ $markerstyle }}\">MODIFIED</span>\n                 {{ end }}\n+\n+                {{ block \"statPill\" .Stats }} {{ end }}\n \n                 {{ if .IsDelete }}\n                 <a class=\"dark:text-white whitespace-nowrap overflow-x-auto\" {{if $this }}href=\"/{{ $repo }}/blob/{{ $this }}/{{ .Name.Old }}\"{{end}}>\n@@ -72,26 +94,35 @@           </summary>\n \n           <div class=\"transition-all duration-700 ease-in-out\">\n             {{ if .IsDelete }}\n-            <p class=\"text-center text-gray-400 dark:text-gray-500 p-4\">\n-            This file has been deleted in this commit.\n-            </p>\n+              <p class=\"text-center text-gray-400 dark:text-gray-500 p-4\">\n+              This file has been deleted.\n+              </p>\n+            {{ else if .IsCopy }}\n+              <p class=\"text-center text-gray-400 dark:text-gray-500 p-4\">\n+              This file has been copied.\n+              </p>\n+            {{ else if .IsRename }}\n+              <p class=\"text-center text-gray-400 dark:text-gray-500 p-4\">\n+              This file has been renamed.\n+              </p>\n+            {{ else if .IsBinary }}\n+              <p class=\"text-center text-gray-400 dark:text-gray-500 p-4\">\n+              This is a binary file and will not be displayed.\n+              </p>\n             {{ else }}\n-            {{ if .IsBinary }}\n-            <p class=\"text-center text-gray-400 dark:text-gray-500 p-4\">\n-            This is a binary file and will not be displayed.\n-            </p>\n-            {{ else }}\n+            {{ $name := .Name.New }}\n             <pre class=\"overflow-x-auto\"><div class=\"overflow-x-auto\"><div class=\"min-w-full inline-block\">{{- range .TextFragments -}}<div class=\"bg-gray-100 dark:bg-gray-700 text-gray-500 dark:text-gray-400 select-none text-center\">&middot;&middot;&middot;</div>\n              {{- $oldStart := .OldPosition -}}\n              {{- $newStart := .NewPosition -}}\n-             {{- $lineNrStyle := \"min-w-[3rem] flex-shrink-0 select-none text-right\" -}}\n-             {{- $lineNrSepStyle1 := \"text-gray-400 dark:text-gray-500 bg-white dark:bg-gray-800\" -}}\n-             {{- $lineNrSepStyle2 := \"text-gray-400 dark:text-gray-500 bg-white dark:bg-gray-800 pr-2\" -}}\n+             {{- $lineNrStyle := \"min-w-[3.5rem] flex-shrink-0 select-none text-right bg-white dark:bg-gray-800 scroll-mt-10 target:border target:border-amber-500 target:rounded \" -}}\n+             {{- $linkStyle := \"text-gray-400 dark:text-gray-500 hover:underline\" -}}\n+             {{- $lineNrSepStyle1 := \"\" -}}\n+             {{- $lineNrSepStyle2 := \"pr-2\" -}}\n              {{- range .Lines -}}\n                {{- if eq .Op.String \"+\" -}}\n                  <div class=\"bg-green-100 dark:bg-green-800/30 text-green-700 dark:text-green-400 flex min-w-full items-center\">\n                    <div class=\"{{$lineNrStyle}} {{$lineNrSepStyle1}}\"><span aria-hidden=\"true\" class=\"invisible\">{{$newStart}}</span></div>\n-                   <div class=\"{{$lineNrStyle}} {{$lineNrSepStyle2}}\">{{ $newStart }}</div>\n+                   <div class=\"{{$lineNrStyle}} {{$lineNrSepStyle2}}\" id=\"{{$name}}-N{{$newStart}}\"><a class=\"{{$linkStyle}}\" href=\"#{{$name}}-N{{$newStart}}\">{{ $newStart }}</a></div>\n                    <div class=\"w-5 flex-shrink-0 select-none text-center\">{{ .Op.String }}</div>\n                    <div class=\"px-2\">{{ .Line }}</div>\n                  </div>\n@@ -99,7 +130,7 @@                  {{- $newStart = add64 $newStart 1 -}}\n                {{- end -}}\n                {{- if eq .Op.String \"-\" -}}\n                  <div class=\"bg-red-100 dark:bg-red-800/30 text-red-700 dark:text-red-400 flex min-w-full items-center\">\n-                   <div class=\"{{$lineNrStyle}} {{$lineNrSepStyle1}}\">{{ $oldStart }}</div>\n+                   <div class=\"{{$lineNrStyle}} {{$lineNrSepStyle1}}\" id=\"{{$name}}-O{{$oldStart}}\"><a class=\"{{$linkStyle}}\" href=\"#{{$name}}-O{{$oldStart}}\">{{ $oldStart }}</a></div>\n                    <div class=\"{{$lineNrStyle}} {{$lineNrSepStyle2}}\"><span aria-hidden=\"true\" class=\"invisible\">{{$oldStart}}</span></div>\n                    <div class=\"w-5 flex-shrink-0 select-none text-center\">{{ .Op.String }}</div>\n                    <div class=\"px-2\">{{ .Line }}</div>\n@@ -108,8 +139,8 @@                  {{- $oldStart = add64 $oldStart 1 -}}\n                {{- end -}}\n                {{- if eq .Op.String \" \" -}}\n                  <div class=\"bg-white dark:bg-gray-800 text-gray-500 dark:text-gray-400 flex min-w-full items-center\">\n-                   <div class=\"{{$lineNrStyle}} {{$lineNrSepStyle1}}\">{{ $oldStart }}</div>\n-                   <div class=\"{{$lineNrStyle}} {{$lineNrSepStyle2}}\">{{ $newStart }}</div>\n+                   <div class=\"{{$lineNrStyle}} {{$lineNrSepStyle1}}\" id=\"{{$name}}-O{{$oldStart}}\"><a class=\"{{$linkStyle}}\" href=\"#{{$name}}-O{{$oldStart}}\">{{ $oldStart }}</a></div>\n+                   <div class=\"{{$lineNrStyle}} {{$lineNrSepStyle2}}\" id=\"{{$name}}-N{{$newStart}}\"><a class=\"{{$linkStyle}}\" href=\"#{{$name}}-N{{$newStart}}\">{{ $newStart }}</a></div>\n                    <div class=\"w-5 flex-shrink-0 select-none text-center\">{{ .Op.String }}</div>\n                    <div class=\"px-2\">{{ .Line }}</div>\n                  </div>\n@@ -119,7 +150,6 @@                {{- end -}}\n              {{- end -}}\n              {{- end -}}</div></div></pre>\n             {{- end -}}\n-            {{ end }}\n           </div>\n \n         </details>\n@@ -130,3 +160,16 @@   </section>\n   {{ end }}\n   {{ end }}\n {{ end }}\n+\n+{{ define \"statPill\" }}\n+  <div class=\"flex items-center font-mono text-sm\">\n+    {{ if and .Insertions .Deletions }}\n+      <span class=\"rounded-l p-1 select-none bg-green-100 text-green-700 dark:bg-green-800/50 dark:text-green-400\">+{{ .Insertions }}</span>\n+      <span class=\"rounded-r p-1 select-none bg-red-100 text-red-700 dark:bg-red-800/50 dark:text-red-400\">-{{ .Deletions }}</span>\n+    {{ else if .Insertions }}\n+      <span class=\"rounded p-1 select-none bg-green-100 text-green-700 dark:bg-green-800/50 dark:text-green-400\">+{{ .Insertions }}</span>\n+    {{ else if .Deletions }}\n+      <span class=\"rounded p-1 select-none bg-red-100 text-red-700 dark:bg-red-800/50 dark:text-red-400\">-{{ .Deletions }}</span>\n+    {{ end }}\n+  </div>\n+{{ end }}\ndiff --git a/appview/pages/templates/repo/commit.html b/appview/pages/templates/repo/commit.html\nindex 3aecab7816608c10479737166c14b934fa6e3593..01854483562c37f6806f34b5b6b97daf046c9007 100644\n--- a/appview/pages/templates/repo/commit.html\n+++ b/appview/pages/templates/repo/commit.html\n@@ -4,8 +4,6 @@ {{ define \"repoContent\" }}\n \n {{ $repo := .RepoInfo.FullName }}\n {{ $commit := .Diff.Commit }}\n-{{ $stat := .Diff.Stat }}\n-{{ $diff := .Diff.Diff }}\n \n <section class=\"commit dark:text-white\">\n   <div id=\"commit-message\">\n@@ -13,7 +11,7 @@     {{ $messageParts := splitN $commit.Message \"\\n\\n\" 2 }}\n     <div>\n       <p class=\"pb-2\">{{ index $messageParts 0 }}</p>\n       {{ if gt (len $messageParts) 1 }}\n-      <p class=\"mt-1 cursor-text pb-2 text-sm\">{{ nl2br (unwrapText (index $messageParts 1)) }}</p>\n+      <p class=\"mt-1 cursor-text pb-2 text-sm\">{{ nl2br (index $messageParts 1) }}</p>\n       {{ end }}\n     </div>\n   </div>\n@@ -29,8 +27,6 @@             <a href=\"mailto:{{ $commit.Author.Email }}\" class=\"no-underline hover:underline text-gray-500 dark:text-gray-300\">{{ $commit.Author.Name }}</a>\n           {{ end }}\n           <span class=\"px-1 select-none before:content-['\\00B7']\"></span>\n           {{ timeFmt $commit.Author.When }}\n-          <span class=\"px-1 select-none before:content-['\\00B7']\"></span>\n-          <span>{{ $stat.FilesChanged }}</span> files <span class=\"font-mono\">(+{{ $stat.Insertions }}, -{{ $stat.Deletions }})</span>\n           <span class=\"px-1 select-none before:content-['\\00B7']\"></span>\n       </p>\n \n@@ -43,21 +39,6 @@           {{ end }}\n       </p>\n   </div>\n \n-  <div class=\"diff-stat\">\n-    <br>\n-    <strong class=\"text-sm uppercase mb-4 dark:text-gray-200\">Changed files</strong>\n-    <div class=\"overflow-x-auto\">\n-      {{ range $diff }}\n-      <ul class=\"dark:text-gray-200\">\n-        {{ if .IsDelete }}\n-        <li><a href=\"#file-{{ .Name.Old }}\" class=\"dark:hover:text-gray-300\">{{ .Name.Old }}</a></li>\n-        {{ else }}\n-        <li><a href=\"#file-{{ .Name.New }}\" class=\"dark:hover:text-gray-300\">{{ .Name.New }}</a></li>\n-        {{ end }}\n-      </ul>\n-      {{ end }}\n-    </div>\n-  </div>\n </section>\n \n {{end}}\ndiff --git a/appview/pages/templates/repo/index.html b/appview/pages/templates/repo/index.html\nindex ae84e194dbc640bfadf605562382c0d12415c2cf..7c1d809e1d56a8a7fd07dc08a9911500f9726e8d 100644\n--- a/appview/pages/templates/repo/index.html\n+++ b/appview/pages/templates/repo/index.html\n@@ -146,7 +146,7 @@                           {{ if gt (len $messageParts) 1 }}\n                               <p\n                                   class=\"hidden mt-1 text-sm cursor-text pb-2 dark:text-gray-300\"\n                               >\n-                                  {{ nl2br (unwrapText (index $messageParts 1)) }}\n+                                  {{ nl2br (index $messageParts 1) }}\n                               </p>\n                           {{ end }}\n                       </div>\ndiff --git a/appview/pages/templates/repo/issues/issues.html b/appview/pages/templates/repo/issues/issues.html\nindex c44035344c16d69cb390fe05bde6521abee7a342..baf59343b86675391af15e064159e6951ee51b51 100644\n--- a/appview/pages/templates/repo/issues/issues.html\n+++ b/appview/pages/templates/repo/issues/issues.html\n@@ -4,7 +4,7 @@ {{ define \"repoContent\" }}\n     <div class=\"flex justify-between items-center\">\n         <p>\n         filtering\n-        <select class=\"border px-1 bg-white border-gray-200 dark:bg-gray-800 dark:border-gray-700\" onchange=\"window.location.href = '/{{ .RepoInfo.FullName }}/issues?state=' + this.value\">\n+        <select class=\"border p-1 bg-white border-gray-200 dark:bg-gray-800 dark:border-gray-700\" onchange=\"window.location.href = '/{{ .RepoInfo.FullName }}/issues?state=' + this.value\">\n           <option value=\"open\" {{ if .FilteringByOpen }}selected{{ end }}>open ({{ .RepoInfo.Stats.IssueCount.Open }})</option>\n           <option value=\"closed\" {{ if not .FilteringByOpen }}selected{{ end }}>closed ({{ .RepoInfo.Stats.IssueCount.Closed }})</option>\n         </select>\ndiff --git a/appview/pages/templates/repo/log.html b/appview/pages/templates/repo/log.html\nindex 36c93cbff8091097696712e16d468a388105003d..9812dd1b402407452e9f6edd514e353db94822c2 100644\n--- a/appview/pages/templates/repo/log.html\n+++ b/appview/pages/templates/repo/log.html\n@@ -83,7 +83,7 @@                                     {{ if gt (len $messageParts) 1 }}\n                                         <p\n                                             class=\"hidden mt-1 text-sm cursor-text pb-2 dark:text-gray-300\"\n                                         >\n-                                            {{ nl2br (unwrapText (index $messageParts 1)) }}\n+                                            {{ nl2br (index $messageParts 1) }}\n                                         </p>\n                                     {{ end }}\n                                 </div>\ndiff --git a/appview/pages/templates/repo/pulls/patch.html b/appview/pages/templates/repo/pulls/patch.html\nindex acb351908f673d449835b04a16f68d2d77d1505b..c8190398b30ccef21c786a8cbfbe1be76e4d2d66 100644\n--- a/appview/pages/templates/repo/pulls/patch.html\n+++ b/appview/pages/templates/repo/pulls/patch.html\n@@ -69,19 +69,6 @@               </article>\n           {{ end }}\n       </section>\n \n-      <div id=\"diff-stat\">\n-        <br>\n-        <strong class=\"text-sm uppercase mb-4\">Changed files</strong>\n-        {{ range .Diff.Diff }}\n-        <ul>\n-          {{ if .IsDelete }}\n-          <li><a href=\"#file-{{ .Name.Old }}\">{{ .Name.Old }}</a></li>\n-          {{ else }}\n-          <li><a href=\"#file-{{ .Name.New }}\">{{ .Name.New }}</a></li>\n-          {{ end }}\n-        </ul>\n-        {{ end }}\n-      </div>\n   </div>\n \n   <section>\ndiff --git a/appview/pages/templates/repo/pulls/pull.html b/appview/pages/templates/repo/pulls/pull.html\nindex b80c1604fb99298ab56f15a705bdf0451c4da428..6e9f363ee87d48fd8828bde6792568e37b393a3c 100644\n--- a/appview/pages/templates/repo/pulls/pull.html\n+++ b/appview/pages/templates/repo/pulls/pull.html\n@@ -156,7 +156,7 @@             </div>\n           {{ end }}\n         </div>\n     </details>\n-    <hr class=\"md:hidden\"/>\n+    <hr class=\"md:hidden border-t border-gray-300 dark:border-gray-600\"/>\n     {{ end }}\n   {{ end }}\n {{ end }}\ndiff --git a/appview/pages/templates/repo/pulls/pulls.html b/appview/pages/templates/repo/pulls/pulls.html\nindex 8149f705453ea69e9bb4c6e01e41748069412cbc..663cc2cedaf2677567732e745970180e55576769 100644\n--- a/appview/pages/templates/repo/pulls/pulls.html\n+++ b/appview/pages/templates/repo/pulls/pulls.html\n@@ -5,7 +5,7 @@     <div class=\"flex justify-between items-center\">\n         <p class=\"dark:text-white\">\n             filtering\n             <select\n-                class=\"border px-1 bg-white dark:bg-gray-800 border-gray-200 dark:border-gray-600 dark:text-white\"\n+                class=\"border p-1 bg-white dark:bg-gray-800 border-gray-200 dark:border-gray-600 dark:text-white\"\n                 onchange=\"window.location.href = '/{{ .RepoInfo.FullName }}/pulls?state=' + this.value\"\n             >\n                 <option value=\"open\" {{ if .FilteringBy.IsOpen }}selected{{ end }}>\ndiff --git a/appview/pages/templates/repo/tree.html b/appview/pages/templates/repo/tree.html\nindex 6ececaf31b686113e7b561a7ac0af7afd143feb8..52fa434aaab103c0b52af993a0c37d21278f9e11 100644\n--- a/appview/pages/templates/repo/tree.html\n+++ b/appview/pages/templates/repo/tree.html\n@@ -28,18 +28,19 @@         <div id=\"dir-info\" class=\"text-gray-500 dark:text-gray-400 text-xs md:text-sm flex flex-wrap items-center gap-1 md:gap-0\">\n           {{ $stats := .TreeStats }}\n \n           <span>at <a href=\"/{{ $.RepoInfo.FullName }}/tree/{{ $.Ref }}\">{{ $.Ref }}</a></span>\n-          <span class=\"select-none px-1 md:px-2 [&:before]:content-['·']\"></span>\n           {{ if eq $stats.NumFolders 1 }}\n-            <span>{{ $stats.NumFolders }} folder</span>\n             <span class=\"select-none px-1 md:px-2 [&:before]:content-['·']\"></span>\n+            <span>{{ $stats.NumFolders }} folder</span>\n           {{ else if gt $stats.NumFolders 1 }}\n+            <span class=\"select-none px-1 md:px-2 [&:before]:content-['·']\"></span>\n             <span>{{ $stats.NumFolders }} folders</span>\n-            <span class=\"select-none px-1 md:px-2 [&:before]:content-['·']\"></span>\n           {{ end }}\n \n           {{ if eq $stats.NumFiles 1 }}\n+            <span class=\"select-none px-1 md:px-2 [&:before]:content-['·']\"></span>\n             <span>{{ $stats.NumFiles }} file</span>\n           {{ else if gt $stats.NumFiles 1 }}\n+            <span class=\"select-none px-1 md:px-2 [&:before]:content-['·']\"></span>\n             <span>{{ $stats.NumFiles }} files</span>\n           {{ end }}\n \ndiff --git a/types/diff.go b/types/diff.go\nindex a8a4c22cf121b6ee742d6f20dc86a63c4e072389..e45d68d3f7874dcfb258e9bc5832d0ac1c7d4384 100644\n--- a/types/diff.go\n+++ b/types/diff.go\n@@ -23,6 +23,20 @@ \tIsCopy        bool                   `json:\"is_copy\"`\n \tIsRename      bool                   `json:\"is_rename\"`\n }\n \n+type DiffStat struct {\n+\tInsertions int64\n+\tDeletions  int64\n+}\n+\n+func (d *Diff) Stats() DiffStat {\n+\tvar stats DiffStat\n+\tfor _, f := range d.TextFragments {\n+\t\tstats.Insertions += f.LinesAdded\n+\t\tstats.Deletions += f.LinesDeleted\n+\t}\n+\treturn stats\n+}\n+\n // A nicer git diff representation.\n type NiceDiff struct {\n \tCommit struct {\n",
    "title": "appview: add stats and line-nr links to diffs",
    "pullId": 44,
    "source": {
      "branch": "more-diff-stats"
    },
    "targetRepo": "at://did:plc:wshs7t2adsemcrrd4snkeqli/sh.tangled.repo/3liuighjy2h22",
    "targetBranch": "master"
  }
}