forked from tangled.org/core
this repo has no description

Compare changes

Choose any two refs to compare.

Changed files
+159 -12
appview
pages
templates
contrib
knotserver
+90
appview/pages/templates/fragments/multiline-select.html
···
+
{{ define "fragments/multiline-select" }}
+
<script>
+
function highlight(scroll = false) {
+
document.querySelectorAll(".hl").forEach(el => {
+
el.classList.remove("hl");
+
});
+
+
const hash = window.location.hash;
+
if (!hash || !hash.startsWith("#L")) {
+
return;
+
}
+
+
const rangeStr = hash.substring(2);
+
const parts = rangeStr.split("-");
+
let startLine, endLine;
+
+
if (parts.length === 2) {
+
startLine = parseInt(parts[0], 10);
+
endLine = parseInt(parts[1], 10);
+
} else {
+
startLine = parseInt(parts[0], 10);
+
endLine = startLine;
+
}
+
+
if (isNaN(startLine) || isNaN(endLine)) {
+
console.log("nan");
+
console.log(startLine);
+
console.log(endLine);
+
return;
+
}
+
+
let target = null;
+
+
for (let i = startLine; i<= endLine; i++) {
+
const idEl = document.getElementById(`L${i}`);
+
if (idEl) {
+
const el = idEl.closest(".line");
+
if (el) {
+
el.classList.add("hl");
+
target = el;
+
}
+
}
+
}
+
+
if (scroll && target) {
+
target.scrollIntoView({
+
behavior: "smooth",
+
block: "center",
+
});
+
}
+
}
+
+
document.addEventListener("DOMContentLoaded", () => {
+
console.log("DOMContentLoaded");
+
highlight(true);
+
});
+
window.addEventListener("hashchange", () => {
+
console.log("hashchange");
+
highlight();
+
});
+
window.addEventListener("popstate", () => {
+
console.log("popstate");
+
highlight();
+
});
+
+
const lineNumbers = document.querySelectorAll('a[href^="#L"');
+
let startLine = null;
+
+
lineNumbers.forEach(el => {
+
el.addEventListener("click", (event) => {
+
event.preventDefault();
+
const currentLine = parseInt(el.href.split("#L")[1]);
+
+
if (event.shiftKey && startLine !== null) {
+
const endLine = currentLine;
+
const min = Math.min(startLine, endLine);
+
const max = Math.max(startLine, endLine);
+
const newHash = `#L${min}-${max}`;
+
history.pushState(null, '', newHash);
+
} else {
+
const newHash = `#L${currentLine}`;
+
history.pushState(null, '', newHash);
+
startLine = currentLine;
+
}
+
+
highlight();
+
});
+
});
+
</script>
+
{{ end }}
+7 -2
appview/pages/templates/layouts/profilebase.html
···
{{ define "content" }}
{{ template "profileTabs" . }}
-
<section class="bg-white dark:bg-gray-800 p-6 rounded w-full dark:text-white drop-shadow-sm">
+
<section class="bg-white dark:bg-gray-800 px-2 py-6 md:p-6 rounded w-full dark:text-white drop-shadow-sm">
<div class="grid grid-cols-1 md:grid-cols-11 gap-4">
-
<div class="md:col-span-3 order-1 md:order-1">
+
{{ $style := "hidden md:block md:col-span-3" }}
+
{{ if eq $.Active "overview" }}
+
{{ $style = "md:col-span-3" }}
+
{{ end }}
+
<div class="{{ $style }} order-1 order-1">
<div class="flex flex-col gap-4">
{{ template "user/fragments/profileCard" .Card }}
{{ block "punchcard" .Card.Punchcard }} {{ end }}
</div>
</div>
+
{{ block "profileContent" . }} {{ end }}
</div>
</section>
+1
appview/pages/templates/repo/blob.html
···
{{ end }}
</div>
{{ end }}
+
{{ template "fragments/multiline-select" }}
{{ end }}
+6 -1
appview/pages/templates/repo/fragments/shortTimeAgo.html
···
{{ define "repo/fragments/shortTimeAgo" }}
-
{{ template "repo/fragments/timeWrapper" (dict "Time" . "Content" (print (. | shortRelTimeFmt) " ago")) }}
+
{{ $formatted := shortRelTimeFmt . }}
+
{{ $content := printf "%s ago" $formatted }}
+
{{ if eq $formatted "now" }}
+
{{ $content = "now" }}
+
{{ end }}
+
{{ template "repo/fragments/timeWrapper" (dict "Time" . "Content" $content) }}
{{ end }}
+3 -2
appview/pages/templates/strings/string.html
···
hx-boost="true"
href="/strings/{{ .String.Did }}/{{ .String.Rkey }}/edit">
{{ i "pencil" "size-4" }}
-
<span class="hidden md:inline">edit</span>
+
<span class="hidden md:inline">edit</span>
{{ i "loader-circle" "w-4 h-4 animate-spin hidden group-[.htmx-request]:inline" }}
</a>
<button
···
hx-confirm="Are you sure you want to delete the string `{{ .String.Filename }}`?"
>
{{ i "trash-2" "size-4" }}
-
<span class="hidden md:inline">delete</span>
+
<span class="hidden md:inline">delete</span>
{{ i "loader-circle" "w-4 h-4 animate-spin hidden group-[.htmx-request]:inline" }}
</button>
</div>
···
<div id="blob-contents" class="whitespace-pre peer-target:bg-yellow-200 dark:peer-target:bg-yellow-900">{{ .String.Contents | escapeHtml }}</div>
{{ end }}
</div>
+
{{ template "fragments/multiline-select" }}
</section>
{{ end }}
+44
contrib/Tiltfile
···
+
common_env = {
+
"TANGLED_VM_SPINDLE_OWNER": os.getenv("TANGLED_VM_SPINDLE_OWNER", default=""),
+
"TANGLED_VM_KNOT_OWNER": os.getenv("TANGLED_VM_KNOT_OWNER", default=""),
+
"TANGLED_DB_PATH": os.getenv("TANGLED_DB_PATH", default="dev.db"),
+
"TANGLED_DEV": os.getenv("TANGLED_DEV", default="true"),
+
}
+
+
nix_globs = ["nix/**", "flake.nix", "flake.lock"]
+
+
local_resource(
+
name="appview",
+
serve_cmd="nix run .#watch-appview",
+
serve_dir="..",
+
deps=nix_globs,
+
env=common_env,
+
allow_parallel=True,
+
)
+
+
local_resource(
+
name="tailwind",
+
serve_cmd="nix run .#watch-tailwind",
+
serve_dir="..",
+
deps=nix_globs,
+
env=common_env,
+
allow_parallel=True,
+
)
+
+
local_resource(
+
name="redis",
+
serve_cmd="redis-server",
+
serve_dir="..",
+
deps=nix_globs,
+
env=common_env,
+
allow_parallel=True,
+
)
+
+
local_resource(
+
name="vm",
+
serve_cmd="nix run --impure .#vm",
+
serve_dir="..",
+
deps=nix_globs,
+
env=common_env,
+
allow_parallel=True,
+
)
+2 -1
flake.nix
···
nativeBuildInputs = [
pkgs.go
pkgs.air
+
pkgs.tilt
pkgs.gopls
pkgs.httpie
pkgs.litecli
···
tailwind-watcher =
pkgs.writeShellScriptBin "run"
''
-
${pkgs.tailwindcss}/bin/tailwindcss -w -i input.css -o ./appview/pages/static/tw.css
+
${pkgs.tailwindcss}/bin/tailwindcss --watch=always -i input.css -o ./appview/pages/static/tw.css
'';
in {
fmt = {
+2 -5
input.css
···
}
/* LineHighlight */
.chroma .hl {
-
background-color: #bcc0cc;
+
@apply bg-amber-400/30 dark:bg-amber-500/20;
}
+
/* LineNumbersTable */
.chroma .lnt {
white-space: pre;
···
text-decoration: underline;
}
}
-
-
.chroma .line:has(.ln:target) {
-
@apply bg-amber-400/30 dark:bg-amber-500/20;
-
}
+4 -1
knotserver/git/language.go
···
import (
"context"
"path"
+
"strings"
"github.com/go-enry/go-enry/v2"
"github.com/go-git/go-git/v5/plumbing/object"
···
return nil
}
-
if enry.IsGenerated(filepath, content) {
+
if enry.IsGenerated(filepath, content) ||
+
enry.IsBinary(content) ||
+
strings.HasSuffix(filepath, "bun.lock") {
return nil
}