Socket
Socket
Sign inDemoInstall

liveblog-client

Package Overview
Dependencies
26
Maintainers
4
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 3.4.3 to 3.5.1

app/images/icon-stop.svg

2

app/scripts/liveblog-advertising/activities.js

@@ -10,3 +10,3 @@ import adManagTemplate from 'scripts/liveblog-advertising/views/main.ng1';

controller: advertisingController,
betaMark: true,
betaMark: false,
category: superdesk.MENU_MAIN,

@@ -13,0 +13,0 @@ adminTools: true,

@@ -73,2 +73,3 @@ BlogListController.$inject = [

$scope.isUserAllowedToOpenBlog = blogSecurityService.canAccessBlog;
$scope.isUserAllowedToSelectblog = blogSecurityService.canAccessblogCheckbox;
// blog list embed code.

@@ -426,3 +427,3 @@ function fetchBloglistEmbed() {

const criteria = {
max_results: $scope.maxResults,
max_results: params.max_results,
embedded: {original_creator: 1},

@@ -429,0 +430,0 @@ sort: '[("versioncreated", -1)]',

@@ -96,3 +96,3 @@ /**

unreadPostsService.startListening();
unreadPostsService.startListening(blog);
// return the list of items from the editor

@@ -191,2 +191,13 @@ function getItemsFromEditor() {

function removeEditFlag(postId, flag) {
postsService.removeFlagPost(flag);
findPostAndUpdate(postId, undefined, angular.noop);
}
function cleanUpFlag() {
if ($scope.currentPost && $scope.currentPost.edit_flag) {
removeEditFlag($scope.currentPost._id, $scope.currentPost.edit_flag);
}
}
// ask in a modalbox if the user is sure to want to overwrite editor.

@@ -198,2 +209,3 @@ // call the callback if user say yes or if editor is empty

if (isEditorClean()) {
cleanUpFlag();
deferred.resolve();

@@ -205,3 +217,23 @@ } else {

))
.then(() => {
cleanUpFlag();
deferred.resolve();
}, deferred.reject);
}
return deferred.promise;
}
function doOrAskBeforeIfPostFlagged(post) {
var deferred = $q.defer();
if (post.edit_flag) {
let subMsg = post.edit_flag.users.length > 1 ? 'other users are' : 'another user is';
let confirmMsg =
`Currently ${subMsg} editing this post. Do you still want to proceed?`;
modal
.confirm(confirmMsg)
.then(deferred.resolve, deferred.reject);
} else {
deferred.resolve();
}

@@ -244,2 +276,61 @@ return deferred.promise;

/**
* Basically this just receives the data from flag registry with
* the users information attached to it. It also includes the flag TTL
*/
$scope.$on('posts:updateFlag', (event, data) => {
data.flags.forEach((flag, index) => {
findPostAndUpdate(flag.postId, flag, afterPostFlagUpdate);
});
});
$scope.$on('posts:deletedFlag', (event, data) => {
const refreshCallback = () => {
$scope.$apply();
};
const flag = data.update ? data.flag : undefined;
const callback = data.update ? afterPostFlagUpdate : refreshCallback;
findPostAndUpdate(data.flag.postId, flag, callback);
});
function findPostAndUpdate(postId, flag, cb) {
let foundPost;
let placesToLook = [
self.timelineStickyInstance,
self.timelineInstance,
self.contributionsPostsInstance,
self.draftPostsInstance,
];
// let's loop over the possible places to find the post and update it
for (let place of placesToLook) {
place.pagesManager.updatePostFlag(postId, flag, (post) => {
cb(post, flag);
foundPost = post;
});
if (foundPost) break;
}
}
function afterPostFlagUpdate(post, flag) {
// let's also update post if its being edited
if ($scope.currentPost && $scope.currentPost._id === post._id) {
$scope.currentPost.edit_flag = flag;
}
// to trigger rendering
$scope.$apply();
// let's set the timeout and refresh when expired
postsService.setFlagTimeout(post, () => {
if ($scope.currentPost && post._id === $scope.currentPost._id) {
cleanEditor();
} else {
$scope.$apply();
}
});
}
// remove and clean every items from the editor

@@ -252,2 +343,3 @@ function cleanEditor(actionDisabled) {

}
$scope.enableEditor = false;

@@ -322,18 +414,21 @@

function savingPost(blog) {
postsService.savePost(blog._id,
$scope.currentPost,
getItemsFromEditor(),
{post_status: 'open', sticky: $scope.sticky, lb_highlight: $scope.highlight}
).then((post) => {
notify.pop();
notify.info(gettext('Post saved'));
let postParams = {
post_status: 'open',
sticky: $scope.sticky,
lb_highlight: $scope.highlight,
};
cleanEditor();
$scope.selectedPostType = 'Default';
$scope.actionPending = false;
}, () => {
notify.pop();
notify.error(gettext('Something went wrong. Please try again later'));
$scope.actionPending = false;
});
postsService.savePost(blog._id, $scope.currentPost, getItemsFromEditor(), postParams)
.then((post) => {
notify.pop();
notify.info(gettext('Post saved'));
cleanEditor();
$scope.selectedPostType = 'Default';
$scope.actionPending = false;
}, () => {
notify.pop();
notify.error(gettext('Something went wrong. Please try again later'));
$scope.actionPending = false;
});
}

@@ -470,4 +565,21 @@

}
$scope.openPanel('editor');
doOrAskBeforeIfEditorIsNotEmpty().then(fillEditor.bind(null, post));
function openEditPost(post) {
$scope.openPanel('editor');
doOrAskBeforeIfEditorIsNotEmpty().then(() => {
// let's flag the post so other users are aware of editing status
postsService.flagPost(post._id);
// do editor stuff
fillEditor(post);
});
}
if (post.edit_flag) {
doOrAskBeforeIfPostFlagged(post).then(() => {
openEditPost(post);
});
} else {
openEditPost(post);
}
},

@@ -527,29 +639,11 @@ saveAsContribution: function() {

}, () => {
notify.error(gettext('Something went wrong with scoarers status. Please try again later'));
notify.error(gettext('Something went wrong with scorers status. Please try again later'));
});
}
notify.info(gettext('Saving post'));
const getAllposts = $scope.blogEdit.timelineInstance.pagesManager.allPosts();
savingPost(blog);
blog.total_posts += 1;
const filtered = getAllposts.filter((el) => el.lb_highlight == false && el.sticky == false);
if (blog.posts_limit != 0 && blog.total_posts >= blog.posts_limit) {
const deleted = {deleted: true};
const post = filtered[(filtered.length - 1)];
postsService.savePost(post.blog, post, [], deleted).then((message) => {
$rootScope.$broadcast('removing_timeline_post', {post: post});
notify.pop();
notify.info(gettext('Wait! saving post'));
$timeout(() => {
savingPost(blog);
}, 1000);
}, () => {
notify.pop();
notify.error(gettext('Something went wrong'));
});
} else {
savingPost(blog);
}
blog.total_posts += 1;
cleanUpFlag();
});

