repo_name string | dataset string | owner string | lang string | func_name string | code string | docstring string | url string | sha string |
|---|---|---|---|---|---|---|---|---|
TickTickSync | github_2023 | thesamim | typescript | Logger.constructor | constructor(logManager: EventEmitter2, module: string, minLevel: string) {
this.logManager = logManager;
this.module = module;
this.minLevel = this.levelToInt(minLevel);
} | /**
* Creates an instance of Logger.
* @param {EventEmitter2} logManager
* @param {string} module
* @param {string} minLevel
* @memberof Logger
*/ | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/utils/logging.ts#L201-L205 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | Logger.levelToInt | private levelToInt(minLevel: string): number {
if (minLevel.toLowerCase() in this.levels) return this.levels[minLevel.toLowerCase()];
else return 99;
} | /**
* Converts a string level (trace/debug/info/warn/error) into a number
*
* @param minLevel
*/ | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/utils/logging.ts#L212-L215 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | Logger.log | public log(logLevel: string, message: string, objects?: any): void {
const level = this.levelToInt(logLevel);
if (level < this.minLevel) return;
const logEntry: LogEntry = {
level: logLevel,
module: this.module,
message,
objects,
trace... | /**
* Central logging method.
* @param logLevel
* @param message
*/ | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/utils/logging.ts#L222-L248 | a094e6542e42ecf8a6a48e537ac94928648a282a |
TickTickSync | github_2023 | thesamim | typescript | Logger.logWithId | public logWithId(logLevel: string, traceId: string, message: string, objects?: any): void {
const level = this.levelToInt(logLevel);
if (level < this.minLevel) return;
const logEntry: LogEntry = {
level: logLevel,
module: this.module,
message,
obj... | /**
* Central logging method with a trace ID to track calls between modules/components.
* @param logLevel
* @param message
*/ | https://github.com/thesamim/TickTickSync/blob/a094e6542e42ecf8a6a48e537ac94928648a282a/src/utils/logging.ts#L271-L284 | a094e6542e42ecf8a6a48e537ac94928648a282a |
drizzle-dbml-generator | github_2023 | L-Mario564 | typescript | DBML.escapeSpaces | public escapeSpaces(str: string) {
this.built += /\W/.test(str) || /^[0-9_]/.test(str) ? `"${str}"` : str;
return this;
} | /**
* Escapes characters that aren't allowed in DBML surrounding the input with double quotes
*/ | https://github.com/L-Mario564/drizzle-dbml-generator/blob/45de8330f8bb70dc8cf081034cebdf5f4563cac7/src/dbml.ts#L20-L23 | 45de8330f8bb70dc8cf081034cebdf5f4563cac7 |
sveltekit-view-transition | github_2023 | paoloricciuti | typescript | generateUsers | const generateUsers = (count: number): User[] => {
const users: User[] = [];
for (let i = 1; i <= count; i++) {
const sex = faker.datatype.boolean() ? 'female' : 'male';
users.push({
id: i,
username: faker.internet.userName(),
full_name: faker.person.fullName({
sex
}),
profile_picture_url: `htt... | // Generate fake user data | https://github.com/paoloricciuti/sveltekit-view-transition/blob/014ec4aa337189fef59d222f16954f63dcc2328a/examples/sveltegram/src/lib/fake-data.ts#L40-L56 | 014ec4aa337189fef59d222f16954f63dcc2328a |
sveltekit-view-transition | github_2023 | paoloricciuti | typescript | generatePhotos | const generatePhotos = (count: number): Photo[] => {
const photos: Photo[] = [];
for (let i = 1; i <= count; i++) {
const randomUserId = faker.number.int({ min: 1, max: users.length });
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const user = users.find((user) => user.id === randomUserI... | // Generate fake photos | https://github.com/paoloricciuti/sveltekit-view-transition/blob/014ec4aa337189fef59d222f16954f63dcc2328a/examples/sveltegram/src/lib/fake-data.ts#L59-L74 | 014ec4aa337189fef59d222f16954f63dcc2328a |
sveltekit-view-transition | github_2023 | paoloricciuti | typescript | generateComments | const generateComments = (count: number, users: User[]): Comment[] => {
const comments: Comment[] = [];
for (let i = 1; i <= count; i++) {
const randomUserId = faker.number.int({ min: 1, max: users.length });
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const user = users.find((user) => ... | // Generate fake comments | https://github.com/paoloricciuti/sveltekit-view-transition/blob/014ec4aa337189fef59d222f16954f63dcc2328a/examples/sveltegram/src/lib/fake-data.ts#L77-L92 | 014ec4aa337189fef59d222f16954f63dcc2328a |
sveltekit-view-transition | github_2023 | paoloricciuti | typescript | generateStories | const generateStories = (count: number, users: User[]) => {
const stories: Story[] = [];
for (let i = 1; i <= count; i++) {
const randomUserId = faker.number.int({ min: 1, max: users.length });
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
const user = users.find((user) => user.id === ran... | // Generate fake stories | https://github.com/paoloricciuti/sveltekit-view-transition/blob/014ec4aa337189fef59d222f16954f63dcc2328a/examples/sveltegram/src/lib/fake-data.ts#L95-L115 | 014ec4aa337189fef59d222f16954f63dcc2328a |
pcz | github_2023 | primecitizens | typescript | append | const append = (
load: (ptr: number) => number | bigint,
elemSz: number,
refJsArray: heap.Ref<TypedArray>,
offsetInJsArray: number,
goArray: Pointer,
goArrayLen: number
): number => {
const jsArray = A.H.get<TypedArray>(refJsArray);
if (jsArray.length <= offsetInJsArray) return 0;
... | // append go numeric values to js array. | https://github.com/primecitizens/pcz/blob/e00ae90b764455c5da0d49431a5cdd6a9aac5b9c/std/ffi/js/array/ffi_bindings.ts#L18-L39 | e00ae90b764455c5da0d49431a5cdd6a9aac5b9c |
pcz | github_2023 | primecitizens | typescript | copy | const copy = (
store: (ptr: number, val: number | bigint) => void,
elemSz: number,
refJsArray: heap.Ref<TypedArray>,
offsetInJsArray: number,
goArray: Pointer,
goArrayLen: number
): number => {
const jsArray = A.H.get<TypedArray>(refJsArray);
if (jsArray.length <= offsetInJsArray) ret... | // copy js numeric values in array to go array. | https://github.com/primecitizens/pcz/blob/e00ae90b764455c5da0d49431a5cdd6a9aac5b9c/std/ffi/js/array/ffi_bindings.ts#L42-L63 | e00ae90b764455c5da0d49431a5cdd6a9aac5b9c |
pcz | github_2023 | primecitizens | typescript | Heap.take | public take<T>(ref: heap.Ref<T>): T {
const x = this.H[ref];
this.free(ref);
return x;
} | // take is the combination of get() and free(). | https://github.com/primecitizens/pcz/blob/e00ae90b764455c5da0d49431a5cdd6a9aac5b9c/std/ffi/js/bindings/bindgen.ts#L107-L111 | e00ae90b764455c5da0d49431a5cdd6a9aac5b9c |
pcz | github_2023 | primecitizens | typescript | Application.init | public async init(src: Promise<Response>): Promise<WebAssembly.WebAssemblyInstantiatedSource> {
let fn = WebAssembly.instantiateStreaming;
if (!fn) {
fn = async (resp: Response | PromiseLike<Response>, importObject: any) => {
const source = await (await resp).arrayBuffer();
return await We... | // @param src is a Promise<Response>, normally returned by a fetch() call. | https://github.com/primecitizens/pcz/blob/e00ae90b764455c5da0d49431a5cdd6a9aac5b9c/std/ffi/js/bindings/bindgen.ts#L193-L203 | e00ae90b764455c5da0d49431a5cdd6a9aac5b9c |
pcz | github_2023 | primecitizens | typescript | Application.initSync | public initSync(src: BufferSource | string): WebAssembly.WebAssemblyInstantiatedSource {
if (typeof src === "string") {
if (src.startsWith("data:")) {
// data url format is like `data:application/wasm,<base64 encoded string>`
src = src.substring(src.indexOf(","));
}
src = atob(src... | // - data url string (with content base64 encoded) | https://github.com/primecitizens/pcz/blob/e00ae90b764455c5da0d49431a5cdd6a9aac5b9c/std/ffi/js/bindings/bindgen.ts#L211-L232 | e00ae90b764455c5da0d49431a5cdd6a9aac5b9c |
pcz | github_2023 | primecitizens | typescript | Application.run | public run(inst: WebAssembly.Instance): Promise<number> {
if (!this._exited) {
throw new Error("Concurrent run() is not supported, create multiple Applications instead.");
}
this._runid++;
this._exited = false;
this._exitPromise = new Promise((resolve) => {
this._exitResolveFn = resolve... | // } | https://github.com/primecitizens/pcz/blob/e00ae90b764455c5da0d49431a5cdd6a9aac5b9c/std/ffi/js/bindings/bindgen.ts#L282-L320 | e00ae90b764455c5da0d49431a5cdd6a9aac5b9c |
pcz | github_2023 | primecitizens | typescript | importModule | const importModule: ModuleImporter = (module: string, factory: ModuleFactory): void => {
if (this.importObject[module]) {
// TODO: allow unique function imports in the same namespace.
throw new Error(`duplicate module name ${module}`);
}
this.importObject[module] = factory(this);
... | // constants below are used by inserted module imports (see ./@ffi.ts). | https://github.com/primecitizens/pcz/blob/e00ae90b764455c5da0d49431a5cdd6a9aac5b9c/std/ffi/js/bindings/bindgen.ts#L537-L544 | e00ae90b764455c5da0d49431a5cdd6a9aac5b9c |
my-react-native-playground | github_2023 | bufgix | typescript | round | const round = (value: number, precision = 0) => {
"worklet";
const p = Math.pow(10, precision);
return Math.round(value * p) / p;
}; | /**
* reference: https://www.youtube.com/watch?v=xeLdmn3se1I&t=423s thanks to William Candillon <3
*/ | https://github.com/bufgix/my-react-native-playground/blob/586d292b1aeaf7cccdef5d7291e7c85085a2b252/src/components/SolarTimePicker/Maths.ts#L14-L18 | 586d292b1aeaf7cccdef5d7291e7c85085a2b252 |
my-react-native-playground | github_2023 | bufgix | typescript | cuberoot | const cuberoot = (x: number) => {
"worklet";
const y = Math.pow(Math.abs(x), 1 / 3);
return x < 0 ? -y : y;
}; | // https://stackoverflow.com/questions/27176423 | https://github.com/bufgix/my-react-native-playground/blob/586d292b1aeaf7cccdef5d7291e7c85085a2b252/src/components/SolarTimePicker/Maths.ts#L22-L26 | 586d292b1aeaf7cccdef5d7291e7c85085a2b252 |
feeddeck | github_2023 | feeddeck | typescript | main | const main = (args: string[]) => {
if (args.length === 1 && args[0] === 'scheduler') {
log('info', 'Start scheduler...');
runScheduler().then(() => {
Deno.exit(0);
}).catch((err) => {
log('error', 'Scheduler crashed', { error: err.toString() });
Deno.exit(1);
});
} else if (args.le... | /**
* Next to the Supabase Edge functions we also have to create an command which
* can be run inside of a Docker container. This command is used to start the
* scheduler or worker, to refetch the feeds for all user sources.
*/ | https://github.com/feeddeck/feeddeck/blob/50ad24a7bc8d4f9ae06edbe38f14da057d686bae/supabase/functions/_cmd/cmd.ts#L11-L40 | 50ad24a7bc8d4f9ae06edbe38f14da057d686bae |
feeddeck | github_2023 | feeddeck | typescript | sleep | const sleep = (ms: number) => {
return new Promise((resolve) => setTimeout(resolve, ms));
}; | /**
* `sleep` is a helper function which can be used to wait for a specific amount
* of time.
*/ | https://github.com/feeddeck/feeddeck/blob/50ad24a7bc8d4f9ae06edbe38f14da057d686bae/supabase/functions/_cmd/scheduler/scheduler.ts#L60-L62 | 50ad24a7bc8d4f9ae06edbe38f14da057d686bae |
feeddeck | github_2023 | feeddeck | typescript | scheduleSources | const scheduleSources = async (
supabaseClient: SupabaseClient,
redisClient: Redis,
) => {
try {
/**
* The `profileCreatedAt` is used to fetch all user profiles which are newer
* than 7 days. This is used to only fetch users which are having an active
* subscription or which are new to FeedDeck... | /**
* `scheduleSources` fetches all users and their sources from the Supabase
* database and schedules them for the worker.
*/ | https://github.com/feeddeck/feeddeck/blob/50ad24a7bc8d4f9ae06edbe38f14da057d686bae/supabase/functions/_cmd/scheduler/scheduler.ts#L68-L200 | 50ad24a7bc8d4f9ae06edbe38f14da057d686bae |
feeddeck | github_2023 | feeddeck | typescript | isBoard | const isBoard = (board: string): boolean => {
const boards = [
'a',
'c',
'w',
'm',
'cgl',
'cm',
'f',
'n',
'jp',
'vt',
'v',
'vg',
'vm',
'vmg',
'vp',
'vr',
'vrpg',
'vst',
'co',
'g',
'tv',
'k',
'o',
'an',
'tg',
'sp',
... | /**
* `isBoard` checks if the provided `board` is a valid 4chan board.
* The list of boards must be synced with the list of boards in the
* `add_source_fourchan.dart` file in the Flutter app.
*/ | https://github.com/feeddeck/feeddeck/blob/50ad24a7bc8d4f9ae06edbe38f14da057d686bae/supabase/functions/_shared/feed/fourchan.ts#L17-L98 | 50ad24a7bc8d4f9ae06edbe38f14da057d686bae |
feeddeck | github_2023 | feeddeck | typescript | skipEntry | const skipEntry = (
index: number,
entry: FeedEntry,
sourceUpdatedAt: number,
): boolean => {
if (index === 50) {
return true;
}
if (
!entry.title?.value ||
(entry.links.length === 0 || !entry.links[0].href) ||
!entry.published
) {
return true;
}
if (
entry.published &&
M... | /**
* `skipEntry` is used to determin if an entry should be skipped or not. When a
* entry in the RSS feed is skipped it will not be added to the database. An
* entry will be skipped when
* - it is not within the first 50 entries of the feed, because we only keep the
* last 50 items of each source in our delete ... | https://github.com/feeddeck/feeddeck/blob/50ad24a7bc8d4f9ae06edbe38f14da057d686bae/supabase/functions/_shared/feed/fourchan.ts#L232-L257 | 50ad24a7bc8d4f9ae06edbe38f14da057d686bae |
feeddeck | github_2023 | feeddeck | typescript | generateSourceId | const generateSourceId = async (
userId: string,
columnId: string,
link: string,
): Promise<string> => {
return `fourchan-${userId}-${columnId}-${await utils.md5(link)}`;
}; | /**
* `generateSourceId` generates a unique source id based on the user id, column
* id and the link of the RSS feed. We use the MD5 algorithm for the link to
* generate the id.
*/ | https://github.com/feeddeck/feeddeck/blob/50ad24a7bc8d4f9ae06edbe38f14da057d686bae/supabase/functions/_shared/feed/fourchan.ts#L264-L270 | 50ad24a7bc8d4f9ae06edbe38f14da057d686bae |
feeddeck | github_2023 | feeddeck | typescript | generateItemId | const generateItemId = async (
sourceId: string,
identifier: string,
): Promise<string> => {
return `${sourceId}-${await utils.md5(identifier)}`;
}; | /**
* `generateItemId` generates a unique item id based on the source id and the
* identifier of the item. We use the MD5 algorithm for the identifier, which
* can be the link of the item or the id of the item.
*/ | https://github.com/feeddeck/feeddeck/blob/50ad24a7bc8d4f9ae06edbe38f14da057d686bae/supabase/functions/_shared/feed/fourchan.ts#L277-L282 | 50ad24a7bc8d4f9ae06edbe38f14da057d686bae |
feeddeck | github_2023 | feeddeck | typescript | getItemDescription | const getItemDescription = (entry: FeedEntry): string | undefined => {
if (entry.description?.value) {
return unescape(entry.description?.value);
}
return undefined;
}; | /**
* `getItemDescription` returns the description of an item based on the provided
* description.
*/ | https://github.com/feeddeck/feeddeck/blob/50ad24a7bc8d4f9ae06edbe38f14da057d686bae/supabase/functions/_shared/feed/fourchan.ts#L288-L294 | 50ad24a7bc8d4f9ae06edbe38f14da057d686bae |
feeddeck | github_2023 | feeddeck | typescript | getMedia | const getMedia = (entry: FeedEntry): string | undefined => {
if (entry.description?.value) {
const matches = /<img[^>]+\bsrc=["']([^"']+)["']/.exec(
unescape(entry.description.value),
);
if (
matches && matches.length == 2 &&
(matches[1].startsWith('https://') || matches[1].startsWith('h... | /**
* `getMedia` returns a media url for the provided feed `entry` (item). To get
* the media we check if the description of the entry contains an image.
*/ | https://github.com/feeddeck/feeddeck/blob/50ad24a7bc8d4f9ae06edbe38f14da057d686bae/supabase/functions/_shared/feed/fourchan.ts#L300-L315 | 50ad24a7bc8d4f9ae06edbe38f14da057d686bae |
feeddeck | github_2023 | feeddeck | typescript | request | const request = async (
url: string,
options: { token: string; params?: Record<string, string> },
) => {
const res = await utils.fetchWithTimeout(
`https://api.github.com${url}${
options.params ? `?${new URLSearchParams(options.params).toString()}` : ''
}`,
{
method: 'GET',
headers: ... | /**
* `request` is a helper function to make a request to the GitHub API.
*/ | https://github.com/feeddeck/feeddeck/blob/50ad24a7bc8d4f9ae06edbe38f14da057d686bae/supabase/functions/_shared/feed/github.ts#L375-L400 | 50ad24a7bc8d4f9ae06edbe38f14da057d686bae |
feeddeck | github_2023 | feeddeck | typescript | getLinkFromApiUrl | const getLinkFromApiUrl = (url?: string): string => {
if (!url) {
return 'https://github.com/notifications';
}
if (/^https:\/\/api.github.com\/repos\/.*\/.*\/pulls\/\d+$/.test(url)) {
const n = url.lastIndexOf('pulls');
url = url.slice(0, n) + url.slice(n).replace('pulls', 'pull');
}
return `htt... | /**
* `getLinkFromApiUrl` returns a link which can be clicked by a user based on
* the given GitHub API url. If there is no url given we return the default
* GitHub notifications link.
*/ | https://github.com/feeddeck/feeddeck/blob/50ad24a7bc8d4f9ae06edbe38f14da057d686bae/supabase/functions/_shared/feed/github.ts#L407-L420 | 50ad24a7bc8d4f9ae06edbe38f14da057d686bae |
feeddeck | github_2023 | feeddeck | typescript | formatDescription | const formatDescription = (notification: any): string | undefined => {
switch (notification.reason) {
case 'assign':
return 'You were assigned to the issue.';
case 'author':
return 'You created the thread.';
case 'comment':
return 'You commented on the thread.';
case 'ci_activity':
... | /**
* `formatDescription` formats the description for a notification based on the
* notification reason.
* See: https://docs.github.com/en/rest/activity/notifications?apiVersion=2022-11-28#about-notification-reasons
*/ | https://github.com/feeddeck/feeddeck/blob/50ad24a7bc8d4f9ae06edbe38f14da057d686bae/supabase/functions/_shared/feed/github.ts#L428-L457 | 50ad24a7bc8d4f9ae06edbe38f14da057d686bae |
feeddeck | github_2023 | feeddeck | typescript | formatEvent | const formatEvent = (
// deno-lint-ignore no-explicit-any
event: any,
): {
title: string | undefined;
link: string | undefined;
description: string | undefined;
} | undefined => {
switch (event.type) {
case 'CommitCommentEvent':
if (event.payload?.comment?.html_url) {
return {
ti... | /**
* `formatEvent` formats the given event by returning a proper title, link and
* description for a item as we save it in our database. If the event type is
* not supported or a required field is missing we return an error.
*/ | https://github.com/feeddeck/feeddeck/blob/50ad24a7bc8d4f9ae06edbe38f14da057d686bae/supabase/functions/_shared/feed/github.ts#L464-L805 | 50ad24a7bc8d4f9ae06edbe38f14da057d686bae |
feeddeck | github_2023 | feeddeck | typescript | skipEntry | const skipEntry = (
index: number,
entry: FeedEntry,
sourceUpdatedAt: number,
): boolean => {
if (index === 50) {
return true;
}
if (
!entry.title?.value ||
(entry.links.length === 0 || !entry.links[0].href) || !entry.published
) {
return true;
}
if (Math.floor(entry.published.getTim... | /**
* `skipEntry` is used to determin if an entry should be skipped or not. When a
* entry in the RSS feed is skipped it will not be added to the database. An
* entry will be skipped when
* - it is not within the first 50 entries of the feed, because we only keep the
* last 50 items of each source in our delete ... | https://github.com/feeddeck/feeddeck/blob/50ad24a7bc8d4f9ae06edbe38f14da057d686bae/supabase/functions/_shared/feed/googlenews.ts#L148-L169 | 50ad24a7bc8d4f9ae06edbe38f14da057d686bae |
feeddeck | github_2023 | feeddeck | typescript | generateSourceId | const generateSourceId = async (
userId: string,
columnId: string,
link: string,
): Promise<string> => {
return `googlenews-${userId}-${columnId}-${await utils.md5(link)}`;
}; | /**
* `generateSourceId` generates a unique source id based on the user id, column
* id and the link of the RSS feed. We use the MD5 algorithm for the link to
* generate the id.
*/ | https://github.com/feeddeck/feeddeck/blob/50ad24a7bc8d4f9ae06edbe38f14da057d686bae/supabase/functions/_shared/feed/googlenews.ts#L176-L182 | 50ad24a7bc8d4f9ae06edbe38f14da057d686bae |
feeddeck | github_2023 | feeddeck | typescript | generateItemId | const generateItemId = async (
sourceId: string,
identifier: string,
): Promise<string> => {
return `${sourceId}-${await utils.md5(identifier)}`;
}; | /**
* `generateItemId` generates a unique item id based on the source id and the
* identifier of the item. We use the MD5 algorithm for the identifier, which
* can be the link of the item or the id of the item.
*/ | https://github.com/feeddeck/feeddeck/blob/50ad24a7bc8d4f9ae06edbe38f14da057d686bae/supabase/functions/_shared/feed/googlenews.ts#L189-L194 | 50ad24a7bc8d4f9ae06edbe38f14da057d686bae |
feeddeck | github_2023 | feeddeck | typescript | getMedia | const getMedia = async (
redisClient: Redis,
entry: FeedEntry,
): Promise<string | undefined> => {
try {
if (entry.source?.url) {
const cacheKey = `scraper-googlenews-${entry.source?.url}`;
const cachedMediaURL = await redisClient.get(cacheKey);
if (cachedMediaURL) {
return cachedMe... | /**
* `getMedia` returns the icon of the source if it exists. The icon can then be
* used within the `item.media` field. If we are not able to get an icon for the
* source we return `undefined`.
*
* To get the item we have to use the `getFavicon` function against the
* `source.url` of the `entry`. Since this func... | https://github.com/feeddeck/feeddeck/blob/50ad24a7bc8d4f9ae06edbe38f14da057d686bae/supabase/functions/_shared/feed/googlenews.ts#L206-L230 | 50ad24a7bc8d4f9ae06edbe38f14da057d686bae |
feeddeck | github_2023 | feeddeck | typescript | skipEntry | const skipEntry = (
index: number,
entry: FeedEntry,
sourceUpdatedAt: number,
): boolean => {
if (index === 50) {
return true;
}
if (
!entry.id || !entry.title?.value ||
(entry.links.length === 0 || !entry.links[0].href) || !entry.published
) {
return true;
}
if (Math.floor(entry.pub... | /**
* `skipEntry` is used to determin if an entry should be skipped or not. When a
* entry in the RSS feed is skipped it will not be added to the database. An
* entry will be skipped when
* - it is not within the first 50 entries of the feed, because we only keep the
* last 50 items of each source in our delete ... | https://github.com/feeddeck/feeddeck/blob/50ad24a7bc8d4f9ae06edbe38f14da057d686bae/supabase/functions/_shared/feed/lemmy.ts#L227-L248 | 50ad24a7bc8d4f9ae06edbe38f14da057d686bae |
feeddeck | github_2023 | feeddeck | typescript | generateSourceId | const generateSourceId = async (
userId: string,
columnId: string,
link: string,
): Promise<string> => {
return `lemmy-${userId}-${columnId}-${await utils.md5(link)}`;
}; | /**
* `generateSourceId` generates a unique source id based on the user id, column
* id and the link of the RSS feed. We use the MD5 algorithm for the link to
* generate the id.
*/ | https://github.com/feeddeck/feeddeck/blob/50ad24a7bc8d4f9ae06edbe38f14da057d686bae/supabase/functions/_shared/feed/lemmy.ts#L255-L261 | 50ad24a7bc8d4f9ae06edbe38f14da057d686bae |
feeddeck | github_2023 | feeddeck | typescript | generateItemId | const generateItemId = async (
sourceId: string,
identifier: string,
): Promise<string> => {
return `${sourceId}-${await utils.md5(identifier)}`;
}; | /**
* `generateItemId` generates a unique item id based on the source id and the
* identifier of the item. We use the MD5 algorithm for the identifier, which
* can be the link of the item or the id of the item.
*/ | https://github.com/feeddeck/feeddeck/blob/50ad24a7bc8d4f9ae06edbe38f14da057d686bae/supabase/functions/_shared/feed/lemmy.ts#L268-L273 | 50ad24a7bc8d4f9ae06edbe38f14da057d686bae |
feeddeck | github_2023 | feeddeck | typescript | getDescription | const getDescription = (entry: FeedEntry): string | undefined => {
if (entry.description?.value) {
return unescape(entry.description.value);
}
return undefined;
}; | /**
* `getDescription` returns the description for a feed entry. If the entry does
* not contain a description we return `undefined`.
*/ | https://github.com/feeddeck/feeddeck/blob/50ad24a7bc8d4f9ae06edbe38f14da057d686bae/supabase/functions/_shared/feed/lemmy.ts#L279-L285 | 50ad24a7bc8d4f9ae06edbe38f14da057d686bae |
feeddeck | github_2023 | feeddeck | typescript | getMedia | const getMedia = (entry: FeedEntry): string | undefined => {
if (entry.links && entry.links.length > 0 && entry.links[0].href) {
const parsedUrl = new URL(entry.links[0].href);
if (
/**
* Images
*/
parsedUrl.pathname.endsWith('.jpg') ||
parsedUrl.pathname.endsWith('.jpeg') ||
... | /**
* `getMedia` returns the media for a feed entry. If the link of an entry ends
* with a image or video extension it is considered as media file. This is not
* always the case, since the link could also be a link to a website which is
* then not used as media.
*/ | https://github.com/feeddeck/feeddeck/blob/50ad24a7bc8d4f9ae06edbe38f14da057d686bae/supabase/functions/_shared/feed/lemmy.ts#L293-L325 | 50ad24a7bc8d4f9ae06edbe38f14da057d686bae |
feeddeck | github_2023 | feeddeck | typescript | skipEntry | const skipEntry = (
index: number,
entry: FeedEntry,
sourceUpdatedAt: number,
): boolean => {
if (index === 50) {
return true;
}
if ((entry.links.length === 0 || !entry.links[0].href) || !entry.published) {
return true;
}
if (Math.floor(entry.published.getTime() / 1000) <= (sourceUpdatedAt - 1... | /**
* `skipEntry` is used to determin if an entry should be skipped or not. When a
* entry in the RSS feed is skipped it will not be added to the database. An
* entry will be skipped when
* - it is not within the first 50 entries of the feed, because we only keep the
* last 50 items of each source in our delete ... | https://github.com/feeddeck/feeddeck/blob/50ad24a7bc8d4f9ae06edbe38f14da057d686bae/supabase/functions/_shared/feed/mastodon.ts#L161-L179 | 50ad24a7bc8d4f9ae06edbe38f14da057d686bae |
feeddeck | github_2023 | feeddeck | typescript | generateSourceId | const generateSourceId = async (
userId: string,
columnId: string,
link: string,
): Promise<string> => {
return `mastodon-${userId}-${columnId}-${await utils.md5(link)}`;
}; | /**
* `generateSourceId` generates a unique source id based on the user id, column
* id and the link of the RSS feed. We use the MD5 algorithm for the link to
* generate the id.
*/ | https://github.com/feeddeck/feeddeck/blob/50ad24a7bc8d4f9ae06edbe38f14da057d686bae/supabase/functions/_shared/feed/mastodon.ts#L186-L192 | 50ad24a7bc8d4f9ae06edbe38f14da057d686bae |
feeddeck | github_2023 | feeddeck | typescript | generateItemId | const generateItemId = async (
sourceId: string,
identifier: string,
): Promise<string> => {
return `${sourceId}-${await utils.md5(identifier)}`;
}; | /**
* `generateItemId` generates a unique item id based on the source id and the
* identifier of the item. We use the MD5 algorithm for the identifier, which
* can be the link of the item or the id of the item.
*/ | https://github.com/feeddeck/feeddeck/blob/50ad24a7bc8d4f9ae06edbe38f14da057d686bae/supabase/functions/_shared/feed/mastodon.ts#L199-L204 | 50ad24a7bc8d4f9ae06edbe38f14da057d686bae |
feeddeck | github_2023 | feeddeck | typescript | getMedia | const getMedia = (entry: FeedEntry): string[] | undefined => {
if (entry['media:content']) {
const images = [];
for (const media of entry['media:content']) {
if (media.medium === 'image' && media.url) {
images.push(media.url);
}
}
return images;
}
return undefined;
}; | /**
* `getMedia` returns all images for the provided feed entry from it's
* `media:content` field. If we could not get an image we return `undefined`.
*/ | https://github.com/feeddeck/feeddeck/blob/50ad24a7bc8d4f9ae06edbe38f14da057d686bae/supabase/functions/_shared/feed/mastodon.ts#L210-L223 | 50ad24a7bc8d4f9ae06edbe38f14da057d686bae |
feeddeck | github_2023 | feeddeck | typescript | getVideos | const getVideos = (entry: FeedEntry): string[] | undefined => {
if (entry['media:content']) {
const videos = [];
for (const media of entry['media:content']) {
if (media.medium === 'video' && media.url) {
videos.push(media.url);
}
}
return videos;
}
return undefined;
}; | /**
* `getVideos` returns all videos for the provided feed entry from it's
* `media:content` field. If we could not get a video we return `undefined`.
*/ | https://github.com/feeddeck/feeddeck/blob/50ad24a7bc8d4f9ae06edbe38f14da057d686bae/supabase/functions/_shared/feed/mastodon.ts#L229-L242 | 50ad24a7bc8d4f9ae06edbe38f14da057d686bae |
feeddeck | github_2023 | feeddeck | typescript | getAuthor | const getAuthor = (entry: FeedEntry): string | undefined => {
if (entry.links.length > 0 && entry.links[0].href) {
const urlParts = entry.links[0].href.replace('https://', '').split('/');
if (urlParts.length === 3) {
return `${urlParts[1]}@${urlParts[0]}`;
}
}
return undefined;
}; | /**
* `getAuthor` returns the author for the provided feed entry based on the link
* to the entry.
*/ | https://github.com/feeddeck/feeddeck/blob/50ad24a7bc8d4f9ae06edbe38f14da057d686bae/supabase/functions/_shared/feed/mastodon.ts#L248-L257 | 50ad24a7bc8d4f9ae06edbe38f14da057d686bae |
feeddeck | github_2023 | feeddeck | typescript | skipEntry | const skipEntry = (
index: number,
entry: FeedEntry,
sourceUpdatedAt: number,
): boolean => {
if (index === 50) {
return true;
}
if (
!entry.title?.value ||
(entry.links.length === 0 || !entry.links[0].href) || !entry.published
) {
return true;
}
if (Math.floor(entry.published.getTim... | /**
* `skipEntry` is used to determin if an entry should be skipped or not. When a
* entry in the RSS feed is skipped it will not be added to the database. An
* entry will be skipped when
* - it is not within the first 50 entries of the feed, because we only keep the
* last 50 items of each source in our
* de... | https://github.com/feeddeck/feeddeck/blob/50ad24a7bc8d4f9ae06edbe38f14da057d686bae/supabase/functions/_shared/feed/medium.ts#L179-L236 | 50ad24a7bc8d4f9ae06edbe38f14da057d686bae |
feeddeck | github_2023 | feeddeck | typescript | generateSourceId | const generateSourceId = async (
userId: string,
columnId: string,
link: string,
): Promise<string> => {
return `medium-${userId}-${columnId}-${await utils.md5(link)}`;
}; | /**
* `generateSourceId` generates a unique source id based on the user id, column
* id and the link of the RSS feed. We use the MD5 algorithm for the link to
* generate the id.
*/ | https://github.com/feeddeck/feeddeck/blob/50ad24a7bc8d4f9ae06edbe38f14da057d686bae/supabase/functions/_shared/feed/medium.ts#L243-L249 | 50ad24a7bc8d4f9ae06edbe38f14da057d686bae |
feeddeck | github_2023 | feeddeck | typescript | generateItemId | const generateItemId = async (
sourceId: string,
identifier: string,
): Promise<string> => {
return `${sourceId}-${await utils.md5(identifier)}`;
}; | /**
* `generateItemId` generates a unique item id based on the source id and the
* identifier of the item. We use the MD5 algorithm for the identifier, which
* can be the link of the item or the id of the item.
*/ | https://github.com/feeddeck/feeddeck/blob/50ad24a7bc8d4f9ae06edbe38f14da057d686bae/supabase/functions/_shared/feed/medium.ts#L256-L261 | 50ad24a7bc8d4f9ae06edbe38f14da057d686bae |
feeddeck | github_2023 | feeddeck | typescript | getItemDescription | const getItemDescription = (entry: FeedEntry): string | undefined => {
if (entry.content?.value) {
return unescape(entry.content.value);
}
if (entry.description?.value) {
return unescape(entry.description.value);
}
return undefined;
}; | /**
* `getItemDescription` returns the description of the item. If the item has a
* `content` property we use that as our description, otherwise we use the
* `description` property.
*/ | https://github.com/feeddeck/feeddeck/blob/50ad24a7bc8d4f9ae06edbe38f14da057d686bae/supabase/functions/_shared/feed/medium.ts#L268-L278 | 50ad24a7bc8d4f9ae06edbe38f14da057d686bae |
feeddeck | github_2023 | feeddeck | typescript | getMedia | const getMedia = (entry: FeedEntry): string | undefined => {
if (entry.content?.value) {
const matches = /<img[^>]+\bsrc=["']([^"']+)["']/.exec(
unescape(entry.content.value),
);
if (matches && matches.length == 2 && matches[1].startsWith('https://')) {
return matches[1];
}
}
if (entr... | /**
* `getMedia` returns an image for the provided feed entry from it's content or
* description. If we could not get an image from the content or description we
* return `undefined`.
*/ | https://github.com/feeddeck/feeddeck/blob/50ad24a7bc8d4f9ae06edbe38f14da057d686bae/supabase/functions/_shared/feed/medium.ts#L285-L305 | 50ad24a7bc8d4f9ae06edbe38f14da057d686bae |
feeddeck | github_2023 | feeddeck | typescript | skipEntry | const skipEntry = (
index: number,
entry: FeedEntry,
sourceUpdatedAt: number,
): boolean => {
if (index === 50) {
return true;
}
if (
!entry.title?.value ||
(entry.links.length === 0 || !entry.links[0].href) || !entry.published
) {
return true;
}
if (Math.floor(entry.published.getTim... | /**
* `skipEntry` is used to determin if an entry should be skipped or not. When a
* entry in the RSS feed is skipped it will not be added to the database. An
* entry will be skipped when
* - it is not within the first 50 entries of the feed, because we only keep the
* last 50 items of each source in our delete ... | https://github.com/feeddeck/feeddeck/blob/50ad24a7bc8d4f9ae06edbe38f14da057d686bae/supabase/functions/_shared/feed/nitter.ts#L140-L161 | 50ad24a7bc8d4f9ae06edbe38f14da057d686bae |
feeddeck | github_2023 | feeddeck | typescript | generateSourceId | const generateSourceId = async (
userId: string,
columnId: string,
link: string,
): Promise<string> => {
return `nitter-${userId}-${columnId}-${await utils.md5(link)}`;
}; | /**
* `generateSourceId` generates a unique source id based on the user id, column
* id and the link of the RSS feed. We use the MD5 algorithm for the link to
* generate the id.
*/ | https://github.com/feeddeck/feeddeck/blob/50ad24a7bc8d4f9ae06edbe38f14da057d686bae/supabase/functions/_shared/feed/nitter.ts#L228-L234 | 50ad24a7bc8d4f9ae06edbe38f14da057d686bae |
feeddeck | github_2023 | feeddeck | typescript | generateItemId | const generateItemId = async (
sourceId: string,
identifier: string,
): Promise<string> => {
return `${sourceId}-${await utils.md5(identifier)}`;
}; | /**
* `generateItemId` generates a unique item id based on the source id and the
* identifier of the item. We use the MD5 algorithm for the identifier, which
* can be the link of the item or the id of the item.
*/ | https://github.com/feeddeck/feeddeck/blob/50ad24a7bc8d4f9ae06edbe38f14da057d686bae/supabase/functions/_shared/feed/nitter.ts#L240-L245 | 50ad24a7bc8d4f9ae06edbe38f14da057d686bae |
feeddeck | github_2023 | feeddeck | typescript | getMedia | const getMedia = (entry: FeedEntry): string[] | undefined => {
const images = [];
if (entry.description?.value) {
const re = /<img[^>]+\bsrc=["']([^"']+)["']/g;
let matches;
do {
matches = re.exec(unescape(entry.description.value));
if (
matches && matches.length == 2
) {
... | /**
* `getMedia` returns an image for the provided feed entry from it's
* description. If we could not get an image from the description we return
* `undefined`.
*/ | https://github.com/feeddeck/feeddeck/blob/50ad24a7bc8d4f9ae06edbe38f14da057d686bae/supabase/functions/_shared/feed/nitter.ts#L252-L274 | 50ad24a7bc8d4f9ae06edbe38f14da057d686bae |
feeddeck | github_2023 | feeddeck | typescript | replaceDomain | const replaceDomain = (url: string): string => {
let finalUrl = url;
for (const pinterestUrl of pinterestUrls) {
if (pinterestUrl !== 'pinterest.com') {
finalUrl = finalUrl.replace(pinterestUrl, 'pinterest.com');
}
}
return finalUrl;
}; | /**
* `replaceDomain` replaces the domain of the Pinterest url with
* `pinterest.com`.
*/ | https://github.com/feeddeck/feeddeck/blob/50ad24a7bc8d4f9ae06edbe38f14da057d686bae/supabase/functions/_shared/feed/pinterest.ts#L207-L216 | 50ad24a7bc8d4f9ae06edbe38f14da057d686bae |
feeddeck | github_2023 | feeddeck | typescript | skipEntry | const skipEntry = (
index: number,
entry: FeedEntry,
sourceUpdatedAt: number,
): boolean => {
if (index === 50) {
return true;
}
if ((entry.links.length === 0 || !entry.links[0].href) || !entry.published) {
return true;
}
if (Math.floor(entry.published.getTime() / 1000) <= (sourceUpdatedAt - 1... | /**
* `skipEntry` is used to determin if an entry should be skipped or not. When a
* entry in the RSS feed is skipped it will not be added to the database. An
* entry will be skipped when
* - it is not within the first 50 entries of the feed, because we only keep the
* last 50 items of each source in our
* de... | https://github.com/feeddeck/feeddeck/blob/50ad24a7bc8d4f9ae06edbe38f14da057d686bae/supabase/functions/_shared/feed/pinterest.ts#L229-L247 | 50ad24a7bc8d4f9ae06edbe38f14da057d686bae |
feeddeck | github_2023 | feeddeck | typescript | generateSourceId | const generateSourceId = async (
userId: string,
columnId: string,
link: string,
): Promise<string> => {
return `pinterest-${userId}-${columnId}-${await utils.md5(link)}`;
}; | /**
* `generateSourceId` generates a unique source id based on the user id, column
* id and the link of the RSS feed. We use the MD5 algorithm for the link to
* generate the id.
*/ | https://github.com/feeddeck/feeddeck/blob/50ad24a7bc8d4f9ae06edbe38f14da057d686bae/supabase/functions/_shared/feed/pinterest.ts#L254-L260 | 50ad24a7bc8d4f9ae06edbe38f14da057d686bae |
feeddeck | github_2023 | feeddeck | typescript | generateItemId | const generateItemId = async (
sourceId: string,
identifier: string,
): Promise<string> => {
return `${sourceId}-${await utils.md5(identifier)}`;
}; | /**
* `generateItemId` generates a unique item id based on the source id and the
* identifier of the item. We use the MD5 algorithm for the identifier, which
* can be the link of the item or the id of the item.
*/ | https://github.com/feeddeck/feeddeck/blob/50ad24a7bc8d4f9ae06edbe38f14da057d686bae/supabase/functions/_shared/feed/pinterest.ts#L267-L272 | 50ad24a7bc8d4f9ae06edbe38f14da057d686bae |
feeddeck | github_2023 | feeddeck | typescript | getItemDescription | const getItemDescription = (entry: FeedEntry): string | undefined => {
if (entry.description?.value) {
return unescape(entry.description.value);
}
return undefined;
}; | /**
* `getItemDescription` returns the description of the item. If the item has a
* `content` property we use that as our description, otherwise we use the
* `description` property.
*/ | https://github.com/feeddeck/feeddeck/blob/50ad24a7bc8d4f9ae06edbe38f14da057d686bae/supabase/functions/_shared/feed/pinterest.ts#L279-L285 | 50ad24a7bc8d4f9ae06edbe38f14da057d686bae |
feeddeck | github_2023 | feeddeck | typescript | getMedia | const getMedia = (entry: FeedEntry): string | undefined => {
if (entry.description?.value) {
const matches = /<img[^>]+\bsrc=["']([^"']+)["']/.exec(
unescape(entry.description.value),
);
if (matches && matches.length == 2 && matches[1].startsWith('https://')) {
return matches[1];
}
}
... | /**
* `getMedia` returns an image for the provided feed entry from it's content or
* description. If we could not get an image from the content or description we
* return `undefined`.
*/ | https://github.com/feeddeck/feeddeck/blob/50ad24a7bc8d4f9ae06edbe38f14da057d686bae/supabase/functions/_shared/feed/pinterest.ts#L292-L303 | 50ad24a7bc8d4f9ae06edbe38f14da057d686bae |
feeddeck | github_2023 | feeddeck | typescript | skipEntry | const skipEntry = (
index: number,
entry: FeedEntry,
sourceUpdatedAt: number,
): boolean => {
if (index === 50) {
return true;
}
if (!entry.title?.value || !entry.published) {
return true;
}
if (Math.floor(entry.published.getTime() / 1000) <= (sourceUpdatedAt - 10)) {
return true;
}
r... | /**
* `skipEntry` is used to determin if an entry should be skipped or not. When a
* entry in the RSS feed is skipped it will not be added to the database. An
* entry will be skipped when
* - it is not within the first 50 entries of the feed, because we only keep the
* last 50 items of each source in our delete ... | https://github.com/feeddeck/feeddeck/blob/50ad24a7bc8d4f9ae06edbe38f14da057d686bae/supabase/functions/_shared/feed/podcast.ts#L144-L162 | 50ad24a7bc8d4f9ae06edbe38f14da057d686bae |
feeddeck | github_2023 | feeddeck | typescript | getRSSFeedFromApplePodcast | const getRSSFeedFromApplePodcast = async (id: string): Promise<string> => {
const resp = await utils.fetchWithTimeout(
`https://itunes.apple.com/lookup?id=${id}&entity=podcast`,
{ method: 'get' },
5000,
);
const podcast = await resp.json();
if (
!podcast || !podcast.results || podcast.results.l... | /**
* `getRSSFeedFromApplePodcast` returns the RSS feed url for the provided Apple
* Podcast id.
*/ | https://github.com/feeddeck/feeddeck/blob/50ad24a7bc8d4f9ae06edbe38f14da057d686bae/supabase/functions/_shared/feed/podcast.ts#L168-L184 | 50ad24a7bc8d4f9ae06edbe38f14da057d686bae |
feeddeck | github_2023 | feeddeck | typescript | generateSourceId | const generateSourceId = async (
userId: string,
columnId: string,
link: string,
): Promise<string> => {
return `podcast-${userId}-${columnId}-${await utils.md5(link)}`;
}; | /**
* `generateSourceId` generates a unique source id based on the user id, column
* id and the link of the RSS feed. We use the MD5 algorithm for the link to
* generate the id.
*/ | https://github.com/feeddeck/feeddeck/blob/50ad24a7bc8d4f9ae06edbe38f14da057d686bae/supabase/functions/_shared/feed/podcast.ts#L191-L197 | 50ad24a7bc8d4f9ae06edbe38f14da057d686bae |
feeddeck | github_2023 | feeddeck | typescript | generateItemId | const generateItemId = async (
sourceId: string,
identifier: string,
): Promise<string> => {
return `${sourceId}-${await utils.md5(identifier)}`;
}; | /**
* `generateItemId` generates a unique item id based on the source id and the
* identifier of the item. We use the MD5 algorithm for the identifier, which
* can be the link of the item or the id of the item.
*/ | https://github.com/feeddeck/feeddeck/blob/50ad24a7bc8d4f9ae06edbe38f14da057d686bae/supabase/functions/_shared/feed/podcast.ts#L204-L209 | 50ad24a7bc8d4f9ae06edbe38f14da057d686bae |
feeddeck | github_2023 | feeddeck | typescript | getMedia | const getMedia = (entry: FeedEntry): string | undefined => {
if (entry.attachments && entry.attachments.length > 0) {
for (const attachment of entry.attachments) {
if (attachment.url) {
return attachment.url;
}
}
}
return undefined;
}; | /**
* `getMedia` returns the mp3 file for the podcast episode. For podcast rss
* feeds the file should be available in the attachments field.
*/ | https://github.com/feeddeck/feeddeck/blob/50ad24a7bc8d4f9ae06edbe38f14da057d686bae/supabase/functions/_shared/feed/podcast.ts#L215-L225 | 50ad24a7bc8d4f9ae06edbe38f14da057d686bae |
feeddeck | github_2023 | feeddeck | typescript | skipEntry | const skipEntry = (
index: number,
entry: FeedEntry,
sourceUpdatedAt: number,
): boolean => {
if (index === 50) {
return true;
}
if (
!entry.title?.value ||
(entry.links.length === 0 || !entry.links[0].href) || !entry.published
) {
return true;
}
if (Math.floor(entry.published.getTim... | /**
* `skipEntry` is used to determin if an entry should be skipped or not. When a
* entry in the RSS feed is skipped it will not be added to the database. An
* entry will be skipped when
* - it is not within the first 50 entries of the feed, because we only keep the
* last 50 items of each source in our delete ... | https://github.com/feeddeck/feeddeck/blob/50ad24a7bc8d4f9ae06edbe38f14da057d686bae/supabase/functions/_shared/feed/reddit.ts#L132-L153 | 50ad24a7bc8d4f9ae06edbe38f14da057d686bae |
feeddeck | github_2023 | feeddeck | typescript | generateSourceId | const generateSourceId = async (
userId: string,
columnId: string,
link: string,
): Promise<string> => {
return `reddit-${userId}-${columnId}-${await utils.md5(link)}`;
}; | /**
* `generateSourceId` generates a unique source id based on the user id, column
* id and the link of the RSS feed. We use the MD5 algorithm for the link to
* generate the id.
*/ | https://github.com/feeddeck/feeddeck/blob/50ad24a7bc8d4f9ae06edbe38f14da057d686bae/supabase/functions/_shared/feed/reddit.ts#L160-L166 | 50ad24a7bc8d4f9ae06edbe38f14da057d686bae |
feeddeck | github_2023 | feeddeck | typescript | generateItemId | const generateItemId = async (
sourceId: string,
identifier: string,
): Promise<string> => {
return `${sourceId}-${await utils.md5(identifier)}`;
}; | /**
* `generateItemId` generates a unique item id based on the source id and the
* identifier of the item. We use the MD5 algorithm for the identifier, which
* can be the link of the item or the id of the item.
*/ | https://github.com/feeddeck/feeddeck/blob/50ad24a7bc8d4f9ae06edbe38f14da057d686bae/supabase/functions/_shared/feed/reddit.ts#L173-L178 | 50ad24a7bc8d4f9ae06edbe38f14da057d686bae |
feeddeck | github_2023 | feeddeck | typescript | getDescription | const getDescription = (entry: FeedEntry): string | undefined => {
if (entry.content?.value) {
const content = unescape(entry.content.value);
return content.replaceAll('<table>', '').replaceAll('<tr>', '').replaceAll(
'<td>',
'',
).replaceAll('</table>', '').replaceAll('</tr>', '').replaceAll(... | /**
* `getDescription` returns the description for a feed entry. If the entry does
* not contain a description we return `undefined`. Some Reddit feed items are
* containing a table, which we have to remove from the description, to improve
* the rendering in the Flutter app.
*/ | https://github.com/feeddeck/feeddeck/blob/50ad24a7bc8d4f9ae06edbe38f14da057d686bae/supabase/functions/_shared/feed/reddit.ts#L186-L199 | 50ad24a7bc8d4f9ae06edbe38f14da057d686bae |
feeddeck | github_2023 | feeddeck | typescript | getMedia | const getMedia = (entry: FeedEntry): string | undefined => {
if (
// deno-lint-ignore no-explicit-any
(entry as any)['media:thumbnail'] && (entry as any)['media:thumbnail'].url
) {
// deno-lint-ignore no-explicit-any
return (entry as any)['media:thumbnail'].url;
}
return undefined;
}; | /**
* `getMedia` returns the media for a feed entry. If the entry does not contain
* a media we return `undefined`. Some Reddit feed items are containing a
* thumbnail, which we can use as media.
*/ | https://github.com/feeddeck/feeddeck/blob/50ad24a7bc8d4f9ae06edbe38f14da057d686bae/supabase/functions/_shared/feed/reddit.ts#L206-L216 | 50ad24a7bc8d4f9ae06edbe38f14da057d686bae |
feeddeck | github_2023 | feeddeck | typescript | getFeed | const getFeed = async (
source: ISource,
feedData: string | undefined,
): Promise<Feed | undefined> => {
try {
const feed = await feedutils.getAndParseFeed(
source.options!.rss!,
source,
feedData,
);
return feed;
} catch (_) {
return undefined;
}
}; | /**
* `getFeed` is a helper function to get a RSS feed for a source. It returns
* the feed or undefined if the request failed or the returned response could
* not be parsed as a feed.
*/ | https://github.com/feeddeck/feeddeck/blob/50ad24a7bc8d4f9ae06edbe38f14da057d686bae/supabase/functions/_shared/feed/rss.ts#L165-L179 | 50ad24a7bc8d4f9ae06edbe38f14da057d686bae |
feeddeck | github_2023 | feeddeck | typescript | getFeedFromWebsite | const getFeedFromWebsite = async (
source: ISource,
): Promise<Feed | undefined> => {
try {
const response = await utils.fetchWithTimeout(
source.options!.rss!,
{ method: 'get' },
5000,
);
const html = await response.text();
const $ = cheerio.load(html);
let rssLink = $('link[... | /**
* `getFeedFromWebsite` is a helper function to get a RSS feed from a website.
* This function can be used to get the RSS feed after the call to `getFeed`
* failed. This could happen when a user provided an url to a website instead of
* a RSS feed.
*
* In the function we are checking if there is a
* `<link re... | https://github.com/feeddeck/feeddeck/blob/50ad24a7bc8d4f9ae06edbe38f14da057d686bae/supabase/functions/_shared/feed/rss.ts#L195-L223 | 50ad24a7bc8d4f9ae06edbe38f14da057d686bae |
feeddeck | github_2023 | feeddeck | typescript | skipEntry | const skipEntry = (
index: number,
entry: FeedEntry,
sourceUpdatedAt: number,
): boolean => {
if (index === 50) {
return true;
}
if (
!entry.title?.value ||
(entry.links.length === 0 || !entry.links[0].href) ||
(!entry.published && !entry.updated && !entry['dc:date'])
) {
return true;... | /**
* `skipEntry` is used to determin if an entry should be skipped or not. When a
* entry in the RSS feed is skipped it will not be added to the database. An
* entry will be skipped when
* - it is not within the first 50 entries of the feed, because we only keep the
* last 50 items of each source in our delete ... | https://github.com/feeddeck/feeddeck/blob/50ad24a7bc8d4f9ae06edbe38f14da057d686bae/supabase/functions/_shared/feed/rss.ts#L235-L270 | 50ad24a7bc8d4f9ae06edbe38f14da057d686bae |
feeddeck | github_2023 | feeddeck | typescript | getDCDateTimestamp | const getDCDateTimestamp = (dcdate: Date | { value: Date }): number => {
if (dcdate instanceof Date) {
return Math.floor(dcdate.getTime() / 1000);
} else {
return Math.floor(dcdate.value.getTime() / 1000);
}
}; | /**
* `getDCDateTimestamp` is a helper function to get the timestamp of a `dc:date`
* tag. The `dc:date` tag can either be a `Date` object or an object with a
* `value` property which is a `Date` object.
*/ | https://github.com/feeddeck/feeddeck/blob/50ad24a7bc8d4f9ae06edbe38f14da057d686bae/supabase/functions/_shared/feed/rss.ts#L277-L283 | 50ad24a7bc8d4f9ae06edbe38f14da057d686bae |
feeddeck | github_2023 | feeddeck | typescript | generateSourceId | const generateSourceId = async (
userId: string,
columnId: string,
link: string,
): Promise<string> => {
return `rss-${userId}-${columnId}-${await utils.md5(link)}`;
}; | /**
* `generateSourceId` generates a unique source id based on the user id, column
* id and the link of the RSS feed. We use the MD5 algorithm for the link to
* generate the id.
*/ | https://github.com/feeddeck/feeddeck/blob/50ad24a7bc8d4f9ae06edbe38f14da057d686bae/supabase/functions/_shared/feed/rss.ts#L290-L296 | 50ad24a7bc8d4f9ae06edbe38f14da057d686bae |
feeddeck | github_2023 | feeddeck | typescript | generateItemId | const generateItemId = async (
sourceId: string,
identifier: string,
): Promise<string> => {
return `${sourceId}-${await utils.md5(identifier)}`;
}; | /**
* `generateItemId` generates a unique item id based on the source id and the
* identifier of the item. We use the MD5 algorithm for the identifier, which
* can be the link of the item or the id of the item.
*/ | https://github.com/feeddeck/feeddeck/blob/50ad24a7bc8d4f9ae06edbe38f14da057d686bae/supabase/functions/_shared/feed/rss.ts#L303-L308 | 50ad24a7bc8d4f9ae06edbe38f14da057d686bae |
feeddeck | github_2023 | feeddeck | typescript | getItemDescription | const getItemDescription = (entry: FeedEntry): string | undefined => {
if (entry.description?.value) {
return unescape(entry.description?.value);
}
if (entry.content?.value) {
return unescape(entry.content?.value);
}
return undefined;
}; | /**
* `getItemDescription` returns the description of an item based on the provided
* description and content. In the first step we try to use the description of
* the items as our description. If that is not available, we try to use the
* content. If that is not available, we return undefined. We also remove all
... | https://github.com/feeddeck/feeddeck/blob/50ad24a7bc8d4f9ae06edbe38f14da057d686bae/supabase/functions/_shared/feed/rss.ts#L317-L327 | 50ad24a7bc8d4f9ae06edbe38f14da057d686bae |
feeddeck | github_2023 | feeddeck | typescript | getMedia | const getMedia = (entry: FeedEntry): string | undefined => {
if (entry['media:content'] && entry['media:content'].length > 0) {
for (const media of entry['media:content']) {
if (
media.medium && media.medium === 'image' && media.url &&
(media.url.startsWith('https://') || media.url.startsWit... | /**
* `getMedia` returns a media url for the provided feed `entry` (item). To get
* the media we check all the different media tags that are available in the
* feed. If we find a media tag with a medium of `image` we return the url of
* that tag. If we don't find any media tags with a medium of `image` we check
* ... | https://github.com/feeddeck/feeddeck/blob/50ad24a7bc8d4f9ae06edbe38f14da057d686bae/supabase/functions/_shared/feed/rss.ts#L338-L418 | 50ad24a7bc8d4f9ae06edbe38f14da057d686bae |
feeddeck | github_2023 | feeddeck | typescript | getVideo | const getVideo = (entry: FeedEntry): string | undefined => {
if (entry.attachments && entry.attachments.length > 0) {
for (const attachment of entry.attachments) {
if (
attachment.mimeType && attachment.mimeType.startsWith('video/') &&
attachment.url &&
(attachment.url.startsWith('ht... | /**
* `getVideo` checks if the attachments of the feed entry contains a video. If
* that is the case we return the url of the video.
*/ | https://github.com/feeddeck/feeddeck/blob/50ad24a7bc8d4f9ae06edbe38f14da057d686bae/supabase/functions/_shared/feed/rss.ts#L424-L439 | 50ad24a7bc8d4f9ae06edbe38f14da057d686bae |
feeddeck | github_2023 | feeddeck | typescript | skipEntry | const skipEntry = (
index: number,
entry: FeedEntry,
sourceUpdatedAt: number,
): boolean => {
if (index === 50) {
return true;
}
if (
!entry.title?.value ||
(entry.links.length === 0 || !entry.links[0].href) || !entry.published
) {
return true;
}
if (Math.floor(entry.published.getTim... | /**
* `skipEntry` is used to determin if an entry should be skipped or not. When a
* entry in the RSS feed is skipped it will not be added to the database. An
* entry will be skipped when
* - it is not within the first 50 entries of the feed, because we only keep the
* last 50 items of each source in our delete ... | https://github.com/feeddeck/feeddeck/blob/50ad24a7bc8d4f9ae06edbe38f14da057d686bae/supabase/functions/_shared/feed/stackoverflow.ts#L108-L129 | 50ad24a7bc8d4f9ae06edbe38f14da057d686bae |
feeddeck | github_2023 | feeddeck | typescript | generateSourceId | const generateSourceId = async (
userId: string,
columnId: string,
link: string,
): Promise<string> => {
return `stackoverflow-${userId}-${columnId}-${await utils.md5(link)}`;
}; | /**
* `generateSourceId` generates a unique source id based on the user id, column
* id and the link of the RSS feed. We use the MD5 algorithm for the link to
* generate the id.
*/ | https://github.com/feeddeck/feeddeck/blob/50ad24a7bc8d4f9ae06edbe38f14da057d686bae/supabase/functions/_shared/feed/stackoverflow.ts#L136-L142 | 50ad24a7bc8d4f9ae06edbe38f14da057d686bae |
feeddeck | github_2023 | feeddeck | typescript | generateItemId | const generateItemId = async (
sourceId: string,
identifier: string,
): Promise<string> => {
return `${sourceId}-${await utils.md5(identifier)}`;
}; | /**
* `generateItemId` generates a unique item id based on the source id and the
* identifier of the item. We use the MD5 algorithm for the identifier, which
* can be the link of the item or the id of the item.
*/ | https://github.com/feeddeck/feeddeck/blob/50ad24a7bc8d4f9ae06edbe38f14da057d686bae/supabase/functions/_shared/feed/stackoverflow.ts#L149-L154 | 50ad24a7bc8d4f9ae06edbe38f14da057d686bae |
feeddeck | github_2023 | feeddeck | typescript | skipEntry | const skipEntry = (
index: number,
entry: FeedEntry,
sourceUpdatedAt: number,
): boolean => {
if (index === 50) {
return true;
}
if (
!entry.title?.value ||
(entry.links.length === 0 || !entry.links[0].href) || !entry.published
) {
return true;
}
if (Math.floor(entry.published.getTim... | /**
* `skipEntry` is used to determin if an entry should be skipped or not. When a
* entry in the RSS feed is skipped it will not be added to the database. An
* entry will be skipped when
* - it is not within the first 50 entries of the feed, because we only keep the
* last 50 items of each source in our delete ... | https://github.com/feeddeck/feeddeck/blob/50ad24a7bc8d4f9ae06edbe38f14da057d686bae/supabase/functions/_shared/feed/tumblr.ts#L124-L145 | 50ad24a7bc8d4f9ae06edbe38f14da057d686bae |
feeddeck | github_2023 | feeddeck | typescript | generateSourceId | const generateSourceId = async (
userId: string,
columnId: string,
link: string,
): Promise<string> => {
return `tumblr-${userId}-${columnId}-${await utils.md5(link)}`;
}; | /**
* `generateSourceId` generates a unique source id based on the user id, column
* id and the link of the RSS feed. We use the MD5 algorithm for the link to
* generate the id.
*/ | https://github.com/feeddeck/feeddeck/blob/50ad24a7bc8d4f9ae06edbe38f14da057d686bae/supabase/functions/_shared/feed/tumblr.ts#L152-L158 | 50ad24a7bc8d4f9ae06edbe38f14da057d686bae |
feeddeck | github_2023 | feeddeck | typescript | generateItemId | const generateItemId = async (
sourceId: string,
identifier: string,
): Promise<string> => {
return `${sourceId}-${await utils.md5(identifier)}`;
}; | /**
* `generateItemId` generates a unique item id based on the source id and the
* identifier of the item. We use the MD5 algorithm for the identifier, which
* can be the link of the item or the id of the item.
*/ | https://github.com/feeddeck/feeddeck/blob/50ad24a7bc8d4f9ae06edbe38f14da057d686bae/supabase/functions/_shared/feed/tumblr.ts#L165-L170 | 50ad24a7bc8d4f9ae06edbe38f14da057d686bae |
feeddeck | github_2023 | feeddeck | typescript | getMedia | const getMedia = (entry: FeedEntry): string | undefined => {
if (entry.description?.value) {
const matches = /<img[^>]+\bsrc=["']([^"']+)["']/.exec(
unescape(entry.description.value),
);
if (matches && matches.length == 2 && matches[1].startsWith('https://')) {
return matches[1];
}
}
... | /**
* `getMedia` returns an image for the provided feed entry from it's
* description. If we could not get an image from the description we return
* `undefined`.
*/ | https://github.com/feeddeck/feeddeck/blob/50ad24a7bc8d4f9ae06edbe38f14da057d686bae/supabase/functions/_shared/feed/tumblr.ts#L177-L188 | 50ad24a7bc8d4f9ae06edbe38f14da057d686bae |
feeddeck | github_2023 | feeddeck | typescript | skipEntry | const skipEntry = (
index: number,
entry: FeedEntry,
sourceUpdatedAt: number,
): boolean => {
if (index === 50) {
return true;
}
if (
!entry.title?.value ||
(entry.links.length === 0 || !entry.links[0].href) || !entry.published
) {
return true;
}
if (Math.floor(entry.published.getTim... | /**
* `skipEntry` is used to determin if an entry should be skipped or not. When a
* entry in the RSS feed is skipped it will not be added to the database. An
* entry will be skipped when
* - it is not within the first 50 entries of the feed, because we only keep the
* last 50 items of each source in our delete ... | https://github.com/feeddeck/feeddeck/blob/50ad24a7bc8d4f9ae06edbe38f14da057d686bae/supabase/functions/_shared/feed/youtube.ts#L178-L199 | 50ad24a7bc8d4f9ae06edbe38f14da057d686bae |
feeddeck | github_2023 | feeddeck | typescript | generateSourceId | const generateSourceId = async (
userId: string,
columnId: string,
link: string,
): Promise<string> => {
return `youtube-${userId}-${columnId}-${await utils.md5(link)}`;
}; | /**
* `generateSourceId` generates a unique source id based on the user id, column
* id and the link of the RSS feed. We use the MD5 algorithm for the link to
* generate the id.
*/ | https://github.com/feeddeck/feeddeck/blob/50ad24a7bc8d4f9ae06edbe38f14da057d686bae/supabase/functions/_shared/feed/youtube.ts#L206-L212 | 50ad24a7bc8d4f9ae06edbe38f14da057d686bae |
feeddeck | github_2023 | feeddeck | typescript | generateItemId | const generateItemId = async (
sourceId: string,
identifier: string,
): Promise<string> => {
return `${sourceId}-${await utils.md5(identifier)}`;
}; | /**
* `generateItemId` generates a unique item id based on the source id and the
* identifier of the item. We use the MD5 algorithm for the identifier, which
* can be the link of the item or the id of the item.
*/ | https://github.com/feeddeck/feeddeck/blob/50ad24a7bc8d4f9ae06edbe38f14da057d686bae/supabase/functions/_shared/feed/youtube.ts#L219-L224 | 50ad24a7bc8d4f9ae06edbe38f14da057d686bae |
feeddeck | github_2023 | feeddeck | typescript | getDescription | const getDescription = (entry: FeedEntry): string | undefined => {
if (entry['media:group'] && entry['media:group']['media:description']) {
return unescape(entry['media:group']['media:description'].value);
}
return undefined;
}; | /**
* `getDescription` returns the description for a feed entry. If the entry does
* not contain a description we return `undefined`.
*/ | https://github.com/feeddeck/feeddeck/blob/50ad24a7bc8d4f9ae06edbe38f14da057d686bae/supabase/functions/_shared/feed/youtube.ts#L230-L236 | 50ad24a7bc8d4f9ae06edbe38f14da057d686bae |
feeddeck | github_2023 | feeddeck | typescript | getMedia | const getMedia = (entry: FeedEntry): string | undefined => {
if (
// deno-lint-ignore no-explicit-any
entry['media:group'] && ((entry['media:group'] as any)['media:thumbnail'])
) {
// deno-lint-ignore no-explicit-any
return (entry['media:group'] as any)['media:thumbnail'].url;
}
return undefine... | /**
* `getMedia` returns the media for a feed entry. If the entry does not contain
* a media we return `undefined`. The media is the thumbnail of the video and
* not the video itself, because the video can be get using the entry link.
*/ | https://github.com/feeddeck/feeddeck/blob/50ad24a7bc8d4f9ae06edbe38f14da057d686bae/supabase/functions/_shared/feed/youtube.ts#L243-L253 | 50ad24a7bc8d4f9ae06edbe38f14da057d686bae |
feeddeck | github_2023 | feeddeck | typescript | getChannelId | const getChannelId = async (url: string): Promise<string | undefined> => {
try {
const response = await utils.fetchWithTimeout(url, { method: 'get' }, 5000);
const html = await response.text();
const match = html.match(
/"https:\/\/www.youtube.com\/feeds\/videos.xml\?channel_id\=(.*?)"/,
);
... | /**
* `getChannelId` returns the channel id based on the given url. For some
* YouTube urls we have to get the complete HTML content of the site and grep
* for the RSS feed link. Based on the RSS link we can then get the channel id.
*/ | https://github.com/feeddeck/feeddeck/blob/50ad24a7bc8d4f9ae06edbe38f14da057d686bae/supabase/functions/_shared/feed/youtube.ts#L260-L274 | 50ad24a7bc8d4f9ae06edbe38f14da057d686bae |
feeddeck | github_2023 | feeddeck | typescript | getChannelIcon | const getChannelIcon = async (
channelId: string,
): Promise<string | undefined> => {
try {
const response = await utils.fetchWithTimeout(
`https://www.googleapis.com/youtube/v3/channels?id=${channelId}&part=id%2Csnippet&maxResults=1&key=${FEEDDECK_SOURCE_YOUTUBE_API_KEY}`,
{ method: 'get' },
... | /**
* `getChannelIcon` returns the icon for a channel with the provided
* `channelId`.
*
* This function only works when a valid API key for the YouTube API was
* provided. If no API key was provided this function will return `undefined`
* and the source will not have an proper icon.
*/ | https://github.com/feeddeck/feeddeck/blob/50ad24a7bc8d4f9ae06edbe38f14da057d686bae/supabase/functions/_shared/feed/youtube.ts#L284-L306 | 50ad24a7bc8d4f9ae06edbe38f14da057d686bae |
feeddeck | github_2023 | feeddeck | typescript | extractFavicons | const extractFavicons = (html: string): string[] => {
const $ = cheerio.load(html);
const hrefs = rels
.map((rel) => {
return $(`link[rel="${rel}"]`)
.map((_, el) => $(el).attr('href'))
.get();
})
.flat();
return hrefs;
}; | /**
* `extractFavicons` extracts all icons from the provided `html` string via
* `cheerio`. It returns a list of links to all the favicons.
*/ | https://github.com/feeddeck/feeddeck/blob/50ad24a7bc8d4f9ae06edbe38f14da057d686bae/supabase/functions/_shared/feed/utils/getFavicon.ts#L77-L88 | 50ad24a7bc8d4f9ae06edbe38f14da057d686bae |
feeddeck | github_2023 | feeddeck | typescript | getFaviconsFrom | const getFaviconsFrom = async (
hrefs: string[],
url?: string,
): Promise<Favicon[]> => {
const favicons = await Promise.all([
...hrefs
.filter((href) => (isRelativeURL(href) && !url ? false : true))
.map((href) =>
getFaviconFrom(
processURL(isRelativeURL(href) ? url + href : hre... | /**
* `getFaviconsFrom` takes a list of links (`hrefs`) and returns a list of
* `Favicon`s. The `url` parameter is required to create an absolute url from
* relative urls in the `hrefs` array. The list of `hrefs` is filtered based on
* our defined paths before they are processed.
*/ | https://github.com/feeddeck/feeddeck/blob/50ad24a7bc8d4f9ae06edbe38f14da057d686bae/supabase/functions/_shared/feed/utils/getFavicon.ts#L96-L115 | 50ad24a7bc8d4f9ae06edbe38f14da057d686bae |
feeddeck | github_2023 | feeddeck | typescript | getFaviconFrom | const getFaviconFrom = async (url: string): Promise<Favicon | undefined> => {
const response = await fetchWithTimeout(url, { method: 'get' }, 1000);
if (!response || !response.ok) return undefined;
const contentType = response.headers.get('content-type') ?? '';
if (!response.ok || !contentType || !contentType.... | /**
* `getFaviconFrom` takes a `url` and returns a `Favicon` if the url returns a
* valid icon. A url is considered as valid if the returned response code is ok
* and if the content type is an image.
*/ | https://github.com/feeddeck/feeddeck/blob/50ad24a7bc8d4f9ae06edbe38f14da057d686bae/supabase/functions/_shared/feed/utils/getFavicon.ts#L122-L135 | 50ad24a7bc8d4f9ae06edbe38f14da057d686bae |
feeddeck | github_2023 | feeddeck | typescript | processURL | const processURL = (url: string, removeParams: boolean): string => {
if (isRelativeURL(url)) return url;
if (url.startsWith('//')) url = 'https:' + url;
if (!url.startsWith('http')) url = 'https://' + url;
const parsed = new URL(url);
return removeParams ? parsed.origin : parsed.toString();
}; | /**
* `processURL` takes a url and returns a url that is guaranteed to be absolute
* and without any query parameters when the `removeParams` parameter is set to
* `true`.
*/ | https://github.com/feeddeck/feeddeck/blob/50ad24a7bc8d4f9ae06edbe38f14da057d686bae/supabase/functions/_shared/feed/utils/getFavicon.ts#L142-L148 | 50ad24a7bc8d4f9ae06edbe38f14da057d686bae |
feeddeck | github_2023 | feeddeck | typescript | isRelativeURL | const isRelativeURL = (url: string): boolean => {
return url.startsWith('/') && !url.startsWith('//') &&
!url.startsWith('http');
}; | /**
* `isRelativeURL` checks if the provided `url` is a relative url. If this is
* the case the function returns `true`, if the url is absolute it returns
* `false`.
*/ | https://github.com/feeddeck/feeddeck/blob/50ad24a7bc8d4f9ae06edbe38f14da057d686bae/supabase/functions/_shared/feed/utils/getFavicon.ts#L155-L158 | 50ad24a7bc8d4f9ae06edbe38f14da057d686bae |
feeddeck | github_2023 | feeddeck | typescript | uploadFile | const uploadFile = async (
supabaseClient: SupabaseClient,
bucket: string,
sourcePath: string,
targetPath: string,
): Promise<string | undefined> => {
try {
const fileResponse = await fetchWithTimeout(
sourcePath,
{ method: 'get' },
5000,
);
const file = await fileResponse.blob()... | /**
* `uploadFile` uploads the provided file via it's `sourcePath` to the
* `targetPath` within the provided `bucket`. For this we have to fetch the file
* first and then upload it to the Supabase storage.
*/ | https://github.com/feeddeck/feeddeck/blob/50ad24a7bc8d4f9ae06edbe38f14da057d686bae/supabase/functions/_shared/feed/utils/uploadFile.ts#L48-L83 | 50ad24a7bc8d4f9ae06edbe38f14da057d686bae |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.