Skip to content

Commit a8e0e45

Browse files
author
Ajit Kumar
committed
feat(plugin package update, schema update)
1 parent e0aaca6 commit a8e0e45

File tree

14 files changed

+203
-2830
lines changed

14 files changed

+203
-2830
lines changed

client/components/adsense.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ export default function AdSense({ className = '', name = 'plugin', style = {}, r
2828
}, 0);
2929

3030
return (
31-
<div className={className} style={{ zIndex: '1', ...style }} ref={ref}>
31+
<div className={className} style={{ zIndex: '1', ...style, minHeight: '100px' }} ref={ref}>
3232
<ins
3333
className='adsbygoogle'
3434
style={{ display: 'block', zIndex: 1, position: 'relative' }}

client/components/plugins/index.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import alert from 'components/dialogs/alert';
44
import confirm from 'components/dialogs/confirm';
55
import prompt from 'components/dialogs/prompt';
66
import select from 'components/dialogs/select';
7-
import { calcRating, capitalize, getLoggedInUser, hideLoading, showLoading } from 'lib/helpers';
7+
import { calcRating, capitalize, getLoggedInUser, hideLoading, showLoading, since } from 'lib/helpers';
88
import Router from 'lib/Router';
99

1010
export default function Plugins({ user, orderBy, status, name }) {
@@ -53,23 +53,24 @@ export default function Plugins({ user, orderBy, status, name }) {
5353
}
5454

5555
function Plugin({
56-
name,
5756
id,
58-
version,
59-
downloads,
57+
name,
6058
status,
61-
isAdmin,
6259
userId,
63-
user_id: pluginUser,
60+
version,
61+
isAdmin,
62+
downloads,
6463
votes_up: upVotes,
64+
user_id: pluginUser,
65+
package_updated_at: updatedAt,
6566
votes_down: downVotes,
6667
comment_count: comments,
6768
}) {
6869
return (
6970
<a href={`/plugin/${id}`} className='plugin'>
7071
<div className='plugin-icon' style={{ backgroundImage: `url(/plugin-icon/${id})` }} />
7172
<div className='plugin-info'>
72-
<h2>{name}</h2>
73+
<h2 style={{ whiteSpace: 'nowrap', overflow: 'hidden', textOverflow: 'ellipsis' }}>{name}</h2>
7374
<div className='info'>
7475
<div title='Downloads counter'>
7576
{downloads.toLocaleString()} <span className='icon download' />
@@ -92,6 +93,7 @@ function Plugin({
9293
<strong>{version}</strong>
9394
</small>
9495
</p>
96+
<small>Updated {updatedAt ? since(updatedAt) : 'never'}</small>
9597
<Actions id={id} isAdmin={isAdmin} user={userId} pluginsUser={pluginUser} />
9698
</div>
9799
</a>

client/lib/helpers.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import moment from 'moment';
2+
13
const on = {
24
showloading: [],
35
hideloading: [],
@@ -114,3 +116,8 @@ export function gravatar(github) {
114116
export function calcRating(votesUp, votesDown) {
115117
return !votesUp && !votesDown ? 'Unrated' : `${Math.round((votesUp / (votesDown + votesUp)) * 100)}%`;
116118
}
119+
120+
export function since(date) {
121+
const now = moment().add(new Date().getTimezoneOffset(), 'minutes');
122+
return moment(date).from(now);
123+
}

client/pages/plugin/index.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import './style.scss';
2+
import 'highlight.js/styles/github-dark.css';
23
import AdSense from 'components/adsense';
34
import AjaxForm from 'components/ajaxForm';
45
import alert from 'components/dialogs/alert';
@@ -7,8 +8,9 @@ import prompt from 'components/dialogs/prompt';
78
import Input from 'components/input';
89
import MonthSelect from 'components/MonthSelect';
910
import YearSelect from 'components/YearSelect';
11+
import hilightjs from 'highlight.js';
1012
import Ref from 'html-tag-js/ref';
11-
import { calcRating, getLoggedInUser, gravatar } from 'lib/helpers';
13+
import { calcRating, getLoggedInUser, gravatar, since } from 'lib/helpers';
1214
import Router from 'lib/Router';
1315
import { marked } from 'marked';
1416
import moment from 'moment/moment';
@@ -33,6 +35,7 @@ export default async function Plugin({ id: pluginId, section = 'description' })
3335
votes_up: votesUp,
3436
votes_down: votesDown,
3537
comment_count: commentCount,
38+
package_updated_at: updatedAt,
3639
author_verified: authorVerified,
3740
} = plugin;
3841

@@ -69,6 +72,10 @@ export default async function Plugin({ id: pluginId, section = 'description' })
6972
/** @type {Ref} */
7073
let currentSection;
7174

75+
for (const code of $description.getAll('pre code')) {
76+
hilightjs.highlightElement(code);
77+
}
78+
7279
changeSection(section, false);
7380
renderComments(commentListRef, userId, user, pluginId, author);
7481

@@ -94,6 +101,7 @@ export default async function Plugin({ id: pluginId, section = 'description' })
94101
<div className='info-container'>
95102
<div className='info'>
96103
<strong>{name}</strong>
104+
<small>Updated {updatedAt ? since(updatedAt) : 'never'}</small>
97105
</div>
98106
<div className='info'>
99107
<span className='chip'>v {version}</span>
@@ -298,12 +306,11 @@ function Comment({
298306
const meta = Ref();
299307
const flagRef = Ref();
300308
const reply = Ref();
301-
const now = moment().add(new Date().getTimezoneOffset(), 'minutes');
302309
const createTime = moment(updatedAt);
303310
const args = [id, pluginAuthor, pluginUserId, user];
304311
const userIsPluginAuthor = user && pluginUserId === user?.id;
305312

306-
const createDuration = moment.duration(now.diff(createTime)).humanize();
313+
const createDuration = since(createTime);
307314

308315
if (vote === 1) {
309316
dp.append(<div className='icon thumb_up primary' />);

client/pages/plugin/style.scss

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -223,4 +223,14 @@
223223
color: red;
224224
}
225225
}
226+
227+
article {
228+
font-size: 14px;
229+
230+
input {
231+
height: unset;
232+
padding: unset;
233+
margin: unset;
234+
}
235+
}
226236
}

client/pages/publishPlugin/index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ export default async function PublishPlugin({ mode = 'publish', id }) {
176176
throw new Error('Version should be greater than previous version.');
177177
}
178178

179-
const changelogs = await zip.file('changelogs.md')?.async('string');
179+
const changelogs = (await zip.file('changelogs.md')?.async('string')) || (await zip.file('changelog.md')?.async('string'));
180180

181181
if (changelogs) {
182182
changelogsInput.el.value = changelogs;

0 commit comments

Comments
 (0)