@@ -587,2 +681,3 @@ },

isEditorClean: isEditorClean,
cleanUpFlag: cleanUpFlag,
setPending: function(value) {

@@ -717,2 +812,21 @@ $scope.actionPending = value;

});
// we listen to change route event in order to remove flag when leaving the
// the editor view. We also make sure to destroy it to avoid multiple listeners
const sentinel = $rootScope.$on('$routeChangeSuccess', (e, currentRoute, prevRoute) => {
if ($scope.currentPost) {
cleanUpFlag();
}
});
$scope.$on('$destroy', sentinel);
// receives update data of the blog from backend.
// for we will just update total posts and posts limit
$scope.$on('blog:limits', (event, data) => {
if (blog._id === data.blog_id) {
blog['posts_limit'] = data.stats['posts_limit'];
blog['total_posts'] = data.stats['total_posts'];
}
});
}

@@ -188,3 +188,3 @@ /**

if (outputTheme.styles && outputTheme.settings.removeStylesESI) {
if (outputTheme.styles && outputTheme.settings && outputTheme.settings.removeStylesESI) {
vm.output.styleUrl = outputTheme.public_url + outputTheme.styles[outputTheme.styles.length - 1];

@@ -464,3 +464,3 @@ }

return l.type="text/javascript",l.onload=t,l.async=!0,l.src=e,o.parentNode.insertBefore(l,o),l}};
liveblog.load("${parentIframe}parent-iframe.js?"+parseInt(new Date().getTime()/900000,10),function(){"function"==typeof
liveblog.load("${parentIframe}parent-iframe.js?"+parseInt(new Date().getTime()/900000,10),function(){"function"==typeof
liveblog.loadCallback&&liveblog.loadCallback()});</script>`;

@@ -467,0 +467,0 @@

@@ -39,2 +39,9 @@ import postTpl from 'scripts/liveblog-edit/views/post.ng1';

link: function(scope, elem, attrs) {
// we set timeout function to remove edit flag after expireAt date
if (scope.post.edit_flag) {
postsService.setFlagTimeout(scope.post, () => {
scope.$apply();
});
}
// if the escape key is press then clear the reorder action.

@@ -76,2 +83,10 @@ function escClearReorder(e) {

},
userify: function(user) {
if (!user) return;
if (user._id === $rootScope.currentUser._id)
return 'You';
return user.display_name;
},
removePost: function(post) {

@@ -78,0 +93,0 @@ postsService.remove(angular.copy(post)).then((message) => {

@@ -162,15 +162,20 @@ import postsTpl from 'scripts/liveblog-edit/views/posts.ng1';

self.isLoading = true;
self.pagesManager.retrieveUpdate(true).then(() => {
// Regenerate the embed otherwise the image doesn't appear
if (window.hasOwnProperty('instgrm')) {
window.instgrm.Embeds.process();
}
// only update if posts belong to same blog
const posts = eventParams.posts || [];
if (eventParams.deleted === true) {
notify.pop();
notify.info(gettext('Post removed'));
}
self.isLoading = false;
});
if (posts && posts.length > 0 && posts.find((x) => x.blog === $scope.lbPostsBlogId)) {
self.isLoading = true;
self.pagesManager.retrieveUpdate(true).then(() => {
// Regenerate the embed otherwise the image doesn't appear
if (window.hasOwnProperty('instgrm')) {
window.instgrm.Embeds.process();
}
if (eventParams.deleted === true) {
notify.pop();
notify.info(gettext('Post removed'));
}
self.isLoading = false;
});
}
}, 100);

@@ -177,0 +182,0 @@

@@ -112,5 +112,32 @@

const SirTrevor = SirTrevorParam.$get();
var onRemoveBlock = function() {
const editorOptions = SirTrevor.Block.prototype.getOptions();
// I don't like this solution using timeout, but we need to wait just a bit
// to check if operations are done (block removing, reset, edit, etc)
setTimeout(() => {
if (editorOptions.isEditorClean()) {
editorOptions.disableSubmit(true);
// NOTE: this below was meant to remove the flag indicator from the
// post in timeline. We don't need to remove the flag as the post is still
// being edited. Clicking `delete` button doesn't mean deleting the post bu
// the block in the editor.
// const editor = SirTrevor.getInstance(0);
// if (editor && editor.blocks.length === 0) {
// editorOptions.cleanUpFlag();
// }
}
}, 500);
};
// let's make sure to avoid double binding
SirTrevor.EventBus.off('block:remove');
SirTrevor.EventBus.on('block:remove', onRemoveBlock);
// change the remove trash icon by a cross
SirTrevor.BlockDeletion.prototype.attributes['data-icon'] = 'close';
SirTrevor.BlockDeletion.prototype.attributes['data-icon'] = 'close';
// extends the options given as parameter to the editor contructor

@@ -120,4 +147,4 @@ SirTrevorOptions.$extend({

const self = this;
// when a new block is added, remove empty blocks
function removeEmptyBlockExceptTheBlock(newBlock) {

@@ -132,13 +159,2 @@ _.each(self.blocks, (block) => {

SirTrevor.EventBus.on('block:create:new', removeEmptyBlockExceptTheBlock);
var onRemoveBlock = function() {
const editorOptions = self.options;
if (editorOptions.isEditorClean()) {
editorOptions.disableSubmit(true);
}
};
onRemoveBlock = onRemoveBlock.bind(self);
SirTrevor.EventBus.on('block:remove', onRemoveBlock);
},

@@ -145,0 +161,0 @@ blockTypes: ['Text', 'Image', 'Embed', 'Quote', 'Comment'],

@@ -201,2 +201,17 @@ pagesManagerFactory.$inject = ['postsService', '$q', 'lodash', 'moment', 'instagramService'];

/**
* Receives edit flags information, loop over them and find the right
* posts to update the data, then triggers callback
*/
function updatePostFlag(postId, flag, cb) {
self.pages.forEach((page, pageIndex) => {
page.posts.forEach((post, postIndex) => {
if (post._id === postId) {
self.pages[pageIndex].posts[postIndex]['edit_flag'] = flag;
cb(self.pages[pageIndex].posts[postIndex]);
}
});
});
}
/**
* Update the latest update date by using the given posts

@@ -408,2 +423,6 @@ * @param {array} posts - List of posts

/**
* Updates flag information, look for the right post and updates it
*/
updatePostFlag: updatePostFlag,
/**
* Returns the number of posts in the local pages

@@ -410,0 +429,0 @@ */

