From 813c34cfbe1d7829bac31eaddcc33d254d7af7c6 Mon Sep 17 00:00:00 2001 From: Nistor Mihai Date: Wed, 7 Jan 2015 13:27:38 +0200 Subject: [PATCH] Squashed 'plugins/embed/' changes from ba7ff04..b8efbcf b8efbcf Merge pull request #256 from nistormihai/rp-image-issues 6c411f2 feature: image-fix plugin. 3875e52 Merge pull request #255 from actionless/add-xml-reporte 7d8e94a Merge pull request #254 from actionless/LBSD-148-e2e-reorder-posts eb9e096 tests: e2e: added junit reporter 83c62f4 tests: e2e: added test for post reorder; cleaned-up spec file d895b58 tests: e2e: added test for post unpublish ea0c107 Merge branch 'devel' of https://github.com/liveblog/plugin-liveblog-embed-server into LBSD-147-e2e-unpublish-post2 262da13 style(tests: e2e): slight style fixes 1f4fa79 tests: e2e: added test for post delete 1690ef6 fix(tests: e2e): moved 'expect' git-subtree-dir: plugins/embed git-subtree-split: b8efbcf566b24b0a0502262c8b98a23e68ed38c6 --- .gitignore | 1 + .../scripts/js/build/themes/rp/desktop.js | 4 +- gui-resources/scripts/js/plugins/image-fix.js | 32 +++ gui-themes/themes/rp/desktop.js | 4 +- gui-themes/themes/rp/desktop/liveblog.css | 5 + package.json | 1 + protractor-conf.js | 4 + spec/embed_spec.js | 261 ++++++++++++++---- spec/helpers/liveblog_backend.js | 2 +- spec/helpers/liveblog_posts.js | 52 +++- 10 files changed, 301 insertions(+), 65 deletions(-) create mode 100644 gui-resources/scripts/js/plugins/image-fix.js diff --git a/.gitignore b/.gitignore index 1439e7d7c..e3413ee1e 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ logs/** gui-resources/scripts/js/bower_components/** server-test-results.xml client-test-results.xml +e2e-test-results/ docs/docco/test/** docs/docco/scripts/** !docs/docco/scripts/index.html diff --git a/gui-resources/scripts/js/build/themes/rp/desktop.js b/gui-resources/scripts/js/build/themes/rp/desktop.js index 621ff6b9b..724b5b5bd 100644 --- a/gui-resources/scripts/js/build/themes/rp/desktop.js +++ b/gui-resources/scripts/js/build/themes/rp/desktop.js @@ -1,2 +1,2 @@ -liveblog.define("plugins",{}),liveblog.define("plugins/pagination",["plugins","lib/utils"],function(i,e){return i.pagination=function(){e.dispatcher.once("initialize.posts-view",function(i){i.collection.clearPaginationParams(),liveblog.limit&&(i.collection.syncParams.pagination.limit=parseInt(liveblog.limit,10)),i.flags.loadingNextPage=!1,i.updateNextPageOffset=function(){this.collection.syncParams.pagination.offset=this.collection.length},i.topPage=function(){return delete this.collection.syncParams.pagination["order.end"],this.collection.syncParams.pagination.offset=0,this.collection.fetchPage({reset:!0})},i.nextPage=function(){if(!this.flags.loadingNextPage&&this.hasNextPage()){e.dispatcher.trigger("loading.posts-view",this),this.flags.loadingNextPage=!0,this.updateNextPageOffset();var i=this;return this.collection.fetchPage().done(function(){i.flags.loadingNextPage=!1,e.dispatcher.trigger("loaded.posts-view",i)})}},i.hasNextPage=function(){return this.collection.length96?i-87:i>64?i-29:i-48}function a(i){var a,t=0,n=i.split("."),r=n[0],o=n[1]||"",c=1,s=0,l=1;for(45===i.charCodeAt(0)&&(t=1,l=-1),t;ta;a++)i[a]=Math.round((i[a-1]||0)+6e4*i[a]);i[e-1]=1/0}function r(i,e){var a,t=[];for(a=0;a').helper("i18n",e,{},{msgid:"Load more posts ..."}).write("")}function s(i,e){return e=e.shiftBlocks(u),i.write('')}function l(i,e){return e=e.shiftBlocks(u),i.write('data-gimme="posts.nextPage"')}i.register("themeBase/plugins/after-button-pagination",e); -var u={itemClass:t,main:n,loadNext:c,loadingNext:s,additionalAttributes:l};return e}(),{render:function(e,a){return i.render("themeBase/plugins/after-button-pagination",e,a)}}}),liveblog.define("tmpl!themeBase/plugins/before-button-pagination",["dust"],function(i){return function(){function e(i,e){return e=e.shiftBlocks(u),i.partial(a,e,null)}function a(i,e){return e=e.shiftBlocks(u),i.reference(e.get(["baseItem"],!1),e,"h")}function t(i,e){return e=e.shiftBlocks(u),i.write("load-next")}function n(i,e){return e=e.shiftBlocks(u),i.block(e.getBlock("loadNext"),e,{block:r},null).block(e.getBlock("loadingNext"),e,{block:o},null)}function r(i,e){return e=e.shiftBlocks(u),i}function o(i,e){return e=e.shiftBlocks(u),i}function c(i,e){return e=e.shiftBlocks(u),i.write('Load top posts')}function s(i,e){return e=e.shiftBlocks(u),i.write('')}function l(i,e){return e=e.shiftBlocks(u),i.write('data-gimme="posts.beforePage"')}i.register("themeBase/plugins/before-button-pagination",e);var u={itemClass:t,main:n,loadNext:c,loadingNext:s,additionalAttributes:l};return e}(),{render:function(e,a){return i.render("themeBase/plugins/before-button-pagination",e,a)}}}),liveblog.define("plugins/button-pagination",["backbone","plugins","plugins/pagination","dust","lib/utils","lib/helpers/display-toggle","tmpl!themeBase/item/base","tmpl!themeBase/plugins/after-button-pagination","tmpl!themeBase/plugins/before-button-pagination"],function(i,e,a,t,n,r){return delete e.pagination,e["button-pagination"]=function(e){a(e),n.dispatcher.on("initialize.blog-view",function(i){i.clientEvents({'click [data-gimme="posts.to-top"]':"toTop"}),i.toTop=function(){var i=this.$el.offset();window.scrollTo(i.left,i.top)}}),n.dispatcher.once("add-all.posts-view",function(e){var a={};a.baseItem=t.themed("themeBase/item/base"),0===e.$('[data-gimme="posts.beforePage"]').length&&t.renderThemed("themeBase/plugins/before-button-pagination",a,function(a,t){var n=i.$(t);r(n,!1),e.$el.prepend(n)}),0===e.$('[data-gimme="posts.nextPage"]').length&&t.renderThemed("themeBase/plugins/after-button-pagination",a,function(a,t){var n=i.$(t);r(n,!1),e.$el.append(n)})}),n.dispatcher.once("add-all.posts-view",function(i){i.checkNextPage(),i.checkTopPage()}),n.dispatcher.once("initialize.posts-view",function(i){i.clientEvents({'click [data-gimme="posts.nextPage"]':"buttonNextPage",'click [data-gimme="posts.beforePage"]':"buttonTopPage"}),i.checkTopPage=function(){r(this.$('[data-gimme="posts.beforePage"]'),this.hasTopPage())},i.checkNextPage=function(){r(this.$('[data-gimme="posts.nextPage"]'),this.hasNextPage()),n.dispatcher.trigger("pagination-next-updated.posts-view",this)},i.buttonNextPage=function(){i.flags.buttonNextPage=!0;var e=i.$('[data-gimme="posts.nextPage"]');e.addClass("loading"),i.nextPage().done(function(){i.flags.buttonNextPage=!1,e.removeClass("loading"),i.checkNextPage()})},i.buttonTopPage=function(){var e=i.$('[data-gimme="posts.beforePage"]');e.addClass("loading"),i.flags.topPage=!1,i.topPage().done(function(){e.removeClass("loading"),r(e,!1),i.checkNextPage()})}})},e["button-pagination"]}),function(){var i=[].indexOf||function(i){for(var e=0,a=this.length;a>e;e++)if(e in this&&this[e]===i)return e;return-1},e=[].slice;!function(i,e){return"function"==typeof liveblog.define&&liveblog.define.amd?liveblog.define("waypoints",["jquery"],function(a){return e(a,i)}):e(i.jQuery,i)}(window,function(a,t){var n,r,o,c,s,l,u,A,f,m,d,p,g,h,b,T;return n=a(t),A=i.call(t,"ontouchstart")>=0,c={horizontal:{},vertical:{}},s=1,u={},l="waypoints-context-id",d="resize.waypoints",p="scroll.waypoints",g=1,h="waypoints-waypoint-ids",b="waypoint",T="waypoints",r=function(){function i(i){var e=this;this.$element=i,this.element=i[0],this.didResize=!1,this.didScroll=!1,this.id="context"+s++,this.oldScroll={x:i.scrollLeft(),y:i.scrollTop()},this.waypoints={horizontal:{},vertical:{}},this.element[l]=this.id,u[this.id]=this,i.bind(p,function(){var i;return e.didScroll||A?void 0:(e.didScroll=!0,i=function(){return e.doScroll(),e.didScroll=!1},t.setTimeout(i,a[T].settings.scrollThrottle))}),i.bind(d,function(){var i;return e.didResize?void 0:(e.didResize=!0,i=function(){return a[T]("refresh"),e.didResize=!1},t.setTimeout(i,a[T].settings.resizeThrottle))})}return i.prototype.doScroll=function(){var i,e=this;return i={horizontal:{newScroll:this.$element.scrollLeft(),oldScroll:this.oldScroll.x,forward:"right",backward:"left"},vertical:{newScroll:this.$element.scrollTop(),oldScroll:this.oldScroll.y,forward:"down",backward:"up"}},!A||i.vertical.oldScroll&&i.vertical.newScroll||a[T]("refresh"),a.each(i,function(i,t){var n,r,o;return o=[],r=t.newScroll>t.oldScroll,n=r?t.forward:t.backward,a.each(e.waypoints[i],function(i,e){var a,n;return t.oldScroll<(a=e.offset)&&a<=t.newScroll?o.push(e):t.newScroll<(n=e.offset)&&n<=t.oldScroll?o.push(e):void 0}),o.sort(function(i,e){return i.offset-e.offset}),r||o.reverse(),a.each(o,function(i,e){return e.options.continuous||i===o.length-1?e.trigger([n]):void 0})}),this.oldScroll={x:i.horizontal.newScroll,y:i.vertical.newScroll}},i.prototype.refresh=function(){var i,e,t,n=this;return t=a.isWindow(this.element),e=this.$element.offset(),this.doScroll(),i={horizontal:{contextOffset:t?0:e.left,contextScroll:t?0:this.oldScroll.x,contextDimension:this.$element.width(),oldScroll:this.oldScroll.x,forward:"right",backward:"left",offsetProp:"left"},vertical:{contextOffset:t?0:e.top,contextScroll:t?0:this.oldScroll.y,contextDimension:t?a[T]("viewportHeight"):this.$element.height(),oldScroll:this.oldScroll.y,forward:"down",backward:"up",offsetProp:"top"}},a.each(i,function(i,e){return a.each(n.waypoints[i],function(i,t){var n,r,o,c,s;return n=t.options.offset,o=t.offset,r=a.isWindow(t.element)?0:t.$element.offset()[e.offsetProp],a.isFunction(n)?n=n.apply(t.element):"string"==typeof n&&(n=parseFloat(n),t.options.offset.indexOf("%")>-1&&(n=Math.ceil(e.contextDimension*n/100))),t.offset=r-e.contextOffset+e.contextScroll-n,t.options.onlyOnScroll&&null!=o||!t.enabled?void 0:null!==o&&o<(c=e.oldScroll)&&c<=t.offset?t.trigger([e.backward]):null!==o&&o>(s=e.oldScroll)&&s>=t.offset?t.trigger([e.forward]):null===o&&e.oldScroll>=t.offset?t.trigger([e.forward]):void 0})})},i.prototype.checkEmpty=function(){return a.isEmptyObject(this.waypoints.horizontal)&&a.isEmptyObject(this.waypoints.vertical)?(this.$element.unbind([d,p].join(" ")),delete u[this.id]):void 0},i}(),o=function(){function i(i,e,t){var n,r;"bottom-in-view"===t.offset&&(t.offset=function(){var i;return i=a[T]("viewportHeight"),a.isWindow(e.element)||(i=e.$element.height()),i-a(this).outerHeight()}),this.$element=i,this.element=i[0],this.axis=t.horizontal?"horizontal":"vertical",this.callback=t.handler,this.context=e,this.enabled=t.enabled,this.id="waypoints"+g++,this.offset=null,this.options=t,e.waypoints[this.axis][this.id]=this,c[this.axis][this.id]=this,n=null!=(r=this.element[h])?r:[],n.push(this.id),this.element[h]=n}return i.prototype.trigger=function(i){return this.enabled?(null!=this.callback&&this.callback.apply(this.element,i),this.options.triggerOnce?this.destroy():void 0):void 0},i.prototype.disable=function(){return this.enabled=!1},i.prototype.enable=function(){return this.context.refresh(),this.enabled=!0},i.prototype.destroy=function(){return delete c[this.axis][this.id],delete this.context.waypoints[this.axis][this.id],this.context.checkEmpty()},i.getWaypointsByElement=function(i){var e,t;return(t=i[h])?(e=a.extend({},c.horizontal,c.vertical),a.map(t,function(i){return e[i]})):[]},i}(),m={init:function(i,e){var t;return e=a.extend({},a.fn[b].defaults,e),null==(t=e.handler)&&(e.handler=i),this.each(function(){var i,t,n,c;return i=a(this),n=null!=(c=e.context)?c:a.fn[b].defaults.context,a.isWindow(n)||(n=i.closest(n)),n=a(n),t=u[n[0][l]],t||(t=new r(n)),new o(i,t,e)}),a[T]("refresh"),this},disable:function(){return m._invoke.call(this,"disable")},enable:function(){return m._invoke.call(this,"enable")},destroy:function(){return m._invoke.call(this,"destroy")},prev:function(i,e){return m._traverse.call(this,i,e,function(i,e,a){return e>0?i.push(a[e-1]):void 0})},next:function(i,e){return m._traverse.call(this,i,e,function(i,e,a){return ei.oldScroll.y})},left:function(i){return null==i&&(i=t),f._filter(i,"horizontal",function(i,e){return e.offset<=i.oldScroll.x})},right:function(i){return null==i&&(i=t),f._filter(i,"horizontal",function(i,e){return e.offset>i.oldScroll.x})},enable:function(){return f._invoke("enable")},disable:function(){return f._invoke("disable")},destroy:function(){return f._invoke("destroy")},extendFn:function(i,e){return m[i]=e},_invoke:function(i){var e;return e=a.extend({},c.vertical,c.horizontal),a.each(e,function(e,a){return a[i](),!0})},_filter:function(i,e,t){var n,r;return(n=u[a(i)[0][l]])?(r=[],a.each(n.waypoints[e],function(i,e){return t(n,e)?r.push(e):void 0}),r.sort(function(i,e){return i.offset-e.offset}),a.map(r,function(i){return i.element})):[]}},a[T]=function(){var i,a;return a=arguments[0],i=2<=arguments.length?e.call(arguments,1):[],f[a]?f[a].apply(null,i):f.aggregate.call(null,a)},a[T].settings={resizeThrottle:100,scrollThrottle:30},n.on("load.waypoints",function(){return a[T]("refresh")})})}.call(this),liveblog.require.config({paths:{twitterWidgets:"//platform.twitter.com/widgets"},shim:{twitterWidgets:{exports:"twttr"}}}),liveblog.define("plugins/twitter-widgets",["underscore","backbone","plugins","dust","lib/utils"],function(i,e,a,t,n){return a["twitter-widgets"]=function(){if(n.isClient){n.dispatcher.on("before-render.post-view",function(i){"source/twitter"===i.model.get("item")&&(i.parentView()._twitterPosts||(i.parentView()._twitterPosts=[]),i.parentView()._twitterPosts.push(i))}),n.dispatcher.on("add-all.posts-view",function(i){e(i)});var e=function(e){e._twitterPosts&&liveblog.require(["twitterWidgets","waypoints"],function(a){a.ready(function(){i.each(e._twitterPosts,function(i){i.$el.waypoint(function(){var e=i.model.get("Meta").id_str;a.widgets.createTweet(e,i.$el.find(".post-content-full").get(0),function(){i.$el.find(".post-core-content").remove()},{cards:"all"})},{triggerOnce:!0,offset:"120%",context:e.el})}),e._twitterPosts=[]})},function(){})}}},a["twitter-widgets"]}),liveblog.define("lib/helpers/escape-RegExp",[],function(){var i=function(i){return i.replace(/([.*+?^=!:${}()|\[\]\/\\])/g,"\\$1")};return i}),liveblog.define("plugins/post-hash",["plugins","lib/utils","lib/helpers/escape-RegExp"],function(i,e,a){i["post-hash"]=function(){var i,t="liveblog.item.id",n=liveblog.hashmark?liveblog.hashmark:"?";i=e.isClient?window.location.href:liveblog.locationHref||"/",e.dispatcher.on("initialize.post-view",function(e){e.permalink=function(r){var o=r&&r.hashMark?r.hashMark:n,c=!1,s=t+"="+parseFloat(e.model.get("Order"));if(-1===i.indexOf(o))c=i+o+s;else if(-1!==i.indexOf(t+"=")){var l=new RegExp(a(t)+"=[^&#]*");c=i.replace(l,s)}else c=i+"&"+s;return c}}),e.dispatcher.on("initialize.posts-view",function(e){var a=i.indexOf(t+"=");-1!==a&&(e.collection.syncParams.pagination["order.end"]=parseFloat(i.substr(a+t.length+1)),e.flags.hasTopPage=!0,e.flags.autoRender=!1)})}}),liveblog.define("lib/helpers/fixed-encodeURIComponent",[],function(){return function(i){return encodeURIComponent(i).replace(/'/g,"%27").replace(/!/g,"%21").replace(/\(/g,"%28").replace(/\)/g,"%29").replace(/\*/g,"%2A").replace(/~/g,"%7E")}}),liveblog.define("lib/helpers/visibility-toggle",[],function(){var i=function(i,e){var a="";return a=void 0!==e?e?"visible":"hidden":"visible"===i.css("visibility")?"hidden":"visible",i.css("visibility",a),"visible"===a?!0:!1};return i}),liveblog.define("config/social-share-plugin",{urls:{pin:"//pinterest.com/pin/create/button/?url=%s&media=%s&description=%s",twt:"//twitter.com/home?status=%s %s: %s",lin:"//www.linkedin.com/shareArticle?mini=true&url=%s&title=%s&summary=%s",ggl:"//plus.google.com/share?url=%s&t=",email:"mailto:?to=&subject=%s&body=%s",fb:"//www.facebook.com/sharer.php?s=100&p[title]=%s&p[summary]=%s&p[url]=%s%s",fbImageComp:"&p[images][%s]=%s"},shareWindowSize:{pin:{h:400,w:700},twt:{h:400,w:570},lin:{h:400,w:570},ggl:{h:400,w:570},email:{h:1024,w:768},fb:{h:400,w:570}}}),liveblog.define("tmpl!themeBase/plugins/social-share-anchor",["dust"],function(i){return function(){function e(i,e){return i.write('').helper("i18n",e,{},{msgid:"Share"}).write("")}return i.register("themeBase/plugins/social-share-anchor",e),e}(),{render:function(e,a){return i.render("themeBase/plugins/social-share-anchor",e,a)}}}),liveblog.define("tmpl!themeBase/plugins/social-share",["dust"],function(i){return function(){function e(i,e){return i.write('')}function a(i,e){return i.write('')}return i.register("themeBase/plugins/social-share",e),e}(),{render:function(e,a){return i.render("themeBase/plugins/social-share",e,a)}}}),liveblog.define("plugins/social-share",["backbone","underscore","plugins","lib/utils","dust","lib/gettext","lib/helpers/fixed-encodeURIComponent","lib/helpers/visibility-toggle","config/social-share-plugin","tmpl!themeBase/plugins/social-share-anchor","tmpl!themeBase/plugins/social-share"],function(i,e,a,t,n,r,o,c,s){t.isClient&&(a["social-share"]=function(){t.dispatcher.on("after-render.post-view",function(i){n.renderThemed("themeBase/plugins/social-share-anchor",{},function(e,a){i.$('[data-gimme="post.social-share-placeholder"]').html(a)})}),t.dispatcher.on("initialize.post-view",function(i){i.clientEvents({'click [data-gimme="post.social"]':"share"}),i.share=function(i){i.preventDefault();var e=this,t=a(e);e.socialShareUrls=l(t),n.renderThemed("themeBase/plugins/social-share",u(t),function(i,a){e.$('[data-gimme="post.social-share-placeholder"]').append(a)}),A(e);var r=e.$('[data-gimme="post.share-social"]'),o=e.$('[data-gimme^="post.share"]');"hidden"===r.css("visibility")&&c(o,!1),c(r)},i.openShareWindow=function(i){i.preventDefault();var e=this.$(i.target).data("gimme"),a=s.shareWindowSize[e].h,t=s.shareWindowSize[e].w,n=this.socialShareUrls[e],r="resizable, height="+a+", width="+t,o=window.open(n,"",r);return o.focus(),!1}});var a=function(e){var a=e.parentView().parentView().model,t=o(a.get("Title")),n=o(e.$(".result-content .result-text:last").text()),c="";e.permalink&&"function"==typeof e.permalink&&(c=o(e.permalink()));var l=e.$(".result-content img:first").attr("src");l||(l=i.$("img:first").attr("src"));var u="";e.$(".result-content img").each(function(e){u+=r.sprintf(s.fbURLImageComp,[e,i.$(this).attr("src")])});var A={pin:[c,l,t],twt:[r.gettext("Now reading"),t,c],lin:[c,t,n],ggl:[c],email:[r.gettext("Check out this Live Blog"),c],fb:[t,n,c,u]};return A},l=function(i){var a={};return delete i.email,e.each(i,function(e,t){a[t]=r.sprintf(s.urls[t],i[t])}),a},u=function(i){var e={};return e.emailurl=r.sprintf(s.urls.email,i.email),e},A=function(i){var a={};e.each(i.socialShareUrls,function(i,e){a['click [data-gimme="'+e+'"]']="openShareWindow"}),i.clientEvents(a),i.delegateEvents()}})}),liveblog.define("plugins/ivw",[],function(){return function(){"undefined"!=typeof RPO&&RPO.reloadIVW&&RPO.reloadIVW()}}),liveblog.define("plugins/ivw-counter",["plugins","plugins/button-pagination","plugins/ivw","lib/utils"],function(i,e,a,t){return delete i["button-pagination"],i["ivw-counter"]=function(i){e(i),t.dispatcher.once("initialize.posts-view",function(i){i.clientEvents({'click [data-gimme="posts.nextPage"]':"ivwCounter"}),i.ivwCounter=function(){i.buttonNextPage(),a()}})},i["ivw-counter"]}),liveblog.define("plugins/status",["backbone","plugins","lib/utils","lib/gettext","moment"],function(i,e,a,t,n){return a.isClient?(e.status=function(){a.dispatcher.on("initialize.blog-view",function(i){a.dispatcher.on("after-poller.blog-model conditional-render.blog-view",function(){var e=t.sprintf('',n().milliseconds(),n().format(t.pgettext("moment","status-time")));i.$('[data-gimme="blog.status"]').html(t.sprintf(t.gettext("updated at %s"),e))}),a.dispatcher.on("before-poller.blog-model",function(){i.$('[data-gimme="blog.status"]').html(t.gettext("updating..."))})})},e.status):void 0}),liveblog.define("tmpl!themeBase/plugins/pending-items-message",["dust"],function(i){return function(){function e(i){return i.write('')}return i.register("themeBase/plugins/pending-items-message",e),e}(),{render:function(e,a){return i.render("themeBase/plugins/pending-items-message",e,a)}}}),liveblog.define("plugins/pending-messages",["lib/gettext","plugins","lib/utils","dust","tmpl!themeBase/item/base","tmpl!themeBase/plugins/pending-items-message"],function(i,e,a,t){return e.pendingMessages=function(){var e={};a.dispatcher.once("initialize.blog-view",function(i){e=i}),a.dispatcher.once("after-render.blog-view",function(i){t.renderThemed("themeBase/plugins/pending-items-message",{},function(e,a){i.$('[data-gimme="posts.pending-message-placeholder"]').html(a)})}),a.isClient&&(a.dispatcher.once("initialize.posts-view",function(i){i.pauseAutoRender=function(){this.flags.autoRender=!1},i.resumeAutoRender=function(){this.flags.autoRender=!0},e.$el.on("click",'[data-gimme="posts.pending-message"],[data-gimme="posts.pending-message-holder"]',function(){i.renderPending()})}),a.dispatcher.on("update-pending.posts-view",function(a){var t="",n=a.pendingCounter;n>0&&(t=i.sprintf(i.ngettext("one new post","%(count)s new posts",n),{count:n})),e.$('[data-gimme="posts.pending-message"]').html(t).toggle(n>0),e.$('[data-gimme="posts.pending-message-holder"]').toggle(n>0)}))},e.pendingMessages}),liveblog.define("plugins/stop-auto-render",["lib/utils","plugins"],function(i,e){return e.stopAutoRender=function(){i.isClient&&i.dispatcher.once("initialize.posts-view",function(i){i.flags.autoRender=!1})},e.stopAutoRender}),liveblog.define("plugins/ivw-refresh",["plugins","plugins/ivw","lib/utils"],function(i,e,a){return i["ivw-refresh"]=function(){a.dispatcher.once("initialize.blog-view",function(i){a.isClient&&i.$el.on("click",'[data-gimme="posts.pending-message-holder"]',function(){e()})})},i["ivw-refresh"]}),liveblog.define("tmpl!theme/container",["dust"],function(i){return function(){function e(i,e){return e=e.shiftBlocks(p),i.partial("themeBase/container",e,null)}function a(i,e){return e=e.shiftBlocks(p),i.write('
').block(e.getBlock("main"),e,{block:t},null).write("
")}function t(i,e){return e=e.shiftBlocks(p),i.write('
').block(e.getBlock("contentContainer"),e,{block:n},null).block(e.getBlock("footer"),e,{block:m},null).write("
")}function n(i,e){return e=e.shiftBlocks(p),i.write('
').block(e.getBlock("content"),e,{block:r},null).write("
")}function r(i,e){return e=e.shiftBlocks(p),i.block(e.getBlock("contentTopContainer"),e,{block:o},null).block(e.getBlock("contentMiddleContainer"),e,{block:l},null).block(e.getBlock("contentBottomContainer"),e,{block:f},null)}function o(i,e){return e=e.shiftBlocks(p),i.write('
').block(e.getBlock("contentTop"),e,{block:c},null).write("
")}function c(i,e){return e=e.shiftBlocks(p),i.block(e.getBlock("refreshBlock"),e,{block:s},null)}function s(i,e){return e=e.shiftBlocks(p),i}function l(i,e){return e=e.shiftBlocks(p),i.write('
').block(e.getBlock("contentMiddle"),e,{block:u},null).write("
")}function u(i,e){return e=e.shiftBlocks(p),i.block(e.getBlock("postsList"),e,{block:A},null)}function A(i,e){return e=e.shiftBlocks(p),i}function f(i,e){return e=e.shiftBlocks(p),i}function m(i,e){return e=e.shiftBlocks(p),i}function d(i,e){return e=e.shiftBlocks(p),i.write('
')}i.register("theme/container",e);var p={mainContainer:a,refreshBlock:d};return e}(),{render:function(e,a){return i.render("theme/container",e,a)}}}),liveblog.define("tmpl!theme/item/base",["dust"],function(i){return function(){function e(i,e){return e=e.shiftBlocks(d),i.partial("themeBase/item/base",e,null)}function a(i,e){return e=e.shiftBlocks(d),i}function t(i,e){return e=e.shiftBlocks(d),i.write('").block(e.getBlock("commentBefore"),e,{block:c},null).block(e.getBlock("contentMainFull"),e,{block:s},null).block(e.getBlock("commentAfter"),e,{block:m},null)}function n(i,e){return e=e.shiftBlocks(d),i}function r(i,e){return e=e.shiftBlocks(d),i}function o(i,e){return e=e.shiftBlocks(d),i}function c(i,e){return e=e.shiftBlocks(d),i}function s(i,e){return e=e.shiftBlocks(d),i.write('
').block(e.getBlock("contentFull"),e,{block:l},null).write("
")}function l(i,e){return e=e.shiftBlocks(d),i.block(e.getBlock("contentCoreContainer"),e,{block:u},null).block(e.getBlock("contentAttrContainer"),e,{block:f},null)}function u(i,e){return e=e.shiftBlocks(d),i.write('
').block(e.getBlock("contentCore"),e,{block:A},null).write("
")}function A(i,e){return e=e.shiftBlocks(d),i}function f(i,e){return e=e.shiftBlocks(d),i}function m(i,e){return e=e.shiftBlocks(d),i}i.register("theme/item/base",e);var d={headerContainer:a,contentMainBody:t};return e}(),{render:function(e,a){return i.render("theme/item/base",e,a)}}}),liveblog.define("themeFile",["css!theme/liveblog","plugins/button-pagination","plugins/twitter-widgets","plugins/post-hash","plugins/social-share","plugins/ivw-counter","plugins/status","plugins/pending-messages","plugins/stop-auto-render","plugins/ivw-refresh","tmpl!theme/container","tmpl!theme/item/base"],function(){return{plugins:["button-pagination","twitter-widgets","post-hash","social-share","ivw-counter","status","pending-messages","stop-auto-render","ivw-refresh"]}}); \ No newline at end of file +liveblog.define("plugins",{}),liveblog.define("plugins/pagination",["plugins","lib/utils"],function(e,i){return e.pagination=function(){i.dispatcher.once("initialize.posts-view",function(e){e.collection.clearPaginationParams(),liveblog.limit&&(e.collection.syncParams.pagination.limit=parseInt(liveblog.limit,10)),e.flags.loadingNextPage=!1,e.updateNextPageOffset=function(){this.collection.syncParams.pagination.offset=this.collection.length},e.topPage=function(){return delete this.collection.syncParams.pagination["order.end"],this.collection.syncParams.pagination.offset=0,this.collection.fetchPage({reset:!0})},e.nextPage=function(){if(!this.flags.loadingNextPage&&this.hasNextPage()){i.dispatcher.trigger("loading.posts-view",this),this.flags.loadingNextPage=!0,this.updateNextPageOffset();var e=this;return this.collection.fetchPage().done(function(){e.flags.loadingNextPage=!1,i.dispatcher.trigger("loaded.posts-view",e)})}},e.hasNextPage=function(){return this.collection.length96?e-87:e>64?e-29:e-48}function a(e){var a,t=0,n=e.split("."),r=n[0],o=n[1]||"",c=1,s=0,l=1;for(45===e.charCodeAt(0)&&(t=1,l=-1),t;ta;a++)e[a]=Math.round((e[a-1]||0)+6e4*e[a]);e[i-1]=1/0}function r(e,i){var a,t=[];for(a=0;a').helper("i18n",i,{},{msgid:"Load more posts ..."}).write("")}function s(e,i){return i=i.shiftBlocks(u),e.write('')}function l(e,i){return i=i.shiftBlocks(u),e.write('data-gimme="posts.nextPage"')}e.register("themeBase/plugins/after-button-pagination",i); +var u={itemClass:t,main:n,loadNext:c,loadingNext:s,additionalAttributes:l};return i}(),{render:function(i,a){return e.render("themeBase/plugins/after-button-pagination",i,a)}}}),liveblog.define("tmpl!themeBase/plugins/before-button-pagination",["dust"],function(e){return function(){function i(e,i){return i=i.shiftBlocks(u),e.partial(a,i,null)}function a(e,i){return i=i.shiftBlocks(u),e.reference(i.get(["baseItem"],!1),i,"h")}function t(e,i){return i=i.shiftBlocks(u),e.write("load-next")}function n(e,i){return i=i.shiftBlocks(u),e.block(i.getBlock("loadNext"),i,{block:r},null).block(i.getBlock("loadingNext"),i,{block:o},null)}function r(e,i){return i=i.shiftBlocks(u),e}function o(e,i){return i=i.shiftBlocks(u),e}function c(e,i){return i=i.shiftBlocks(u),e.write('Load top posts')}function s(e,i){return i=i.shiftBlocks(u),e.write('')}function l(e,i){return i=i.shiftBlocks(u),e.write('data-gimme="posts.beforePage"')}e.register("themeBase/plugins/before-button-pagination",i);var u={itemClass:t,main:n,loadNext:c,loadingNext:s,additionalAttributes:l};return i}(),{render:function(i,a){return e.render("themeBase/plugins/before-button-pagination",i,a)}}}),liveblog.define("plugins/button-pagination",["backbone","plugins","plugins/pagination","dust","lib/utils","lib/helpers/display-toggle","tmpl!themeBase/item/base","tmpl!themeBase/plugins/after-button-pagination","tmpl!themeBase/plugins/before-button-pagination"],function(e,i,a,t,n,r){return delete i.pagination,i["button-pagination"]=function(i){a(i),n.dispatcher.on("initialize.blog-view",function(e){e.clientEvents({'click [data-gimme="posts.to-top"]':"toTop"}),e.toTop=function(){var e=this.$el.offset();window.scrollTo(e.left,e.top)}}),n.dispatcher.once("add-all.posts-view",function(i){var a={};a.baseItem=t.themed("themeBase/item/base"),0===i.$('[data-gimme="posts.beforePage"]').length&&t.renderThemed("themeBase/plugins/before-button-pagination",a,function(a,t){var n=e.$(t);r(n,!1),i.$el.prepend(n)}),0===i.$('[data-gimme="posts.nextPage"]').length&&t.renderThemed("themeBase/plugins/after-button-pagination",a,function(a,t){var n=e.$(t);r(n,!1),i.$el.append(n)})}),n.dispatcher.once("add-all.posts-view",function(e){e.checkNextPage(),e.checkTopPage()}),n.dispatcher.once("initialize.posts-view",function(e){e.clientEvents({'click [data-gimme="posts.nextPage"]':"buttonNextPage",'click [data-gimme="posts.beforePage"]':"buttonTopPage"}),e.checkTopPage=function(){r(this.$('[data-gimme="posts.beforePage"]'),this.hasTopPage())},e.checkNextPage=function(){r(this.$('[data-gimme="posts.nextPage"]'),this.hasNextPage()),n.dispatcher.trigger("pagination-next-updated.posts-view",this)},e.buttonNextPage=function(){e.flags.buttonNextPage=!0;var i=e.$('[data-gimme="posts.nextPage"]');i.addClass("loading"),e.nextPage().done(function(){e.flags.buttonNextPage=!1,i.removeClass("loading"),e.checkNextPage()})},e.buttonTopPage=function(){var i=e.$('[data-gimme="posts.beforePage"]');i.addClass("loading"),e.flags.topPage=!1,e.topPage().done(function(){i.removeClass("loading"),r(i,!1),e.checkNextPage()})}})},i["button-pagination"]}),function(){var e=[].indexOf||function(e){for(var i=0,a=this.length;a>i;i++)if(i in this&&this[i]===e)return i;return-1},i=[].slice;!function(e,i){return"function"==typeof liveblog.define&&liveblog.define.amd?liveblog.define("waypoints",["jquery"],function(a){return i(a,e)}):i(e.jQuery,e)}(window,function(a,t){var n,r,o,c,s,l,u,A,f,m,d,p,g,h,b,T;return n=a(t),A=e.call(t,"ontouchstart")>=0,c={horizontal:{},vertical:{}},s=1,u={},l="waypoints-context-id",d="resize.waypoints",p="scroll.waypoints",g=1,h="waypoints-waypoint-ids",b="waypoint",T="waypoints",r=function(){function e(e){var i=this;this.$element=e,this.element=e[0],this.didResize=!1,this.didScroll=!1,this.id="context"+s++,this.oldScroll={x:e.scrollLeft(),y:e.scrollTop()},this.waypoints={horizontal:{},vertical:{}},this.element[l]=this.id,u[this.id]=this,e.bind(p,function(){var e;return i.didScroll||A?void 0:(i.didScroll=!0,e=function(){return i.doScroll(),i.didScroll=!1},t.setTimeout(e,a[T].settings.scrollThrottle))}),e.bind(d,function(){var e;return i.didResize?void 0:(i.didResize=!0,e=function(){return a[T]("refresh"),i.didResize=!1},t.setTimeout(e,a[T].settings.resizeThrottle))})}return e.prototype.doScroll=function(){var e,i=this;return e={horizontal:{newScroll:this.$element.scrollLeft(),oldScroll:this.oldScroll.x,forward:"right",backward:"left"},vertical:{newScroll:this.$element.scrollTop(),oldScroll:this.oldScroll.y,forward:"down",backward:"up"}},!A||e.vertical.oldScroll&&e.vertical.newScroll||a[T]("refresh"),a.each(e,function(e,t){var n,r,o;return o=[],r=t.newScroll>t.oldScroll,n=r?t.forward:t.backward,a.each(i.waypoints[e],function(e,i){var a,n;return t.oldScroll<(a=i.offset)&&a<=t.newScroll?o.push(i):t.newScroll<(n=i.offset)&&n<=t.oldScroll?o.push(i):void 0}),o.sort(function(e,i){return e.offset-i.offset}),r||o.reverse(),a.each(o,function(e,i){return i.options.continuous||e===o.length-1?i.trigger([n]):void 0})}),this.oldScroll={x:e.horizontal.newScroll,y:e.vertical.newScroll}},e.prototype.refresh=function(){var e,i,t,n=this;return t=a.isWindow(this.element),i=this.$element.offset(),this.doScroll(),e={horizontal:{contextOffset:t?0:i.left,contextScroll:t?0:this.oldScroll.x,contextDimension:this.$element.width(),oldScroll:this.oldScroll.x,forward:"right",backward:"left",offsetProp:"left"},vertical:{contextOffset:t?0:i.top,contextScroll:t?0:this.oldScroll.y,contextDimension:t?a[T]("viewportHeight"):this.$element.height(),oldScroll:this.oldScroll.y,forward:"down",backward:"up",offsetProp:"top"}},a.each(e,function(e,i){return a.each(n.waypoints[e],function(e,t){var n,r,o,c,s;return n=t.options.offset,o=t.offset,r=a.isWindow(t.element)?0:t.$element.offset()[i.offsetProp],a.isFunction(n)?n=n.apply(t.element):"string"==typeof n&&(n=parseFloat(n),t.options.offset.indexOf("%")>-1&&(n=Math.ceil(i.contextDimension*n/100))),t.offset=r-i.contextOffset+i.contextScroll-n,t.options.onlyOnScroll&&null!=o||!t.enabled?void 0:null!==o&&o<(c=i.oldScroll)&&c<=t.offset?t.trigger([i.backward]):null!==o&&o>(s=i.oldScroll)&&s>=t.offset?t.trigger([i.forward]):null===o&&i.oldScroll>=t.offset?t.trigger([i.forward]):void 0})})},e.prototype.checkEmpty=function(){return a.isEmptyObject(this.waypoints.horizontal)&&a.isEmptyObject(this.waypoints.vertical)?(this.$element.unbind([d,p].join(" ")),delete u[this.id]):void 0},e}(),o=function(){function e(e,i,t){var n,r;"bottom-in-view"===t.offset&&(t.offset=function(){var e;return e=a[T]("viewportHeight"),a.isWindow(i.element)||(e=i.$element.height()),e-a(this).outerHeight()}),this.$element=e,this.element=e[0],this.axis=t.horizontal?"horizontal":"vertical",this.callback=t.handler,this.context=i,this.enabled=t.enabled,this.id="waypoints"+g++,this.offset=null,this.options=t,i.waypoints[this.axis][this.id]=this,c[this.axis][this.id]=this,n=null!=(r=this.element[h])?r:[],n.push(this.id),this.element[h]=n}return e.prototype.trigger=function(e){return this.enabled?(null!=this.callback&&this.callback.apply(this.element,e),this.options.triggerOnce?this.destroy():void 0):void 0},e.prototype.disable=function(){return this.enabled=!1},e.prototype.enable=function(){return this.context.refresh(),this.enabled=!0},e.prototype.destroy=function(){return delete c[this.axis][this.id],delete this.context.waypoints[this.axis][this.id],this.context.checkEmpty()},e.getWaypointsByElement=function(e){var i,t;return(t=e[h])?(i=a.extend({},c.horizontal,c.vertical),a.map(t,function(e){return i[e]})):[]},e}(),m={init:function(e,i){var t;return i=a.extend({},a.fn[b].defaults,i),null==(t=i.handler)&&(i.handler=e),this.each(function(){var e,t,n,c;return e=a(this),n=null!=(c=i.context)?c:a.fn[b].defaults.context,a.isWindow(n)||(n=e.closest(n)),n=a(n),t=u[n[0][l]],t||(t=new r(n)),new o(e,t,i)}),a[T]("refresh"),this},disable:function(){return m._invoke.call(this,"disable")},enable:function(){return m._invoke.call(this,"enable")},destroy:function(){return m._invoke.call(this,"destroy")},prev:function(e,i){return m._traverse.call(this,e,i,function(e,i,a){return i>0?e.push(a[i-1]):void 0})},next:function(e,i){return m._traverse.call(this,e,i,function(e,i,a){return ie.oldScroll.y})},left:function(e){return null==e&&(e=t),f._filter(e,"horizontal",function(e,i){return i.offset<=e.oldScroll.x})},right:function(e){return null==e&&(e=t),f._filter(e,"horizontal",function(e,i){return i.offset>e.oldScroll.x})},enable:function(){return f._invoke("enable")},disable:function(){return f._invoke("disable")},destroy:function(){return f._invoke("destroy")},extendFn:function(e,i){return m[e]=i},_invoke:function(e){var i;return i=a.extend({},c.vertical,c.horizontal),a.each(i,function(i,a){return a[e](),!0})},_filter:function(e,i,t){var n,r;return(n=u[a(e)[0][l]])?(r=[],a.each(n.waypoints[i],function(e,i){return t(n,i)?r.push(i):void 0}),r.sort(function(e,i){return e.offset-i.offset}),a.map(r,function(e){return e.element})):[]}},a[T]=function(){var e,a;return a=arguments[0],e=2<=arguments.length?i.call(arguments,1):[],f[a]?f[a].apply(null,e):f.aggregate.call(null,a)},a[T].settings={resizeThrottle:100,scrollThrottle:30},n.on("load.waypoints",function(){return a[T]("refresh")})})}.call(this),liveblog.require.config({paths:{twitterWidgets:"//platform.twitter.com/widgets"},shim:{twitterWidgets:{exports:"twttr"}}}),liveblog.define("plugins/twitter-widgets",["underscore","backbone","plugins","dust","lib/utils"],function(e,i,a,t,n){return a["twitter-widgets"]=function(){if(n.isClient){n.dispatcher.on("before-render.post-view",function(e){"source/twitter"===e.model.get("item")&&(e.parentView()._twitterPosts||(e.parentView()._twitterPosts=[]),e.parentView()._twitterPosts.push(e))}),n.dispatcher.on("add-all.posts-view",function(e){i(e)});var i=function(i){i._twitterPosts&&liveblog.require(["twitterWidgets","waypoints"],function(a){a.ready(function(){e.each(i._twitterPosts,function(e){e.$el.waypoint(function(){var i=e.model.get("Meta").id_str;a.widgets.createTweet(i,e.$el.find(".post-content-full").get(0),function(){e.$el.find(".post-core-content").remove()},{cards:"all"})},{triggerOnce:!0,offset:"120%",context:i.el})}),i._twitterPosts=[]})},function(){})}}},a["twitter-widgets"]}),liveblog.define("lib/helpers/escape-RegExp",[],function(){var e=function(e){return e.replace(/([.*+?^=!:${}()|\[\]\/\\])/g,"\\$1")};return e}),liveblog.define("plugins/post-hash",["plugins","lib/utils","lib/helpers/escape-RegExp"],function(e,i,a){e["post-hash"]=function(){var e,t="liveblog.item.id",n=liveblog.hashmark?liveblog.hashmark:"?";e=i.isClient?window.location.href:liveblog.locationHref||"/",i.dispatcher.on("initialize.post-view",function(i){i.permalink=function(r){var o=r&&r.hashMark?r.hashMark:n,c=!1,s=t+"="+parseFloat(i.model.get("Order"));if(-1===e.indexOf(o))c=e+o+s;else if(-1!==e.indexOf(t+"=")){var l=new RegExp(a(t)+"=[^&#]*");c=e.replace(l,s)}else c=e+"&"+s;return c}}),i.dispatcher.on("initialize.posts-view",function(i){var a=e.indexOf(t+"=");-1!==a&&(i.collection.syncParams.pagination["order.end"]=parseFloat(e.substr(a+t.length+1)),i.flags.hasTopPage=!0,i.flags.autoRender=!1)})}}),liveblog.define("lib/helpers/fixed-encodeURIComponent",[],function(){return function(e){return encodeURIComponent(e).replace(/'/g,"%27").replace(/!/g,"%21").replace(/\(/g,"%28").replace(/\)/g,"%29").replace(/\*/g,"%2A").replace(/~/g,"%7E")}}),liveblog.define("lib/helpers/visibility-toggle",[],function(){var e=function(e,i){var a="";return a=void 0!==i?i?"visible":"hidden":"visible"===e.css("visibility")?"hidden":"visible",e.css("visibility",a),"visible"===a?!0:!1};return e}),liveblog.define("config/social-share-plugin",{urls:{pin:"//pinterest.com/pin/create/button/?url=%s&media=%s&description=%s",twt:"//twitter.com/home?status=%s %s: %s",lin:"//www.linkedin.com/shareArticle?mini=true&url=%s&title=%s&summary=%s",ggl:"//plus.google.com/share?url=%s&t=",email:"mailto:?to=&subject=%s&body=%s",fb:"//www.facebook.com/sharer.php?s=100&p[title]=%s&p[summary]=%s&p[url]=%s%s",fbImageComp:"&p[images][%s]=%s"},shareWindowSize:{pin:{h:400,w:700},twt:{h:400,w:570},lin:{h:400,w:570},ggl:{h:400,w:570},email:{h:1024,w:768},fb:{h:400,w:570}}}),liveblog.define("tmpl!themeBase/plugins/social-share-anchor",["dust"],function(e){return function(){function i(e,i){return e.write('').helper("i18n",i,{},{msgid:"Share"}).write("")}return e.register("themeBase/plugins/social-share-anchor",i),i}(),{render:function(i,a){return e.render("themeBase/plugins/social-share-anchor",i,a)}}}),liveblog.define("tmpl!themeBase/plugins/social-share",["dust"],function(e){return function(){function i(e,i){return e.write('')}function a(e,i){return e.write('')}return e.register("themeBase/plugins/social-share",i),i}(),{render:function(i,a){return e.render("themeBase/plugins/social-share",i,a)}}}),liveblog.define("plugins/social-share",["backbone","underscore","plugins","lib/utils","dust","lib/gettext","lib/helpers/fixed-encodeURIComponent","lib/helpers/visibility-toggle","config/social-share-plugin","tmpl!themeBase/plugins/social-share-anchor","tmpl!themeBase/plugins/social-share"],function(e,i,a,t,n,r,o,c,s){t.isClient&&(a["social-share"]=function(){t.dispatcher.on("after-render.post-view",function(e){n.renderThemed("themeBase/plugins/social-share-anchor",{},function(i,a){e.$('[data-gimme="post.social-share-placeholder"]').html(a)})}),t.dispatcher.on("initialize.post-view",function(e){e.clientEvents({'click [data-gimme="post.social"]':"share"}),e.share=function(e){e.preventDefault();var i=this,t=a(i);i.socialShareUrls=l(t),n.renderThemed("themeBase/plugins/social-share",u(t),function(e,a){i.$('[data-gimme="post.social-share-placeholder"]').append(a)}),A(i);var r=i.$('[data-gimme="post.share-social"]'),o=i.$('[data-gimme^="post.share"]');"hidden"===r.css("visibility")&&c(o,!1),c(r)},e.openShareWindow=function(e){e.preventDefault();var i=this.$(e.target).data("gimme"),a=s.shareWindowSize[i].h,t=s.shareWindowSize[i].w,n=this.socialShareUrls[i],r="resizable, height="+a+", width="+t,o=window.open(n,"",r);return o.focus(),!1}});var a=function(i){var a=i.parentView().parentView().model,t=o(a.get("Title")),n=o(i.$(".result-content .result-text:last").text()),c="";i.permalink&&"function"==typeof i.permalink&&(c=o(i.permalink()));var l=i.$(".result-content img:first").attr("src");l||(l=e.$("img:first").attr("src"));var u="";i.$(".result-content img").each(function(i){u+=r.sprintf(s.fbURLImageComp,[i,e.$(this).attr("src")])});var A={pin:[c,l,t],twt:[r.gettext("Now reading"),t,c],lin:[c,t,n],ggl:[c],email:[r.gettext("Check out this Live Blog"),c],fb:[t,n,c,u]};return A},l=function(e){var a={};return delete e.email,i.each(e,function(i,t){a[t]=r.sprintf(s.urls[t],e[t])}),a},u=function(e){var i={};return i.emailurl=r.sprintf(s.urls.email,e.email),i},A=function(e){var a={};i.each(e.socialShareUrls,function(e,i){a['click [data-gimme="'+i+'"]']="openShareWindow"}),e.clientEvents(a),e.delegateEvents()}})}),liveblog.define("plugins/ivw",[],function(){return function(){"undefined"!=typeof RPO&&RPO.reloadIVW&&RPO.reloadIVW()}}),liveblog.define("plugins/ivw-counter",["plugins","plugins/button-pagination","plugins/ivw","lib/utils"],function(e,i,a,t){return delete e["button-pagination"],e["ivw-counter"]=function(e){i(e),t.dispatcher.once("initialize.posts-view",function(e){e.clientEvents({'click [data-gimme="posts.nextPage"]':"ivwCounter"}),e.ivwCounter=function(){e.buttonNextPage(),a()}})},e["ivw-counter"]}),liveblog.define("plugins/status",["backbone","plugins","lib/utils","lib/gettext","moment"],function(e,i,a,t,n){return a.isClient?(i.status=function(){a.dispatcher.on("initialize.blog-view",function(e){a.dispatcher.on("after-poller.blog-model conditional-render.blog-view",function(){var i=t.sprintf('',n().milliseconds(),n().format(t.pgettext("moment","status-time")));e.$('[data-gimme="blog.status"]').html(t.sprintf(t.gettext("updated at %s"),i))}),a.dispatcher.on("before-poller.blog-model",function(){e.$('[data-gimme="blog.status"]').html(t.gettext("updating..."))})})},i.status):void 0}),liveblog.define("tmpl!themeBase/plugins/pending-items-message",["dust"],function(e){return function(){function i(e){return e.write('')}return e.register("themeBase/plugins/pending-items-message",i),i}(),{render:function(i,a){return e.render("themeBase/plugins/pending-items-message",i,a)}}}),liveblog.define("plugins/pending-messages",["lib/gettext","plugins","lib/utils","dust","tmpl!themeBase/item/base","tmpl!themeBase/plugins/pending-items-message"],function(e,i,a,t){return i.pendingMessages=function(){var i={};a.dispatcher.once("initialize.blog-view",function(e){i=e}),a.dispatcher.once("after-render.blog-view",function(e){t.renderThemed("themeBase/plugins/pending-items-message",{},function(i,a){e.$('[data-gimme="posts.pending-message-placeholder"]').html(a)})}),a.isClient&&(a.dispatcher.once("initialize.posts-view",function(e){e.pauseAutoRender=function(){this.flags.autoRender=!1},e.resumeAutoRender=function(){this.flags.autoRender=!0},i.$el.on("click",'[data-gimme="posts.pending-message"],[data-gimme="posts.pending-message-holder"]',function(){e.renderPending()})}),a.dispatcher.on("update-pending.posts-view",function(a){var t="",n=a.pendingCounter;n>0&&(t=e.sprintf(e.ngettext("one new post","%(count)s new posts",n),{count:n})),i.$('[data-gimme="posts.pending-message"]').html(t).toggle(n>0),i.$('[data-gimme="posts.pending-message-holder"]').toggle(n>0)}))},i.pendingMessages}),liveblog.define("plugins/stop-auto-render",["lib/utils","plugins"],function(e,i){return i.stopAutoRender=function(){e.isClient&&e.dispatcher.once("initialize.posts-view",function(e){e.flags.autoRender=!1})},i.stopAutoRender}),liveblog.define("plugins/ivw-refresh",["plugins","plugins/ivw","lib/utils"],function(e,i,a){return e["ivw-refresh"]=function(){a.dispatcher.once("initialize.blog-view",function(e){a.isClient&&e.$el.on("click",'[data-gimme="posts.pending-message-holder"]',function(){i()})})},e["ivw-refresh"]}),liveblog.define("plugins/image-fix",["lib/utils","plugins"],function(e,i){return i.imageFix=function(){e.dispatcher.on("before-render.post-view",function(e){if("posttype/image"===e.model.get("item")||"posttype/normal"===e.model.get("item")){var i=e.model.get("Content");i=i.replace(/null(\n )?/,""),i=i.replace(new RegExp("]*)>(.*?)","gi"),function(e,i){return i.replace(/"(.*?)content\/media_archive\/image([^"]*)"/,function(i){e=""}),e}),i=i.replace(/"(.*?)content\/media_archive\/image([^"]*)"/,function(e){return e+' class="liveblog-local"'}),e.model.set({Content:i},{silent:!0})}})},i.imageFix}),liveblog.define("tmpl!theme/container",["dust"],function(e){return function(){function i(e,i){return i=i.shiftBlocks(p),e.partial("themeBase/container",i,null)}function a(e,i){return i=i.shiftBlocks(p),e.write('
').block(i.getBlock("main"),i,{block:t},null).write("
")}function t(e,i){return i=i.shiftBlocks(p),e.write('
').block(i.getBlock("contentContainer"),i,{block:n},null).block(i.getBlock("footer"),i,{block:m},null).write("
")}function n(e,i){return i=i.shiftBlocks(p),e.write('
').block(i.getBlock("content"),i,{block:r},null).write("
")}function r(e,i){return i=i.shiftBlocks(p),e.block(i.getBlock("contentTopContainer"),i,{block:o},null).block(i.getBlock("contentMiddleContainer"),i,{block:l},null).block(i.getBlock("contentBottomContainer"),i,{block:f},null)}function o(e,i){return i=i.shiftBlocks(p),e.write('
').block(i.getBlock("contentTop"),i,{block:c},null).write("
")}function c(e,i){return i=i.shiftBlocks(p),e.block(i.getBlock("refreshBlock"),i,{block:s},null)}function s(e,i){return i=i.shiftBlocks(p),e}function l(e,i){return i=i.shiftBlocks(p),e.write('
').block(i.getBlock("contentMiddle"),i,{block:u},null).write("
")}function u(e,i){return i=i.shiftBlocks(p),e.block(i.getBlock("postsList"),i,{block:A},null)}function A(e,i){return i=i.shiftBlocks(p),e}function f(e,i){return i=i.shiftBlocks(p),e}function m(e,i){return i=i.shiftBlocks(p),e}function d(e,i){return i=i.shiftBlocks(p),e.write('
')}e.register("theme/container",i);var p={mainContainer:a,refreshBlock:d};return i}(),{render:function(i,a){return e.render("theme/container",i,a)}}}),liveblog.define("tmpl!theme/item/base",["dust"],function(e){return function(){function i(e,i){return i=i.shiftBlocks(d),e.partial("themeBase/item/base",i,null)}function a(e,i){return i=i.shiftBlocks(d),e}function t(e,i){return i=i.shiftBlocks(d),e.write('").block(i.getBlock("commentBefore"),i,{block:c},null).block(i.getBlock("contentMainFull"),i,{block:s},null).block(i.getBlock("commentAfter"),i,{block:m},null)}function n(e,i){return i=i.shiftBlocks(d),e}function r(e,i){return i=i.shiftBlocks(d),e}function o(e,i){return i=i.shiftBlocks(d),e}function c(e,i){return i=i.shiftBlocks(d),e}function s(e,i){return i=i.shiftBlocks(d),e.write('
').block(i.getBlock("contentFull"),i,{block:l},null).write("
")}function l(e,i){return i=i.shiftBlocks(d),e.block(i.getBlock("contentCoreContainer"),i,{block:u},null).block(i.getBlock("contentAttrContainer"),i,{block:f},null)}function u(e,i){return i=i.shiftBlocks(d),e.write('
').block(i.getBlock("contentCore"),i,{block:A},null).write("
")}function A(e,i){return i=i.shiftBlocks(d),e}function f(e,i){return i=i.shiftBlocks(d),e}function m(e,i){return i=i.shiftBlocks(d),e}e.register("theme/item/base",i);var d={headerContainer:a,contentMainBody:t};return i}(),{render:function(i,a){return e.render("theme/item/base",i,a)}}}),liveblog.define("themeFile",["css!theme/liveblog","plugins/button-pagination","plugins/twitter-widgets","plugins/post-hash","plugins/social-share","plugins/ivw-counter","plugins/status","plugins/pending-messages","plugins/stop-auto-render","plugins/ivw-refresh","plugins/image-fix","tmpl!theme/container","tmpl!theme/item/base"],function(){return{plugins:["button-pagination","twitter-widgets","post-hash","social-share","ivw-counter","status","pending-messages","stop-auto-render","ivw-refresh","image-fix"]}}); \ No newline at end of file diff --git a/gui-resources/scripts/js/plugins/image-fix.js b/gui-resources/scripts/js/plugins/image-fix.js new file mode 100644 index 000000000..2ab5712d6 --- /dev/null +++ b/gui-resources/scripts/js/plugins/image-fix.js @@ -0,0 +1,32 @@ +'use strict'; + +define([ + 'lib/utils', + 'plugins' +], function (utils, plugins) { + plugins.imageFix = function (config) { + utils.dispatcher.on('before-render.post-view', function (view) { + if (view.model.get('item') !== 'posttype/image' && + view.model.get('item') !== 'posttype/normal') { + return; + } + var Content = view.model.get('Content'); + // remove 'null' with or without   trailing. + Content = Content.replace(/null(\n )?/, ''); + // replace all links that have images with the actuall image. + Content = Content.replace(new RegExp(']*)>(.*?)', 'gi'), function(all, attr) { + attr.replace(/"(.*?)content\/media_archive\/image([^"]*)"/, function(link) { + all = ''; + }); + return all; + }); + // add a class for all local images. + Content = Content.replace(/"(.*?)content\/media_archive\/image([^"]*)"/, function(link) { + return link + ' class="liveblog-local"'; + }); + view.model.set({Content: Content}, {silent: true}); + }); + + }; + return plugins.imageFix; +}); diff --git a/gui-themes/themes/rp/desktop.js b/gui-themes/themes/rp/desktop.js index a0880d635..b7bfcf07d 100644 --- a/gui-themes/themes/rp/desktop.js +++ b/gui-themes/themes/rp/desktop.js @@ -11,6 +11,7 @@ define([ 'plugins/pending-messages', 'plugins/stop-auto-render', 'plugins/ivw-refresh', + 'plugins/image-fix', 'tmpl!theme/container', 'tmpl!theme/item/base' ], function() { @@ -24,7 +25,8 @@ define([ 'status', 'pending-messages', 'stop-auto-render', - 'ivw-refresh' + 'ivw-refresh', + 'image-fix' ] }; }); diff --git a/gui-themes/themes/rp/desktop/liveblog.css b/gui-themes/themes/rp/desktop/liveblog.css index 56407e37b..73cfb9bd0 100644 --- a/gui-themes/themes/rp/desktop/liveblog.css +++ b/gui-themes/themes/rp/desktop/liveblog.css @@ -40,6 +40,11 @@ padding: 0; } +#livedesk-root .liveblog-local +{ + width: 100%; +} + #livedesk-root blockquote { border: none; padding-bottom: 0px; diff --git a/package.json b/package.json index b169e3363..2b39ef31c 100644 --- a/package.json +++ b/package.json @@ -66,6 +66,7 @@ "grunt-karma-coveralls": "^2.5.1", "grunt-mocha-test": "^0.10.2", "grunt-open": "^0.2.3", + "jasmine-reporters": "^1.0.0", "jssha": "^1.5.0", "karma": "^0.12.9", "karma-chrome-launcher": "^0.1.3", diff --git a/protractor-conf.js b/protractor-conf.js index 638857e56..a144fc1de 100644 --- a/protractor-conf.js +++ b/protractor-conf.js @@ -44,5 +44,9 @@ exports.config = { }, takeScreenShotsOnlyForFailedSpecs: true })); + require('jasmine-reporters'); + jasmine.getEnv().addReporter( + new jasmine.JUnitXmlReporter('e2e-test-results', true, true) + ); } }; diff --git a/spec/embed_spec.js b/spec/embed_spec.js index ab6d6277d..cbf48b95b 100644 --- a/spec/embed_spec.js +++ b/spec/embed_spec.js @@ -6,6 +6,9 @@ var uploadFixtures = require('./helpers/liveblog_fixtures').uploadFixtures; var liveblogBackend = require('./helpers/liveblog_posts.js'); var postCreateAndPublish = liveblogBackend.postCreateAndPublish; var postEdit = liveblogBackend.postEdit; +var postDelete = liveblogBackend.postDelete; +var postUnpublish = liveblogBackend.postUnpublish; +var postsReorder = liveblogBackend.postsReorder; // Protractor Params: var pp = protractor.getInstance().params; @@ -13,82 +16,230 @@ var pp = protractor.getInstance().params; describe('Embed', function() { 'use strict'; - describe(' (when have one post)', function() { - beforeEach(function(done) { - uploadFixtures('posts', 1, function(e, r, j) { - gotoUri('/', function() { - done(); - }); + beforeEach(function(done) { + uploadFixtures('posts', 0, function(e, r, j) { + gotoUri('/', function() { + done(); }); }); + }); - it(' is rendered serverside', function() { - expect( - element(by.css('div[data-gimme="liveblog-layout"]')) - .isDisplayed() - ).toBe(true); - }); - + it(' is rendered serverside', function() { + expect( + element(by.css('div[data-gimme="liveblog-layout"]')) + .isDisplayed() + ).toBe(true); }); - describe(' (when blank)', function() { - beforeEach(function(done) { - uploadFixtures('posts', 0, function(e, r, j) { - gotoUri('/', function() { - done(); - }); - }); + it(' is updating to show just added post', function() { + var postContent = randomText(); + postCreateAndPublish({ + postContent: postContent }); - - it(' is updating to show just added post', function() { - var postContent = randomText(); - postCreateAndPublish({ - postContent: postContent - }); - browser.wait(function() { + browser.wait( + function() { return browser.isElementPresent( by.cssContainingText( 'div.liveblog-content p.post-text', postContent - ) - ); - }, pp.maxTimeout); - expect(true).toBe(true); - }, pp.maxTimeout); + )); + }, + pp.maxTimeout, + 'Just added post should appear on page.' + ); + }, + //it + pp.maxTimeout); - it(' is updating to show just edited post', function() { - var postContent = randomText(), - newContent = randomText(), - postId; - postCreateAndPublish({ - postContent: postContent - }, function(e, r, j, id) { - postId = id; - }); - browser.wait(function() { + it(' is updating to show just edited post', function() { + var postContent = randomText(), + newContent = randomText(), + postId; + postCreateAndPublish({ + postContent: postContent + }, function(e, r, j, id) { + postId = id; + }); + browser.wait( + function() { return browser.isElementPresent( by.cssContainingText( 'div.liveblog-content p.post-text', postContent - ) - ); - }, pp.maxTimeout) - .then(function() { - postEdit({ - postId: postId, - newContent: newContent - }); - browser.wait(function() { + )); + }, + pp.maxTimeout, + 'Just added post should appear on page.' + ).then(function() { + postEdit({ + postId: postId, + newContent: newContent + }); + browser.wait( + function() { return browser.isElementPresent( by.cssContainingText( 'div.liveblog-content p.post-text', newContent ) ); - }, pp.maxTimeout); - expect(true).toBe(true); + }, + pp.maxTimeout, + 'Just edited post should be updated on page.' + ); + }); + }, + //it + pp.maxTimeout * 2); + + it(' is updating to show what post was just deleted', function() { + var postContent = randomText(), + postId; + postCreateAndPublish({ + postContent: postContent + }, function(e, r, j, id) { + postId = id; + }); + browser.wait( + function() { + return browser.isElementPresent( + by.cssContainingText( + 'div.liveblog-content p.post-text', + postContent + )); + }, + pp.maxTimeout, + 'Just added post should appear on page.' + ).then(function() { + postDelete({ + postId: postId }); - }, pp.maxTimeout * 2); - }); + browser.wait( + function() { + return element.all( + by.cssContainingText( + 'div.liveblog-content p.post-text', + postContent + ) + ).count().then( + function(count) { + return count === 0; + } + ); + }, pp.maxTimeout, + 'Just deleted post should disappear from page.' + ); + }); + }, + //it + pp.maxTimeout * 2); + + it(' is updating to show what post was just ubpublished', function() { + var postContent = randomText(), + postId; + postCreateAndPublish({ + postContent: postContent + }, function(e, r, j, id) { + postId = id; + }); + browser.wait( + function() { + return browser.isElementPresent( + by.cssContainingText( + 'div.liveblog-content p.post-text', + postContent + )); + }, + pp.maxTimeout, + 'Just added post should appear on page.' + ).then(function() { + postUnpublish({ + postId: postId + }); + browser.wait( + function() { + return element.all( + by.cssContainingText( + 'div.liveblog-content p.post-text', + postContent + ) + ).count().then( + function(count) { + return count === 0; + } + ); + }, pp.maxTimeout, + 'Just unpublished post should disappear from page.' + ); + }); + }, + //it + pp.maxTimeout * 2); + + it(' is updating to show what posts were reordered', function() { + var firstPostContent = randomText(), + secondPostContent = randomText(), + firstPostId, + secondPostId; + postCreateAndPublish({ + postContent: firstPostContent + }, function(e, r, j, id) { + firstPostId = id; + }); + browser.wait( + function() { + return browser.isElementPresent( + by.cssContainingText( + 'div.liveblog-content p.post-text', + firstPostContent + )); + }, + pp.maxTimeout, + 'First added post should appear on page.' + ).then(function() { + postCreateAndPublish({ + postContent: secondPostContent + }, function(e, r, j, id) { + secondPostId = id; + }); + browser.wait( + function() { + return browser.isElementPresent( + by.cssContainingText( + 'div.liveblog-content p.post-text', + secondPostContent + )); + }, + pp.maxTimeout, + 'Second added post should appear on page.' + ).then(function() { + postsReorder({ + postId: firstPostId, + otherPostId: secondPostId, + before: true + }); + browser.wait( + function() { + var posts = element.all( + by.css('div.liveblog-content p.post-text') + ); + return posts.get(0).getText().then(function(text) { + if (text === firstPostContent) { + return posts.get(1).getText().then(function (text) { + if (text === secondPostContent) { + return true; + } + }); + } + }); + }, pp.maxTimeout, + 'Just reordered posts should update on embed.' + ); + }); + }); + }, + //it + pp.maxTimeout * 3); +//describe Embed }); diff --git a/spec/helpers/liveblog_backend.js b/spec/helpers/liveblog_backend.js index f625de87f..fec2b8a52 100644 --- a/spec/helpers/liveblog_backend.js +++ b/spec/helpers/liveblog_backend.js @@ -31,7 +31,7 @@ function backendRequest(params, callback) { throw new Error(error); } if ( - (response.statusCode !== 200) && (response.statusCode !== 201) + (response.statusCode < 200) && (response.statusCode >= 300) ) { console.log('Request:'); console.log(response.request.href); diff --git a/spec/helpers/liveblog_posts.js b/spec/helpers/liveblog_posts.js index 096730385..4aa5aa8a5 100644 --- a/spec/helpers/liveblog_posts.js +++ b/spec/helpers/liveblog_posts.js @@ -8,7 +8,10 @@ var getIdFromHref = utils.getIdFromHref; exports.postCreate = postCreate; exports.postEdit = postEdit; +exports.postsReorder = postsReorder; exports.postPublish = postPublish; +exports.postUnpublish = postUnpublish; +exports.postDelete = postDelete; exports.postCreateAndPublish = postCreateAndPublish; function postCreate(args, callback) { @@ -36,9 +39,6 @@ function postEdit(args, callback) { var newContent = args.newContent || 'Test post', blogId = args.blogId || protractor.getInstance().params.blogId, postId = args.postId; - if (!postId) { - throw Error('No postId provided'); - } backendRequestAuth({ method: 'PUT', uri: '/my/LiveDesk/Blog/' + blogId + '/Post/' + postId, @@ -50,14 +50,27 @@ function postEdit(args, callback) { }); } +function postsReorder(args, callback) { + callback = callback || function() {}; + args = args || {}; + var blogId = args.blogId || protractor.getInstance().params.blogId, + postId = args.postId, + otherPostId = args.otherPostId, + before = args.before; + backendRequestAuth({ + method: 'PUT', + uri: '/my/LiveDesk/Blog/' + blogId + '/Post/' + postId + '/Post/' + + otherPostId + '/Reorder?before=' + before.toString() + }, function(e, r, j) { + callback(e, r, j); + }); +} + function postPublish(args, callback) { args = args || {}; callback = callback || function() {}; var blogId = args.blogId || protractor.getInstance().params.blogId, postId = args.postId; - if (!postId) { - throw Error('No postId provided'); - } backendRequestAuth({ method: 'POST', uri: '/my/LiveDesk/Blog/' + blogId + '/Post/' + postId + '/Publish', @@ -67,6 +80,33 @@ function postPublish(args, callback) { }); } +function postUnpublish(args, callback) { + args = args || {}; + callback = callback || function() {}; + var blogId = args.blogId || protractor.getInstance().params.blogId, + postId = args.postId; + backendRequestAuth({ + method: 'POST', + uri: '/my/LiveDesk/Blog/' + blogId + '/Post/' + postId + '/Unpublish', + json: {} + }, function(e, r, j) { + callback(e, r, j); + }); +} + +function postDelete(args, callback) { + args = args || {}; + callback = callback || function() {}; + var postId = args.postId; + backendRequestAuth({ + method: 'DELETE', + uri: '/my/Data/Post/' + postId, + json: {} + }, function(e, r, j) { + callback(e, r, j); + }); +} + function postCreateAndPublish(args, callback) { callback = callback || function() {}; postCreate(