Something went wrong. Try again.
Monorepo for Tangled forked from tangled.org/core
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138<script module lang="ts"> import { defineMeta } from "@storybook/addon-svelte-csf"; import StringView from "#lib/components/strings/StringView.svelte";
const textFile = (name: string, $link: string, size: number) => ({ $type: "org.tangled.snippet.string#textFile" as const, name, content: { $type: "blob" as const, ref: { $link }, mimeType: "text/plain", size } });
const codeContents = `use std::collections::HashMap;use std::io::{self, BufRead};
#[derive(Debug, Default)]struct Tally { words: usize, lines: usize, counts: HashMap<String, usize>,}
impl Tally { fn add_line(&mut self, line: &str) { self.lines += 1; for word in line.split_whitespace() { self.words += 1; *self.counts.entry(word.to_lowercase()).or_default() += 1; } }
fn top(&self, n: usize) -> Vec<(&str, usize)> { let mut pairs: Vec<_> = self.counts.iter().map(|(w, c)| (w.as_str(), *c)).collect(); pairs.sort_by(|a, b| b.1.cmp(&a.1).then(a.0.cmp(b.0))); pairs.truncate(n); pairs }}
fn main() -> io::Result<()> { let mut tally = Tally::default(); for line in io::stdin().lock().lines() { tally.add_line(&line?); } println!("{} lines, {} words", tally.lines, tally.words); for (word, count) in tally.top(10) { println!("{count:>6} {word}"); } Ok(())}`; const codeRecord = { $type: "org.tangled.snippet.string" as const, snippet: textFile( "main.rs", "bafkreifqrrwn3ioqkrquhibb3csu6i3kogd76uk6ktptc7s5exim6rfu6u", codeContents.length ), description: "Word frequency counter for stdin", createdAt: "2026-05-01T12:00:00Z" };
const codeBlob = { ref: "3l7abc", path: "main.rs", kind: "code" as const, sizeLabel: `${codeContents.length} B`, lines: codeContents.trimEnd().split("\n").length, contents: codeContents, renderedHtml: null, fileTooLarge: false, defaultView: "code" as const, submodule: null, lastCommit: null };
const markdownContents = "# Architecture\n\nStrings are lightweight snippets powered by ATProto."; const markdownRecord = { $type: "org.tangled.snippet.string" as const, snippet: textFile( "notes.md", "bafkreieify5bix4cmrj4iuxiceb6srr2boltkbbf7yizwtgwurqv42sltm", 68 ), description: "Architecture notes", createdAt: "2026-05-01T12:00:00Z" };
const markdownBlob = { ref: "3l7xyz", path: "notes.md", kind: "markup" as const, sizeLabel: "68 B", lines: 3, contents: markdownContents, renderedHtml: "<h1>Architecture</h1><p>Strings are lightweight snippets powered by ATProto.</p>", fileTooLarge: false, defaultView: "rendered" as const, submodule: null, lastCommit: null };
const { Story } = defineMeta({ title: "Strings/StringView", component: StringView, tags: ["autodocs"], parameters: { auth: true }, args: { ownerHandle: "alice.tangled.org", ownerDid: "did:plc:alice", rkey: "3l7abc", string: codeRecord, blob: codeBlob, isOwner: true, uri: "at://did:plc:alice/org.tangled.snippet.string/3l7abc", starCount: 5, viewerStarRkey: null } });</script>
<Story name="CodeFile" parameters={{ layout: "fullscreen", bones: { class: "mx-auto w-full max-w-page" } }}/>
<Story name="MarkdownSkeletonFixture" args={{ rkey: "3l7xyz", string: markdownRecord, blob: markdownBlob, uri: "at://did:plc:alice/org.tangled.snippet.string/3l7xyz" }}/>
<Story name="NonOwner" args={{ isOwner: false }} />