Skip to content

Commit

Permalink
Merge branch 'master' into issue/506
Browse files Browse the repository at this point in the history
  • Loading branch information
brianhyder committed Apr 8, 2015
2 parents b43ee4a + 56a747b commit 491f254
Show file tree
Hide file tree
Showing 15 changed files with 81 additions and 29 deletions.
13 changes: 10 additions & 3 deletions include/service/entities/article_service.js
Expand Up @@ -251,8 +251,15 @@ module.exports = function ArticleServiceModule(pb) {
);
}

// No need to cutoff article if there's only 1
if(articleCount > 1 && contentSettings.auto_break_articles) {
if(article.article_layout.indexOf('^read_more^') > -1) {
if(articleCount > 1) {
article.article_layout = article.article_layout.substr(0, article.article_layout.indexOf('^read_more^')) + ' <a href="' + pb.config.siteRoot + '/article/' + article.url + '">' + contentSettings.read_more_text + '...</a>';
}
else {
article.article_layout = article.article_layout.split('^read_more^').join('');
}
}
else if(articleCount > 1 && contentSettings.auto_break_articles) {
var breakString = '<br>';
var tempLayout;

Expand Down Expand Up @@ -611,4 +618,4 @@ module.exports = function ArticleServiceModule(pb) {
ArticleService: ArticleService,
MediaLoader: MediaLoader
};
};
};
2 changes: 1 addition & 1 deletion include/service/entities/media_service.js
Expand Up @@ -881,7 +881,7 @@ module.exports = function MediaServiceModule(pb) {
for(var i = 0; i < paths.length; i++) {
try{
var ProviderType = require(paths[i])(pb);
INSTANCE = new ProviderType();
instance = new ProviderType();
break;
}
catch(e){
Expand Down
2 changes: 1 addition & 1 deletion plugins/pencilblue/controllers/article.js
Expand Up @@ -15,7 +15,7 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

module.exports = function PreviewModule(pb) {
module.exports = function ArticleModule(pb) {

//pb dependencies
var util = pb.util;
Expand Down
2 changes: 1 addition & 1 deletion plugins/pencilblue/controllers/feed.js
Expand Up @@ -20,7 +20,7 @@ var path = require('path');
var HtmlEncoder = require('htmlencode');
var async = require('async');

module.exports = function PreviewModule(pb) {
module.exports = function FeedModule(pb) {

//pb dependencies
var util = pb.util;
Expand Down
1 change: 1 addition & 0 deletions plugins/pencilblue/templates/admin/elements/wysiwyg.html
Expand Up @@ -36,6 +36,7 @@
<div class="btn-group btn-group-sm">
<button type="button" class="btn btn-default" onclick="showContentLayoutModal('^wys_id^', 'add_layout_link')" title="^loc_INSERT_LINK^"><i class="fa fa-link"></i></button>
<button type="button" id="media_button" class="btn btn-default" onclick="showContentLayoutModal('^wys_id^', 'add_layout_media')" title="^loc_INSERT_MEDIA^" ng-if="!hideMediaButton"><i class="fa fa-picture-o"></i></button>
<button type="button" class="btn btn-default" onclick="insertReadMore('^wys_id^')" title="^loc_INSERT_READ_MORE^"><i class="fa fa-compress"></i></button>
</div>
<div class="btn-group btn-group-sm one_active">
<button type="button" class="btn btn-default active" onclick="showLayoutView('^wys_id^', 'editable')" title="^loc_WYSIWYG_VIEW^"><i class="fa fa-pencil-square-o"></i></button>
Expand Down
6 changes: 3 additions & 3 deletions plugins/portfolio/controllers/blog.js
Expand Up @@ -23,9 +23,9 @@ module.exports = function BlogModule(pb) {
//pb dependencies
var util = pb.util;
var PluginService = pb.PluginService;
var TopMenu = require(pb.config.docRoot + '/include/theme/top_menu');
var Comments = require(pb.config.docRoot + '/include/theme/comments');
var ArticleService = require(pb.config.docRoot + '/include/service/entities/article_service').ArticleService;
var TopMenu = require(pb.config.docRoot + '/include/theme/top_menu')(pb);
var Comments = require(pb.config.docRoot + '/include/theme/comments')(pb);
var ArticleService = require(pb.config.docRoot + '/include/service/entities/article_service')(pb).ArticleService;

/**
* Blog page of the pencilblue theme
Expand Down
14 changes: 14 additions & 0 deletions plugins/sample/controllers/random_text_view.js
Expand Up @@ -204,6 +204,15 @@ module.exports = function RandomTextViewControllerModule(pb) {
});
});
};

/**
* A sample redirect endpoint
* @method redirectToHomepage
* @params {Function} cb
*/
RandomTextViewController.prototype.redirectToHomePage = function(cb) {
this.redirect('/', cb);
};

/**
* Provides the routes that are to be handled by an instance of this prototype.
Expand Down Expand Up @@ -251,6 +260,11 @@ module.exports = function RandomTextViewControllerModule(pb) {
//called to handle the incoming request. Defaults to "render"
handler: "getRandomText"
},
{
method: 'get',
path: '/sample/redirect/home',
handler: 'redirectToHomePage'
},
// { //Use the setup below to override the home page when your plugin is set as the active theme
// method: 'get',
// path: "/",
Expand Down
10 changes: 5 additions & 5 deletions plugins/sample/sample.js
Expand Up @@ -31,7 +31,7 @@ module.exports = function SamplePluginModule(pb) {
*/
SamplePlugin.onUninstall = function(cb) {
// Remove "sample" nav during uninstall
pb.AdminNavigation.remove("sample");
pb.AdminNavigation.remove("sample");
cb(null, true);
};

Expand Down Expand Up @@ -59,9 +59,9 @@ module.exports = function SamplePluginModule(pb) {
children: [
{
id: "sample_1",
title: "Sample Child 1",
title: "Random Text",
icon: "cog",
href: "/admin/sample/1",
href: "/sample/random/text",
access: pb.SecurityService.ACCESS_USER
}
]
Expand All @@ -79,9 +79,9 @@ module.exports = function SamplePluginModule(pb) {
// Add a child to the top level node "sample"
pb.AdminNavigation.addChild("sample", {
id: "sample_3",
title: "Sample Child 3",
title: "Redirect Home",
icon: "cog",
href: "/admin/sample/3",
href: "/sample/redirect/home",
access: pb.SecurityService.ACCESS_USER
});

Expand Down
7 changes: 7 additions & 0 deletions public/css/admin.css
Expand Up @@ -414,6 +414,13 @@ form .error
outline: none;
}

.layout_editable .read_more_break {
border: none;
border-top: 1px dashed #333333;
color: #333333;
text-align: center;
}

.layout_code, .layout_markdown
{
background-color: #333333;
Expand Down
32 changes: 29 additions & 3 deletions public/js/admin/elements/wysiwyg.js
Expand Up @@ -44,6 +44,7 @@ function initWYSIWYG() {

$('.wysiwyg').each(function() {
var wysId = $(this).attr('id').split('wysiwyg_').join('');
loadReadMoreBreak(wysId);
loadLayoutMediaPreviews(wysId);
});
}
Expand Down Expand Up @@ -242,6 +243,18 @@ function addLayoutLink(wysId)
$('#wysiwyg_modal_' + wysId).modal('hide');
}

function insertReadMore(wysId)
{
toolbarAction(wysId, 'inserthtml', '<hr class="read_more_break"></hr>');
}

function loadReadMoreBreak(wysId) {
var layout = $('#wysiwyg_' + wysId + ' .layout_editable').html();
layout = layout.split('^read_more^').join('<hr class="read_more_break"></hr>');

$('#wysiwyg_' + wysId + ' .layout_editable').html(layout);
}

function getLayoutMediaOptions(wysId)
{
var activeMedia = getActiveMedia();//$('#active_media .media_item');
Expand Down Expand Up @@ -364,9 +377,22 @@ function getWYSIWYGLayout(wysId, cb) {

i++;

if(i >= mediaCount)
{
cb($('#temp_editable').html());
if(i >= mediaCount){
var s = 0;
var readMoreCount = $('#temp_editable .read_more_break').length;
$('#temp_editable .read_more_break').each(function() {
if(s === 0) {
$(this).replaceWith('^read_more^');
}
else {
$(this).replaceWith('');
}

s++;
if(s >= readMoreCount) {
cb($('#temp_editable').html());
}
});
}
});
}
3 changes: 2 additions & 1 deletion public/localization/de-de.js
Expand Up @@ -313,7 +313,8 @@ var loc = {
INACTIVE_SECTIONS: 'Entfernen Sie Sektionen, indem Sie sie hierhin ziehen.',
PUBLISHED: 'Veröffentlicht',
UNPUBLISHED: 'Unveröffentlicht',
DRAFT: 'Entwurf'
DRAFT: 'Entwurf',
INSERT_READ_MORE: 'Legen Sie eine Pause mehr lesen'
},
wysiwyg: {
NORMAL_TEXT: 'Normaler Text',
Expand Down
3 changes: 2 additions & 1 deletion public/localization/en-us.js
Expand Up @@ -306,7 +306,8 @@ var loc =
PUBLISHED: 'Published',
UNPUBLISHED: 'Unpublished',
DRAFT: 'Draft',
ALLOW_COMMENTS: 'Allow comments'
ALLOW_COMMENTS: 'Allow comments',
INSERT_READ_MORE: 'Insert a read more break',
},
wysiwyg: {
NORMAL_TEXT: 'Normal text',
Expand Down
3 changes: 2 additions & 1 deletion public/localization/pl-pl.js
Expand Up @@ -309,7 +309,8 @@ var loc =
INACTIVE_SECTIONS: 'Przeciągnij tutaj niezwiązane sekcje',
PUBLISHED: 'Opublikowany',
UNPUBLISHED: 'Nieopublikowany',
DRAFT: 'Projekt'
DRAFT: 'Projekt',
INSERT_READ_MORE: 'Włóż czytaj więcej przerwę'
},
wysiwyg: {
NORMAL_TEXT: 'Normalny tekst',
Expand Down
3 changes: 2 additions & 1 deletion public/localization/ro-ro.js
Expand Up @@ -300,7 +300,8 @@ var loc =
INACTIVE_SECTIONS: 'Trage aici sectiunile care nu sunt asociate',
PUBLISHED: 'Publicat',
UNPUBLISHED: 'Nepublicat',
DRAFT: 'Draft'
DRAFT: 'Draft',
INSERT_READ_MORE: 'Introduceți o pauză mai citit'
},
wysiwyg: {
NORMAL_TEXT: 'Text normal',
Expand Down
9 changes: 1 addition & 8 deletions test/include/config_tests.js
Expand Up @@ -10,15 +10,8 @@ describe('Configuration', function() {

it('should provide a valid base configuration', function() {

//it takes a few seconds to load the prototypes based on the
//configuration so we modify the timeout to ensure that small build
//runners complete the test in a timely manner
this.timeout(3000);

var config = Configuration.getBaseConfig();
config.should.be.type('object');

var pb = new Lib(config);
});
});

Expand Down Expand Up @@ -47,4 +40,4 @@ describe('Configuration', function() {
config.siteRoot.should.eql('http://apples.2.apples.com');
});
});
});
});

0 comments on commit 491f254

Please sign in to comment.