Skip to content

Commit

Permalink
Add Data_Alt Column
Browse files Browse the repository at this point in the history
  • Loading branch information
ingalls committed Oct 17, 2024
1 parent a0b95e5 commit 330394a
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 5 deletions.
2 changes: 2 additions & 0 deletions api/lib/models/Icon.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export type Icon = {
iconset: string;
type2525b: string;
data: string;
data_alt: string;
path: string;
username: string;
}
Expand Down Expand Up @@ -40,6 +41,7 @@ export default class IconModel extends Modeler<typeof pgschema.Icon> {
iconset: pgschema.Icon.iconset,
type2525b: pgschema.Icon.type2525b,
data: pgschema.Icon.data,
data_alt: pgschema.Icon.data_alt,
path: pgschema.Icon.path,
username: pgschema.Iconset.username
}).from(this.generic)
Expand Down
2 changes: 1 addition & 1 deletion api/lib/schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ export const Icon = pgTable('icons', {
iconset: text().notNull().references(() => Iconset.uid),
type2525b: text(),
data: text().notNull(),
data_alt: text().notNull(),
data_alt: text(),
path: text().notNull()
});

Expand Down
6 changes: 3 additions & 3 deletions api/lib/sprites.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
import spritesmith from 'spritesmith';
import Vinyl from 'vinyl';
import { promisify } from 'node:util'
import type { Icon } from './schema.js';
import { type InferSelectModel } from 'drizzle-orm';
import { Static } from '@sinclair/typebox';
import { IconResponse } from './types.js';

const SpriteSmith = promisify(spritesmith.run);

type SpriteConfig = {
name?: string;
};

export default async function(icons: Array<InferSelectModel<typeof Icon>>, config: SpriteConfig = {}) {
export default async function(icons: Array<Static<typeof IconResponse>>, config: SpriteConfig = {}) {
const doc = await SpriteSmith({
src: icons.map((icon) => {
return new Vinyl({
Expand Down
4 changes: 3 additions & 1 deletion api/migrations/0067_strange_lifeguard.sql
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
UPDATE settings
SET value = Replace(value, '"', '')
WHERE Starts_With(key, 'group:')
WHERE Starts_With(key, 'group:');

ALTER TABLE icons
ADD COLUMN data_alt TEXT;
2 changes: 2 additions & 0 deletions api/routes/icons.ts
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ export default async function router(schema: Schema, config: Config) {
body: Type.Object({
name: Default.NameField,
data: Type.String(),
data_alt: Type.Optional(Type.String()),
type2525b: Type.Optional(Type.Union([Type.String(), Type.Null()]))
}),
res: IconResponse
Expand Down Expand Up @@ -404,6 +405,7 @@ export default async function router(schema: Schema, config: Config) {
body: Type.Object({
name: Type.Optional(Type.String()),
data: Type.Optional(Type.String()),
data_alt: Type.Optional(Type.String()),
type2525b: Type.Optional(Type.Union([Type.String(), Type.Null()]))
}),
res: IconResponse
Expand Down

0 comments on commit 330394a

Please sign in to comment.