Apply style fixes

This commit is contained in:
Jacob Karlsson 2020-05-03 23:14:19 +02:00
parent f63a0dfa0a
commit 3b753f16ac
4 changed files with 22 additions and 22 deletions

View File

@ -22,7 +22,7 @@
},
"dependencies": {
"@fraction/base16-css": "^1.1.0",
"@fraction/flotilla": "Powersource/flotilla#add-meme-2",
"@fraction/flotilla": "github:Powersource/flotilla#add-meme-2",
"@koa/router": "^8.0.0",
"debug": "^4.1.1",
"env-paths": "^2.2.0",

View File

@ -313,9 +313,7 @@ router
.get("/imageSearch", async (ctx) => {
const { query } = ctx.query;
const blobs = query
? await blob.search({ query })
: {}
const blobs = query ? await blob.search({ query }) : {};
ctx.body = await imageSearchView({ blobs, query });
})

View File

@ -177,11 +177,11 @@ module.exports = ({ cooler, isPublic }) => {
return new Promise((resolve, reject) => {
ssb.meme.search(query, (err, blobs) => {
if (err) return reject(err)
if (err) return reject(err);
return resolve(blobs)
})
})
return resolve(blobs);
});
});
},
};

View File

@ -132,7 +132,11 @@ const template = (...elements) => {
navLink({ href: "/mentions", emoji: "💬", text: i18n.mentions }),
navLink({ href: "/inbox", emoji: "✉️", text: i18n.private }),
navLink({ href: "/search", emoji: "🔍", text: i18n.search }),
navLink({ href: "/imageSearch", emoji: "🖼️", text: i18n.imageSearch }),
navLink({
href: "/imageSearch",
emoji: "🖼️",
text: i18n.imageSearch,
}),
navLink({ href: "/settings", emoji: "⚙", text: i18n.settings })
)
),
@ -1043,33 +1047,33 @@ exports.searchView = ({ messages, query }) => {
};
const imageResult = ({ id, infos }) => {
const encodedBlobId = encodeURIComponent(id)
const encodedBlobId = encodeURIComponent(id);
// only rendering the first message result so far
// todo: render links to the others as well
const info = infos[0]
const encodedMsgId = encodeURIComponent(info.msg)
const info = infos[0];
const encodedMsgId = encodeURIComponent(info.msg);
return div(
{
class: "image-result"
class: "image-result",
},
[
a(
{
href: `/blob/${encodedBlobId}`
href: `/blob/${encodedBlobId}`,
},
img({ src: `/image/256/${encodedBlobId}` }),
img({ src: `/image/256/${encodedBlobId}` })
),
a(
{
href: `/thread/${encodedMsgId}#${encodedMsgId}`,
class: "result-text"
class: "result-text",
},
info.name
)
),
]
);
}
};
exports.imageSearchView = ({ blobs, query }) => {
const searchInput = input({
@ -1102,14 +1106,12 @@ exports.imageSearchView = ({ blobs, query }) => {
),
div(
{
class: "image-search-grid"
class: "image-search-grid",
},
Object.keys(blobs)
// todo: add pagination
.slice(0, 30)
.map((blobId) =>
imageResult({ id: blobId, infos: blobs[blobId] })
)
.map((blobId) => imageResult({ id: blobId, infos: blobs[blobId] }))
)
);
};