@@ -18,5 +18,6 @@ /**

'userList',
'session',
];
export default function postsService(api, $q, userList) {
export default function postsService(api, $q, userList, session) {
var listOfUsers = [];

@@ -336,2 +337,40 @@

function flagPost(postId) {
return api('post_flags').save({postId: postId});
}
function removeFlagPost(flag) {
api('post_flags').remove(flag);
}
function setFlagTimeout(post, cb) {
// perhaps not the best place to put this but I needed this
// to be accessible from diferent directives. If there is another/better way
// please improve this ;)
const editFlag = post.edit_flag;
const current = moment().utc();
const flatExpireAt = moment(editFlag.expireAt);
const seconds = flatExpireAt.diff(current, 'seconds');
const key = `flagTimeout_${editFlag.postId}`;
// if flag is already expired, let's remove id right away
if (seconds < 0) {
removeFlagPost(editFlag);
return;
}
// try to remove previous timeout just in case
clearTimeout(window[key]);
window[key] = setTimeout(() => {
post.edit_flag = undefined;
cb();
// then remove also from backend if user is editing
if (editFlag.users.indexOf(session.identity) !== -1) {
removeFlagPost(editFlag);
}
}, seconds * 1000);
}
return {

@@ -342,2 +381,5 @@ getPosts: getPosts,

savePost: savePost,
flagPost: flagPost,
removeFlagPost: removeFlagPost,
setFlagTimeout: setFlagTimeout,
saveDraft: function(blogId, post, items, sticky, highlight) {

@@ -344,0 +386,0 @@ return savePost(

@@ -15,2 +15,3 @@ /**

export default function unreadPostsService($rootScope) {
let blog;
let listener;

@@ -73,3 +74,4 @@ let contributions = [];

if (eventParams.post_status === 'submitted') {
contributions = contributions.concat(eventParams.posts);
let onlyCurrentBlogPosts = eventParams.posts.filter(x => x.blog === blog._id); // eslint-disable-line
contributions = contributions.concat(onlyCurrentBlogPosts);
}

@@ -91,4 +93,5 @@

reset: reset,
startListening: function() {
startListening: function(currentBlog) {
if (!listener) {
blog = currentBlog;
listener = $rootScope.$on('posts', onPostReceive);

@@ -102,2 +105,3 @@ }

listener = undefined;
blog = undefined;
}

@@ -104,0 +108,0 @@ },

@@ -184,3 +184,3 @@ import listViewTpl from 'scripts/liveblog-freetypes/views/list.ng1';

controllerAs: 'self',
betaMark: true,
betaMark: false,
category: superdesk.MENU_MAIN,

@@ -187,0 +187,0 @@ adminTools: true,

@@ -51,2 +51,11 @@ angular.module('liveblog.security', [])

}
function canAccessblogCheckbox(blog) {
const userType = $rootScope.currentUser.user_type;
if (userType === 'user') {
return canCreateABlog() && isMemberOfBlog(blog);
} else if (userType === 'administrator') {
return isAdmin();
}
}
function goToSettings() {

@@ -79,4 +88,5 @@ const def = $q.defer();

canAccessBlog: canAccessBlog,
canAccessblogCheckbox: canAccessblogCheckbox,
};
},
]);

@@ -33,2 +33,3 @@ import incomingSyndicationTpl from 'scripts/liveblog-syndication/views/incoming-syndication.ng1';

// simply attach a listener to our store
scope.store.connect((state) => {

@@ -65,9 +66,9 @@ scope.posts = state.posts;

scope.$on('posts', (e, data) => {
if (data.hasOwnProperty('deleted') && data.deleted === true
|| data.posts && data.posts[0].syndication_in) {
// let's wait for tasks to finish and then pull data from backend
setTimeout(() => {
IncomingSyndicationActions
.getPosts(scope.blogId, scope.syndId);
}
IncomingSyndicationActions
.getPosts(scope.blogId, scope.syndId);
scope.$apply();
}, 1000);
});

@@ -74,0 +75,0 @@

@@ -189,5 +189,3 @@ import listTpl from 'scripts/liveblog-themes/views/list.ng1';

// Removing simple theme https://dev.sourcefabric.org/browse/LBSD-2199
// const systemThemes = ['angular', 'classic', 'default', 'amp', 'simple'];
const systemThemes = ['angular', 'classic', 'default', 'amp'];
const systemThemes = ['angular', 'classic', 'default', 'amp', 'simple'];
const isSystemTheme = systemThemes.indexOf(theme.name) !== -1;

@@ -291,3 +289,3 @@

notify.pop();
notify.error(error.data.error);
notify.error(error.data._message);
});

@@ -294,0 +292,0 @@ });

@@ -61,7 +61,12 @@ import angular from 'angular';

opts.el = $(element.find('textarea'));
// clean older instances if any
if (scope.editor)
scope.editor.destroy();
scope.editor = new SirTrevor.Editor(opts);
scope.editor.get = function() {
const list = [];
// sort blocks by index.
scope.editor.blocks.sort((a, b) => a.$el.index() - b.$el.index());

@@ -68,0 +73,0 @@ angular.forEach(scope.editor.blocks, (block) => {

@@ -49,2 +49,10 @@ /**

+ '|twitter\\.com\\/.*\\/status)(?:.|\\n)*(iframe|blockquote)';
var generalPattern = new RegExp(socialEmbedRegex, 'i');
var youtubePattern = new RegExp('(?:https?:\\/\\/)?'
+ '(?:www\\.)?(?:youtu\\.be\\/|youtube\\.com\\/|youtube-nocookie\\.com\\/'
+ '(?:embed\\/|v\\/|watch\\?v=|watch\\?.+&v=))(\\w+)', 'i');
var facebookPattern = /(?:post\.php|video\.php)\?href=(https?(\w|%|\.)+)/i;
var instagramPattern = /(https?:\/\/(?:www)?\.?instagram\.com\/p\/(?:\w+.)+\/)/i;
var twitterPattern = /(https?:\/\/(?:www|mobile)?\.?twitter\.com\/\w+\/status\/\d+)/i;
var bcPattern = /(http|https)?:?\/\/players.brightcove.net\/\d*\/[a-zA-Z\d_-]*\/index\.html\?videoId=\d*/i;

