Skip to content

Commit

Permalink
Template now added as class name on article items in the list manager #…
Browse files Browse the repository at this point in the history
  • Loading branch information
victorjonsson committed Oct 31, 2014
1 parent f42068e commit 145c22c
Show file tree
Hide file tree
Showing 9 changed files with 148 additions and 36 deletions.
2 changes: 1 addition & 1 deletion arlima.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
Plugin URI: https://github.com/victorjonsson/Arlima
Description: Manage the order of posts on your front page, or any page you want. This is a plugin suitable for online newspapers that's in need of a fully customizable front page.
Author: VK (<a href="http://twitter.com/chredd">@chredd</a>, <a href="http://twitter.com/znoid">@znoid</a>, <a href="http://twitter.com/victor_jonsson">@victor_jonsson</a>, <a href="http://twitter.com/lefalque">@lefalque</a>)
Version: 3.0.beta.52
Version: 3.0.beta.53
License: GPL2
License URI: http://www.gnu.org/licenses/gpl-2.0.html
*/
Expand Down
45 changes: 44 additions & 1 deletion classes/ListFactory.php
Original file line number Diff line number Diff line change
Expand Up @@ -1246,4 +1246,47 @@ protected static function removePrefix($array = array(), $prefix, $preserve_std_
return $convert_to_std ? (object)$new_array:$new_array;
}

}
}

/*
Istället för att ha en factory som kan göra allt mellan himmel och jord
skulle man kunna ha repositories som hantera crud-operationer på listor och versioner
och sen en builder som kan sätta ihop en lista så som man vill ha den
$build = new Arlima_ListBuilder();
$list = Arlima_List::builder(323) # list id
->loadVersion(1234) # version
->loadPreview()
->includeFuturePosts()
->build();
$list_repo = new Arlima_ListRepository();
$list_repo->load();
$list_repo->create();
$list_repo->update();
$list_repo->delete();
$list_repo->getListId();
$list_repo->loadListSlugs();
$version_repo = new Arlima_VersionRepository();
$version_repo->save($articles, $list_id, $preview=false);
$version_repo->updateArticlePublishDate( $post );
$version_repo->updateArticle( );
$version_repo->getLatestArticle($post_id);
$version_repo->loadListsByPostId($post_id);
$version_repo->removeOldVersions($list_id, $num_versions_to_keep=10)
Arlima_AbstractDBRepository { ärvs av våra två repos
get_result()
db_table()
install()
uninstall()
}
*/
2 changes: 1 addition & 1 deletion constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
or define('ARLIMA_COMPILE_LESS_IN_BROWSER', ARLIMA_DEV_MODE);

// Plugin version (only edit this via grunt!)
define('ARLIMA_FILE_VERSION', '3.0.beta.52' .(ARLIMA_DEV_MODE ? '__'.time():''));
define('ARLIMA_FILE_VERSION', '3.0.beta.53' .(ARLIMA_DEV_MODE ? '__'.time():''));

// Which type of tag to use for images in Arlima RSS feeds
defined('ARLIMA_RSS_IMG_TAG')
Expand Down
8 changes: 4 additions & 4 deletions js/arlima/arlima.js

Large diffs are not rendered by default.

