Skip to content
This repository has been archived by the owner on Jul 2, 2021. It is now read-only.

Commit

Permalink
Merge pull request #49 from Wikia/fastboot-proto
Browse files Browse the repository at this point in the history
XW-2700 | Enable FastBoot on Mobile Wiki
  • Loading branch information
kvas-damian authored Apr 6, 2017
2 parents af5d33c + 22e43c6 commit fcae934
Show file tree
Hide file tree
Showing 831 changed files with 4,973 additions and 28,059 deletions.
File renamed without changes.
3 changes: 2 additions & 1 deletion front/main/.ember-cli → .ember-cli
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,6 @@
Setting `disableAnalytics` to true will prevent any data from being sent.
*/
"disableAnalytics": false,
"output-path": "../../www/mobile-wiki/main/"
"output-path": "dist/mobile-wiki/",
"port": 7001
}
19 changes: 9 additions & 10 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
www/
bower_components/
crowdin/
dist/
node_modules/
public/moment
tasks/
tmp/
vendor/

front/common/bower_components/

front/main/bower_components/
front/main/node_modules/
front/main/public/moment
front/main/vendor/
front/main/tmp/

server/node_modules
# Script copied from Google documentation
app/inline-scripts/tracking-ua-init.js
18 changes: 18 additions & 0 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,23 @@
"prefer-rest-params": 0,
"quotes": [2, "single", {"allowTemplateLiterals": true}],
"wrap-iife": [2, "inside"]
},
"env": {
"es6": true,
"browser": true,
"jquery": true
},
"globals": {
"$script": true,
"Ember": true,
"FastBoot": true,
"FastClick": true,
"ga": true,
"Hammer": true,
"Headroom": true,
"M": true,
"VisitSource": true,
"Weppy": true,
"Wikia": true
}
}
19 changes: 12 additions & 7 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,21 +1,26 @@
# See http://help.github.com/ignore-files/ for more about ignoring files.

# dependencies
**/node_modules/
**/bower_components/

# compiled output
/www/
/test/
/dist
/tmp
/vendor

# others
# misc
/.sass-cache
/connect.lock
/coverage/*
/libpeerconnection.log
npm-debug.log
testem.log
.idea/
.DS_Store
.settings
.sass-cache
*.sublime-*
*.sw[a-z]
*.orig
*.log
*.iml

# coverage files
**/coverage.*
43 changes: 0 additions & 43 deletions .svgo.yml

This file was deleted.

File renamed without changes.
3 changes: 3 additions & 0 deletions .watchmanconfig
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"ignore_dirs": ["tmp", "dist"]
}
3 changes: 0 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,3 @@ RUN mkdir -p /build
COPY package.json /build
COPY . /build
WORKDIR /build

# install dependencies
RUN npm run setup-for-local
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import Ember from 'ember';
import {getGroup} from 'common/modules/abtest';
import {getGroup} from '../modules/abtest';