@@ -101,11 +109,12 @@ function fixDataEmbed(data) {

function cleanupURL(string) {
var m;
if ((m = twitterPattern.exec(string)) !== null) {
return m[1];
}
return string;
}
function replaceEmbedWithUrl(string) {
var generalPattern = new RegExp(socialEmbedRegex, 'i');
var youtubePattern = new RegExp('(?:https?:\\/\\/)?'
+ '(?:www\\.)?(?:youtu\\.be\\/|youtube\\.com\\/|youtube-nocookie\\.com\\/'
+ '(?:embed\\/|v\\/|watch\\?v=|watch\\?.+&v=))(\\w+)', 'i');
var facebookPattern = /(?:post\.php|video\.php)\?href=(https?(\w|%|\.)+)/i;
var instagramPattern = /(https?:\/\/(?:www)?\.?instagram\.com\/p\/(?:\w+.)+\/)/i;
var twitterPattern = /(https?:\/\/(?:www|mobile)?\.?twitter\.com\/\w+\/status\/\d+)/i;
var bcPattern = /(http|https)?:?\/\/players.brightcove.net\/\d*\/[a-zA-Z\d_-]*\/index\.html\?videoId=\d*/i;
var m;

@@ -204,2 +213,3 @@

if (isURI(input)) {
input = cleanupURL(input);
// request the embedService with the provided url

@@ -206,0 +216,0 @@ self.getOptions().embedService.get(input, self.getOptions().coverMaxWidth).then(

{
"name": "liveblog-client",
"version": "3.4.3",
"version": "3.5.1",
"repository": {

@@ -5,0 +5,0 @@ "type": "git",

@@ -13,5 +13,3 @@ const webpack = require('webpack');

'process.env': {NODE_ENV: JSON.stringify('production')}
}),
new webpack.optimize.DedupePlugin()
// new webpack.optimize.UglifyJsPlugin()
})
)

@@ -18,0 +16,0 @@ }

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc