Просмотр исходного кода

line lenght fixes (except for lang strings)

Rafał Pitoń 9 лет назад
Родитель
Сommit
2a76a8b8fd

+ 15 - 2
misago/frontend/gulpfile.js

@@ -115,7 +115,13 @@ gulp.task('cleanprod', function(cb) {
   ], {force: true}, cb);
 });
 
-gulp.task('prepareprod', ['cleanprod', 'compressjs', 'compresscss', 'copyfonts', 'copyimg']);
+gulp.task('prepareprod', [
+  'cleanprod',
+  'compressjs',
+  'compresscss',
+  'copyfonts',
+  'copyimg'
+]);
 
 gulp.task('deployjs', ['prepareprod'], function() {
   return gulp.src('dist/js/**/*')
@@ -197,7 +203,14 @@ gulp.task('collecttests', ['cleantest'], function() {
     .pipe(gulp.dest('test/dist'));
 });
 
-gulp.task('starttestserver', ['collecttests', 'collecttestsutils', 'collecttestjs', 'collecttestcss', 'collecttestfonts', 'collecttestimg'], function() {
+gulp.task('starttestserver', [
+    'collecttests',
+    'collecttestsutils',
+    'collecttestjs',
+    'collecttestcss',
+    'collecttestfonts',
+    'collecttestimg'
+], function() {
   connect.server({
     port: 8080,
     root: 'test'

+ 7 - 3
misago/frontend/misago/components/footer/footer-nav.js

@@ -9,7 +9,9 @@
 
     if (url) {
       return m('li',
-        m('a', {href: url}, Misago.get(_.settings, legalType + '_title', defaultTitle))
+        m('a', {href: url},
+          Misago.get(_.settings, legalType + '_title', defaultTitle)
+        )
       );
     } else {
       return null;
@@ -33,8 +35,10 @@
         items.push(m('li.forum-footnote', m.trust(_.settings.forum_footnote)));
       }
 
-      items.push(legalLink(_, 'terms_of_service', gettext('Terms of service')));
-      items.push(legalLink(_, 'privacy_policy', gettext('Privacy policy')));
+      items.push(
+        legalLink(_, 'terms_of_service', gettext('Terms of service')));
+      items.push(
+        legalLink(_, 'privacy_policy', gettext('Privacy policy')));
 
       return m('ul.list-inline.footer-nav', items);
     }

+ 3 - 1
misago/frontend/misago/components/misago-markup.js

@@ -7,7 +7,9 @@
 
   Misago.MisagoMarkup = {
     view: function(ctrl, content) {
-      return m('article.misago-markup', {config: setupMarkup}, m.trust(content));
+      return m('article.misago-markup', {config: setupMarkup},
+        m.trust(content)
+      );
     }
   };
 }(Misago.prototype));

+ 8 - 3
misago/frontend/misago/components/navbar/forum-navbar.js

@@ -6,14 +6,19 @@
       var desktopNavbar = [];
 
       if (_.settings.forum_branding_display) {
-        desktopNavbar.push(_.component(Misago.BrandFull, _.settings.forum_branding_text));
+        desktopNavbar.push(
+          _.component(Misago.BrandFull, _.settings.forum_branding_text));
       }
 
       desktopNavbar.push(m('ul.nav.navbar-nav', [
-        m('li', m("a", {config: m.route, href: _.router.url('index')}, 'Index'))
+        m('li',
+          m("a", {config: m.route, href: _.router.url('index')}, 'Index')
+        )
       ]));
 
-      return m('nav.navbar.navbar-default.navbar-static-top[role="navigation"]', [
+      var navbarStyle = '.navbar.navbar-default.navbar-static-top';
+
+      return m('nav' + navbarStyle + '[role="navigation"]', [
         m('.container.navbar-full.hidden-xs.hidden-sm', desktopNavbar)
       ]);
     }

+ 6 - 2
misago/frontend/misago/routes/index.js

@@ -18,10 +18,14 @@
     },
     view: function(ctrl) {
       return m('.container', [
-        m('h1', ['Count: ', m('strong', ctrl.count())]),
+        m('h1', [
+          'Count: ', m('strong', ctrl.count())
+        ]),
         m('p', 'Clicky click button to increase count!.'),
         m('p',
-          m('button.btn.btn-primary', {onclick: ctrl.increment}, 'Clicky clicky!')
+          m('button.btn.btn-primary', {onclick: ctrl.increment},
+            'Clicky clicky!'
+          )
         )
       ]);
     }

+ 1 - 1
misago/frontend/misago/routes/legal.js

@@ -44,7 +44,7 @@
         return m('.page.legal-page.' + dashedTypeName + '-page', [
           _.component(Misago.PageHeader, {title: this.vm.title}),
           m('.container',
-            m.trust(this.vm.body)
+            _.component(MisagoMarkup. Misago.this.vm.body)
           )
         ]);
       }

+ 2 - 1
misago/frontend/misago/services/ajax.js

@@ -3,7 +3,8 @@
 
   var Ajax = function(_) {
     var cookieRegex = new RegExp(_.context.CSRF_COOKIE_NAME + '\=([^;]*)');
-    this.csrfToken = Misago.get(document.cookie.match(cookieRegex), 0).split('=')[1];
+    this.csrfToken = Misago.get(
+      document.cookie.match(cookieRegex), 0).split('=')[1];
 
     /*
       List of GETs underway

+ 2 - 1
misago/frontend/misago/services/router.js

@@ -164,7 +164,8 @@
   });
 
   Misago.addService('start-routing', function(_) {
-    _.router.startRouting(Misago.urls, document.getElementById('router-fixture'));
+    _.router.startRouting(
+      Misago.urls, document.getElementById('router-fixture'));
     _.router.delegateClicks(document.getElementById(_.setup.fixture));
   }, {before: '_end'});
 }(Misago.prototype));

+ 3 - 0
misago/frontend/misago/services/tick.js

@@ -2,9 +2,12 @@
   'use strict';
 
   Misago.addService('start-tick', function(_) {
+    var ticks = m.prop();
+
     _.runloop.run(function() {
       m.startComputation();
       // just tick once a minute so stuff gets rerendered
+      ticks(ticks() + 1);
       // syncing dynamic timestamps, etc ect
       m.endComputation();
     }, 'tick', 60000);

+ 9 - 2
misago/frontend/misago/urls.js

@@ -5,8 +5,15 @@
   urls.url('/', Misago.IndexRoute, 'index');
 
   // Legal pages
-  urls.url('/terms-of-service/', Misago.TermsOfServiceRoute, 'terms_of_service');
-  urls.url('/privacy-policy/', Misago.PrivacyPolicyRoute, 'privacy_policy');
+  urls.url(
+    '/terms-of-service/',
+    Misago.TermsOfServiceRoute,
+    'terms_of_service');
+
+  urls.url(
+    '/privacy-policy/',
+    Misago.PrivacyPolicyRoute,
+    'privacy_policy');
 
   Misago.urls = urls;
 } (Misago.prototype, Misago.prototype.UrlConf));

+ 1 - 1
misago/frontend/misago/utils/accessors.js

@@ -22,7 +22,7 @@
   Misago.pop = function(obj, key, value) {
     var returnValue = Misago.get(obj, key, value);
     if (Misago.has(obj, key)) {
-      delete obj[key];
+      obj[key] = null;
     }
     return returnValue;
   };

+ 2 - 1
misago/frontend/misago/utils/urlconf.js

@@ -2,7 +2,8 @@
   'use strict';
 
   Misago.UrlConfInvalidComponentError = function(name) {
-    this.message = "route's " + name + " component should be an array or object";
+    this.message = "route's " + name + " component " +
+                   "should be an array or object";
 
     this.toString = function() {
       return this.message;

+ 3 - 1
misago/frontend/misago/utils/views-shortcuts.js

@@ -2,6 +2,8 @@
   'use strict';
 
   Misago.loadingPage = function(_) {
-    return m('.page.page-loading', _.component(Misago.Loader));
+    return m('.page.page-loading',
+      _.component(Misago.Loader)
+    );
   };
 } (Misago.prototype));

+ 3 - 3
misago/frontend/test/tests/unit/accessors.js

@@ -3,7 +3,7 @@
 
   QUnit.module("Accessors");
 
-  QUnit.test("Misago.has accessor", function(assert) {
+  QUnit.test("Misago.has", function(assert) {
     var testObj = {valid: 'okay'};
 
     assert.equal(Misago.has(testObj, 'invalid'), false,
@@ -12,7 +12,7 @@
       "Misago.has() returned true for existing key");
   });
 
-  QUnit.test("Misago.get accessor", function(assert) {
+  QUnit.test("Misago.get", function(assert) {
     var testObj = {valid: 'okay'};
 
     assert.equal(Misago.get(testObj, 'invalid'), undefined,
@@ -25,7 +25,7 @@
       "Misago.get() returned value for existing key instead of fallback");
   });
 
-  QUnit.test("Misago.pop accessor", function(assert) {
+  QUnit.test("Misago.pop", function(assert) {
     var testObj = {valid: 'okay', other_valid: 'okay'};
 
     assert.equal(Misago.pop(testObj, 'invalid'), undefined,

+ 3 - 2
misago/frontend/test/tests/unit/component-factory.js

@@ -3,12 +3,13 @@
 
   QUnit.module("Component factory");
 
-  QUnit.test("service factory registers component() function on container", function(assert) {
+  QUnit.test("service factory", function(assert) {
     var container = {};
 
     var service = getMisagoService('component-factory');
     service(container);
 
-    assert.ok(container.component, "service has set component factory on container.");
+    assert.ok(container.component,
+      "service factory has set component on container.");
   });
 }());

+ 1 - 1
misago/frontend/test/tests/unit/conf.js

@@ -7,7 +7,7 @@
 
   QUnit.module("Conf service");
 
-  QUnit.test("preloaded configuration was stored on container", function(assert) {
+  QUnit.test("service factory", function(assert) {
     var settings = {
       'forum_name': 'Misago Community'
     };

+ 6 - 3
misago/frontend/test/tests/unit/ordered-list.js

@@ -10,10 +10,12 @@
   });
 
   QUnit.test("OrderedList stores and returns items", function(assert) {
-    assert.equal(list.has('invalid_key'), false, "list.has() returned false for nonexisting key");
+    assert.equal(list.has('invalid_key'), false,
+      "list.has() returned false for nonexisting key");
 
     list.add('valid_key', 'valid_value');
-    assert.ok(list.has('valid_key'), "list.has() returned true for existing key");
+    assert.ok(list.has('valid_key'),
+      "list.has() returned true for existing key");
     assert.equal(list.get('valid_key'), 'valid_value',
       "list.get() returned value for existing key");
 
@@ -32,7 +34,8 @@
 
     var unorderedList = list.values();
 
-    assert.equal(list.isOrdered, false, "list.values() didn't set isOrdered flag on list");
+    assert.equal(list.isOrdered, false,
+      "list.values() didn't set isOrdered flag on list");
 
     assert.equal(unorderedList[0], 'apple', 'unorderedList[0] is apple');
     assert.equal(unorderedList[1], 'banana', 'unorderedList[1] is banana');

+ 15 - 8
misago/frontend/test/tests/unit/router.js

@@ -3,7 +3,7 @@
 
   QUnit.module("Router");
 
-  QUnit.test("cleanUrl cleans url's that should be routed", function(assert) {
+  QUnit.test("cleanUrl", function(assert) {
     var container = {
       context: {
         'STATIC_URL': '/static/',
@@ -16,20 +16,24 @@
 
     assert.equal(router.cleanUrl('/'), '/');
     assert.equal(router.cleanUrl('/lorem-ipsum/'), '/lorem-ipsum/');
-    assert.equal(router.cleanUrl('/lorem-ipsum/dolor/'), '/lorem-ipsum/dolor/');
+    assert.equal(
+      router.cleanUrl('/lorem-ipsum/dolor/'), '/lorem-ipsum/dolor/');
 
     assert.equal(router.cleanUrl('/static/'), undefined);
     assert.equal(router.cleanUrl('http://nocookie.somewhere.com/'), undefined);
     assert.equal(router.cleanUrl('/static/test.png'), undefined);
-    assert.equal(router.cleanUrl('http://nocookie.somewhere.com/test.png'), undefined);
+    assert.equal(
+      router.cleanUrl('http://nocookie.somewhere.com/test.png'), undefined);
 
     container.context.STATIC_URL = '/misago/static/';
     router = service(container);
     router.baseUrl = '/misago/';
 
     assert.equal(router.cleanUrl('/misago/'), '/misago/');
-    assert.equal(router.cleanUrl('/misago/lorem-ipsum/'), '/misago/lorem-ipsum/');
-    assert.equal(router.cleanUrl('/misago/lorem-ipsum/dolor/'), '/misago/lorem-ipsum/dolor/');
+    assert.equal(router.cleanUrl('/misago/lorem-ipsum/'),
+                 '/misago/lorem-ipsum/');
+    assert.equal(router.cleanUrl('/misago/lorem-ipsum/dolor/'),
+                 '/misago/lorem-ipsum/dolor/');
 
     assert.equal(router.cleanUrl('/'), undefined);
     assert.equal(router.cleanUrl('/lorem-ipsum/'), undefined);
@@ -38,10 +42,11 @@
     assert.equal(router.cleanUrl('/misago/static/'), undefined);
     assert.equal(router.cleanUrl('http://nocookie.somewhere.com/'), undefined);
     assert.equal(router.cleanUrl('/misago/static/test.png'), undefined);
-    assert.equal(router.cleanUrl('http://nocookie.somewhere.com/test.png'), undefined);
+    assert.equal(
+      router.cleanUrl('http://nocookie.somewhere.com/test.png'), undefined);
   });
 
-  QUnit.test("staticUrl and mediaUrl prefix paths", function(assert) {
+  QUnit.test("staticUrl and mediaUrl", function(assert) {
     var container = {
       context: {
         'STATIC_URL': '/static/',
@@ -54,7 +59,9 @@
 
     assert.equal(router.staticUrl('logo.png'), '/static/logo.png',
       'staticUrl correctly prefixed url to static asset.');
-    assert.equal(router.mediaUrl('avatar_1.png'), 'http://nocookie.somewhere.com/avatar_1.png',
+    assert.equal(
+      router.mediaUrl('avatar_1.png'),
+      'http://nocookie.somewhere.com/avatar_1.png',
       'mediaUrl correctly prefixed url to media asset.');
   });
 }());

+ 23 - 15
misago/frontend/test/tests/unit/service-container.js

@@ -14,7 +14,7 @@
     }
   });
 
-  QUnit.test("addService registers service in container", function(assert) {
+  QUnit.test("addService", function(assert) {
     assert.expect(2);
 
     var MockServiceFactory = function() {
@@ -29,17 +29,18 @@
       "addService() registered MockServiceFactory service in container");
   });
 
-  QUnit.test("service factories are called", function(assert) {
+  QUnit.test("_initServices", function(assert) {
     assert.expect(1);
 
     var MockServiceFactory = function(_) {
-      assert.ok(_, 'MockServiceFactory was called with container as argument.');
+      assert.ok(
+        _, 'MockServiceFactory was called with container as argument.');
     };
 
     container._initServices([{key: 'test', item: MockServiceFactory}]);
   });
 
-  QUnit.test("factories return values are set as context on container", function(assert) {
+  QUnit.test("factories return values handling", function(assert) {
     assert.expect(1);
 
     var MockServiceFactory = function() {
@@ -47,10 +48,11 @@
     };
 
     container._initServices([{key: 'test', item: MockServiceFactory}]);
-    assert.equal(container.test, 'ok!', 'MockServiceFactory return value was set on container.');
+    assert.equal(container.test, 'ok!',
+      "MockServiceFactory return value was set on container.");
   });
 
-  QUnit.test("factories returning nothing don't set context on container", function(assert) {
+  QUnit.test("factories returning nothing", function(assert) {
     assert.expect(1);
 
     var MockServiceFactory = function() {
@@ -58,19 +60,22 @@
     };
 
     container._initServices([{key: 'test', item: MockServiceFactory}]);
-    assert.equal(container.test, undefined, "MockServiceFactory return value wasn't set on container.");
+    assert.equal(container.test, undefined,
+      "MockServiceFactory return value wasn't set on container.");
   });
 
-  QUnit.test("services can be destroyed", function(assert) {
+  QUnit.test("_destroyServices", function(assert) {
     assert.expect(2);
 
     var MockService = {
       factory: function(_) {
-        assert.ok(_, "MockService's factory was called with container as argument.");
+        assert.ok(
+          _, "MockService's factory was called with container as argument.");
       },
 
       destroy: function(_) {
-        assert.ok(_, "MockService's destroy was called with container as argument.");
+        assert.ok(
+          _, "MockService's destroy was called with container as argument.");
       }
     };
 
@@ -80,7 +85,7 @@
     container._destroyServices(services);
   });
 
-  QUnit.test("services are initialized and destroyed in right order", function(assert) {
+  QUnit.test("initialize and destroy order", function(assert) {
     assert.expect(2);
 
     var initializationOrder = [];
@@ -116,15 +121,18 @@
     container._initServices(services);
     container._destroyServices(services);
 
-    assert.deepEqual(initializationOrder, [1, 2], 'services were initialized in right order.');
-    assert.deepEqual(destructionOrder, [2, 1], 'services were destroyed in right order.');
+    assert.deepEqual(initializationOrder, [1, 2],
+      'services were initialized in right order.');
+    assert.deepEqual(destructionOrder, [2, 1],
+      'services were destroyed in right order.');
   });
 
-  QUnit.test("initialization data is stored on container", function(assert) {
+  QUnit.test("initialization data storage", function(assert) {
     assert.expect();
 
     container.init({fixture: 'test'});
 
-    assert.equal(container.setup.fixture, 'test', 'container stored initialization data');
+    assert.equal(container.setup.fixture, 'test',
+      'container stored initialization data');
   });
 }());

+ 2 - 2
misago/frontend/test/tests/unit/string-utils.js

@@ -3,7 +3,7 @@
 
   QUnit.module("String Utils");
 
-  QUnit.test("startsWith utility", function(assert) {
+  QUnit.test("startsWith", function(assert) {
     assert.expect(4);
 
     assert.ok(startsWith("Boberson", "Bob"),
@@ -15,7 +15,7 @@
     assert.ok(!startsWith("", "Boberson"), 'tested empty string');
   });
 
-  QUnit.test("endsWith utility", function(assert) {
+  QUnit.test("endsWith", function(assert) {
     assert.expect(4);
 
     assert.ok(endsWith("Boberson", "son"),

+ 8 - 6
misago/frontend/test/tests/unit/title.js

@@ -12,7 +12,7 @@
     }
   });
 
-  QUnit.test("service sets title.set method on container", function(assert) {
+  QUnit.test("service factory", function(assert) {
     var service = getMisagoService('page-title');
 
     var container = {settings: {forum_name: 'Lorem Ipsum'}};
@@ -21,7 +21,7 @@
     assert.ok(container.title.set, 'title.set is set on container');
   });
 
-  QUnit.test("title.set() call with no arguments sets title to forum name", function(assert) {
+  QUnit.test("title.set() call with no arguments", function(assert) {
     var service = getMisagoService('page-title');
 
     var container = {settings: {forum_name: 'Lorem Ipsum'}};
@@ -32,24 +32,26 @@
       'no argument call for title.set changed title to Lorem Ipsum');
   });
 
-  QUnit.test("title.set() call with string argument sets valid title", function(assert) {
+  QUnit.test("title.set() call with string argument", function(assert) {
     var service = getMisagoService('page-title');
 
     var container = {settings: {forum_name: 'Lorem Ipsum'}};
     service(container);
 
     container.title.set("Hello!");
-    assert.equal(document.title, 'Hello! | Lorem Ipsum', 'string argument changed title');
+    assert.equal(
+      document.title, 'Hello! | Lorem Ipsum', 'string argument changed title');
   });
 
-  QUnit.test("title.set() call with object argument sets valid title", function(assert) {
+  QUnit.test("title.set() call with object argument", function(assert) {
     var service = getMisagoService('page-title');
 
     var container = {settings: {forum_name: 'Lorem Ipsum'}};
     service(container);
 
     container.title.set({title: "Hello!"});
-    assert.equal(document.title, 'Hello! | Lorem Ipsum', 'object argument changed title');
+    assert.equal(
+      document.title, 'Hello! | Lorem Ipsum', 'object argument changed title');
 
     container.title.set({title: "User", page: 1});
     assert.equal(document.title, 'User | Lorem Ipsum',

+ 8 - 6
misago/frontend/test/tests/unit/urlconf.js

@@ -9,16 +9,18 @@
     }
   });
 
-  QUnit.test("UrlConf.url registers pattern in config", function(assert) {
+  QUnit.test("url registers pattern in config", function(assert) {
     var component = {test: 'test'};
 
     urlconf.url('/test/', component, 'test_url');
     var patterns = urlconf.patterns();
 
-    assert.equal(patterns.length, 1, 'url() has registered single URL in config');
-    assert.deepEqual(patterns[0],
-                     {pattern: '/test/', component: component, name: 'test_url'},
-                     'url() has registered valid URL in config');
+    assert.equal(patterns.length, 1,
+      'url() has registered single URL in config');
+    assert.deepEqual(
+      patterns[0],
+      {pattern: '/test/', component: component, name: 'test_url'},
+      'url() has registered valid URL in config');
   });
 
   QUnit.test("UrlConf.url(conf) includes child config", function(assert) {
@@ -40,6 +42,6 @@
     ];
 
     assert.deepEqual(urlconf.patterns(), expected_patterns,
-                     'url() has included other urlconf');
+      'url() has included other urlconf');
   });
 }(Misago.prototype));