mirror of
https://github.com/linsa-io/linsa.git
synced 2026-01-12 12:20:23 +01:00
fix: link (#115)
* start * . * seeding connections * . * wip * wip: learning state * wip: notes section * wip: many * topics * chore: update schema * update package * update sidebar * update page section * feat: profile * fix: remove z index * fix: wrong type * add avatar * add avatar * wip * . * store page section key * remove atom page section * fix rerender * fix rerender * fix rerender * fix rerender * fix link * search light/dark mode * bubble menu ui * . * fix: remove unecessary code * chore: mark as old for old schema * chore: adapt new schema * fix: add topic schema but null for now * fix: add icon on personal link * fix: list item * fix: set url fetched when editing * fix: remove image * feat: add icon to link * feat: custom url zod validation * fix: metadata test * chore: update utils * fix: link * fix: url fetcher * . * . * fix: add link, section * chore: seeder * . * . * . * . * fix: change checkbox to learning state * fix: click outside editing form * feat: constant * chore: move to master folder * chore: adapt new schema * chore: cli for new schema * fix: new schema for dev seed * fix: seeding * update package * chore: forcegraph seed * bottombar * if isEdit delete icon * showCreate X button * . * options * chore: implement topic from public global group * chore: update learning state * fix: change implementation for outside click * chore: implement new form param * chore: update env example * feat: link form refs exception * new page button layout, link topic search fixed * chore: enable topic * chore: update seed * profile * chore: move framer motion package from root to web and add nuqs * chore: add LearningStateValue * chore: implement active state * profile * chore: use fancy switch and update const * feat: filter implementation * dropdown menu * . * sidebar topics * topic selected color * feat: topic detail * fix: collapsible page * pages - sorted by, layout, visible mode * . * . * . * topic status sidebar * topic button and count * fix: topic * page delete/topic buttons * search ui * selected topic for page * selected topic status sidebar * removed footer * update package * . --------- Co-authored-by: Nikita <github@nikiv.dev> Co-authored-by: marshennikovaolga <marshennikova@gmail.com> Co-authored-by: Kisuyo <ig.intr3st@gmail.com>
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
import { co, CoMap, Encoders } from "jazz-tools"
|
||||
import { GlobalTopic } from "./global-topic"
|
||||
import { GlobalTopic } from "./global-topic.old"
|
||||
|
||||
// GlobalLinkAiSummary is high quality title, description, summary of link (generated by AI)
|
||||
export class GlobalLinkAiSummary extends CoMap {
|
||||
@@ -11,7 +11,8 @@
|
||||
import { CoMap, co, Account, Profile } from "jazz-tools"
|
||||
import { PersonalPageLists } from "./personal-page"
|
||||
import { PersonalLinkLists } from "./personal-link"
|
||||
import { GlobalTopicLists } from "./global-topic"
|
||||
import { ListOfTopics } from "./master/topic"
|
||||
|
||||
export class UserRoot extends CoMap {
|
||||
name = co.string
|
||||
username = co.string
|
||||
@@ -24,9 +25,9 @@ export class UserRoot extends CoMap {
|
||||
personalPages = co.ref(PersonalPageLists)
|
||||
|
||||
// not implemented yet
|
||||
topicsWantToLearn = co.ref(GlobalTopicLists)
|
||||
topicsLearning = co.ref(GlobalTopicLists)
|
||||
topicsLearned = co.ref(GlobalTopicLists)
|
||||
topicsWantToLearn = co.ref(ListOfTopics)
|
||||
topicsLearning = co.ref(ListOfTopics)
|
||||
topicsLearned = co.ref(ListOfTopics)
|
||||
}
|
||||
|
||||
export class LaAccount extends Account {
|
||||
@@ -53,9 +54,9 @@ export class LaAccount extends Account {
|
||||
personalPages: PersonalPageLists.create([], { owner: this }),
|
||||
|
||||
// not implemented yet
|
||||
topicsWantToLearn: GlobalTopicLists.create([], { owner: this }),
|
||||
topicsLearning: GlobalTopicLists.create([], { owner: this }),
|
||||
topicsLearned: GlobalTopicLists.create([], { owner: this })
|
||||
topicsWantToLearn: ListOfTopics.create([], { owner: this }),
|
||||
topicsLearning: ListOfTopics.create([], { owner: this }),
|
||||
topicsLearned: ListOfTopics.create([], { owner: this })
|
||||
},
|
||||
{ owner: this }
|
||||
)
|
||||
@@ -63,7 +64,6 @@ export class LaAccount extends Account {
|
||||
}
|
||||
}
|
||||
|
||||
export * from "./global-link"
|
||||
export * from "./global-topic"
|
||||
export * from "./master/topic"
|
||||
export * from "./personal-link"
|
||||
export * from "./personal-page"
|
||||
|
||||
15
web/lib/schema/master/force-graph.ts
Normal file
15
web/lib/schema/master/force-graph.ts
Normal file
@@ -0,0 +1,15 @@
|
||||
import { co, CoList, CoMap } from "jazz-tools"
|
||||
|
||||
export class Connection extends CoMap {
|
||||
name = co.string
|
||||
}
|
||||
|
||||
export class ListOfConnections extends CoList.Of(co.ref(Connection)) {}
|
||||
|
||||
export class ForceGraph extends CoMap {
|
||||
name = co.string
|
||||
prettyName = co.string
|
||||
connections = co.optional.ref(ListOfConnections)
|
||||
}
|
||||
|
||||
export class ListOfForceGraphs extends CoList.Of(co.ref(ForceGraph)) {}
|
||||
12
web/lib/schema/master/public-group.ts
Normal file
12
web/lib/schema/master/public-group.ts
Normal file
@@ -0,0 +1,12 @@
|
||||
import { co, CoMap, Group } from "jazz-tools"
|
||||
import { ListOfForceGraphs } from "./force-graph"
|
||||
import { ListOfTopics } from "./topic"
|
||||
|
||||
export class PublicGlobalGroupRoot extends CoMap {
|
||||
forceGraphs = co.ref(ListOfForceGraphs)
|
||||
topics = co.ref(ListOfTopics)
|
||||
}
|
||||
|
||||
export class PublicGlobalGroup extends Group {
|
||||
root = co.ref(PublicGlobalGroupRoot)
|
||||
}
|
||||
33
web/lib/schema/master/topic.ts
Normal file
33
web/lib/schema/master/topic.ts
Normal file
@@ -0,0 +1,33 @@
|
||||
import { co, CoList, CoMap } from "jazz-tools"
|
||||
|
||||
export class Link extends CoMap {
|
||||
title = co.string
|
||||
url = co.string
|
||||
}
|
||||
|
||||
export class ListOfLinks extends CoList.Of(co.ref(Link)) {}
|
||||
|
||||
export class Section extends CoMap {
|
||||
title = co.string
|
||||
links = co.ref(ListOfLinks)
|
||||
}
|
||||
|
||||
export class ListOfSections extends CoList.Of(co.ref(Section)) {}
|
||||
|
||||
export class LatestGlobalGuide extends CoMap {
|
||||
sections = co.ref(ListOfSections)
|
||||
}
|
||||
|
||||
export class TopicConnection extends CoMap {
|
||||
name = co.string
|
||||
}
|
||||
|
||||
export class ListOfTopicConnections extends CoList.Of(co.ref(TopicConnection)) {}
|
||||
|
||||
export class Topic extends CoMap {
|
||||
name = co.string
|
||||
prettyName = co.string
|
||||
latestGlobalGuide = co.ref(LatestGlobalGuide)
|
||||
}
|
||||
|
||||
export class ListOfTopics extends CoList.Of(co.ref(Topic)) {}
|
||||
@@ -1,34 +1,68 @@
|
||||
import { co, CoList, CoMap } from "jazz-tools"
|
||||
import { nullable } from "../types"
|
||||
import { GlobalLink } from "./global-link"
|
||||
import { GlobalTopic } from "./global-topic"
|
||||
import { co, CoList, CoMap, Encoders, ID } from "jazz-tools"
|
||||
import { Topic } from "./master/topic"
|
||||
|
||||
export class LinkMetadata extends CoMap {
|
||||
url = co.string
|
||||
title = co.string
|
||||
favicon = co.string
|
||||
description = nullable(co.string)
|
||||
class BaseModel extends CoMap {
|
||||
createdAt = co.encoded(Encoders.Date)
|
||||
updatedAt = co.encoded(Encoders.Date)
|
||||
}
|
||||
|
||||
/*
|
||||
* Link is link user added, it wraps over Link and lets user add notes and other things to it,
|
||||
* (as well as set own title/description/summary if GlobalLink ones is not good enough or is lacking)
|
||||
*/
|
||||
export class PersonalLink extends CoMap {
|
||||
export class PersonalLink extends BaseModel {
|
||||
url = co.string
|
||||
icon = co.optional.string // is an icon URL
|
||||
title = co.string
|
||||
slug = co.string
|
||||
description = co.optional.string
|
||||
completed = co.boolean
|
||||
sequence = co.number
|
||||
isLink = co.boolean
|
||||
meta = co.optional.ref(LinkMetadata)
|
||||
|
||||
// not yet implemented
|
||||
learningState = co.optional.literal("wantToLearn", "learning", "learned")
|
||||
notes = co.optional.string
|
||||
summary = co.optional.string
|
||||
globalLink = co.optional.ref(GlobalLink)
|
||||
topic = co.optional.ref(GlobalTopic)
|
||||
topic = co.optional.ref(Topic)
|
||||
}
|
||||
|
||||
export class PersonalLinkLists extends CoList.Of(co.ref(PersonalLink)) {}
|
||||
|
||||
export function updatePersonalLink(link: PersonalLink, data: Partial<PersonalLink>): void {
|
||||
Object.assign(link, { ...data, updatedAt: new Date() })
|
||||
}
|
||||
|
||||
export function createPersonalLinkList(owner: { group: any }): PersonalLinkLists {
|
||||
return PersonalLinkLists.create([], { owner: owner.group })
|
||||
}
|
||||
|
||||
export function addToPersonalLinkList(list: PersonalLinkLists, item: PersonalLink): void {
|
||||
list.push(item)
|
||||
}
|
||||
|
||||
export function removeFromPersonalLinkList(list: PersonalLinkLists, id: ID<PersonalLink>): void {
|
||||
const index = list.findIndex(item => item?.id === id)
|
||||
if (index !== -1) {
|
||||
list.splice(index, 1)
|
||||
}
|
||||
}
|
||||
|
||||
export function updateInPersonalLinkList(
|
||||
list: PersonalLinkLists,
|
||||
id: ID<PersonalLink>,
|
||||
data: Partial<PersonalLink>
|
||||
): void {
|
||||
const item = list.find(item => item?.id === id)
|
||||
if (item) {
|
||||
Object.assign(item, { ...data, updatedAt: new Date() })
|
||||
}
|
||||
}
|
||||
|
||||
export function getFromPersonalLinkList(
|
||||
list: PersonalLinkLists,
|
||||
id: ID<PersonalLink>
|
||||
): PersonalLink | null | undefined {
|
||||
return list.find(item => item?.id === id)
|
||||
}
|
||||
|
||||
export function safelyAccessPersonalLink<T>(
|
||||
link: PersonalLink | null | undefined,
|
||||
accessor: (link: PersonalLink) => T,
|
||||
defaultValue: T
|
||||
): T {
|
||||
return link ? accessor(link) : defaultValue
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { co, CoList, CoMap } from "jazz-tools"
|
||||
import { GlobalTopic } from "./global-topic"
|
||||
import { Topic } from "./master/topic"
|
||||
|
||||
/*
|
||||
* Page, content that user can write to. Similar to Notion/Reflect page. It holds ProseMirror editor content + metadata.
|
||||
@@ -11,7 +11,7 @@ export class PersonalPage extends CoMap {
|
||||
title = co.string
|
||||
slug = co.string
|
||||
content = co.optional.json()
|
||||
topic = co.optional.ref(GlobalTopic)
|
||||
topic = co.optional.ref(Topic)
|
||||
// backlinks = co.optional.ref() // other PersonalPages linking to this page TODO: add, think through how to do it well, efficiently
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user