Skip to content

Commit

Permalink
update authors helper to use newer code standards
Browse files Browse the repository at this point in the history
  • Loading branch information
vikaspotluri123 committed Mar 18, 2019
1 parent 14854c8 commit c8dcaa2
Showing 1 changed file with 24 additions and 20 deletions.
44 changes: 24 additions & 20 deletions core/server/helpers/authors.js
Expand Up @@ -6,27 +6,31 @@
// By default, authors are separated by commas.
//
// Note that the standard {{#each authors}} implementation is unaffected by this helper.
const proxy = require('./proxy'),
_ = require('lodash'),
urlService = require('../services/url'),
SafeString = proxy.SafeString,
templates = proxy.templates,
models = proxy.models;

module.exports = function authors(options) {
options = options || {};
options.hash = options.hash || {};
const proxy = require('./proxy');
const _ = require('lodash');
const urlService = require('../services/url');
const {SafeString, templates, models} = proxy;

const autolink = !(_.isString(options.hash.autolink) && options.hash.autolink === 'false'),
separator = _.isString(options.hash.separator) ? options.hash.separator : ', ',
prefix = _.isString(options.hash.prefix) ? options.hash.prefix : '',
suffix = _.isString(options.hash.suffix) ? options.hash.suffix : '',
limit = options.hash.limit ? parseInt(options.hash.limit, 10) : undefined,
visibilityArr = models.Base.Model.parseVisibilityString(options.hash.visibility);
module.exports = function authors(options = {}) {
options.hash = options.hash || {};

let output = '',
from = options.hash.from ? parseInt(options.hash.from, 10) : 1,
to = options.hash.to ? parseInt(options.hash.to, 10) : undefined;
let {
autolink,
separator = ', ',
prefix = '',
suffix = '',
limit,
visibility,
from = 1,
to
} = options.hash;
let output = '';
const visibilityArr = models.Base.Model.parseVisibilityString(visibility);

autolink = !(_.isString(autolink) && autolink === 'false');
limit = limit ? parseInt(limit, 10) : limit;
from = from ? parseInt(from, 10) : from;
to = to ? parseInt(to, 10) : to;

function createAuthorsList(authors) {
function processAuthor(author) {
Expand All @@ -36,7 +40,7 @@ module.exports = function authors(options) {
}) : _.escape(author.name);
}

return models.Base.Model.filterByVisibility(authors, visibilityArr, !!options.hash.visibility, processAuthor);
return models.Base.Model.filterByVisibility(authors, visibilityArr, !!visibility, processAuthor);
}

if (this.authors && this.authors.length) {
Expand Down

0 comments on commit c8dcaa2

Please sign in to comment.