Skip to content

Commit

Permalink
Use lfeslint
Browse files Browse the repository at this point in the history
  • Loading branch information
ross-pfahler authored and markdoten committed May 17, 2016
1 parent f762760 commit 00d4781
Show file tree
Hide file tree
Showing 17 changed files with 508 additions and 520 deletions.
33 changes: 22 additions & 11 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"build": "npm run-script clean-build && mkdir -p dist && ./node_modules/requirejs/bin/r.js -o ./tools/build.conf.js",
"build-css": "npm run build-sdk && npm run copy-dists",
"clean-build": "rm -rf dist",
"hint": "./node_modules/jshint/bin/jshint src/ tests/spec; echo",
"hint": "./node_modules/.bin/lfeslint",
"test": "./node_modules/karma/bin/karma start tests/karma.conf.js --singleRun",
"test-ci": "./node_modules/karma/bin/karma start tools/karma.conf.js --singleRun --reporters dots,junit,coverage && npm run send-to-coveralls",
"karma": "./node_modules/karma/bin/karma start tools/karma.conf.js",
Expand All @@ -34,18 +34,29 @@
"devDependencies": {
"coveralls": "~2.3.0",
"jsdoc": "git://github.com/jsdoc3/jsdoc.git",
"jshint": "~2.1.0",
"karma": "0.10.5",
"karma-cajon": "*",
"karma-chrome-launcher": "0.1.0",
"karma-coffee-preprocessor": "0.1.0",
"karma-coverage": "0.1.2",
"karma-jasmine": "0.1.3",
"karma-phantomjs-launcher": "0.1.0",
"karma-requirejs": "0.2.0",
"karma-script-launcher": "0.1.0",
"karma": "~0.10.5",
"karma-cajon": "0.0.1",
"karma-chrome-launcher": "~0.1.0",
"karma-coverage": "~0.1.2",
"karma-jasmine": "~0.1.3",
"karma-phantomjs-launcher": "~0.1.0",
"karma-requirejs": "~0.2.0",
"karma-script-launcher": "~0.1.0",
"lfcdn": "git+ssh://[email protected]:Livefyre/lfcdn.git",
"lfeslint": "git+ssh://[email protected]/Livefyre/lfeslint.git",
"phantomjs": "~1.9.2-2",
"requirejs": "2.1.9",
"rework": "git://github.com/gobengo/rework.git"
},
"lfeslint": {
"ignore": [
"lib/*"
],
"global": [
"define",
"expect",
"jasmine",
"requirejs"
]
}
}
62 changes: 31 additions & 31 deletions requirejs.conf.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ require.config({
rework: 'lib/rework/rework'
},
packages: [{
name: "auth",
location: "lib/auth/src"
name: 'auth',
location: 'lib/auth/src'
},{
name: 'templates',
location: 'src/ui/templates'
name: 'templates',
location: 'src/ui/templates'
},{
name: 'eref',
location: 'lib/eref-js/src'
name: 'eref',
location: 'lib/eref-js/src'
},{
name: 'livefyre-bootstrap',
location: 'lib/livefyre-bootstrap/src'
name: 'livefyre-bootstrap',
location: 'lib/livefyre-bootstrap/src'
},{
name: 'stream',
location: 'lib/stream/src'
Expand Down Expand Up @@ -67,12 +67,12 @@ require.config({
name: 'streamhub-wall',
location: 'lib/streamhub-wall/src'
},{
name: "streamhub-share",
location: "lib/streamhub-share/src",
main: "share-button"
name: 'streamhub-share',
location: 'lib/streamhub-share/src',
main: 'share-button'
},{
name: "livefyre-bootstrap",
location: "lib/livefyre-bootstrap/src"
name: 'livefyre-bootstrap',
location: 'lib/livefyre-bootstrap/src'
},{
name: 'tests',
location: 'tests'
Expand All @@ -81,38 +81,38 @@ require.config({
location: 'lib/view/src',
main: 'view'
},{
name: "css",
location: "lib/require-css",
main: "css"
name: 'css',
location: 'lib/require-css',
main: 'css'
},{
name: "less",
location: "lib/require-less",
main: "less"
name: 'less',
location: 'lib/require-less',
main: 'less'
},{
name: "mout",
location: "lib/mout/src",
main: "index"
name: 'mout',
location: 'lib/mout/src',
main: 'index'
}],
shim: {
jquery: {
exports: '$'
exports: '$'
},
jasmine: {
exports: 'jasmine'
exports: 'jasmine'
},
'jasmine-html': {
deps: ['jasmine'],
exports: 'jasmine'
deps: ['jasmine'],
exports: 'jasmine'
},
'blanket-jasmine': {
exports: 'blanket',
deps: ['jasmine']
exports: 'blanket',
deps: ['jasmine']
},
'jasmine-jquery': {
deps: ['jquery']
deps: ['jquery']
},
rework: {
exports: 'rework'
exports: 'rework'
}
},
css: {
Expand All @@ -127,7 +127,7 @@ require.config({
paths: ['lib'],
relativeUrls: true,
modifyVars: {
'@icon-font-path': "\"http://cdn.livefyre.com/libs/livefyre-bootstrap/v1.1.0/fonts/\""
'@icon-font-path': '"http://cdn.livefyre.com/libs/livefyre-bootstrap/v1.1.0/fonts/"'
}
}
});
58 changes: 29 additions & 29 deletions src/default-permalink-content-renderer.js
Original file line number Diff line number Diff line change
@@ -1,41 +1,41 @@
'use strict'
'use strict';

var Modal = require('streamhub-sdk/modal');
var permalinkViewFactory = require('streamhub-permalink/permalink-view-factory');
var styles = require('css!./css/styles.css');
var sdkStyles = require('css!streamhub-sdk/css/style.css');
require('css!./css/styles.css');
require('css!streamhub-sdk/css/style.css');
var packageAttribute = require('./package-attribute');

var defaultPermalinkContentHandler = function (content) {
//Get the view for the content
var cvf = permalinkViewFactory();
var contentView = cvf.createContentView(content, {
sharer: { canShare: function() {} }
});

//Show the contentView in a modal
var contentModalView = new Modal();

packageAttribute.decorateModal(contentModalView);
contentModalView.show(contentView, true);


var closeBtn = contentView.el.parentElement.parentElement.querySelector('.hub-modal-close');
closeBtn.className += ' permalink-modal-close fycon-x';
closeBtn.innerHTML = '';
contentView.$el.css('max-width', '640px');//Necessary evil, until CSS things are sorted
contentView.$el.addClass(defaultPermalinkContentHandler.CLASSES.PERMALINK);
contentView.$el.find('.content-footer').append('\
<div class="hub-modal-content-permalink">\
<button class="permalink-button" type="button">View Context</button>\
</div>\
');

this.modalView = contentModalView;
// Get the view for the content
var cvf = permalinkViewFactory();
var contentView = cvf.createContentView(content, {
sharer: {canShare: function () {}}
});

// Show the contentView in a modal
var contentModalView = new Modal();

packageAttribute.decorateModal(contentModalView);
contentModalView.show(contentView, true);


var closeBtn = contentView.el.parentElement.parentElement.querySelector('.hub-modal-close');
closeBtn.className += ' permalink-modal-close fycon-x';
closeBtn.innerHTML = '';
contentView.$el.css('max-width', '640px'); // Necessary evil, until CSS things are sorted
contentView.$el.addClass(defaultPermalinkContentHandler.CLASSES.PERMALINK);
contentView.$el.find('.content-footer').append('\
<div class="hub-modal-content-permalink">\
<button class="permalink-button" type="button">View Context</button>\
</div>\
');

this.modalView = contentModalView;
};

defaultPermalinkContentHandler.CLASSES = {
PERMALINK: 'permalink-content'
PERMALINK: 'permalink-content'
};

module.exports = defaultPermalinkContentHandler;
6 changes: 3 additions & 3 deletions src/enums.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
var permalink = {}
var permalink = {};

/**
* Keys for the different types of permalinkable Livefyre items.
* @type {Object.<string, string>}
*/
permalink.KEYS = {
CONTENT: 'content',
CONTENT_OPTIONS: 'content-options'
CONTENT: 'content',
CONTENT_OPTIONS: 'content-options'
};

module.exports = permalink;
80 changes: 39 additions & 41 deletions src/handlers/content.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'use strict'
'use strict';

var fetchContent = require('streamhub-sdk/content/fetch-content');
var uriInterpreter = require('streamhub-permalink/uri-interpreter');
Expand All @@ -13,49 +13,47 @@ var uriInterpreter = require('streamhub-permalink/uri-interpreter');
* @param [contentInfo.environment] {string=} For environments other than production
*/
var contentHandler = function (permalink, key, contentInfo, callback) {
var contentId = contentInfo.contentId,
collectionId = contentInfo.collectionId,
environment = contentInfo.environment,
network = contentInfo.network,
collection,
opts;

opts = {
contentId: contentId,
collectionId: collectionId,
network: network
};

if (environment) {
opts.environment = environment;

if (!uriInterpreter.isEnvironmentValid(environment)) {
throw new Error('Invalid environment: ' + environment);
}
var contentId = contentInfo.contentId,
collectionId = contentInfo.collectionId,
environment = contentInfo.environment,
network = contentInfo.network,
opts;

opts = {
contentId: contentId,
collectionId: collectionId,
network: network
};

if (environment) {
opts.environment = environment;

if (!uriInterpreter.isEnvironmentValid(environment)) {
throw new Error('Invalid environment: ' + environment);
}

if (!uriInterpreter.isNetworkValid(network)) {
throw new Error('Invalid network: ' + network);
}

if (!uriInterpreter.isNetworkValid(network)) {
throw new Error('Invalid network: ' + network);
}

fetchContent(opts, handler);

/**
* Recieves content and sets it and a handler on the Permalink instance.
* @param [err] {*=}
* @param [content] {Content=} Content instance
*/
function handler(err, content) {
if (err) {
throw new Error('Error fetching permalink content: ' + err);
}

fetchContent(opts, handler);

/**
* Recieves content and sets it and a handler on the Permalink instance.
* @param [err] {*=}
* @param [content] {Content=} Content instance
*/
function handler(err, content) {
if (err) {
throw new Error('Error fetching permalink content: ' + err);
return;
}

permalink.set('content-options', opts);
permalink.default(key, require('streamhub-permalink/default-permalink-content-renderer'));
permalink.set(key, content);
callback();
}
permalink.set('content-options', opts);
permalink.default(key, require('streamhub-permalink/default-permalink-content-renderer'));
permalink.set(key, content);
callback();
}
};

module.exports = contentHandler;
42 changes: 21 additions & 21 deletions src/permalink-view-factory.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
'use strict'
'use strict';

var AttachmentGalleryModal = require('streamhub-sdk/modal/views/attachment-gallery-modal');
var ContentViewFactory = require('streamhub-sdk/content/content-view-factory');
Expand All @@ -14,29 +14,29 @@ var packageAttribute = require('./package-attribute');
* ContentViewFactory or something that subclasses it.
*/
var permalinkViewFactory = function (opts) {
opts = opts || {};
var viewFactory = opts.baseFactory || new ContentViewFactory();
var superMethod = viewFactory.createContentView;
viewFactory.createContentView = function(content) {
//Get the content...
var contentView = superMethod.apply(viewFactory, arguments);
opts = opts || {};
var viewFactory = opts.baseFactory || new ContentViewFactory();
var superMethod = viewFactory.createContentView;
viewFactory.createContentView = function (content) {
// Get the content...
var contentView = superMethod.apply(viewFactory, arguments);

//...update the events list...
contentView.events = contentView.events.extended({
'focusContent.hub': function (e, context) {
var oembedView = new GalleryAttachmentListView(context);
var oembedModalView = new AttachmentGalleryModal();
packageAttribute.decorateModal(oembedModalView);
// ...update the events list...
contentView.events = contentView.events.extended({
'focusContent.hub': function (e, context) {
var oembedView = new GalleryAttachmentListView(context);
var oembedModalView = new AttachmentGalleryModal();
packageAttribute.decorateModal(oembedModalView);

oembedModalView.show(oembedView);
}
});
oembedModalView.show(oembedView);
}
});

//...and return it.
return contentView;
};
// ...and return it.
return contentView;
};

return viewFactory;
}
return viewFactory;
};

module.exports = permalinkViewFactory;
Loading

0 comments on commit 00d4781

Please sign in to comment.