tangled
alpha
login
or
join now
leaflet.pub
/
leaflet
291
fork
atom
a tool for shared writing and social publishing
291
fork
atom
overview
issues
27
pulls
pipelines
mostly removing console logs
cozylittle.house
5 months ago
872c2d0c
2663ef31
+48
-34
16 changed files
expand all
collapse all
unified
split
app
api
oauth
[route]
route.ts
lish
[did]
[publication]
[rkey]
Interactions
Comments
CommentBox.tsx
useHighlight.tsx
dashboard
page.tsx
icon.ts
subscribeToPublication.ts
reader
ReaderContent.tsx
page.tsx
appview
bumpCursor.js
components
ActionBar
Navigation.tsx
ThemeManager
PubPickers
PubBackgroundPickers.tsx
PubThemeSetter.tsx
utils
AutosizeTextarea.tsx
src
utils
addLinkBlock.ts
focusBlock.ts
getBlocksAsHTML.tsx
-1
app/api/oauth/[route]/route.ts
···
121
121
else url = new URL(decodeURIComponent(redirectPath), "https://example.com");
122
122
if (action?.action === "subscribe") {
123
123
let result = await subscribeToPublication(action.publication);
124
124
-
console.log(result);
125
124
if (result.hasFeed === false)
126
125
url.searchParams.set("showSubscribeSuccess", "true");
127
126
}
+18
-14
app/lish/[did]/[publication]/[rkey]/Interactions/Comments/CommentBox.tsx
···
44
44
autoFocus?: boolean;
45
45
}) {
46
46
let mountRef = useRef<HTMLPreElement | null>(null);
47
47
-
let { commentBox: { quote } } = useInteractionState(props.doc_uri);
47
47
+
let {
48
48
+
commentBox: { quote },
49
49
+
} = useInteractionState(props.doc_uri);
48
50
let [loading, setLoading] = useState(false);
49
49
-
51
51
+
50
52
const handleSubmit = async () => {
51
53
if (loading || !view.current) return;
52
52
-
54
54
+
53
55
setLoading(true);
54
56
let currentState = view.current.state;
55
57
let [plaintext, facets] = docToFacetedText(currentState.doc);
···
108
110
"Mod-z": undo,
109
111
"Mod-y": redo,
110
112
"Shift-Mod-z": redo,
111
111
-
"Ctrl-Enter": () => { handleSubmit(); return true; },
112
112
-
"Meta-Enter": () => { handleSubmit(); return true; },
113
113
+
"Ctrl-Enter": () => {
114
114
+
handleSubmit();
115
115
+
return true;
116
116
+
},
117
117
+
"Meta-Enter": () => {
118
118
+
handleSubmit();
119
119
+
return true;
120
120
+
},
113
121
}),
114
122
keymap(baseKeymap),
115
123
autolink({
···
158
166
let xml = new DOMParser().parseFromString(html, "text/html");
159
167
text = xml.textContent || "";
160
168
}
161
161
-
console.log("URL: " + window.location.toString());
162
162
-
console.log("TEXT: " + text, text?.includes(QUOTE_PARAM));
163
169
if (
164
170
text?.includes(QUOTE_PARAM) &&
165
171
text.includes(window.location.toString())
···
190
196
}
191
197
},
192
198
dispatchTransaction(tr) {
193
193
-
console.log("dispatching?");
194
199
let newState = this.state.apply(tr);
195
200
setEditorState(newState);
196
201
view.current?.updateState(newState);
···
207
212
view.current = null;
208
213
};
209
214
}, []);
210
210
-
215
215
+
211
216
return (
212
217
<div className=" flex flex-col">
213
218
{quote && (
···
216
221
<button
217
222
className="text-border absolute -top-3 right-1 bg-bg-page p-1 rounded-full"
218
223
onClick={() =>
219
219
-
setInteractionState(props.doc_uri, { commentBox: { quote: null } })
224
224
+
setInteractionState(props.doc_uri, {
225
225
+
commentBox: { quote: null },
226
226
+
})
220
227
}
221
228
>
222
229
<CloseFillTiny />
···
251
258
view={view}
252
259
/>
253
260
</div>
254
254
-
<ButtonPrimary
255
255
-
compact
256
256
-
onClick={handleSubmit}
257
257
-
>
261
261
+
<ButtonPrimary compact onClick={handleSubmit}>
258
262
{loading ? <DotLoader /> : <ShareSmall />}
259
263
</ButtonPrimary>
260
264
</div>
-1
app/lish/[did]/[publication]/[rkey]/useHighlight.tsx
···
20
20
let highlights = activeHighlight ? [activeHighlight] : [];
21
21
let decodedQuote = quote ? decodeQuotePosition(quote as string) : null;
22
22
if (decodedQuote) highlights.push(decodedQuote);
23
23
-
console.log(highlights);
24
23
return highlights
25
24
.map((quotePosition) => {
26
25
if (!quotePosition) return null;
-1
app/lish/[did]/[publication]/dashboard/page.tsx
···
75
75
</PublicationSWRDataProvider>
76
76
);
77
77
} catch (e) {
78
78
-
console.log(e);
79
78
return <pre>{JSON.stringify(e, undefined, 2)}</pre>;
80
79
}
81
80
}
-2
app/lish/[did]/[publication]/icon.ts
···
46
46
47
47
let identity = await idResolver.did.resolve(did);
48
48
let service = identity?.service?.find((f) => f.id === "#atproto_pds");
49
49
-
console.log(identity);
50
49
if (!service) return null;
51
50
let cid = (record.icon.ref as unknown as { $link: string })["$link"];
52
51
const response = await fetch(
···
56
55
let resizedImage = await sharp(await blob.arrayBuffer())
57
56
.resize({ width: 32, height: 32 })
58
57
.toBuffer();
59
59
-
console.log("fetched favicon!");
60
58
return new Response(new Uint8Array(resizedImage), {
61
59
headers: {
62
60
"Content-Type": "image/png",
-1
app/lish/subscribeToPublication.ts
···
74
74
}
75
75
76
76
export async function unsubscribeToPublication(publication: string) {
77
77
-
console.log("calling unsubscribe!");
78
77
const oauthClient = await createOauthClient();
79
78
let identity = await getIdentityData();
80
79
if (!identity || !identity.atp_did) return;
+27
-1
app/reader/ReaderContent.tsx
···
10
10
import { SpeedyLink } from "components/SpeedyLink";
11
11
import { usePubTheme } from "components/ThemeManager/PublicationThemeProvider";
12
12
import { BaseThemeProvider } from "components/ThemeManager/ThemeProvider";
13
13
+
import { useSmoker } from "components/Toast";
13
14
import { PubLeafletDocument, PubLeafletPublication } from "lexicons/api";
14
15
import { blobRefToSrc } from "src/utils/blobRefToSrc";
15
16
import { Json } from "supabase/database.types";
···
141
142
</div>
142
143
143
144
<PostInterations
145
145
+
postUrl={`props.publication.href}/${postUri.rkey}`}
144
146
quotesCount={quotes}
145
147
commentsCount={comments}
146
148
showComments={pubRecord.preferences?.showComments}
···
192
194
const PostInterations = (props: {
193
195
quotesCount: number;
194
196
commentsCount: number;
197
197
+
postUrl: string;
195
198
showComments: boolean | undefined;
196
199
}) => {
200
200
+
let smoker = useSmoker();
197
201
return (
198
198
-
<div className={`flex gap-2 text-tertiary text-sm `}>
202
202
+
<div className={`flex gap-2 text-tertiary text-sm items-center`}>
199
203
{props.quotesCount === 0 ? null : (
200
204
<div className={`flex gap-1 items-center `}>
201
205
<span className="sr-only">Post quotes</span>
···
208
212
<CommentTiny aria-hidden /> {props.commentsCount}
209
213
</div>
210
214
)}
215
215
+
<Separator classname="h-4 !min-h-0" />
216
216
+
<button
217
217
+
id="copy-post-link"
218
218
+
className="flex gap-1 items-center hover:font-bold px-1"
219
219
+
onClick={() => {
220
220
+
let rect = document
221
221
+
.getElementById("copy-post-link")
222
222
+
?.getBoundingClientRect();
223
223
+
if (!props.postUrl) return;
224
224
+
navigator.clipboard.writeText(props.postUrl);
225
225
+
226
226
+
smoker({
227
227
+
text: <strong>Copied Link</strong>,
228
228
+
position: {
229
229
+
y: rect ? rect.top : 0,
230
230
+
x: rect ? rect.right + 5 : 0,
231
231
+
},
232
232
+
});
233
233
+
}}
234
234
+
>
235
235
+
Share
236
236
+
</button>
211
237
</div>
212
238
);
213
239
};
+1
-1
app/reader/page.tsx
···
163
163
<DashboardLayout
164
164
id="reader"
165
165
cardBorderHidden={false}
166
166
-
currentPage="discover"
166
166
+
currentPage="reader"
167
167
defaultTab="reader"
168
168
actions={null}
169
169
tabs={{
-4
appview/bumpCursor.js
···
7
7
} else {
8
8
let newCursor = (cursor + 300 * 60 * 60 * 12).toString();
9
9
writeFileSync(cursorFile, (cursor + 300 * 60 * 60 * 12).toString());
10
10
-
console.log(`
11
11
-
old cursor: ${cursor}
12
12
-
new cursor: ${newCursor}
13
13
-
`);
14
10
}
+2
-2
components/ActionBar/Navigation.tsx
···
88
88
let thisPublication = identity?.publications?.find(
89
89
(pub) => pub.uri === props.publication,
90
90
);
91
91
-
console.log(identity);
92
91
return (
93
92
<>
94
93
<HomeButton current={props.currentPage === "home"} />
···
128
127
icon={readerUnreads ? <ReaderUnreadSmall /> : <ReaderReadSmall />}
129
128
label="Reader"
130
129
className={`
131
131
-
${readerUnreads ? "text-accent-contrast! border-accent-contrast" : props.current ? "bg-border-light! border-border" : ""}
130
130
+
${readerUnreads && "text-accent-contrast!"}
131
131
+
${props.current && "border-accent-contrast!"}
132
132
`}
133
133
/>
134
134
</Link>
-1
components/ThemeManager/PubPickers/PubBackgroundPickers.tsx
···
67
67
if (file) {
68
68
const reader = new FileReader();
69
69
reader.onload = (e) => {
70
70
-
console.log("loaded!", props.bgImage);
71
70
props.setBgImage({
72
71
src: e.target?.result as string,
73
72
file,
-1
components/ThemeManager/PubThemeSetter.tsx
···
62
62
onSubmit={async (e) => {
63
63
e.preventDefault();
64
64
if (!pub) return;
65
65
-
console.log(image);
66
65
setLoading(true);
67
66
let result = await updatePublicationTheme({
68
67
uri: pub.uri,
-1
components/utils/AutosizeTextarea.tsx
···
19
19
let { noWrap, ...rest } = props;
20
20
useImperativeHandle(ref, () => textarea.current as HTMLTextAreaElement);
21
21
22
22
-
console.log({ noWrap });
23
22
return (
24
23
<div
25
24
className={`${styles["grow-wrap"]} ${props.className} ${noWrap ? styles["no-wrap"] : ""}`}
-1
src/utils/addLinkBlock.ts
···
59
59
}
60
60
61
61
if (data.data.links?.player?.[0]) {
62
62
-
console.log(data.data.links.player);
63
62
let embed = data.data.links?.player?.[0];
64
63
await rep.mutate.assertFact([
65
64
{
-1
src/utils/focusBlock.ts
···
85
85
top: nextBlockViewClientRect.top + 12,
86
86
left: Math.max(position.left, nextBlockViewClientRect.left),
87
87
});
88
88
-
console.log(pos);
89
88
break;
90
89
}
91
90
case "bottom": {
-1
src/utils/getBlocksAsHTML.tsx
···
187
187
let [alignment] = await scanIndex(tx).eav(b.value, "block/text-alignment");
188
188
let toHtml = BlockTypeToHTML[b.type];
189
189
let element = await toHtml(b, tx, alignment?.data.value);
190
190
-
console.log(element);
191
190
return renderToStaticMarkup(element);
192
191
}