diff --git a/front/common/.bowerrc b/.bowerrc similarity index 100% rename from front/common/.bowerrc rename to .bowerrc diff --git a/front/main/.ember-cli b/.ember-cli similarity index 84% rename from front/main/.ember-cli rename to .ember-cli index 893cbd1de89..1a8c565881f 100644 --- a/front/main/.ember-cli +++ b/.ember-cli @@ -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 } diff --git a/.eslintignore b/.eslintignore index 4dec55b7d65..6ba3a34bd06 100644 --- a/.eslintignore +++ b/.eslintignore @@ -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 diff --git a/.eslintrc b/.eslintrc index fd4b3e527a3..88b90ee8fcf 100644 --- a/.eslintrc +++ b/.eslintrc @@ -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 } } diff --git a/.gitignore b/.gitignore index 07ac1d5e915..577dffd1687 100644 --- a/.gitignore +++ b/.gitignore @@ -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.* diff --git a/.svgo.yml b/.svgo.yml deleted file mode 100644 index c64d6bb8ad3..00000000000 --- a/.svgo.yml +++ /dev/null @@ -1,43 +0,0 @@ -plugins: - - removeDoctype - - removeXMLProcInst - - removeComments - - removeMetadata - - removeEditorsNSData - - cleanupAttrs - - minifyStyles - - convertStyleToAttrs - - cleanupIDs: false - - removeRasterImages - - removeUselessDefs - - cleanupNumericValues - - cleanupListOfValues - - convertColors - - removeUnknownsAndDefaults - - removeNonInheritableGroupAttrs - - removeUselessStrokeAndFill - - removeViewBox - - cleanupEnableBackground - - removeHiddenElems - - removeEmptyText - - convertShapeToPath - - moveElemsAttrsToGroup - - moveGroupAttrsToElems - - collapseGroups - - convertPathData: false - - convertTransform - - removeEmptyAttrs - - removeEmptyContainers - - mergePaths - - removeUnusedNS - - transformsWithOnePath - - sortAttrs - - removeTitle - - removeDesc - - removeDimensions - - removeAttrs - - addClassesToSVGElement - - removeStyleElement -js2svg: - pretty: true - indent: ' ' diff --git a/front/main/.template-lintrc.js b/.template-lintrc.js similarity index 100% rename from front/main/.template-lintrc.js rename to .template-lintrc.js diff --git a/.watchmanconfig b/.watchmanconfig new file mode 100644 index 00000000000..e7834e3e4f3 --- /dev/null +++ b/.watchmanconfig @@ -0,0 +1,3 @@ +{ + "ignore_dirs": ["tmp", "dist"] +} diff --git a/Dockerfile b/Dockerfile index 405dc924192..98d03a0f5ca 100644 --- a/Dockerfile +++ b/Dockerfile @@ -19,6 +19,3 @@ RUN mkdir -p /build COPY package.json /build COPY . /build WORKDIR /build - -# install dependencies -RUN npm run setup-for-local diff --git a/front/main/app/.eslintrc b/app/.eslintrc similarity index 100% rename from front/main/app/.eslintrc rename to app/.eslintrc diff --git a/front/main/app/app.js b/app/app.js similarity index 100% rename from front/main/app/app.js rename to app/app.js diff --git a/front/main/app/components/ab-test.js b/app/components/ab-test.js similarity index 83% rename from front/main/app/components/ab-test.js rename to app/components/ab-test.js index f2bb64f1f15..963a2f6a5aa 100644 --- a/front/main/app/components/ab-test.js +++ b/app/components/ab-test.js @@ -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() { diff --git a/front/main/app/components/ad-slot.js b/app/components/ad-slot.js similarity index 100% rename from front/main/app/components/ad-slot.js rename to app/components/ad-slot.js diff --git a/front/main/app/components/ads/invisible-high-impact-2.js b/app/components/ads/invisible-high-impact-2.js similarity index 100% rename from front/main/app/components/ads/invisible-high-impact-2.js rename to app/components/ads/invisible-high-impact-2.js diff --git a/front/main/app/components/alert-notification.js b/app/components/alert-notification.js similarity index 100% rename from front/main/app/components/alert-notification.js rename to app/components/alert-notification.js diff --git a/front/main/app/components/alert-notifications.js b/app/components/alert-notifications.js similarity index 100% rename from front/main/app/components/alert-notifications.js rename to app/components/alert-notifications.js diff --git a/front/main/app/components/application-wrapper.js b/app/components/application-wrapper.js similarity index 84% rename from front/main/app/components/application-wrapper.js rename to app/components/application-wrapper.js index 65ec0a308d5..37b04bb19df 100644 --- a/front/main/app/components/application-wrapper.js +++ b/app/components/application-wrapper.js @@ -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 @@ -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`; }), @@ -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'), + } + }); + } } }, @@ -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 ); }, diff --git a/front/main/app/components/article-comment.js b/app/components/article-comment.js similarity index 83% rename from front/main/app/components/article-comment.js rename to app/components/article-comment.js index 52de92b8ca6..4b07b95a4fc 100644 --- a/front/main/app/components/article-comment.js +++ b/app/components/article-comment.js @@ -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 @@ -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'], @@ -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 = $('
').html(this.get('comment.text')), $figure = $text.find('figure'); @@ -29,7 +33,7 @@ export default Ember.Component.extend({ return $text.html(); }), - user: Ember.computed('users', function () { + user: computed('users', function () { const users = this.get('users'); if (users) { @@ -37,13 +41,13 @@ export default Ember.Component.extend({ } }), - 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; } @@ -77,8 +81,8 @@ export default Ember.Component.extend({ width: this.thumbnailWidth }), $thumbnail = $('${i18n.t('article.empty-label')}
`); + this.hackIntoEmberRendering(`${this.get('i18n').t('article.empty-label')}
`); } if (!this.get('isPreview')) { @@ -101,16 +108,6 @@ export default Component.extend( edit(title, sectionIndex) { this.sendAction('edit', title, sectionIndex); }, - - /** - * @param {string} title - * @param {number} sectionIndex - * @param {*} photoData - * @returns {void} - */ - addPhoto(title, sectionIndex, photoData) { - this.sendAction('addPhoto', title, sectionIndex, photoData); - }, }, /** @@ -208,11 +205,8 @@ export default Component.extend( sectionId, title: this.get('displayTitle'), edit: this.get('edit'), - addPhoto: this.get('addPhoto'), - addPhotoIconVisible: this.get('addPhotoIconVisible'), editIconVisible: this.get('editIconVisible'), editAllowed: this.get('editAllowed'), - addPhotoAllowed: this.get('addPhotoAllowed') }, element: placeholder }) diff --git a/front/main/app/components/article-contribution.js b/app/components/article-contribution.js similarity index 68% rename from front/main/app/components/article-contribution.js rename to app/components/article-contribution.js index 21bdad8eb41..28fed915a75 100644 --- a/front/main/app/components/article-contribution.js +++ b/app/components/article-contribution.js @@ -1,6 +1,6 @@ import Ember from 'ember'; import LanguagesMixin from '../mixins/languages'; -import {track, trackActions} from 'common/utils/track'; +import {track, trackActions} from '../utils/track'; export default Ember.Component.extend( LanguagesMixin, @@ -10,7 +10,6 @@ export default Ember.Component.extend( section: null, sectionId: null, title: null, - uploadFeatureEnabled: null, actions: { /** @@ -34,28 +33,6 @@ export default Ember.Component.extend( this.redirectToLogin('edit-section-no-auth'); } }, - - /** - * Go to add photo - * If login is required to add photo, redirect to login page - * - * @returns {void} - */ - addPhoto() { - if (this.get('addPhotoAllowed')) { - const photoData = this.$('.file-upload-input')[0].files[0]; - - track({ - action: trackActions.click, - category: 'sectioneditor', - label: 'add-photo', - value: this.get('section') - }); - this.sendAction('addPhoto', this.get('title'), this.get('section'), photoData); - } else { - this.redirectToLogin('add-photo-no-auth'); - } - }, }, openLocation(href) { diff --git a/front/main/app/components/article-edit.js b/app/components/article-edit.js similarity index 100% rename from front/main/app/components/article-edit.js rename to app/components/article-edit.js diff --git a/front/main/app/components/article-media-gallery.js b/app/components/article-media-gallery.js similarity index 98% rename from front/main/app/components/article-media-gallery.js rename to app/components/article-media-gallery.js index 5458bdf0ad5..021f58a1aa9 100644 --- a/front/main/app/components/article-media-gallery.js +++ b/app/components/article-media-gallery.js @@ -1,6 +1,6 @@ import Ember from 'ember'; import InViewportMixin from 'ember-in-viewport'; -import Thumbnailer from 'common/modules/thumbnailer'; +import Thumbnailer from '../modules/thumbnailer'; export default Ember.Component.extend( InViewportMixin, diff --git a/front/main/app/components/article-media-linked-gallery.js b/app/components/article-media-linked-gallery.js similarity index 96% rename from front/main/app/components/article-media-linked-gallery.js rename to app/components/article-media-linked-gallery.js index 6de73b1656c..2645cd11008 100644 --- a/front/main/app/components/article-media-linked-gallery.js +++ b/app/components/article-media-linked-gallery.js @@ -1,5 +1,5 @@ import Ember from 'ember'; -import Thumbnailer from 'common/modules/thumbnailer'; +import Thumbnailer from '../modules/thumbnailer'; export default Ember.Component.extend( { diff --git a/front/main/app/components/article-media-map-thumbnail.js b/app/components/article-media-map-thumbnail.js similarity index 91% rename from front/main/app/components/article-media-map-thumbnail.js rename to app/components/article-media-map-thumbnail.js index 0b1ea128420..71ac155ed0b 100644 --- a/front/main/app/components/article-media-map-thumbnail.js +++ b/app/components/article-media-map-thumbnail.js @@ -1,5 +1,5 @@ import Ember from 'ember'; -import {track, trackActions} from 'common/utils/track'; +import {track, trackActions} from '../utils/track'; export default Ember.Component.extend( { diff --git a/front/main/app/components/article-media-thumbnail.js b/app/components/article-media-thumbnail.js similarity index 97% rename from front/main/app/components/article-media-thumbnail.js rename to app/components/article-media-thumbnail.js index 79290d8dec4..d0fc4f0f863 100644 --- a/front/main/app/components/article-media-thumbnail.js +++ b/app/components/article-media-thumbnail.js @@ -2,7 +2,7 @@ import Ember from 'ember'; import InViewportMixin from 'ember-in-viewport'; import ViewportMixin from '../mixins/viewport'; import MediaThumbnailUtilsMixin from '../mixins/media-thumbnail-utils'; -import Thumbnailer from 'common/modules/thumbnailer'; +import Thumbnailer from '../modules/thumbnailer'; export default Ember.Component.extend( InViewportMixin, diff --git a/front/main/app/components/article-table-of-contents.js b/app/components/article-table-of-contents.js similarity index 94% rename from front/main/app/components/article-table-of-contents.js rename to app/components/article-table-of-contents.js index 106f8fe2f0c..72a308efc50 100644 --- a/front/main/app/components/article-table-of-contents.js +++ b/app/components/article-table-of-contents.js @@ -1,5 +1,5 @@ import Ember from 'ember'; -import {track, trackActions} from 'common/utils/track'; +import {track, trackActions} from '../utils/track'; export default Ember.Component.extend( { diff --git a/front/main/app/components/article-wrapper.js b/app/components/article-wrapper.js similarity index 65% rename from front/main/app/components/article-wrapper.js rename to app/components/article-wrapper.js index 16db09f7049..9044d68517f 100644 --- a/front/main/app/components/article-wrapper.js +++ b/app/components/article-wrapper.js @@ -2,9 +2,11 @@ import Ember from 'ember'; import LanguagesMixin from '../mixins/languages'; import PortableInfoboxHeroImageMixin from '../mixins/portable-infobox-hero-image'; import ViewportMixin from '../mixins/viewport'; -import {track, trackActions} from 'common/utils/track'; +import {track, trackActions} from '../utils/track'; import {namespace as mediawikiNamespace} from '../utils/mediawiki-namespace'; +const {Component, computed, inject} = Ember; + /** * @typedef {Object} ArticleSectionHeader * @property {HTMLElement} element @@ -14,13 +16,14 @@ import {namespace as mediawikiNamespace} from '../utils/mediawiki-namespace'; * @property {string} section */ -export default Ember.Component.extend( +export default Component.extend( PortableInfoboxHeroImageMixin, LanguagesMixin, ViewportMixin, { classNames: ['article-wrapper'], - currentUser: Ember.inject.service(), + currentUser: inject.service(), + wikiVariables: inject.service(), displayEmptyArticleInfo: true, hammerOptions: { touchAction: 'auto', @@ -40,15 +43,7 @@ export default Ember.Component.extend( * * @returns {boolean} True if contribution component is enabled for this community */ - contributionEnabledForCommunity: Ember.computed(() => { - if (Ember.getWithDefault(Mercury, 'wiki.disableMobileSectionEditor', false)) { - // When disableMobileSectionEditor is set to true, no contribution tools should - // show up - return false; - } - - return true; - }), + contributionEnabledForCommunity: computed.not('wikiVariables.disableMobileSectionEditor'), /** * Checks if mobile contribution features are enabled. @@ -56,7 +51,7 @@ export default Ember.Component.extend( * * @returns {boolean} True if the contribution features should be rendered on the page */ - contributionEnabled: Ember.computed('model.isMainPage', function () { + contributionEnabled: computed('model.isMainPage', function () { return !this.get('model.isMainPage') && this.get('contributionEnabledForCommunity') && // @todo XW-1196: Enable article editing on category and file pages @@ -64,20 +59,12 @@ export default Ember.Component.extend( this.getWithDefault('model.ns', 0) !== mediawikiNamespace.FILE; }), - /** - * Determine if the upload photo icon should be rendered. - * Only enabled for Japanese wikias - * - * @returns {boolean} True if the upload photo icon should be rendered - */ - addPhotoIconVisible: Ember.computed.oneWay('isJapaneseWikia'), - /** * Determine if the edit section icon should be rendered * * @returns {boolean} True if the edit icon should be rendered */ - editIconVisible: Ember.computed.oneWay('contributionEnabled'), + editIconVisible: computed.oneWay('contributionEnabled'), /** * For section editor, checks if the user is allowed to edit @@ -87,9 +74,9 @@ export default Ember.Component.extend( * * @returns {boolean} True if edit is allowed */ - editAllowed: Ember.computed(function () { - const isCoppaWiki = Ember.getWithDefault(Mercury, 'wiki.isCoppaWiki', false), - disableAnonymousEditing = Ember.getWithDefault(Mercury, 'wiki.disableAnonymousEditing', false), + editAllowed: computed(function () { + const isCoppaWiki = this.get('wikiVariables.isCoppaWiki') || false, + disableAnonymousEditing = this.get('wikiVariables.disableAnonymousEditing') || false, isLoggedIn = this.get('currentUser.isAuthenticated'); if (isLoggedIn) { @@ -99,16 +86,6 @@ export default Ember.Component.extend( } }), - /** - * For add photo, check if the user is allowed to upload - * Only logged in users are allowed to add photo - * - * @returns {boolean} True if add photo is allowed - */ - addPhotoAllowed: Ember.computed(function () { - return this.get('currentUser.isAuthenticated'); - }), - actions: { /** * @param {string} title @@ -119,16 +96,6 @@ export default Ember.Component.extend( this.sendAction('edit', title, sectionIndex); }, - /** - * @param {string} title - * @param {number} sectionIndex - * @param {*} photoData - * @returns {void} - */ - addPhoto(title, sectionIndex, photoData) { - this.sendAction('addPhoto', title, sectionIndex, photoData); - }, - /** * @param {string} lightboxType * @param {*} lightboxData @@ -157,9 +124,6 @@ export default Ember.Component.extend( * @returns {void} */ didInsertElement() { - $(window).off('scroll.mobileWiki.preload'); - window.scrollTo(0, M.prop('scroll')); - Ember.run.scheduleOnce('afterRender', this, () => { this.sendAction('articleRendered'); }); diff --git a/front/main/app/components/category-members-grouped.js b/app/components/category-members-grouped.js similarity index 86% rename from front/main/app/components/category-members-grouped.js rename to app/components/category-members-grouped.js index 7b7b1dcc3df..fc96dc7af22 100644 --- a/front/main/app/components/category-members-grouped.js +++ b/app/components/category-members-grouped.js @@ -1,12 +1,13 @@ import Ember from 'ember'; import AlertNotificationsMixin from '../mixins/alert-notifications'; -import {track, trackActions} from 'common/utils/track'; +import {track, trackActions} from '../utils/track'; -const {Component, Logger, $, run} = Ember; +const {Component, Logger, $, run, inject} = Ember; export default Component.extend( AlertNotificationsMixin, { + i18n: inject.service(), classNames: ['category-members-grouped'], classNameBindings: ['isLoading'], isLoading: false, @@ -36,7 +37,7 @@ export default Component.extend( }) .catch((error) => { this.addAlert({ - message: i18n.t('category-page.load-error'), + message: this.get('i18n').t('category-page.load-error'), type: 'alert' }); diff --git a/front/main/app/components/collapsible-menu.js b/app/components/collapsible-menu.js similarity index 94% rename from front/main/app/components/collapsible-menu.js rename to app/components/collapsible-menu.js index 4562bbd3a32..1bdc5a3508c 100644 --- a/front/main/app/components/collapsible-menu.js +++ b/app/components/collapsible-menu.js @@ -1,5 +1,5 @@ import Ember from 'ember'; -import {track, trackActions} from 'common/utils/track'; +import {track, trackActions} from '../utils/track'; export default Ember.Component.extend( { diff --git a/front/main/app/components/curated-content-item.js b/app/components/curated-content-item.js similarity index 95% rename from front/main/app/components/curated-content-item.js rename to app/components/curated-content-item.js index b47e8764228..b9d629d9380 100644 --- a/front/main/app/components/curated-content-item.js +++ b/app/components/curated-content-item.js @@ -1,7 +1,7 @@ import Ember from 'ember'; import CuratedContentThumbnailMixin from '../mixins/curated-content-thumbnail'; import ViewportMixin from '../mixins/viewport'; -import {track, trackActions} from 'common/utils/track'; +import {track, trackActions} from '../utils/track'; export default Ember.Component.extend( CuratedContentThumbnailMixin, @@ -11,7 +11,7 @@ export default Ember.Component.extend( attributeBindings: ['href'], classNames: ['curated-content-item'], classNameBindings: ['type'], - openSection: Ember.K, + openSection() {}, href: Ember.computed.oneWay('model.url'), type: Ember.computed.oneWay('model.type'), diff --git a/front/main/app/components/curated-content-section.js b/app/components/curated-content-section.js similarity index 100% rename from front/main/app/components/curated-content-section.js rename to app/components/curated-content-section.js diff --git a/front/main/app/components/curated-content.js b/app/components/curated-content.js similarity index 100% rename from front/main/app/components/curated-content.js rename to app/components/curated-content.js diff --git a/app/components/fastboot-only/body-bottom.js b/app/components/fastboot-only/body-bottom.js new file mode 100644 index 00000000000..c12a04ae339 --- /dev/null +++ b/app/components/fastboot-only/body-bottom.js @@ -0,0 +1,9 @@ +import Ember from 'ember'; + +const {Component, computed} = Ember; + +export default Component.extend({ + tagName: '', + layoutName: 'components/fastboot-only/body-bottom', + noExternals: computed.bool('queryParams.noexternals'), +}); diff --git a/app/components/fastboot-only/head-bottom.js b/app/components/fastboot-only/head-bottom.js new file mode 100644 index 00000000000..7b88a570ea3 --- /dev/null +++ b/app/components/fastboot-only/head-bottom.js @@ -0,0 +1,10 @@ +import Ember from 'ember'; + +const {Component, computed} = Ember; + +export default Component.extend({ + tagName: '', + layoutName: 'components/fastboot-only/head-bottom', + wikiVariables: null, + isRtl: computed.equal('wikiVariables.language.contentDir', 'rtl') +}); diff --git a/app/components/fastboot-only/tracking-pixels.js b/app/components/fastboot-only/tracking-pixels.js new file mode 100644 index 00000000000..033b9f197ed --- /dev/null +++ b/app/components/fastboot-only/tracking-pixels.js @@ -0,0 +1,10 @@ +import Ember from 'ember'; + +const {Component, computed, inject} = Ember; + +export default Component.extend({ + tagName: '', + tracking: inject.service(), + comscore: computed.reads('tracking.config.comscore'), + quantcast: computed.reads('tracking.config.quantcast') +}); diff --git a/front/main/app/components/featured-content-item.js b/app/components/featured-content-item.js similarity index 93% rename from front/main/app/components/featured-content-item.js rename to app/components/featured-content-item.js index 4f1e5927ca4..f06b98e2527 100644 --- a/front/main/app/components/featured-content-item.js +++ b/app/components/featured-content-item.js @@ -1,7 +1,7 @@ import Ember from 'ember'; import CuratedContentThumbnailMixin from '../mixins/curated-content-thumbnail'; import ViewportMixin from '../mixins/viewport'; -import Thumbnailer from 'common/modules/thumbnailer'; +import Thumbnailer from '../modules/thumbnailer'; export default Ember.Component.extend( CuratedContentThumbnailMixin, diff --git a/front/main/app/components/featured-content.js b/app/components/featured-content.js similarity index 98% rename from front/main/app/components/featured-content.js rename to app/components/featured-content.js index 2f0b38e60a5..38760753a54 100644 --- a/front/main/app/components/featured-content.js +++ b/app/components/featured-content.js @@ -1,6 +1,6 @@ import Ember from 'ember'; import ThirdsClickMixin from '../mixins/thirds-click'; -import {track, trackActions} from 'common/utils/track'; +import {track, trackActions} from '../utils/track'; /** * ImageCropData diff --git a/app/components/global-footer/global-footer-bottom-bar.js b/app/components/global-footer/global-footer-bottom-bar.js new file mode 100644 index 00000000000..6a6e2c37244 --- /dev/null +++ b/app/components/global-footer/global-footer-bottom-bar.js @@ -0,0 +1,17 @@ +import Ember from 'ember'; +import config from '../../config/environment'; + +export default Ember.Component.extend({ + tagName: '', + wikiVariables: Ember.inject.service(), + + actions: { + fullSiteClicked() { + this.get('track')('full-site-link'); + $.cookie('useskin', this.getWithDefault('wikiVariables.defaultSkin', 'oasis'), { + domain: config.cookieDomain, + path: '/' + }); + } + } +}); diff --git a/app/components/global-footer/global-footer-link-branded.js b/app/components/global-footer/global-footer-link-branded.js new file mode 100644 index 00000000000..22d872db764 --- /dev/null +++ b/app/components/global-footer/global-footer-link-branded.js @@ -0,0 +1,5 @@ +import Ember from 'ember'; + +export default Ember.Component.extend({ + tagName: '', +}); diff --git a/app/components/global-footer/global-footer-link-image.js b/app/components/global-footer/global-footer-link-image.js new file mode 100644 index 00000000000..22d872db764 --- /dev/null +++ b/app/components/global-footer/global-footer-link-image.js @@ -0,0 +1,5 @@ +import Ember from 'ember'; + +export default Ember.Component.extend({ + tagName: '', +}); diff --git a/app/components/global-footer/global-footer-link-text.js b/app/components/global-footer/global-footer-link-text.js new file mode 100644 index 00000000000..22d872db764 --- /dev/null +++ b/app/components/global-footer/global-footer-link-text.js @@ -0,0 +1,5 @@ +import Ember from 'ember'; + +export default Ember.Component.extend({ + tagName: '', +}); diff --git a/app/components/global-footer/global-footer-section.js b/app/components/global-footer/global-footer-section.js new file mode 100644 index 00000000000..22d872db764 --- /dev/null +++ b/app/components/global-footer/global-footer-section.js @@ -0,0 +1,5 @@ +import Ember from 'ember'; + +export default Ember.Component.extend({ + tagName: '', +}); diff --git a/app/components/global-footer/global-footer.js b/app/components/global-footer/global-footer.js new file mode 100644 index 00000000000..b400d9cc0ba --- /dev/null +++ b/app/components/global-footer/global-footer.js @@ -0,0 +1,16 @@ +import Ember from 'ember'; +import {track, trackActions} from '../../utils/track'; + +export default Ember.Component.extend({ + tagName: '', + + actions: { + track(trackingLabel) { + track({ + action: trackActions.click, + category: 'footer', + label: trackingLabel + }); + } + } +}); diff --git a/front/main/app/components/lightbox-ads.js b/app/components/lightbox-ads.js similarity index 100% rename from front/main/app/components/lightbox-ads.js rename to app/components/lightbox-ads.js diff --git a/front/main/app/components/lightbox-image.js b/app/components/lightbox-image.js similarity index 100% rename from front/main/app/components/lightbox-image.js rename to app/components/lightbox-image.js diff --git a/front/main/app/components/lightbox-map.js b/app/components/lightbox-map.js similarity index 100% rename from front/main/app/components/lightbox-map.js rename to app/components/lightbox-map.js diff --git a/front/main/app/components/lightbox-media.js b/app/components/lightbox-media.js similarity index 98% rename from front/main/app/components/lightbox-media.js rename to app/components/lightbox-media.js index 240301eb929..6d40b40eefc 100644 --- a/front/main/app/components/lightbox-media.js +++ b/app/components/lightbox-media.js @@ -1,7 +1,7 @@ import Ember from 'ember'; import ThirdsClickMixin from '../mixins/thirds-click'; import MediaModel from '../models/media'; -import {normalizeToUnderscore} from 'common/utils/string'; +import {normalizeToUnderscore} from '../utils/string'; export default Ember.Component.extend( ThirdsClickMixin, diff --git a/front/main/app/components/lightbox-video.js b/app/components/lightbox-video.js similarity index 97% rename from front/main/app/components/lightbox-video.js rename to app/components/lightbox-video.js index 77db26fce8b..e3c9c732091 100644 --- a/front/main/app/components/lightbox-video.js +++ b/app/components/lightbox-video.js @@ -1,6 +1,6 @@ import Ember from 'ember'; import ViewportMixin from '../mixins/viewport'; -import VideoLoader from 'common/modules/video-loader'; +import VideoLoader from '../modules/video-loader'; /** * Component that is used inside ligthbox-media component diff --git a/front/main/app/components/lightbox-wrapper.js b/app/components/lightbox-wrapper.js similarity index 100% rename from front/main/app/components/lightbox-wrapper.js rename to app/components/lightbox-wrapper.js diff --git a/front/main/app/components/login-icon.js b/app/components/login-icon.js similarity index 100% rename from front/main/app/components/login-icon.js rename to app/components/login-icon.js diff --git a/front/main/app/components/main-page.js b/app/components/main-page.js similarity index 92% rename from front/main/app/components/main-page.js rename to app/components/main-page.js index 48bdd5a55b3..04d01cc1e56 100644 --- a/front/main/app/components/main-page.js +++ b/app/components/main-page.js @@ -10,6 +10,9 @@ export default Component.extend( tagName: 'section', currentUser: inject.service(), + wikiVariables: inject.service(), + + title: computed.reads('wikiVariables.siteName'), curatedContentToolButtonVisible: computed.and('currentUser.rights.curatedcontent'), diff --git a/front/main/app/components/modal-dialog.js b/app/components/modal-dialog.js similarity index 100% rename from front/main/app/components/modal-dialog.js rename to app/components/modal-dialog.js diff --git a/front/main/app/components/notification-card.js b/app/components/notification-card.js similarity index 97% rename from front/main/app/components/notification-card.js rename to app/components/notification-card.js index 1652dde0f61..ef654999b8a 100644 --- a/front/main/app/components/notification-card.js +++ b/app/components/notification-card.js @@ -23,6 +23,7 @@ export default Component.extend( currentUser: inject.service(), notifications: inject.service(), + i18n: inject.service(), userLanguage: computed.oneWay('currentUser.language'), @@ -113,7 +114,7 @@ export default Component.extend( ns: 'design-system', }, context); - return i18n.t(key, fullContext); + return this.get('i18n').t(key, fullContext); }, actions: { diff --git a/front/main/app/components/portable-infobox-hero-image.js b/app/components/portable-infobox-hero-image.js similarity index 97% rename from front/main/app/components/portable-infobox-hero-image.js rename to app/components/portable-infobox-hero-image.js index 95bdf856404..c3416c8a2bb 100644 --- a/front/main/app/components/portable-infobox-hero-image.js +++ b/app/components/portable-infobox-hero-image.js @@ -1,5 +1,5 @@ import Ember from 'ember'; -import Thumbnailer from 'common/modules/thumbnailer'; +import Thumbnailer from '../modules/thumbnailer'; import ViewportMixin from '../mixins/viewport'; export default Ember.Component.extend( diff --git a/front/main/app/components/portable-infobox-image-collection.js b/app/components/portable-infobox-image-collection.js similarity index 97% rename from front/main/app/components/portable-infobox-image-collection.js rename to app/components/portable-infobox-image-collection.js index 72082cdf31d..09a864aa8f4 100644 --- a/front/main/app/components/portable-infobox-image-collection.js +++ b/app/components/portable-infobox-image-collection.js @@ -1,5 +1,5 @@ import Ember from 'ember'; -import Thumbnailer from 'common/modules/thumbnailer'; +import Thumbnailer from '../modules/thumbnailer'; import ViewportMixin from '../mixins/viewport'; export default Ember.Component.extend( diff --git a/front/main/app/components/portable-infobox.js b/app/components/portable-infobox.js similarity index 97% rename from front/main/app/components/portable-infobox.js rename to app/components/portable-infobox.js index a3105a36891..49da080756f 100644 --- a/front/main/app/components/portable-infobox.js +++ b/app/components/portable-infobox.js @@ -1,6 +1,6 @@ import Ember from 'ember'; import ViewportMixin from '../mixins/viewport'; -import {track, trackActions} from 'common/utils/track'; +import {track, trackActions} from '../utils/track'; export default Ember.Component.extend( ViewportMixin, diff --git a/app/components/show-error-dev.js b/app/components/show-error-dev.js new file mode 100644 index 00000000000..d5608d6f9c9 --- /dev/null +++ b/app/components/show-error-dev.js @@ -0,0 +1,32 @@ +import Ember from 'ember'; +import BaseErrorComponent from 'ember-error-handler/components/ember-error-handler/wsod-screen'; + +const {computed, inject, observer} = Ember; + +export default BaseErrorComponent.extend({ + fastboot: inject.service(), + + descriptor: computed.reads('descriptors.firstObject'), + + additionalData: computed(function () { + const additionalData = this.get('descriptor.additionalData'); + + return additionalData ? JSON.stringify(additionalData, null, 1) : null; + }), + + // descriptor is not available on init(), so we use observer instead + setStatusCode: observer('descriptor', function () { + const fastboot = this.get('fastboot'); + const code = this.get('descriptor.error.code'); + + if (fastboot.get('isFastBoot')) { + if (code >= 400) { + fastboot.set('response.statusCode', code); + } + + if (code >= 500) { + fastboot.get('shoebox').put('serverError', true); + } + } + }) +}); diff --git a/app/components/show-error-prod.js b/app/components/show-error-prod.js new file mode 100644 index 00000000000..32e1a5ec5fa --- /dev/null +++ b/app/components/show-error-prod.js @@ -0,0 +1,25 @@ +import Ember from 'ember'; +import BaseErrorComponent from 'ember-error-handler/components/ember-error-handler/wsod-screen'; + +const {computed, inject, observer} = Ember; + +export default BaseErrorComponent.extend({ + fastboot: inject.service(), + + descriptor: computed.reads('descriptors.firstObject'), + + setStatusCode: observer('descriptor', function () { + const fastboot = this.get('fastboot'); + const code = this.get('descriptor.error.code'); + + if (fastboot.get('isFastBoot')) { + if (code >= 400) { + fastboot.set('response.statusCode', code); + } + + if (code >= 500) { + fastboot.get('shoebox').put('serverError', true); + } + } + }) +}); diff --git a/front/main/app/components/site-head-fandom-bar.js b/app/components/site-head-fandom-bar.js similarity index 51% rename from front/main/app/components/site-head-fandom-bar.js rename to app/components/site-head-fandom-bar.js index a91f6131413..3eaaa40bf89 100644 --- a/front/main/app/components/site-head-fandom-bar.js +++ b/app/components/site-head-fandom-bar.js @@ -1,13 +1,13 @@ import Ember from 'ember'; -import {track, trackActions} from 'common/utils/track'; +import {track, trackActions} from '../utils/track'; -const {Component} = Ember; +const {Component, computed} = Ember; export default Component.extend({ classNames: ['site-head-fandom-bar-wrapper'], - partnerSlot: M.prop('globalNavigation.partner_slot'), - svgName: M.prop('globalNavigation.logo.module.tagline.image-data.name'), + partnerSlot: computed.alias('globalNavigation.partner_slot'), + svgName: computed.alias('globalNavigation.logo.module.tagline.image-data.name'), actions: { trackClick(label) { diff --git a/front/main/app/components/site-head.js b/app/components/site-head.js similarity index 84% rename from front/main/app/components/site-head.js rename to app/components/site-head.js index 22e34a5b4c0..28ce45b1743 100644 --- a/front/main/app/components/site-head.js +++ b/app/components/site-head.js @@ -1,7 +1,7 @@ import Ember from 'ember'; import HeadroomMixin from '../mixins/headroom'; import NotificationsUnreadCountMixin from '../mixins/notifications-unread-count'; -import {track, trackActions} from 'common/utils/track'; +import {track, trackActions} from '../utils/track'; const {computed, Component} = Ember; @@ -28,20 +28,21 @@ export default Component.extend( } }, - wikiaHomepage: M.prop('globalNavigation.logo.module.main.href') || 'http://fandom.wikia.com', + wikiaHomepage: computed.alias('globalNavigation.logo.module.main.href') || 'http://fandom.wikia.com', displayFandomBar: computed('isSearchPage', function () { - return Boolean(M.prop('globalNavigation.logo.module.tagline')) && !this.get('isSearchPage'); + return Boolean(this.get('globalNavigation.logo.module.tagline')) && !this.get('isSearchPage'); }), - svgName: M.prop('globalNavigation.logo.module.main.image-data.name'), + svgName: computed.alias('globalNavigation.logo.module.main.image-data.name'), navIcon: computed('drawerContent', 'drawerVisible', function () { - return this.get('drawerVisible') && this.isDrawerInClosableState() ? 'close' : 'nav'; + return this.get('drawerVisible') && this.isDrawerInClosableState() ? this.get('closeIcon') : 'nav'; }), searchIcon: computed('drawerContent', 'drawerVisible', function () { - return this.get('drawerVisible') && this.get('drawerContent') === 'search' ? 'close' : 'search'; + return this.get('drawerVisible') && this.get('drawerContent') === 'search' ? + this.get('closeIcon') : 'search'; }), offset: computed.readOnly('ads.siteHeadOffset'), diff --git a/front/main/app/components/smart-banner-android.js b/app/components/smart-banner-android.js similarity index 91% rename from front/main/app/components/smart-banner-android.js rename to app/components/smart-banner-android.js index 679135ccd69..84178e07703 100644 --- a/front/main/app/components/smart-banner-android.js +++ b/app/components/smart-banner-android.js @@ -1,14 +1,14 @@ import Ember from 'ember'; -import Thumbnailer from 'common/modules/thumbnailer'; -import {track, trackActions} from 'common/utils/track'; -import {system, standalone} from 'common/utils/browser'; +import Thumbnailer from '../modules/thumbnailer'; +import {track, trackActions} from '../utils/track'; +import {system, standalone} from '../utils/browser'; const { $, Component, computed, get, - getWithDefault, + inject, String, run, } = Ember; @@ -22,6 +22,8 @@ export default Component.extend({ classNames: ['smart-banner-android'], classNameBindings: ['noIcon'], + wikiVariables: inject.service(), + options: { // Language code for App Store appStoreLanguage: 'us', @@ -36,8 +38,10 @@ export default Component.extend({ appId: computed.oneWay(`config.appId.android`), appScheme: computed.oneWay(`config.appScheme.android`), - config: getWithDefault(Mercury, 'wiki.smartBanner', {}), - dbName: get(Mercury, 'wiki.dbName'), + config: computed('wikiVariables', function () { + return this.get('wikiVariables').get('smartBanner') || {}; + }), + dbName: computed.reads('wikiVariables.dbName'), description: computed.oneWay('config.description'), icon: computed.oneWay('config.icon'), iconSize: 92, diff --git a/front/main/app/components/track-click.js b/app/components/track-click.js similarity index 100% rename from front/main/app/components/track-click.js rename to app/components/track-click.js diff --git a/front/main/app/components/trending-articles-item.js b/app/components/trending-articles-item.js similarity index 90% rename from front/main/app/components/trending-articles-item.js rename to app/components/trending-articles-item.js index 7c7eb99e325..e93dd472907 100644 --- a/front/main/app/components/trending-articles-item.js +++ b/app/components/trending-articles-item.js @@ -1,7 +1,7 @@ import Ember from 'ember'; import ViewportMixin from '../mixins/viewport'; -import Thumbnailer from 'common/modules/thumbnailer'; -import {track, trackActions} from 'common/utils/track'; +import Thumbnailer from '../modules/thumbnailer'; +import {track, trackActions} from '../utils/track'; export default Ember.Component.extend( ViewportMixin, diff --git a/front/main/app/components/trending-articles.js b/app/components/trending-articles.js similarity index 100% rename from front/main/app/components/trending-articles.js rename to app/components/trending-articles.js diff --git a/front/main/app/components/trending-videos-item.js b/app/components/trending-videos-item.js similarity index 91% rename from front/main/app/components/trending-videos-item.js rename to app/components/trending-videos-item.js index 8957c350b03..5850c53a4a0 100644 --- a/front/main/app/components/trending-videos-item.js +++ b/app/components/trending-videos-item.js @@ -1,7 +1,7 @@ import Ember from 'ember'; import ViewportMixin from '../mixins/viewport'; -import Thumbnailer from 'common/modules/thumbnailer'; -import {track, trackActions} from 'common/utils/track'; +import Thumbnailer from '../modules/thumbnailer'; +import {track, trackActions} from '../utils/track'; export default Ember.Component.extend( ViewportMixin, diff --git a/front/main/app/components/trending-videos.js b/app/components/trending-videos.js similarity index 100% rename from front/main/app/components/trending-videos.js rename to app/components/trending-videos.js diff --git a/app/components/user-avatar.js b/app/components/user-avatar.js new file mode 100644 index 00000000000..2fa5f3a7dc7 --- /dev/null +++ b/app/components/user-avatar.js @@ -0,0 +1,28 @@ +import Ember from 'ember'; +import {buildUrl} from '../utils/url'; + +const {Component, computed, inject} = Ember; + +export default Component.extend({ + i18n: inject.service(), + classNames: ['user-avatar'], + profileName: computed('username', function () { + const userName = this.get('username') || ''; + + return userName.trim(); + }), + /** + * Returns link to the post author's user page + * @returns {string} + */ + profileUrl: computed('profileName', function () { + return buildUrl({ + namespace: 'User', + title: this.get('profileName'), + }); + }), + displayName: computed('profileName', function () { + return this.get('anonymous') ? this.get('i18n').t('app.username-anonymous') : this.get('profileName'); + }), + shouldWrapInHref: true +}); diff --git a/front/main/app/components/wds-avatar-stack.js b/app/components/wds-avatar-stack.js similarity index 100% rename from front/main/app/components/wds-avatar-stack.js rename to app/components/wds-avatar-stack.js diff --git a/front/main/app/components/wds-spinner.js b/app/components/wds-spinner.js similarity index 100% rename from front/main/app/components/wds-spinner.js rename to app/components/wds-spinner.js diff --git a/front/main/app/components/widget-apester.js b/app/components/widget-apester.js similarity index 100% rename from front/main/app/components/widget-apester.js rename to app/components/widget-apester.js diff --git a/front/main/app/components/widget-discussions-post.js b/app/components/widget-discussions-post.js similarity index 95% rename from front/main/app/components/widget-discussions-post.js rename to app/components/widget-discussions-post.js index 52835a25135..e5102e72db9 100644 --- a/front/main/app/components/widget-discussions-post.js +++ b/app/components/widget-discussions-post.js @@ -1,6 +1,6 @@ import Ember from 'ember'; import {truncate} from '../utils/truncate'; -import nl2br from 'common/utils/nl2br'; +import nl2br from '../utils/nl2br'; const {Component, Handlebars, String, computed} = Ember; diff --git a/front/main/app/components/widget-discussions.js b/app/components/widget-discussions.js similarity index 88% rename from front/main/app/components/widget-discussions.js rename to app/components/widget-discussions.js index 413770be4d5..8078ef309df 100644 --- a/front/main/app/components/widget-discussions.js +++ b/app/components/widget-discussions.js @@ -2,17 +2,16 @@ import Ember from 'ember'; import InViewportMixin from 'ember-in-viewport'; import WidgetDiscussionsModel from '../models/widget-discussions'; -const {Component} = Ember; +const {Component, inject} = Ember; export default Component.extend( InViewportMixin, { - classNames: ['widget-discussions'], + wikiVariables: inject.service(), + classNames: ['widget-discussions'], layoutName: 'components/widget-discussions', - isLoading: true, - model: null, init() { @@ -26,7 +25,7 @@ export default Component.extend( */ didEnterViewport() { this.get('model').find( - Mercury.wiki.id, + this.get('wikiVariables.id'), this.getWithDefault('categoryIds', []), this.get('show'), this.get('itemCount') diff --git a/front/main/app/components/widget-flite.js b/app/components/widget-flite.js similarity index 100% rename from front/main/app/components/widget-flite.js rename to app/components/widget-flite.js diff --git a/front/main/app/components/widget-playbuzz.js b/app/components/widget-playbuzz.js similarity index 100% rename from front/main/app/components/widget-playbuzz.js rename to app/components/widget-playbuzz.js diff --git a/front/main/app/components/widget-polldaddy.js b/app/components/widget-polldaddy.js similarity index 100% rename from front/main/app/components/widget-polldaddy.js rename to app/components/widget-polldaddy.js diff --git a/front/main/app/components/widget-twitter.js b/app/components/widget-twitter.js similarity index 100% rename from front/main/app/components/widget-twitter.js rename to app/components/widget-twitter.js diff --git a/front/main/app/components/widget-vk.js b/app/components/widget-vk.js similarity index 100% rename from front/main/app/components/widget-vk.js rename to app/components/widget-vk.js diff --git a/front/main/app/components/wiki-description.js b/app/components/wiki-description.js similarity index 100% rename from front/main/app/components/wiki-description.js rename to app/components/wiki-description.js diff --git a/front/main/app/components/wikia-drawer.js b/app/components/wikia-drawer.js similarity index 100% rename from front/main/app/components/wikia-drawer.js rename to app/components/wikia-drawer.js diff --git a/front/main/app/components/wikia-in-your-lang.js b/app/components/wikia-in-your-lang.js similarity index 91% rename from front/main/app/components/wikia-in-your-lang.js rename to app/components/wikia-in-your-lang.js index aa6655575d8..890d7268488 100644 --- a/front/main/app/components/wikia-in-your-lang.js +++ b/app/components/wikia-in-your-lang.js @@ -3,12 +3,15 @@ import AlertNotificationsMixin from '../mixins/alert-notifications'; import LanguagesMixin from '../mixins/languages'; import WikiaInYourLangModel from '../models/wikia-in-your-lang'; import localStorageConnector from '../utils/local-storage-connector'; -import {track, trackActions} from 'common/utils/track'; +import {track, trackActions} from '../utils/track'; -export default Ember.Component.extend( +const {Component, inject} = Ember; + +export default Component.extend( AlertNotificationsMixin, LanguagesMixin, { + wikiVariables: inject.service(), alertKey: 'wikiaInYourLang.alertDismissed', /** @@ -100,7 +103,7 @@ export default Ember.Component.extend( let isDifferent = false; if (eligibleCountries.indexOf(userLang) !== -1) { - isDifferent = userLang !== Ember.get(Mercury, 'wiki.language.content'); + isDifferent = userLang !== this.get('wikiVariables.language.content'); } return isDifferent; diff --git a/front/main/app/components/wikia-nav.js b/app/components/wikia-nav.js similarity index 77% rename from front/main/app/components/wikia-nav.js rename to app/components/wikia-nav.js index 75cacc998e0..8ab16746e61 100644 --- a/front/main/app/components/wikia-nav.js +++ b/app/components/wikia-nav.js @@ -2,8 +2,9 @@ import Ember from 'ember'; import LoginLinkMixin from '../mixins/login-link'; import WikiaNavModel from '../models/wikia-nav'; import NoScrollMixin from '../mixins/no-scroll'; +import {buildUrl} from '../utils/url'; import UnreadCountMixin from '../mixins/notifications-unread-count'; -import {track, trackActions} from 'common/utils/track'; +import {track, trackActions} from '../utils/track'; const {Component, computed, inject, get} = Ember; @@ -12,20 +13,27 @@ export default Component.extend( { classNames: ['wikia-nav'], classNameBindings: ['model.inRoot:wikia-nav--in-root'], + currentUser: inject.service(), + wikiVariables: inject.service(), + i18n: inject.service(), notifications: inject.service(), - isUserAuthenticated: computed.oneWay('currentUser.isAuthenticated'), - enableOnSiteNotifications: get(Mercury, 'wiki.enableOnSiteNotifications'), + isUserAuthenticated: computed.oneWay('currentUser.isAuthenticated'), + enableOnSiteNotifications: computed.oneWay('wikiVariables.enableOnSiteNotifications'), /** TODO: Remove with the feature flag IRIS-4170 */ - logoutLink: M.buildUrl({ - namespace: 'Special', - title: 'UserLogout' + logoutLink: computed(function () { + return buildUrl({ + host: this.get('wikiVariables.host'), + namespace: 'Special', + title: 'UserLogout' + }); }), /** TODO: Remove with the feature flag IRIS-4170 */ userProfileLink: computed('currentUser.name', function () { - return M.buildUrl({ + return buildUrl({ + host: this.get('wikiVariables.host'), namespace: 'User', title: this.get('currentUser.name') }); @@ -33,7 +41,11 @@ export default Component.extend( init() { this._super(...arguments); - this.model = WikiaNavModel.create(); + this.model = WikiaNavModel.create({ + dsGlobalNavigation: this.get('wikiVariables.globalNavigation'), + wikiVariables: this.get('wikiVariables'), + i18n: this.get('i18n') + }); this.clickHandlers = { onRandomPageClick: 'loadRandomArticle' }; diff --git a/front/main/app/components/wikia-search-error-not-found.js b/app/components/wikia-search-error-not-found.js similarity index 100% rename from front/main/app/components/wikia-search-error-not-found.js rename to app/components/wikia-search-error-not-found.js diff --git a/front/main/app/components/wikia-search.js b/app/components/wikia-search.js similarity index 81% rename from front/main/app/components/wikia-search.js rename to app/components/wikia-search.js index 20bf009a2b3..0e7ee2e9cd8 100644 --- a/front/main/app/components/wikia-search.js +++ b/app/components/wikia-search.js @@ -1,8 +1,10 @@ import Ember from 'ember'; import NoScrollMixin from '../mixins/no-scroll'; -import {track, trackActions} from 'common/utils/track'; import wrapMeHelper from '../helpers/wrap-me'; -import {escapeRegex, normalizeToUnderscore} from 'common/utils/string'; +import fetch from '../utils/mediawiki-fetch'; +import {escapeRegex, normalizeToUnderscore} from '../utils/string'; +import {track, trackActions} from '../utils/track'; +import {buildUrl} from '../utils/url'; const {Component, computed, observer, inject, run, $} = Ember; @@ -48,7 +50,8 @@ export default Component.extend( suggestions: [], suggestionsEnabled: true, - ajax: inject.service(), + i18n: inject.service(), + wikiVariables: inject.service(), emptyPhraseInput: computed.not('phrase'), hasSuggestions: computed.notEmpty('suggestions'), noScroll: computed.oneWay('hasSuggestions'), @@ -56,8 +59,8 @@ export default Component.extend( // ensures that phrase is changed according to external change this.set('phrase', this.get('query')); }), - searchPlaceholderLabel: computed(() => { - return i18n.t('search:main.search-input-label'); + searchPlaceholderLabel: computed(function () { + return this.get('i18n').t('search:main.search-input-label'); }), didInsertElement() { @@ -189,7 +192,8 @@ export default Component.extend( * @returns {string} */ getSearchURI(phrase) { - return M.buildUrl({ + return buildUrl({ + host: this.get('wikiVariables.host'), path: '/wikia.php', query: { controller: 'MercuryApi', @@ -221,39 +225,48 @@ export default Component.extend( this.startedRequest(phrase); - this.get('ajax').request(uri).then((data) => { - const suggestions = data.items.map((suggestion) => { - return Ember.Object.create(suggestion); + fetch(uri) + .then((response) => { + if (response.ok) { + return response.json().then((data) => { + const suggestions = data.items.map((suggestion) => { + return Ember.Object.create(suggestion); + }); + + /** + * If the user makes one request, request A, and then keeps typing to make + * request B, but request A takes a long time while request B returns quickly, + * then we don't want request A to dump its info into the window after B has + * already inserted the relevant information. + * Also, we don't want to show the suggestion results after a real search + * will be finished, what will happen if search request is still in progress. + */ + if (!this.get('searchRequestInProgress') && phrase === this.get('phrase')) { + this.setSearchSuggestionItems(suggestions); + } + + this.cacheResult(phrase, suggestions); + }); + } else if (response.status === 404) { + // When we get a 404, it means there were no results + if (phrase === this.get('phrase')) { + this.setSearchSuggestionItems(); + } + + this.cacheResult(phrase); + } else { + Ember.Logger.error('Search suggestion error: ', response); + } + }) + .catch((reason) => Ember.Logger.error('Search suggestion error: ', reason)) + .finally(() => { + // We have a response, so we're no longer loading the results + if (phrase === this.get('phrase')) { + this.set('isLoadingResultsSuggestions', false); + } + + this.endedRequest(phrase); }); - - /** - * If the user makes one request, request A, and then keeps typing to make - * request B, but request A takes a long time while request B returns quickly, - * then we don't want request A to dump its info into the window after B has - * already inserted the relevant information. - * Also, we don't want to show the suggestion results after a real search - * will be finished, what will happen if search request is still in progress. - */ - if (!this.get('searchRequestInProgress') && phrase === this.get('phrase')) { - this.setSearchSuggestionItems(suggestions); - } - - this.cacheResult(phrase, suggestions); - }).catch(() => { - // When we get a 404, it means there were no results - if (phrase === this.get('phrase')) { - this.setSearchSuggestionItems(); - } - - this.cacheResult(phrase); - }).finally(() => { - // We have a response, so we're no longer loading the results - if (phrase === this.get('phrase')) { - this.set('isLoadingResultsSuggestions', false); - } - - this.endedRequest(phrase); - }); }, /** diff --git a/front/main/app/components/wikia-stats.js b/app/components/wikia-stats.js similarity index 54% rename from front/main/app/components/wikia-stats.js rename to app/components/wikia-stats.js index 6cf2be841b5..a5665ed4567 100644 --- a/front/main/app/components/wikia-stats.js +++ b/app/components/wikia-stats.js @@ -1,25 +1,28 @@ import Ember from 'ember'; -import {track, trackActions} from 'common/utils/track'; +import {track, trackActions} from '../utils/track'; -export default Ember.Component.extend({ +const {Component, computed, inject} = Ember; + +export default Component.extend({ classNames: ['wikia-stats'], + i18n: inject.service(), - items: Ember.computed('model', function () { + items: computed('model', function () { return [ { - label: i18n.t('app.pages-label'), + label: this.get('i18n').t('app.pages-label'), value: this.get('model.articles'), }, { - label: i18n.t('app.photos-label'), + label: this.get('i18n').t('app.photos-label'), value: this.get('model.images'), }, { - label: i18n.t('app.videos-label'), + label: this.get('i18n').t('app.videos-label'), value: this.get('model.videos'), }, { - label: i18n.t('app.discussions-label'), + label: this.get('i18n').t('app.discussions-label'), url: '/d/f', trackingLabel: 'discussions-clicked', value: this.get('model.discussions'), diff --git a/front/main/app/components/wikia-ui-components/error-info.js b/app/components/wikia-ui-components/error-info.js similarity index 100% rename from front/main/app/components/wikia-ui-components/error-info.js rename to app/components/wikia-ui-components/error-info.js diff --git a/front/main/app/components/wikia-ui-components/icon-button.js b/app/components/wikia-ui-components/icon-button.js similarity index 100% rename from front/main/app/components/wikia-ui-components/icon-button.js rename to app/components/wikia-ui-components/icon-button.js diff --git a/front/main/app/components/wikia-ui-components/sub-header.js b/app/components/wikia-ui-components/sub-header.js similarity index 100% rename from front/main/app/components/wikia-ui-components/sub-header.js rename to app/components/wikia-ui-components/sub-header.js diff --git a/front/main/app/components/wikia-ui-components/wds-button.js b/app/components/wikia-ui-components/wds-button.js similarity index 92% rename from front/main/app/components/wikia-ui-components/wds-button.js rename to app/components/wikia-ui-components/wds-button.js index af22b451eff..211a697506d 100644 --- a/front/main/app/components/wikia-ui-components/wds-button.js +++ b/app/components/wikia-ui-components/wds-button.js @@ -9,7 +9,7 @@ */ import Ember from 'ember'; -import {track, trackActions} from 'common/utils/track'; +import {track, trackActions} from '../../utils/track'; const {Component} = Ember; @@ -20,7 +20,7 @@ export default Component.extend( classNameBindings: ['isSecondary:wds-is-secondary', 'isText:wds-is-text'], isSecondary: false, isText: false, - onClick: Ember.K, + onClick() {}, /** * Handles click event on button - calls proper action if passed diff --git a/app/components/wikia-ui-components/wiki-page-header-curated-main-page.js b/app/components/wikia-ui-components/wiki-page-header-curated-main-page.js new file mode 100644 index 00000000000..b15cb7d10f3 --- /dev/null +++ b/app/components/wikia-ui-components/wiki-page-header-curated-main-page.js @@ -0,0 +1,24 @@ +import Ember from 'ember'; +import {track, trackActions} from '../../utils/track'; + +const {Component, computed, inject} = Ember; + +export default Component.extend( + { + wikiVariables: inject.service(), + classNames: ['wiki-page-header-curated-main-page'], + siteName: computed.reads('wikiVariables.siteName'), + mainPageTitle: computed.reads('wikiVariables.mainPageTitle'), + + actions: { + trackClick(trackingLabel) { + track({ + action: trackActions.click, + category: 'main-page', + label: trackingLabel + }); + } + } + } +); + diff --git a/front/main/app/components/wikia-ui-components/wiki-page-header.js b/app/components/wikia-ui-components/wiki-page-header.js similarity index 79% rename from front/main/app/components/wikia-ui-components/wiki-page-header.js rename to app/components/wikia-ui-components/wiki-page-header.js index eb30e199988..bb117ebd69d 100644 --- a/front/main/app/components/wikia-ui-components/wiki-page-header.js +++ b/app/components/wikia-ui-components/wiki-page-header.js @@ -22,29 +22,32 @@ */ import Ember from 'ember'; -import Thumbnailer from 'common/modules/thumbnailer'; +import Thumbnailer from '../../modules/thumbnailer'; import ViewportMixin from '../../mixins/viewport'; -import {track, trackActions} from 'common/utils/track'; +import {track, trackActions} from '../../utils/track'; -export default Ember.Component.extend( +const {Component, computed, isEmpty, inject, String} = Ember; + +export default Component.extend( ViewportMixin, { + wikiVariables: inject.service(), imageAspectRatio: 16 / 9, classNames: ['wiki-page-header'], classNameBindings: ['heroImage:has-hero-image'], attributeBindings: ['style'], isMainPage: false, - siteName: Ember.get(Mercury, 'wiki.siteName'), - mainPageTitle: Ember.get(Mercury, 'wiki.mainPageTitle'), + siteName: computed.reads('wikiVariables.siteName'), + mainPageTitle: computed.reads('wikiVariables.mainPageTitle'), - style: Ember.computed('heroImage', 'viewportDimensions.width', function () { + style: computed('heroImage', 'viewportDimensions.width', function () { const heroImage = this.get('heroImage'), windowWidth = this.get('viewportDimensions.width'), imageAspectRatio = this.get('imageAspectRatio'); let imageWidth, imageHeight, maxWidth, computedHeight, cropMode, thumbUrl; - if (Ember.isEmpty(heroImage)) { + if (isEmpty(heroImage)) { return ''; } @@ -78,7 +81,7 @@ export default Ember.Component.extend( width: windowWidth }); - return new Ember.String.htmlSafe(`background-image: url(${thumbUrl}); height: ${computedHeight}px`); + return new String.htmlSafe(`background-image: url(${thumbUrl}); height: ${computedHeight}px`); }), actions: { diff --git a/front/main/app/components/wikia-ui-components/wikia-card-list.js b/app/components/wikia-ui-components/wikia-card-list.js similarity index 100% rename from front/main/app/components/wikia-ui-components/wikia-card-list.js rename to app/components/wikia-ui-components/wikia-card-list.js diff --git a/front/main/app/components/wikia-user-profile.js b/app/components/wikia-user-profile.js similarity index 78% rename from front/main/app/components/wikia-user-profile.js rename to app/components/wikia-user-profile.js index a6e7d17d2f5..4954e4594e1 100644 --- a/front/main/app/components/wikia-user-profile.js +++ b/app/components/wikia-user-profile.js @@ -1,8 +1,8 @@ import Ember from 'ember'; import NoScrollMixin from '../mixins/no-scroll'; -import {track, trackActions} from 'common/utils/track'; import NotificationsScrollMenuMixin from '../mixins/notifications-scroll-menu'; import MarkAllNotificationsMixin from '../mixins/mark-all-notifications'; +import {buildUrl} from '../utils/url'; const {Component, computed, inject} = Ember; @@ -14,13 +14,17 @@ export default Component.extend( classNames: ['wikia-user-profile'], currentUser: inject.service(), notifications: inject.service(), + wikiVariables: inject.service(), notificationsList: computed.oneWay('notifications.model.data'), isLoadingNewResults: computed.oneWay('notifications.isLoading'), - logoutLink: M.buildUrl({ - namespace: 'Special', - title: 'UserLogout' + logoutLink: computed(function () { + return buildUrl({ + host: this.get('wikiVariables.host'), + namespace: 'Special', + title: 'UserLogout' + }); }), username: computed.oneWay('currentUser.name'), diff --git a/front/main/app/components/wikia-users.js b/app/components/wikia-users.js similarity index 80% rename from front/main/app/components/wikia-users.js rename to app/components/wikia-users.js index 98fba6d95e9..6f718813341 100644 --- a/front/main/app/components/wikia-users.js +++ b/app/components/wikia-users.js @@ -1,6 +1,6 @@ import Ember from 'ember'; -import Thumbnailer from 'common/modules/thumbnailer'; -import {track, trackActions} from 'common/utils/track'; +import Thumbnailer from '../modules/thumbnailer'; +import {track, trackActions} from '../utils/track'; export default Ember.Component.extend( { diff --git a/front/main/app/controllers/application.js b/app/controllers/application.js similarity index 93% rename from front/main/app/controllers/application.js rename to app/controllers/application.js index 4bdfcc62b70..b815e83317f 100644 --- a/front/main/app/controllers/application.js +++ b/app/controllers/application.js @@ -2,15 +2,18 @@ import Ember from 'ember'; import AlertNotificationsMixin from '../mixins/alert-notifications'; import MediaModel from '../models/media'; import NoScrollMixin from '../mixins/no-scroll'; -import {track, trackActions} from 'common/utils/track'; +import {track, trackActions} from '../utils/track'; -export default Ember.Controller.extend( +const {Controller, inject} = Ember; + +export default Controller.extend( AlertNotificationsMixin, NoScrollMixin, { // This has to be here because we need to access media from ArticleController model to open // lightbox TODO: Should be refactored when decoupling article from application - wikiPage: Ember.inject.controller(), - ads: Ember.inject.service(), + wikiPage: inject.controller(), + ads: inject.service(), + wikiVariables: inject.service(), queryParams: ['file', 'map', { noAds: 'noads' @@ -30,7 +33,6 @@ export default Ember.Controller.extend( drawerContent: null, userMenuVisible: false, fullPage: false, - noMargins: false, lightboxType: null, lightboxModel: null, lightboxVisible: false, @@ -43,8 +45,9 @@ export default Ember.Controller.extend( */ init() { this.setProperties({ - domain: Ember.get(Mercury, 'wiki.dbName') || window.location.href.match(/^https?:\/\/(.*?)\./)[1], - language: Ember.get(Mercury, 'wiki.language') + domain: this.get('wikiVariables.dbName') || + window.location && window.location.href.match(/^https?:\/\/(.*?)\./)[1], + language: this.get('wikiVariables.language') }); // This event is for tracking mobile sessions between Mercury and WikiaMobile diff --git a/front/main/app/controllers/article-edit.js b/app/controllers/article-edit.js similarity index 79% rename from front/main/app/controllers/article-edit.js rename to app/controllers/article-edit.js index bda0827b1a2..ec1959d95b7 100644 --- a/front/main/app/controllers/article-edit.js +++ b/app/controllers/article-edit.js @@ -1,14 +1,18 @@ import Ember from 'ember'; import ArticleEditModel from '../models/article-edit'; -import {track, trackActions} from 'common/utils/track'; -import {normalizeToUnderscore} from 'common/utils/string'; +import {track, trackActions} from '../utils/track'; +import {normalizeToUnderscore} from '../utils/string'; -export default Ember.Controller.extend({ - application: Ember.inject.controller(), +const {Controller, inject, computed} = Ember; + +export default Controller.extend({ + application: inject.controller(), + i18n: inject.service(), + wikiVariables: inject.service(), isPublishing: false, - publishDisabled: Ember.computed('isPublishing', 'model.isDirty', function () { + publishDisabled: computed('isPublishing', 'model.isDirty', function () { return (this.get('isPublishing') === true || this.get('model.isDirty') === false); }), @@ -33,7 +37,7 @@ export default Ember.Controller.extend({ this.transitionToRoute('wiki-page', title).then(() => { this.get('application').addAlert({ - message: i18n.t('edit.success', { + message: this.get('i18n').t('edit.success', { pageTitle: title }), type: 'success' @@ -57,7 +61,7 @@ export default Ember.Controller.extend({ errorMsg = this.errorCodeMap[error] || 'edit.publish-error'; appController.addAlert({ - message: i18n.t(errorMsg), + message: this.get('i18n').t(errorMsg), type: 'alert' }); @@ -80,7 +84,7 @@ export default Ember.Controller.extend({ this.set('isPublishing', true); this.get('application').set('isLoading', true); - ArticleEditModel.publish(this.get('model')).then( + ArticleEditModel.publish(this.get('wikiVariables.host'), this.get('model')).then( this.handlePublishSuccess.bind(this), this.handlePublishError.bind(this) ); diff --git a/app/controllers/article-preview.js b/app/controllers/article-preview.js new file mode 100644 index 00000000000..2a67791b5ae --- /dev/null +++ b/app/controllers/article-preview.js @@ -0,0 +1,9 @@ +import Ember from 'ember'; +import FullPageMixin from '../mixins/full-page'; +import PortableInfoboxHeroImageMixin from '../mixins/portable-infobox-hero-image'; + +export default Ember.Controller.extend( + FullPageMixin, + PortableInfoboxHeroImageMixin, + {} +); diff --git a/app/controllers/article.js b/app/controllers/article.js new file mode 100644 index 00000000000..96d031e4187 --- /dev/null +++ b/app/controllers/article.js @@ -0,0 +1,46 @@ +import Ember from 'ember'; +import {track, trackActions} from '../utils/track'; + +const {Controller, computed, inject} = Ember; + +export default Controller.extend({ + application: inject.controller(), + wikiVariables: inject.service(), + + commentsPage: computed.alias('application.commentsPage'), + mainPageTitle: computed.reads('wikiVariables.mainPageTitle'), + siteName: computed.reads('wikiVariables.siteName'), + + actions: { + /** + * @param {string} title + * @param {number} sectionIndex + * @returns {void} + */ + edit(title, sectionIndex) { + this.transitionToRoute('articleEdit', title, sectionIndex); + + track({ + action: trackActions.click, + category: 'sectioneditor', + label: 'edit', + value: sectionIndex + }); + }, + + /** + * @returns {void} + */ + articleRendered() { + this.send('handleLightbox'); + }, + + trackClick(category, label) { + track({ + action: trackActions.click, + category, + label + }); + } + } +}); diff --git a/front/main/app/controllers/category.js b/app/controllers/category.js similarity index 63% rename from front/main/app/controllers/category.js rename to app/controllers/category.js index 4cd57475a4d..d43f4d35ead 100644 --- a/front/main/app/controllers/category.js +++ b/app/controllers/category.js @@ -1,22 +1,15 @@ import Ember from 'ember'; -const {Controller, RSVP, inject, get, getWithDefault} = Ember; +const {Controller, computed, RSVP, inject} = Ember; export default Controller.extend( { application: inject.controller(), article: inject.controller(), + wikiVariables: inject.service(), - /** - * @returns {void} - */ - init() { - this._super(...arguments); - this.setProperties({ - mainPageTitle: get(Mercury, 'wiki.mainPageTitle'), - siteName: getWithDefault(Mercury, 'wiki.siteName', 'Fandom powered by Wikia') - }); - }, + mainPageTitle: computed.reads('wikiVariables.mainPageTitle'), + siteName: computed.reads('wikiVariables.siteName'), actions: { /** @@ -26,16 +19,6 @@ export default Controller.extend( this.get('article').send('articleRendered', ...arguments); }, - /** - * TODO Remove after XW-2583 is released - * @param {number} index - * @param {number} batch - * @returns {Ember.RSVP.Promise} - */ - loadBatch(index, batch) { - return this.get('model').loadMore(index, batch); - }, - /** * @param {number} page * @returns {Ember.RSVP.Promise} diff --git a/app/controllers/file.js b/app/controllers/file.js new file mode 100644 index 00000000000..fbb6faf9aa2 --- /dev/null +++ b/app/controllers/file.js @@ -0,0 +1,23 @@ +import Ember from 'ember'; + +const {Controller, computed, inject} = Ember; + +export default Controller.extend( + { + application: inject.controller(), + article: inject.controller(), + wikiVariables: inject.service(), + + mainPageTitle: computed.reads('wikiVariables.mainPageTitle'), + siteName: computed.reads('wikiVariables.siteName'), + + actions: { + /** + * @returns {void} + */ + articleRendered() { + this.get('article').send('articleRendered', ...arguments); + } + } + } +); diff --git a/app/controllers/main-page.js b/app/controllers/main-page.js new file mode 100644 index 00000000000..d57daace6ae --- /dev/null +++ b/app/controllers/main-page.js @@ -0,0 +1,11 @@ +import Ember from 'ember'; + +const {Controller, computed, inject} = Ember; + +export default Controller.extend({ + application: inject.controller(), + wikiVariables: inject.service(), + + mainPageTitle: computed.reads('wikiVariables.mainPageTitle'), + siteName: computed.reads('wikiVariables.siteName'), +}); diff --git a/app/controllers/not-found.js b/app/controllers/not-found.js new file mode 100644 index 00000000000..58b7b874f8e --- /dev/null +++ b/app/controllers/not-found.js @@ -0,0 +1,9 @@ +import Ember from 'ember'; + +const {Controller, computed, inject} = Ember; + +export default Controller.extend({ + wikiVariables: inject.service(), + mainPageTitle: computed.reads('wikiVariables.mainPageTitle'), + siteName: computed.reads('wikiVariables.siteName') +}); diff --git a/front/main/app/controllers/search.js b/app/controllers/search.js similarity index 89% rename from front/main/app/controllers/search.js rename to app/controllers/search.js index 22d7d685ea3..589523bb7b0 100644 --- a/front/main/app/controllers/search.js +++ b/app/controllers/search.js @@ -4,6 +4,7 @@ const {Controller, computed, inject, $, run} = Ember; export default Controller.extend({ application: inject.controller(), + fastboot: inject.service(), // TODO: to be removed as we'll be supporting more errors on search page, // see: https://wikia-inc.atlassian.net/browse/DAT-4324 notFoundError: computed.equal('model.error', 'search-error-not-found'), @@ -18,7 +19,10 @@ export default Controller.extend({ */ run.scheduleOnce('afterRender', this, () => { this.set('inputPhrase', this.get('query')); - this.set('inputField', $('.side-search__input')); + + if (!this.get('fastboot.isFastBoot')) { + this.set('inputField', $('.side-search__input')); + } }); }, diff --git a/front/main/app/controllers/wiki-page.js b/app/controllers/wiki-page.js similarity index 100% rename from front/main/app/controllers/wiki-page.js rename to app/controllers/wiki-page.js diff --git a/front/main/app/helpers/duration.js b/app/helpers/duration.js similarity index 100% rename from front/main/app/helpers/duration.js rename to app/helpers/duration.js diff --git a/front/main/app/helpers/equal.js b/app/helpers/equal.js similarity index 100% rename from front/main/app/helpers/equal.js rename to app/helpers/equal.js diff --git a/app/helpers/i18n.js b/app/helpers/i18n.js new file mode 100644 index 00000000000..4c37a55b368 --- /dev/null +++ b/app/helpers/i18n.js @@ -0,0 +1,32 @@ +import Ember from 'ember'; + +const {Helper, inject} = Ember; +/** + * @param {Array} params + * @param {Object} options + * @returns {string} + */ +export default Helper.extend({ + i18n: inject.service(), + + compute(params, options) { + const i18nParams = {}, + value = params.join('.'); + + let namespace = 'main'; + + /** + * @param {string} key + * @returns {void} + */ + Object.keys(options).forEach((key) => { + if (key === 'ns') { + namespace = options[key]; + } else if (options[key] !== undefined) { + i18nParams[key] = options[key]; + } + }); + + return this.get('i18n').t(`${namespace}:${value}`, i18nParams); + } +}); diff --git a/front/main/app/helpers/numeral.js b/app/helpers/numeral.js similarity index 88% rename from front/main/app/helpers/numeral.js rename to app/helpers/numeral.js index 40ad21618b8..1852c0d291e 100644 --- a/front/main/app/helpers/numeral.js +++ b/app/helpers/numeral.js @@ -1,4 +1,5 @@ import Ember from 'ember'; +import numeral from 'numeral'; /** * @param {Array} params diff --git a/front/main/app/helpers/shorten-large-number.js b/app/helpers/shorten-large-number.js similarity index 100% rename from front/main/app/helpers/shorten-large-number.js rename to app/helpers/shorten-large-number.js diff --git a/front/main/app/helpers/svg.js b/app/helpers/svg.js similarity index 100% rename from front/main/app/helpers/svg.js rename to app/helpers/svg.js diff --git a/front/main/app/helpers/thumbnail.js b/app/helpers/thumbnail.js similarity index 96% rename from front/main/app/helpers/thumbnail.js rename to app/helpers/thumbnail.js index e398a3984ca..42533ba11dc 100644 --- a/front/main/app/helpers/thumbnail.js +++ b/app/helpers/thumbnail.js @@ -1,5 +1,5 @@ import Ember from 'ember'; -import Thumbnailer from 'common/modules/thumbnailer'; +import Thumbnailer from '../modules/thumbnailer'; /** * Helper to generate img element with link to thumbnail as the src attribute diff --git a/front/main/app/helpers/time-ago.js b/app/helpers/time-ago.js similarity index 93% rename from front/main/app/helpers/time-ago.js rename to app/helpers/time-ago.js index 710e5ada50a..64725313edb 100644 --- a/front/main/app/helpers/time-ago.js +++ b/app/helpers/time-ago.js @@ -15,6 +15,7 @@ import moment from 'moment'; */ export default Ember.Helper.extend({ momentLocale: Ember.inject.service(), + i18n: Ember.inject.service(), onLocaleChange: Ember.observer('momentLocale.isLoaded', function () { this.recompute(); }), @@ -32,7 +33,7 @@ export default Ember.Helper.extend({ if (now.diff(date, 'days') > 5) { output = date.format('L'); } else if (now.diff(date, 'minutes') < 1) { - output = i18n.t('app.now-label'); + output = this.get('i18n').t('main:app.now-label'); } else { output = date.fromNow(shouldHideAgoPrefix); } diff --git a/front/main/app/helpers/timestamp-to-date.js b/app/helpers/timestamp-to-date.js similarity index 100% rename from front/main/app/helpers/timestamp-to-date.js rename to app/helpers/timestamp-to-date.js diff --git a/front/main/app/helpers/truncate.js b/app/helpers/truncate.js similarity index 100% rename from front/main/app/helpers/truncate.js rename to app/helpers/truncate.js diff --git a/front/main/app/helpers/wrap-me.js b/app/helpers/wrap-me.js similarity index 100% rename from front/main/app/helpers/wrap-me.js rename to app/helpers/wrap-me.js diff --git a/app/index.html b/app/index.html new file mode 100644 index 00000000000..88c7975fba8 --- /dev/null +++ b/app/index.html @@ -0,0 +1,40 @@ + + + +{{content-for 'head'}} +{{content-for 'globals'}} +{{content-for 'get-from-shoebox'}} +{{content-for 'geo-cookie'}} +{{content-for 'load-script'}} +{{content-for 'tracking-quantcast'}} +{{content-for 'tracking-comscore'}} +{{content-for 'tracking-ua-init'}} +{{content-for 'head-footer'}} + + +