mirror of
https://github.com/pawelmalak/snippet-box.git
synced 2025-12-21 13:23:05 +01:00
Merge branch 'master' into search-feature
This commit is contained in:
@@ -3,6 +3,9 @@
|
|||||||
- Fixed date parsing bug ([#22](https://github.com/pawelmalak/snippet-box/issues/22))
|
- Fixed date parsing bug ([#22](https://github.com/pawelmalak/snippet-box/issues/22))
|
||||||
- Minor UI fixes
|
- Minor UI fixes
|
||||||
|
|
||||||
|
### v1.3.1 (2021-10-05)
|
||||||
|
- Added support for raw snippets ([#15](https://github.com/pawelmalak/snippet-box/issues/15))
|
||||||
|
|
||||||
### v1.3 (2021-09-30)
|
### v1.3 (2021-09-30)
|
||||||
- Added dark mode ([#7](https://github.com/pawelmalak/snippet-box/issues/7))
|
- Added dark mode ([#7](https://github.com/pawelmalak/snippet-box/issues/7))
|
||||||
- Added syntax highlighting ([#14](https://github.com/pawelmalak/snippet-box/issues/14))
|
- Added syntax highlighting ([#14](https://github.com/pawelmalak/snippet-box/issues/14))
|
||||||
|
|||||||
@@ -31,9 +31,9 @@ export const SnippetDetails = (props: Props): JSX.Element => {
|
|||||||
const creationDate = dateParser(createdAt);
|
const creationDate = dateParser(createdAt);
|
||||||
const updateDate = dateParser(updatedAt);
|
const updateDate = dateParser(updatedAt);
|
||||||
|
|
||||||
const copyHandler = () => {
|
// const copyHandler = () => {
|
||||||
copy(code);
|
// copy(code);
|
||||||
};
|
// };
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Card>
|
<Card>
|
||||||
@@ -74,6 +74,14 @@ export const SnippetDetails = (props: Props): JSX.Element => {
|
|||||||
|
|
||||||
{/* ACTIONS */}
|
{/* ACTIONS */}
|
||||||
<div className='d-grid g-2' style={{ rowGap: '10px' }}>
|
<div className='d-grid g-2' style={{ rowGap: '10px' }}>
|
||||||
|
<Button
|
||||||
|
text='Delete'
|
||||||
|
color='danger'
|
||||||
|
small
|
||||||
|
outline
|
||||||
|
handler={() => deleteSnippet(id)}
|
||||||
|
/>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
text='Edit'
|
text='Edit'
|
||||||
color='secondary'
|
color='secondary'
|
||||||
@@ -87,18 +95,24 @@ export const SnippetDetails = (props: Props): JSX.Element => {
|
|||||||
});
|
});
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
text='Delete'
|
text='Copy raw url'
|
||||||
color='danger'
|
color='secondary'
|
||||||
small
|
small
|
||||||
outline
|
outline
|
||||||
handler={() => deleteSnippet(id)}
|
handler={() => {
|
||||||
|
const { protocol, host } = window.location;
|
||||||
|
const rawUrl = `${protocol}//${host}/api/snippets/raw/${id}`;
|
||||||
|
copy(rawUrl);
|
||||||
|
}}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Button
|
<Button
|
||||||
text='Copy code'
|
text='Copy code'
|
||||||
color='secondary'
|
color='secondary'
|
||||||
small
|
small
|
||||||
handler={copyHandler}
|
handler={() => copy(code)}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
</Card>
|
</Card>
|
||||||
|
|||||||
@@ -10,16 +10,16 @@ $gray-700: #495057;
|
|||||||
$gray-800: #343a40;
|
$gray-800: #343a40;
|
||||||
$gray-900: #212529;
|
$gray-900: #212529;
|
||||||
$black: #000;
|
$black: #000;
|
||||||
$blue: #3459e6;
|
$blue: #375a7f;
|
||||||
$indigo: #6610f2;
|
$indigo: #6610f2;
|
||||||
$purple: #6f42c1;
|
$purple: #6f42c1;
|
||||||
$pink: #d63384;
|
$pink: #e83e8c;
|
||||||
$red: #da292e;
|
$red: #e74c3c;
|
||||||
$orange: #f8765f;
|
$orange: #fd7e14;
|
||||||
$yellow: #f4bd61;
|
$yellow: #f39c12;
|
||||||
$green: #2fb380;
|
$green: #00bc8c;
|
||||||
$teal: #20c997;
|
$teal: #20c997;
|
||||||
$cyan: #287bb5;
|
$cyan: #3498db;
|
||||||
$primary: $blue;
|
$primary: $blue;
|
||||||
$secondary: $white;
|
$secondary: $white;
|
||||||
$success: $green;
|
$success: $green;
|
||||||
|
|||||||
@@ -215,6 +215,31 @@ export const countTags = asyncWrapper(
|
|||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @description Get raw snippet code
|
||||||
|
* @route /api/snippets/raw/:id
|
||||||
|
* @request GET
|
||||||
|
*/
|
||||||
|
export const getRawCode = asyncWrapper(
|
||||||
|
async (req: Request, res: Response, next: NextFunction): Promise<void> => {
|
||||||
|
const snippet = await SnippetModel.findOne({
|
||||||
|
where: { id: req.params.id },
|
||||||
|
raw: true
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!snippet) {
|
||||||
|
return next(
|
||||||
|
new ErrorResponse(
|
||||||
|
404,
|
||||||
|
`Snippet with id of ${req.params.id} was not found`
|
||||||
|
)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
res.status(200).send(snippet.code);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @description Search snippets
|
* @description Search snippets
|
||||||
* @route /api/snippets/search
|
* @route /api/snippets/search
|
||||||
|
|||||||
@@ -4,6 +4,7 @@ import {
|
|||||||
createSnippet,
|
createSnippet,
|
||||||
deleteSnippet,
|
deleteSnippet,
|
||||||
getAllSnippets,
|
getAllSnippets,
|
||||||
|
getRawCode,
|
||||||
getSnippet,
|
getSnippet,
|
||||||
searchSnippets,
|
searchSnippets,
|
||||||
updateSnippet
|
updateSnippet
|
||||||
@@ -24,4 +25,5 @@ snippetRouter
|
|||||||
.delete(deleteSnippet);
|
.delete(deleteSnippet);
|
||||||
|
|
||||||
snippetRouter.route('/statistics/count').get(countTags);
|
snippetRouter.route('/statistics/count').get(countTags);
|
||||||
snippetRouter.route('/search').post(searchSnippets);
|
snippetRouter.route('/raw/:id').get(getRawCode);
|
||||||
|
snippetRouter.route('/search').post(searchSnippets);
|
||||||
Reference in New Issue
Block a user