export default Ember.Component.extend({
didReceiveAttrs() {
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import Ember from 'ember';
import {isHashLink} from '../utils/article-link';
import {trackPerf} from 'common/utils/track-perf';
import {trackPerf} from '../utils/track-perf';

const {Component, computed, Logger, $} = Ember;
const {Component, computed, inject, Logger, $} = Ember;

/**
* HTMLMouseEvent
Expand All @@ -26,18 +26,25 @@ const {Component, computed, Logger, $} = Ember;
*/

export default Component.extend({
attributeBindings: ['dir'],
classNames: ['application-wrapper'],
classNameBindings: ['smartBannerVisible', 'verticalClass'],
scrollLocation: null,
smartBannerVisible: false,
firstRender: true,

wikiVariables: inject.service(),
fastboot: inject.service(),
currentUser: inject.service(),

dir: computed.reads('wikiVariables.language.contentDir'),

drawerContentComponent: computed('activeDrawerContent', function () {
return `wikia-${this.get('activeDrawerContent')}`;
}),

verticalClass: computed(() => {
const vertical = Ember.get(Mercury, 'wiki.vertical');
verticalClass: computed('wikiVariables', function () {
const vertical = this.get('wikiVariables.vertical');

return `${vertical}-vertical`;
}),
Expand All @@ -56,10 +63,15 @@ export default Component.extend({
if (this.firstRender === true) {
this.firstRender = false;

trackPerf({
name: 'appRendered',
type: 'mark'
});
if (!this.get('fastboot.isFastBoot')) {
trackPerf({
name: 'appRendered',
type: 'mark',
context: {
logged_in: this.get('currentUser.isAuthenticated'),
}
});
}
}
},

Expand Down Expand Up @@ -119,9 +131,9 @@ export default Component.extend({

return (
$target.closest('.mw-content').length &&
// ignore polldaddy content
// ignore polldaddy content
!$target.closest('.PDS_Poll').length &&
// don't need special logic for article references
// don't need special logic for article references
!isReference
);
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
import Ember from 'ember';
import Thumbnailer from 'common/modules/thumbnailer';
import Thumbnailer from '../modules/thumbnailer';

const {Component, computed, inject} = Ember;

/**
* @typedef {Object} ArticleCommentThumbnailData
Expand All @@ -9,7 +11,9 @@ import Thumbnailer from 'common/modules/thumbnailer';
* @property {string} [type]
*/

export default Ember.Component.extend({
export default Component.extend({
i18n: inject.service(),
wikiVariables: inject.service(),
tagName: 'li',
classNames: ['article-comment'],

Expand All @@ -18,7 +22,7 @@ export default Ember.Component.extend({
comment: null,
thumbnailWidth: 480,

text: Ember.computed('comment.text', function () {
text: computed('comment.text', function () {
const $text = $('<div/>').html(this.get('comment.text')),
$figure = $text.find('figure');

Expand All @@ -29,21 +33,21 @@ export default Ember.Component.extend({
return $text.html();
}),

user: Ember.computed('users', function () {
user: computed('users', function () {
const users = this.get('users');

if (users) {
return users[this.get('comment.userName')] || {};
}
}),

userName: Ember.computed('comment.userName', function () {
userName: computed('comment.userName', function () {
// Checks for an IP address to identify an anonymous user. This is very crude and obviously doesn't check IPv6.
const userName = this.get('comment.userName'),
regex = /\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/;

if (regex.test(userName)) {
return i18n.t('app.username-anonymous');
return this.get('i18n').t('app.username-anonymous');
} else {
return userName;
}
Expand Down Expand Up @@ -77,8 +81,8 @@ export default Ember.Component.extend({
width: this.thumbnailWidth
}),
$thumbnail = $('<img/>').attr('src', thumbnailURL),
articlePath = Ember.get(Mercury, 'wiki.articlePath'),
fileNamespace = Ember.getWithDefault(Mercury, 'wiki.namespaces.6', 'File'),
articlePath = this.get('wikiVariables.articlePath'),
fileNamespace = this.get('wikiVariables.namespaces.6') || 'File',
href = `${articlePath}${fileNamespace}:${thumbnailData.name}`,
$anchor = $('<a/>').attr('href', href).append($thumbnail),
$figure = $('<figure/>');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import Ember from 'ember';
import ArticleCommentsModel from '../models/article-comments';
import {track, trackActions} from 'common/utils/track';
import {track, trackActions} from '../utils/track';

const {Component, computed, inject, observer, run} = Ember;

/**
* Component that displays article comments
Expand All @@ -9,8 +11,9 @@ import {track, trackActions} from 'common/utils/track';
*
* TODO: Great refactor XW-1237
*/
export default Ember.Component.extend(
export default Component.extend(
{
wikiVariables: inject.service(),
page: null,
articleId: null,
commentsCount: null,
Expand All @@ -20,14 +23,14 @@ export default Ember.Component.extend(

nextButtonShown: false,
prevButtonShown: false,
showComments: Ember.computed.bool('page'),
showComments: computed.bool('page'),

/**
* observes changes to page property, applies limit `1 <= page <= model.pagesCount`
* and updates model, so it can load a page of comments
*/
pageObserver: Ember.observer('page', 'model.comments', function () {
Ember.run.scheduleOnce('afterRender', this, () => {
pageObserver: observer('page', 'model.comments', function () {
run.scheduleOnce('afterRender', this, () => {
const page = this.get('page'),
count = this.get('model.pagesCount');

Expand Down Expand Up @@ -56,7 +59,7 @@ export default Ember.Component.extend(
/**
* watches changes to model, and scrolls to top of comments
*/
commentsObserver: Ember.observer('model.comments', function () {
commentsObserver: observer('model.comments', function () {
if (this.get('model.comments')) {
this.scrollToTop();
}
Expand All @@ -65,7 +68,7 @@ export default Ember.Component.extend(
/**
* if articleId changes, updates model
*/
articleIdObserver: Ember.observer('articleId', function () {
articleIdObserver: observer('articleId', function () {
this.setProperties({
'model.articleId': this.get('articleId'),
page: null
Expand All @@ -83,7 +86,8 @@ export default Ember.Component.extend(
this._super(...arguments);

this.set('model', ArticleCommentsModel.create({
articleId: this.get('articleId')
articleId: this.get('articleId'),
host: this.get('wikiVariables.host')
}));
},

Expand Down
Loading

0 comments on commit fcae934

Please sign in to comment.