69 changes: 44 additions & 25 deletions js/arlima/dev/ArlimaArticle.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,36 +82,52 @@ var ArlimaArticle = (function($, window, ArlimaJS, ArlimaUtils) {
/**
* Update the title and the style of the item element
*/
ArlimaArticle.prototype.updateItemPresentation = function(checkDate) {
ArlimaArticle.prototype.updateItemPresentation = function() {

var title = '',
currentFormatClass = this.$elem.attr('data-format-class');
_this = this;

/*
Construct the title string
*/
if(this.data.title)
title = this.data.title.replace(/__/g, '');
else if(this.data.content)
title += '[' + this.data.content.replace(/(<.*?>)/ig,"").substring(0,30) +'...]';

if( this.opt('preTitle') ) {
title = this.opt('preTitle') + ' ' + title;
}

if( this.opt('format') ) {

if( currentFormatClass ) {
this.$elem.removeClass(currentFormatClass);
/*
Add format and template classes to item
*/
var extraClasses = [
{classPrefix: '', attr: 'data-format-class', opt: 'format'},
{classPrefix: 'template-', attr: 'data-template-class', opt: 'template'}
];
$.each(extraClasses, function(i, data) {
var currentClassName = _this.$elem.attr(data.attr),
newClassName = data.classPrefix + _this.opt(data.opt),
hasChanged = currentClassName != newClassName;

if( hasChanged && _this.opt(data.opt) ) {
if( currentClassName ) {
_this.$elem.removeClass(currentClassName);
}
_this.$elem
.addClass(newClassName)
.attr(data.attr, newClassName);

} else if( currentClassName && hasChanged ) {
_this.$elem
.removeAttr(data.attr)
.removeClass(currentClassName);
}
var newFormatClass = this.opt('format');
this.$elem
.addClass(newFormatClass)
.attr('data-format-class', newFormatClass);

} else if( currentFormatClass ) {
this.$elem
.removeAttr('data-format-class')
.removeClass(currentFormatClass);
}
});

/*
Is this a section divider
*/
if( this.opt('sectionDivider') ) {
this.$elem.addClass('section-divider');
title = '&ndash;&ndash;&ndash; '+title+' &ndash;&ndash;&ndash;';
Expand All @@ -126,6 +142,10 @@ var ArlimaArticle = (function($, window, ArlimaJS, ArlimaUtils) {
this.$elem.css('background', '');
}
} else {

/*
Display that it has a streamer
*/
if(this.opt('streamerType')) {
var color;
switch (this.opt('streamerType')) {
Expand All @@ -146,29 +166,28 @@ var ArlimaArticle = (function($, window, ArlimaJS, ArlimaUtils) {
}
}

/*
Add some icons
*/
if( this.opt('adminLock') )
title = '<span class="fa fa-lock"></span>' + title;
if( this.opt('scheduled') )
title = '<span class="fa fa-clock-o"></span>' + title;
if( this.opt('fileInclude') )
title = '<span class="fa fa-bolt"></span>' + title;

/*
Display if its a future article
*/
if( !this.isPublished() ) {
title = '<span class="future-push-date">'+ _getDatePresentation(this.data.published * 1000) +'</span>' + title;
this.$elem.addClass('future');
} else {
this.$elem.removeClass('future');
}

// Update item
this.$elem.find('.article-title').html(title);

if( checkDate ) {
if( !this.isPublished() ) {
this.$elem.addClass('future');
} else {
this.$elem.removeClass('future');
}
}
};

/**
Expand Down
4 changes: 2 additions & 2 deletions js/arlima/dev/ArlimaArticleConnection.js
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ var ArlimaArticleConnection = (function($, ArlimaUtils, ArlimaArticleForm, Arlim
if( _this.article.data.image && _this.article.data.image.connected ) {
delete _this.article.data.image.connected;
}
_this.article.updateItemPresentation(true);
_this.article.updateItemPresentation();
}
if( ArlimaArticleForm.$form.find('input.overriding-url-target').val() != target) {
ArlimaArticleForm.change('input.overriding-url-target', target);
Expand Down Expand Up @@ -208,7 +208,7 @@ var ArlimaArticleConnection = (function($, ArlimaUtils, ArlimaArticleForm, Arlim

// Update article publish date
_this.article.data.published = post.published;
_this.article.updateItemPresentation(true);
_this.article.updateItemPresentation();
if( _this.article.isPublished() ) {
_this.$futureNotice.hide();
} else {
Expand Down
4 changes: 3 additions & 1 deletion js/arlima/dev/ArlimaArticleForm.js
Original file line number Diff line number Diff line change
Expand Up @@ -634,8 +634,10 @@ var ArlimaArticleForm = (function($, window, ArlimaArticlePreview, ArlimaUtils,

// Update title element
var dataAffectingTitleAppearance = ['options:preTitle', 'title',
'options:streamerType', 'options:format', 'options:streamerContent', 'options:streamerColor',
'options:streamerType', 'options:format', 'options:streamerContent',
'options:streamerColor', 'options:template',
'options:adminLock', 'options:scheduled'];

if($.inArray(prop, dataAffectingTitleAppearance) > -1) {
_this.article.updateItemPresentation(false);
}
Expand Down
48 changes: 48 additions & 0 deletions js/arlima/dev/ArlimaArticleFormBuilder.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
/* Not yet in use
var ArlimaArticleFormBuilder = (function($) {
var _createBoolFieldHTML = function(varName, selected) {
return '<select><option value="1">Yes</option><option value="">Nej</option></select>';
};
return {
$form : null,
TYPES : {
BOOL : 'boolean',
TEXT : 'text'
},
getFieldHTML : function(type, label, varName, value) {
var html = '<div class="form-field"><strong>'+label+'</strong><div class="field">';
switch (type) {
case this.TYPES.BOOL:
html += _createBoolFieldHTML(label, varName, value);
break;
default :
html += '<em>Unknown field type '+type+'</em>';
break;
}
return html + '</div></div>';
},
addFields : function(fields) {
var html = '',
_this = this;
$.each(fields, function(i, f) {
html += _this.getFieldHTML(f.type, f.label, f.varName, f.value);
});
this.$form.append(html);
},
removeField : function(varName) {
this.$form.find('*[data-prop="'+varName+'"]').remove();
}
};
})(jQuery); */
2 changes: 1 addition & 1 deletion readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ Contributors: @chredd, @znoid, @victor_jonsson, @lefalque, @aaslun
Tags: CMS, e-paper, e-magazine, magazine, newspaper, front page, wysiwyg
Requires at least: 3.8
Tested up to: 3.9.1
Stable tag: 3.0.beta.52
Stable tag: 3.0.beta.53
License: GPL2
License URI: http://www.gnu.org/licenses/gpl-2.0.html

Expand Down

0 comments on commit 145c22c

Please sign in to comment.