refacto: look after remanso now

This commit is contained in:
Julien Calixte
2026-02-14 14:40:11 +01:00
parent 4bd79b8f6c
commit 8b921f1adb
8 changed files with 26 additions and 560 deletions

View File

@@ -21,7 +21,7 @@
<router-link
:to="{
name: 'FluxNoteView',
params: { user: 'lite-note', repo: 'getting-started' },
params: { user: 'remanso-space', repo: 'getting-started' },
}"
class="btn"
>Get started</router-link

View File

@@ -1,9 +1,9 @@
import { nanoid } from 'nanoid'
import indexedDb from 'pouchdb-adapter-indexeddb'
import PouchDb from 'pouchdb-browser'
import { nanoid } from "nanoid"
import indexedDb from "pouchdb-adapter-indexeddb"
import PouchDb from "pouchdb-browser"
import { DataType } from './DataType.enum'
import { Model } from './models/Model'
import { DataType } from "./DataType.enum"
import { Model } from "./models/Model"
PouchDb.plugin(indexedDb)
@@ -20,11 +20,11 @@ class Data {
constructor() {
try {
this.locale = new PouchDb('lite-note', {
adapter: 'indexeddb'
this.locale = new PouchDb("remanso", {
adapter: "indexeddb",
})
} catch (error) {
console.warn('data error', error)
console.warn("data error", error)
}
}
@@ -40,7 +40,7 @@ class Data {
}
public async update<DT extends DataType, T extends Model<DT>>(
model: T
model: T,
): Promise<boolean> {
try {
if (!model._id) {
@@ -71,7 +71,7 @@ class Data {
}
const result = await this.locale?.put({
...doc,
_deleted: true
_deleted: true,
})
return result?.ok ?? false
} catch {
@@ -80,7 +80,7 @@ class Data {
}
public async get<DT extends DataType, T extends Model<DT>>(
id: string
id: string,
): Promise<T | null> {
try {
return ((await this.locale?.get(id)) as T) || null
@@ -91,7 +91,7 @@ class Data {
public async getOrCreate<DT extends DataType, T extends Model<DT>>(
id: string,
initialValue: T
initialValue: T,
): Promise<T> {
const element = await this.get<DT, T>(id)
@@ -108,7 +108,7 @@ class Data {
prefix,
includeDocs = true,
includeAttachments = false,
keys = []
keys = [],
}: GetAllParams): Promise<T[]> {
if (!this.locale) {
return []
@@ -118,13 +118,13 @@ class Data {
const response = await this.locale.allDocs({
include_docs: includeDocs,
attachments: includeAttachments,
keys: keys.map((key) => this.generateId(prefix, key))
keys: keys.map((key) => this.generateId(prefix, key)),
})
if (includeDocs) {
return response.rows
.map((row) => {
if ('error' in row) {
if ("error" in row) {
return null
}
@@ -134,7 +134,7 @@ class Data {
} else {
return response.rows
.map((row) => {
if ('error' in row) {
if ("error" in row) {
return null
}
@@ -148,7 +148,7 @@ class Data {
include_docs: includeDocs,
attachments: includeAttachments,
startkey: prefix ? prefix : undefined,
endkey: prefix ? `${prefix}\ufff0` : undefined
endkey: prefix ? `${prefix}\ufff0` : undefined,
})
return response.rows.map((row) => row.doc) as T[]

View File

@@ -20,7 +20,7 @@ export const getUrl = async ({ did, rkey }: { did: string; rkey: string }) => {
await getEndpoint(did),
)
url.searchParams.set("repo", did)
url.searchParams.set("collection", "space.litenote.note")
url.searchParams.set("collection", "space.remanso.note")
url.searchParams.set("rkey", rkey)
return url.toString()

View File

@@ -92,7 +92,7 @@ export const getUserSettingsContent = async (
repo: string,
files: RepoFile[],
): Promise<Omit<UserSettings, "chosenFontFamily"> | null> => {
const configFile = files.find((file) => file.path === ".litenote.json")
const configFile = files.find((file) => file.path === ".remanso.json")
if (!configFile?.sha) {
return null

View File

@@ -10,7 +10,7 @@ window.twttr = (function (d, s, id) {
const js = d.createElement(s)
js.id = id
js.src = 'https://platform.twitter.com/widgets.js'
js.src = "https://platform.twitter.com/widgets.js"
fjs.parentNode.insertBefore(js, fjs)
t._e = []
@@ -19,22 +19,22 @@ window.twttr = (function (d, s, id) {
}
return t
})(document, 'script', 'twitter-lite-note')
})(document, "script", "twitter-remanso")
export const createTweet = (
tweetId: string,
theme: 'light' | 'dark' = 'light'
theme: "light" | "dark" = "light",
) => {
window.twttr.ready(() => {
window.twttr.widgets.createTweet(
tweetId,
document.getElementById(`tweet-${tweetId}`, { theme })
document.getElementById(`tweet-${tweetId}`, { theme }),
)
})
}
export const generateTweets = () => {
const elements = document.querySelectorAll('.markdown-tweet')
const elements = document.querySelectorAll(".markdown-tweet")
elements.forEach((element) => {
createTweet(element.dataset.tweetId)