diff --git a/js/archive.js b/js/archive.js index 2a50605..097881a 100644 --- a/js/archive.js +++ b/js/archive.js @@ -1,5 +1,6 @@ import { escape, whenReady } from './dom'; import { DataTable, dumbFilterCallback } from './data_tables'; +import { tagsToHtml } from "./utils"; import { globalSetup } from './main'; whenReady(() => { @@ -16,27 +17,10 @@ whenReady(() => { .then(resolve); }, rowCallback: (rowData) => { - const tags = rowData.tags.map((tagData) => { - let tagColorClass; - if (tagData.name.indexOf('nsfw') !== -1) { - tagColorClass = 'is-danger'; - } else if (tagData.name.indexOf('safe') !== -1) { - tagColorClass = 'is-success'; - } else if (tagData.name.indexOf('/') !== -1) { - tagColorClass = 'is-primary'; - } else { - tagColorClass = 'is-info'; - } - - return ` - ${escape(tagData.name)} - `; - }).join(''); - return ` ${escape(rowData.title)} ${escape(rowData.author)} - ${tags} + ${tagsToHtml(rowData.tags)} `; }, filterCallback: dumbFilterCallback, diff --git a/js/user_profile.js b/js/user_profile.js index 3134047..613fc66 100644 --- a/js/user_profile.js +++ b/js/user_profile.js @@ -1,5 +1,6 @@ import { escape, whenReady } from './dom'; import { DataTable, dumbFilterCallback } from './data_tables'; +import { tagsToHtml } from "./utils"; import { globalSetup } from './main'; const getUserInfo = () => { @@ -33,39 +34,23 @@ whenReady(() => { }); }, rowCallback: (rowData) => { - const tags = rowData.tags.map((tagData) => { - let tagColorClass; - if (tagData.name.indexOf('nsfw') !== -1) { - tagColorClass = 'is-danger'; - } else if (tagData.name.indexOf('safe') !== -1) { - tagColorClass = 'is-success'; - } else if (tagData.name.indexOf('/') !== -1) { - tagColorClass = 'is-primary'; - } else { - tagColorClass = 'is-info'; - } - - return ` - ${escape(tagData.name)} - `; - }).join(''); - const userData = getUserInfo(); - const deleteElem = true ? ` + const deleteElem = true ? `
` : ''; + const pasteCreatedAt = new Date(rowData.created_at).toLocaleString(); return ` ${escape(rowData.title)} - ${rowData.created_at} - ${rowData.visibility} - ${rowData.views || 0} - ${tags} + ${pasteCreatedAt} + ${rowData.visibility} + ${rowData.views || 0} + ${tagsToHtml(rowData.tags)} ${deleteElem} `; }, @@ -87,33 +72,17 @@ whenReady(() => { }); }, rowCallback: (rowData) => { - const tags = rowData.tags.map((tagData) => { - let tagColorClass; - if (tagData.name.indexOf('nsfw') !== -1) { - tagColorClass = 'is-danger'; - } else if (tagData.name.indexOf('safe') !== -1) { - tagColorClass = 'is-success'; - } else if (tagData.name.indexOf('/') !== -1) { - tagColorClass = 'is-primary'; - } else { - tagColorClass = 'is-info'; - } - - return ` - ${escape(tagData.name)} - `; - }).join(''); - const recentUpdate = rowData.recently_updated ? `` : ``; + const pasteFavedAt = new Date(rowData.favourited_at).toLocaleString(); // ${escape(rowData.author)} return ` ${escape(rowData.title)} - ${rowData.favourited_at} - ${recentUpdate} - ${tags} + ${pasteFavedAt} + ${recentUpdate} + ${tagsToHtml(rowData.tags)} `; }, filterCallback: dumbFilterCallback diff --git a/js/utils.js b/js/utils.js new file mode 100644 index 0000000..cbadd73 --- /dev/null +++ b/js/utils.js @@ -0,0 +1,23 @@ +import { escape } from "./dom"; + +const tagsToHtml = (tags) => { + + return tags.map(tagData => { + let tagColorClass; + if (tagData.name.indexOf('nsfw') !== -1) { + tagColorClass = 'is-danger'; + } else if (tagData.name.indexOf('safe') !== -1) { + tagColorClass = 'is-success'; + } else if (tagData.name.indexOf('/') !== -1) { + tagColorClass = 'is-primary'; + } else { + tagColorClass = 'is-info'; + } + + return ` + ${escape(tagData.name)} + `; + }).join(''); +}; + +export { tagsToHtml }; diff --git a/theme/bulma/user_profile.php b/theme/bulma/user_profile.php index 6fce0ec..c939ffe 100644 --- a/theme/bulma/user_profile.php +++ b/theme/bulma/user_profile.php @@ -132,7 +132,9 @@ visible == Paste::VISIBILITY_PUBLIC): ?> - format('d F Y') ?> + + format('d F Y') ?> + views ?> tags, $profile_username); ?>