diff --git a/client/boot/index.js b/client/boot/index.js index 210f7660ff5d6..ca53533a026c8 100644 --- a/client/boot/index.js +++ b/client/boot/index.js @@ -171,6 +171,8 @@ function boot() { } else { if ( config.isEnabled( 'oauth' ) ) { LoggedOutLayout = require( 'layout/logged-out-oauth' ); + } else if ( startsWith( window.location.pathname, '/design' ) ) { + LoggedOutLayout = require( 'layout/themes-logged-out' ); } else { LoggedOutLayout = require( 'layout/logged-out' ); } diff --git a/config/wpcalypso.json b/config/wpcalypso.json index 9ee7778e2ad43..23181071d874c 100644 --- a/config/wpcalypso.json +++ b/config/wpcalypso.json @@ -43,6 +43,7 @@ "manage/themes": true, "manage/themes-jetpack": true, "premium-themes": true, + "manage/themes/logged-out": true, "press-this": true, "manage/sharing": true, "manage/plans": true, diff --git a/index.js b/index.js index 8a700db439324..1a63c46903fab 100644 --- a/index.js +++ b/index.js @@ -1,3 +1,5 @@ +require( 'lib/local-storage' )( global ); + /** * External dependencies. */ diff --git a/server/i18nlint/i18nlint.js b/server/i18nlint/i18nlint.js index 635dfcaf50f5d..b9fd1f33c8cd3 100644 --- a/server/i18nlint/i18nlint.js +++ b/server/i18nlint/i18nlint.js @@ -9,7 +9,7 @@ var fs = require( 'fs' ), babel = require( 'babel-core' ), preProcessXGettextJSMatch = require( '../i18n/preprocess-xgettextjs-match.js' ), SourceMapConsumer = require( 'source-map' ).SourceMapConsumer, - tokenize = require( '../../client/lib/interpolate-components/tokenize.js' ), + tokenize = require( '../../shared/lib/interpolate-components/tokenize.js' ), contains = require( 'lodash' ).contains, flow = require( 'lodash' ).flow; diff --git a/server/lib/viewport/index.js b/server/lib/viewport/index.js new file mode 100644 index 0000000000000..83c5fcd6be968 --- /dev/null +++ b/server/lib/viewport/index.js @@ -0,0 +1,3 @@ +module.exports = { + isMobile: () => false +}; diff --git a/server/pages/index.jade b/server/pages/index.jade index 2ee4622465dc6..18bb354ab8bc0 100644 --- a/server/pages/index.jade +++ b/server/pages/index.jade @@ -44,8 +44,11 @@ html(lang=lang, dir=isRTL ? 'rtl' : 'ltr', class=isFluidWidth ? 'is-fluid-width' link(rel='stylesheet', href=urls['style.css']) body(class=isRTL ? 'rtl' : '') - #wpcom.wpcom-site - .wpcom-site__logo.noticon.noticon-wordpress + if layout + #wpcom.wpcom-site!= layout + else + #wpcom.wpcom-site + .wpcom-site__logo.noticon.noticon-wordpress if badge div.environment-badge a(class='bug-report', href=feedbackURL, title='Report an issue', target='_blank') diff --git a/server/pages/index.js b/server/pages/index.js index 695db54b966ba..bd074d586e5cc 100644 --- a/server/pages/index.js +++ b/server/pages/index.js @@ -4,12 +4,16 @@ var express = require( 'express' ), qs = require( 'qs' ), cookieParser = require( 'cookie-parser' ), i18nUtils = require( 'lib/i18n-utils' ), - debug = require( 'debug' )( 'calypso:pages' ); + assign = require( 'lodash/object/assign' ), + debug = require( 'debug' )( 'calypso:pages' ), + React = require( 'react' ), + ReactInjection = require( 'react/lib/ReactInjection' ); var config = require( 'config' ), sanitize = require( 'sanitize' ), utils = require( 'bundler/utils' ), - sections = require( '../../client/sections' ); + sections = require( '../../client/sections' ), + i18n = require( 'lib/mixins/i18n' ); var HASH_LENGTH = 10, URL_BASE_PATH = '/calypso', @@ -344,12 +348,25 @@ module.exports = function() { } } ); - app.get( '/design', function( req, res ) { + app.get( '/design/type?/:tier?', function( req, res ) { if ( req.cookies.wordpress_logged_in || ! config.isEnabled( 'manage/themes/logged-out' ) ) { // the user is probably logged in renderLoggedInRoute( req, res ); } else { - renderLoggedOutRoute( req, res ); + ReactInjection.Class.injectMixin( i18n.mixin ); + i18n.initialize(); + + const themesLoggedOutLayoutComponent = require( 'layout/themes-logged-out' ), + themesLoggedOutLayout = React.createFactory( themesLoggedOutLayoutComponent ), + context = getDefaultContext( req ), + props = { + section: 'themes', + tier: req.params.tier || 'all', + }; + + context.layout = React.renderToString( themesLoggedOutLayout( props ) ); + + res.render( 'index.jade', context ); } } ); diff --git a/shared/components/empty/index.jsx b/shared/components/empty/index.jsx new file mode 100644 index 0000000000000..221dadeca1231 --- /dev/null +++ b/shared/components/empty/index.jsx @@ -0,0 +1,9 @@ +const React = require( 'react' ); + +const EmptyComponent = React.createClass( { + render: function() { + return null; + } +} ); + +module.exports = EmptyComponent; diff --git a/client/components/infinite-list/Makefile b/shared/components/infinite-list/Makefile similarity index 100% rename from client/components/infinite-list/Makefile rename to shared/components/infinite-list/Makefile diff --git a/client/components/infinite-list/README.md b/shared/components/infinite-list/README.md similarity index 100% rename from client/components/infinite-list/README.md rename to shared/components/infinite-list/README.md diff --git a/client/components/infinite-list/index.jsx b/shared/components/infinite-list/index.jsx similarity index 88% rename from client/components/infinite-list/index.jsx rename to shared/components/infinite-list/index.jsx index f1ebd3ac5a5c6..5964337682cfc 100644 --- a/client/components/infinite-list/index.jsx +++ b/shared/components/infinite-list/index.jsx @@ -54,25 +54,26 @@ module.exports = React.createClass( { smartSetState: smartSetState, componentWillMount: function() { - var url = page.current, - newState, scrollPosition; + if ( typeof( window ) !== 'undefined' ) { + var url = page.current, + newState, scrollPosition; - if ( detectHistoryNavigation.loadedViaHistory() ) { - newState = InfiniteListPositionsStore.get( url ); - scrollPosition = InfiniteListScrollStore.get( url ); - } + if ( detectHistoryNavigation.loadedViaHistory() ) { + newState = InfiniteListPositionsStore.get( url ); + scrollPosition = InfiniteListScrollStore.get( url ); + } - if ( newState && scrollPosition ) { - debug( 'overriding scrollTop:', scrollPosition ); - newState.scrollTop = scrollPosition; - } + if ( newState && scrollPosition ) { + debug( 'overriding scrollTop:', scrollPosition ); + newState.scrollTop = scrollPosition; + } - this.scrollHelper = new ScrollHelper( this.boundsForRef ); - this.scrollHelper.props = this.props; - if ( this._contextLoaded() ) { - this._scrollContainer = this.props.context || window; - this.scrollHelper.updateContextHeight( this.getCurrentContextHeight() ); - } + this.scrollHelper = new ScrollHelper( this.boundsForRef ); + this.scrollHelper.props = this.props; + if ( this._contextLoaded() ) { + this._scrollContainer = this.props.context || window; + this.scrollHelper.updateContextHeight( this.getCurrentContextHeight() ); + } this.isScrolling = false; @@ -87,9 +88,10 @@ module.exports = React.createClass( { bottomPlaceholderHeight: 0, scrollTop: 0 }; + debug( 'infinite list mounting', newState ); + this.setState( newState ); + } } - debug( 'infinite list mounting', newState ); - this.setState( newState ); }, componentDidMount: function() { @@ -316,21 +318,22 @@ module.exports = React.createClass( { }, render: function() { - var lastRenderedIndex = this.state.lastRenderedIndex, + var lastRenderedIndex = this.state ? this.state.lastRenderedIndex : this.props.items.length - 1, + firstRenderedIndex = this.state ? this.state.firstRenderedIndex : 0, itemsToRender = [], propsToTransfer = omit( this.props, Object.keys( this.constructor.propTypes ) ), spacerClassName = 'infinite-list__spacer', i; - if ( lastRenderedIndex === -1 || lastRenderedIndex > this.props.items.length - 1 ) { + if ( this.state && lastRenderedIndex === -1 || lastRenderedIndex > this.props.items.length - 1 ) { debug( 'resetting lastRenderedIndex, currently at %s, %d items', lastRenderedIndex, this.props.items.length ); lastRenderedIndex = Math.min( this.state.firstRenderedIndex + this.scrollHelper.initialLastRenderedIndex(), this.props.items.length - 1 ); debug( 'reset lastRenderedIndex to %s', lastRenderedIndex ); } - debug( 'rendering %d to %d', this.state.firstRenderedIndex, lastRenderedIndex ); + debug( 'rendering %d to %d', firstRenderedIndex, lastRenderedIndex ); - for ( i = this.state.firstRenderedIndex; i <= lastRenderedIndex; i++ ) { + for ( i = firstRenderedIndex; i <= lastRenderedIndex; i++ ) { itemsToRender.push( this.props.renderItem( this.props.items[ i ], i ) ); } @@ -342,12 +345,12 @@ module.exports = React.createClass( {
+ style={ { height: this.state ? this.state.topPlaceholderHeight : 0 } } /> { itemsToRender } { this.props.renderTrailingItems() }
+ style={ { height: this.state ? this.state.bottomPlaceholderHeight : 0 } } />
); }, diff --git a/client/components/infinite-list/scroll-helper.js b/shared/components/infinite-list/scroll-helper.js similarity index 100% rename from client/components/infinite-list/scroll-helper.js rename to shared/components/infinite-list/scroll-helper.js diff --git a/client/components/infinite-list/style.scss b/shared/components/infinite-list/style.scss similarity index 100% rename from client/components/infinite-list/style.scss rename to shared/components/infinite-list/style.scss diff --git a/client/components/infinite-list/test/scroll-helper.js b/shared/components/infinite-list/test/scroll-helper.js similarity index 100% rename from client/components/infinite-list/test/scroll-helper.js rename to shared/components/infinite-list/test/scroll-helper.js diff --git a/client/components/main/README.md b/shared/components/main/README.md similarity index 100% rename from client/components/main/README.md rename to shared/components/main/README.md diff --git a/client/components/main/index.jsx b/shared/components/main/index.jsx similarity index 100% rename from client/components/main/index.jsx rename to shared/components/main/index.jsx diff --git a/client/components/main/style.scss b/shared/components/main/style.scss similarity index 100% rename from client/components/main/style.scss rename to shared/components/main/style.scss diff --git a/client/components/search/Makefile b/shared/components/search/Makefile similarity index 100% rename from client/components/search/Makefile rename to shared/components/search/Makefile diff --git a/client/components/search/README.md b/shared/components/search/README.md similarity index 100% rename from client/components/search/README.md rename to shared/components/search/README.md diff --git a/client/components/search/docs/example.jsx b/shared/components/search/docs/example.jsx similarity index 100% rename from client/components/search/docs/example.jsx rename to shared/components/search/docs/example.jsx diff --git a/client/components/search/index.jsx b/shared/components/search/index.jsx similarity index 97% rename from client/components/search/index.jsx rename to shared/components/search/index.jsx index ccc06ae3d5873..dfb12375187f7 100644 --- a/client/components/search/index.jsx +++ b/shared/components/search/index.jsx @@ -1,7 +1,7 @@ /** * External dependencies */ -var React = require( 'react' ), +var React = require( 'react/addons' ), classNames = require( 'classnames' ), debounce = require( 'lodash/function/debounce' ), noop = () => {}; @@ -60,12 +60,17 @@ module.exports = React.createClass( { }; }, - componentWillMount: function() { + componentDidMount: function() { this.id = _instance; _instance++; this.onSearch = this.props.delaySearch ? debounce( this.props.onSearch, SEARCH_DEBOUNCE_MS ) : this.props.onSearch; + this.onSearch = ( this.props.delaySearch ) ? debounce( this.props.onSearch, SEARCH_DEBOUNCE_MS ) : this.props.onSearch; + + if ( this.props.autoFocus ) { + this.focus(); + } }, componentWillReceiveProps: function( nextProps ) { @@ -114,12 +119,6 @@ module.exports = React.createClass( { this.props.onSearchChange( this.state.keyword ); }, - componentDidMount: function() { - if ( this.props.autoFocus ) { - this.focus(); - } - }, - focus: function() { React.findDOMNode( this.refs.searchInput ).focus(); }, diff --git a/client/components/search/style.scss b/shared/components/search/style.scss similarity index 100% rename from client/components/search/style.scss rename to shared/components/search/style.scss diff --git a/client/components/search/test/index.jsx b/shared/components/search/test/index.jsx similarity index 100% rename from client/components/search/test/index.jsx rename to shared/components/search/test/index.jsx diff --git a/client/components/select-dropdown/README.md b/shared/components/select-dropdown/README.md similarity index 100% rename from client/components/select-dropdown/README.md rename to shared/components/select-dropdown/README.md diff --git a/client/components/select-dropdown/docs/example.jsx b/shared/components/select-dropdown/docs/example.jsx similarity index 100% rename from client/components/select-dropdown/docs/example.jsx rename to shared/components/select-dropdown/docs/example.jsx diff --git a/client/components/select-dropdown/index.jsx b/shared/components/select-dropdown/index.jsx similarity index 99% rename from client/components/select-dropdown/index.jsx rename to shared/components/select-dropdown/index.jsx index 0b564721d464f..fa9a986e5617e 100644 --- a/client/components/select-dropdown/index.jsx +++ b/shared/components/select-dropdown/index.jsx @@ -68,7 +68,7 @@ var SelectDropdown = React.createClass( { return initialState; }, - componentWillMount: function() { + componentDidMount: function() { this.id = _instance; _instance++; }, diff --git a/client/components/select-dropdown/item.jsx b/shared/components/select-dropdown/item.jsx similarity index 100% rename from client/components/select-dropdown/item.jsx rename to shared/components/select-dropdown/item.jsx diff --git a/client/components/select-dropdown/separator.jsx b/shared/components/select-dropdown/separator.jsx similarity index 100% rename from client/components/select-dropdown/separator.jsx rename to shared/components/select-dropdown/separator.jsx diff --git a/client/components/select-dropdown/style.scss b/shared/components/select-dropdown/style.scss similarity index 100% rename from client/components/select-dropdown/style.scss rename to shared/components/select-dropdown/style.scss diff --git a/client/components/spinner/README.md b/shared/components/spinner/README.md similarity index 100% rename from client/components/spinner/README.md rename to shared/components/spinner/README.md diff --git a/client/components/spinner/docs/example.jsx b/shared/components/spinner/docs/example.jsx similarity index 100% rename from client/components/spinner/docs/example.jsx rename to shared/components/spinner/docs/example.jsx diff --git a/client/components/spinner/index.jsx b/shared/components/spinner/index.jsx similarity index 96% rename from client/components/spinner/index.jsx rename to shared/components/spinner/index.jsx index cb6a29046aef9..6bc8e80b17f84 100644 --- a/client/components/spinner/index.jsx +++ b/shared/components/spinner/index.jsx @@ -43,7 +43,8 @@ Spinner = React.createClass( { * elements, or false otherwise. */ isSVGCSSAnimationSupported: function() { - return ! /(MSIE |Trident\/)/.test( global.window.navigator.userAgent ); + return false; + return typeof( window ) === undefined || ! /(MSIE |Trident\/)/.test( global.window.navigator.userAgent ); }, getClassName: function() { diff --git a/client/components/spinner/style.scss b/shared/components/spinner/style.scss similarity index 100% rename from client/components/spinner/style.scss rename to shared/components/spinner/style.scss diff --git a/client/layout/README.md b/shared/layout/README.md similarity index 100% rename from client/layout/README.md rename to shared/layout/README.md diff --git a/client/layout/community-translator/README.md b/shared/layout/community-translator/README.md similarity index 100% rename from client/layout/community-translator/README.md rename to shared/layout/community-translator/README.md diff --git a/client/layout/community-translator/invitation-utils.js b/shared/layout/community-translator/invitation-utils.js similarity index 100% rename from client/layout/community-translator/invitation-utils.js rename to shared/layout/community-translator/invitation-utils.js diff --git a/client/layout/community-translator/invitation.jsx b/shared/layout/community-translator/invitation.jsx similarity index 100% rename from client/layout/community-translator/invitation.jsx rename to shared/layout/community-translator/invitation.jsx diff --git a/client/layout/community-translator/launcher.jsx b/shared/layout/community-translator/launcher.jsx similarity index 100% rename from client/layout/community-translator/launcher.jsx rename to shared/layout/community-translator/launcher.jsx diff --git a/client/layout/community-translator/style.scss b/shared/layout/community-translator/style.scss similarity index 100% rename from client/layout/community-translator/style.scss rename to shared/layout/community-translator/style.scss diff --git a/client/layout/error.jsx b/shared/layout/error.jsx similarity index 100% rename from client/layout/error.jsx rename to shared/layout/error.jsx diff --git a/client/layout/index.jsx b/shared/layout/index.jsx similarity index 100% rename from client/layout/index.jsx rename to shared/layout/index.jsx diff --git a/client/layout/logged-out.jsx b/shared/layout/logged-out.jsx similarity index 100% rename from client/layout/logged-out.jsx rename to shared/layout/logged-out.jsx diff --git a/client/layout/masterbar-logged-out-menu.jsx b/shared/layout/masterbar-logged-out-menu.jsx similarity index 100% rename from client/layout/masterbar-logged-out-menu.jsx rename to shared/layout/masterbar-logged-out-menu.jsx diff --git a/client/layout/masterbar-new-post.jsx b/shared/layout/masterbar-new-post.jsx similarity index 100% rename from client/layout/masterbar-new-post.jsx rename to shared/layout/masterbar-new-post.jsx diff --git a/client/layout/masterbar-new-post.scss b/shared/layout/masterbar-new-post.scss similarity index 100% rename from client/layout/masterbar-new-post.scss rename to shared/layout/masterbar-new-post.scss diff --git a/client/layout/masterbar-sections-menu.jsx b/shared/layout/masterbar-sections-menu.jsx similarity index 100% rename from client/layout/masterbar-sections-menu.jsx rename to shared/layout/masterbar-sections-menu.jsx diff --git a/client/layout/masterbar.jsx b/shared/layout/masterbar.jsx similarity index 100% rename from client/layout/masterbar.jsx rename to shared/layout/masterbar.jsx diff --git a/client/layout/package.json b/shared/layout/package.json similarity index 100% rename from client/layout/package.json rename to shared/layout/package.json diff --git a/shared/layout/themes-logged-out.jsx b/shared/layout/themes-logged-out.jsx new file mode 100644 index 0000000000000..2be240fc1a7c9 --- /dev/null +++ b/shared/layout/themes-logged-out.jsx @@ -0,0 +1,63 @@ +/** + * External dependencies + */ +import React from 'react'; +import partialRight from 'lodash/function/partialRight'; + +/** + * Internal dependencies + */ +import Masterbar from './masterbar'; +//import NoticesList from 'notices/notices-list'; +//import notices from 'notices'; +//import title from 'lib/screen-title'; +import Main from 'components/main'; +import themesComponent from 'my-sites/themes/themes-selection'; +import getButtonOptions from 'my-sites/themes/theme-options'; + +const themesFactory = React.createFactory( themesComponent ); + +const ThemesLoggedOutLayout = React.createClass( { + + getDefaultProps() { + return { + section: 'themes', + } + }, + + themesProps: { + getOptions: partialRight( getButtonOptions, () => {}, () => {} ), + sites: false, + setSelectedTheme: () => {}, + togglePreview: () => {}, + loggedIn: false, + }, + + getTier() { + const tier = typeof( window ) !== 'undefined' && window.location.pathname.match( /^\/design\/type\/(free|premium|all)\/?/ ); + if ( tier ) { + return { tier: tier[1] }; + } + }, + + render() { + const sectionClass = 'wp' + ( this.props.section ? ' is-section-' + this.props.section : '' ); + return ( +
+ +
+
+
+ { themesFactory( Object.assign( {}, this.themesProps, this.getTier(), this.props ) ) } +
+
+
+
+ { this.props.tertiary } +
+
+ ); + } +} ); + +export default ThemesLoggedOutLayout; diff --git a/client/lib/infinite-list/actions.js b/shared/lib/infinite-list/actions.js similarity index 100% rename from client/lib/infinite-list/actions.js rename to shared/lib/infinite-list/actions.js diff --git a/client/lib/infinite-list/positions-store.js b/shared/lib/infinite-list/positions-store.js similarity index 100% rename from client/lib/infinite-list/positions-store.js rename to shared/lib/infinite-list/positions-store.js diff --git a/client/lib/infinite-list/scroll-store.js b/shared/lib/infinite-list/scroll-store.js similarity index 100% rename from client/lib/infinite-list/scroll-store.js rename to shared/lib/infinite-list/scroll-store.js diff --git a/client/lib/interpolate-components/Makefile b/shared/lib/interpolate-components/Makefile similarity index 100% rename from client/lib/interpolate-components/Makefile rename to shared/lib/interpolate-components/Makefile diff --git a/client/lib/interpolate-components/README.md b/shared/lib/interpolate-components/README.md similarity index 100% rename from client/lib/interpolate-components/README.md rename to shared/lib/interpolate-components/README.md diff --git a/client/lib/interpolate-components/index.js b/shared/lib/interpolate-components/index.js similarity index 100% rename from client/lib/interpolate-components/index.js rename to shared/lib/interpolate-components/index.js diff --git a/client/lib/interpolate-components/test/lib/warn.js b/shared/lib/interpolate-components/test/lib/warn.js similarity index 100% rename from client/lib/interpolate-components/test/lib/warn.js rename to shared/lib/interpolate-components/test/lib/warn.js diff --git a/client/lib/interpolate-components/test/text.jsx b/shared/lib/interpolate-components/test/text.jsx similarity index 100% rename from client/lib/interpolate-components/test/text.jsx rename to shared/lib/interpolate-components/test/text.jsx diff --git a/client/lib/interpolate-components/tokenize.js b/shared/lib/interpolate-components/tokenize.js similarity index 100% rename from client/lib/interpolate-components/tokenize.js rename to shared/lib/interpolate-components/tokenize.js diff --git a/client/lib/local-storage/Makefile b/shared/lib/local-storage/Makefile similarity index 100% rename from client/lib/local-storage/Makefile rename to shared/lib/local-storage/Makefile diff --git a/client/lib/local-storage/README.md b/shared/lib/local-storage/README.md similarity index 100% rename from client/lib/local-storage/README.md rename to shared/lib/local-storage/README.md diff --git a/client/lib/local-storage/index.js b/shared/lib/local-storage/index.js similarity index 100% rename from client/lib/local-storage/index.js rename to shared/lib/local-storage/index.js diff --git a/client/lib/local-storage/test/test.js b/shared/lib/local-storage/test/test.js similarity index 100% rename from client/lib/local-storage/test/test.js rename to shared/lib/local-storage/test/test.js diff --git a/client/lib/mixins/i18n/Makefile b/shared/lib/mixins/i18n/Makefile similarity index 100% rename from client/lib/mixins/i18n/Makefile rename to shared/lib/mixins/i18n/Makefile diff --git a/client/lib/mixins/i18n/README.md b/shared/lib/mixins/i18n/README.md similarity index 100% rename from client/lib/mixins/i18n/README.md rename to shared/lib/mixins/i18n/README.md diff --git a/client/lib/mixins/i18n/index.js b/shared/lib/mixins/i18n/index.js similarity index 100% rename from client/lib/mixins/i18n/index.js rename to shared/lib/mixins/i18n/index.js diff --git a/client/lib/mixins/i18n/number-format.js b/shared/lib/mixins/i18n/number-format.js similarity index 100% rename from client/lib/mixins/i18n/number-format.js rename to shared/lib/mixins/i18n/number-format.js diff --git a/client/lib/mixins/i18n/test/data.js b/shared/lib/mixins/i18n/test/data.js similarity index 100% rename from client/lib/mixins/i18n/test/data.js rename to shared/lib/mixins/i18n/test/data.js diff --git a/client/lib/mixins/i18n/test/i18nLocalStrings.js b/shared/lib/mixins/i18n/test/i18nLocalStrings.js similarity index 100% rename from client/lib/mixins/i18n/test/i18nLocalStrings.js rename to shared/lib/mixins/i18n/test/i18nLocalStrings.js diff --git a/client/lib/mixins/i18n/test/lib/user-settings.js b/shared/lib/mixins/i18n/test/lib/user-settings.js similarity index 100% rename from client/lib/mixins/i18n/test/lib/user-settings.js rename to shared/lib/mixins/i18n/test/lib/user-settings.js diff --git a/client/lib/mixins/i18n/test/lib/user.js b/shared/lib/mixins/i18n/test/lib/user.js similarity index 100% rename from client/lib/mixins/i18n/test/lib/user.js rename to shared/lib/mixins/i18n/test/lib/user.js diff --git a/client/lib/mixins/i18n/test/test.jsx b/shared/lib/mixins/i18n/test/test.jsx similarity index 100% rename from client/lib/mixins/i18n/test/test.jsx rename to shared/lib/mixins/i18n/test/test.jsx diff --git a/client/lib/mixins/i18n/timezone.js b/shared/lib/mixins/i18n/timezone.js similarity index 100% rename from client/lib/mixins/i18n/timezone.js rename to shared/lib/mixins/i18n/timezone.js diff --git a/client/lib/mixins/url-search/Makefile b/shared/lib/mixins/url-search/Makefile similarity index 100% rename from client/lib/mixins/url-search/Makefile rename to shared/lib/mixins/url-search/Makefile diff --git a/client/lib/mixins/url-search/README.md b/shared/lib/mixins/url-search/README.md similarity index 100% rename from client/lib/mixins/url-search/README.md rename to shared/lib/mixins/url-search/README.md diff --git a/client/lib/mixins/url-search/build-url.js b/shared/lib/mixins/url-search/build-url.js similarity index 100% rename from client/lib/mixins/url-search/build-url.js rename to shared/lib/mixins/url-search/build-url.js diff --git a/client/lib/mixins/url-search/index.js b/shared/lib/mixins/url-search/index.js similarity index 100% rename from client/lib/mixins/url-search/index.js rename to shared/lib/mixins/url-search/index.js diff --git a/client/lib/mixins/url-search/test/build-url.js b/shared/lib/mixins/url-search/test/build-url.js similarity index 100% rename from client/lib/mixins/url-search/test/build-url.js rename to shared/lib/mixins/url-search/test/build-url.js diff --git a/client/lib/react-smart-set-state/index.js b/shared/lib/react-smart-set-state/index.js similarity index 100% rename from client/lib/react-smart-set-state/index.js rename to shared/lib/react-smart-set-state/index.js diff --git a/client/lib/store/Makefile b/shared/lib/store/Makefile similarity index 100% rename from client/lib/store/Makefile rename to shared/lib/store/Makefile diff --git a/client/lib/store/README.md b/shared/lib/store/README.md similarity index 100% rename from client/lib/store/README.md rename to shared/lib/store/README.md diff --git a/client/lib/store/index.js b/shared/lib/store/index.js similarity index 100% rename from client/lib/store/index.js rename to shared/lib/store/index.js diff --git a/client/lib/store/test/index-test.js b/shared/lib/store/test/index-test.js similarity index 100% rename from client/lib/store/test/index-test.js rename to shared/lib/store/test/index-test.js diff --git a/shared/my-sites/themes/index.js b/shared/my-sites/themes/index.js index 863ba94634d93..159ea956d494d 100644 --- a/shared/my-sites/themes/index.js +++ b/shared/my-sites/themes/index.js @@ -22,7 +22,8 @@ const routing = { middlewares: [ { value: controller.navigation, enableLoggedOut: false }, { value: controller.siteSelection, enableLoggedOut: false }, - { value: themesController.themes, enableLoggedOut: true }, + { value: themesController.themes, enableLoggedOut: false }, + { value: () => {}, enableLoggedOut: true } ] }; diff --git a/shared/my-sites/themes/themes-selection.jsx b/shared/my-sites/themes/themes-selection.jsx index 79839b7634fba..ce6ce4ac671ba 100644 --- a/shared/my-sites/themes/themes-selection.jsx +++ b/shared/my-sites/themes/themes-selection.jsx @@ -32,12 +32,18 @@ const ThemesSelection = React.createClass( { search: PropTypes.string, setSelectedTheme: PropTypes.func.isRequired, togglePreview: PropTypes.func.isRequired, - getOptions: PropTypes.func.isRequired + getOptions: PropTypes.func.isRequired, + loggedIn: PropTypes.bool, + }, + + getDefaultProps: function() { + return { loggedIn: true }; }, getInitialState: function() { return { - tier: this.props.tier || config.isEnabled( 'premium-themes' ) ? 'all' : 'free' + tier: this.props.tier || config.isEnabled( 'premium-themes' ) ? 'all' : 'free', + search: this.props.search }; }, @@ -71,7 +77,7 @@ const ThemesSelection = React.createClass( { const url = `/design/type/${tier}${siteId}`; this.setState( { tier } ); Helper.trackClick( 'search bar filter', tier ); - page( buildUrl( url, this.props.search ) ); + page( buildUrl( url, this.state.search ) ); }, onScreenshotClick( theme, resultsRank ) { @@ -86,22 +92,34 @@ const ThemesSelection = React.createClass( { } }, + renderSearch( loggedIn, site ) { + const searchCard = ( + { + this.doSearch(); + this.setState( { search } ) } + } + search={ this.state.search } + tier={ this.state.tier } + select={ this.onTierSelect } /> ); + + if ( loggedIn ) { + return( { searchCard } ); + } + return ( searchCard ); + }, + render() { - var site = this.props.sites.getSelectedSite(); + var site = this.props.sites && this.props.sites.getSelectedSite(); + return (
- - - + { this.renderSearch( this.props.loggedIn, site ) } diff --git a/server/sanitize/index.js b/shared/sanitize/index.js similarity index 100% rename from server/sanitize/index.js rename to shared/sanitize/index.js diff --git a/webpack.config.node.js b/webpack.config.node.js index 7faffe03b03df..b6f4bb6800675 100644 --- a/webpack.config.node.js +++ b/webpack.config.node.js @@ -73,7 +73,29 @@ module.exports = { }, plugins: [ // Require source-map-support at the top, so we get source maps for the bundle - new webpack.BannerPlugin( 'require( "source-map-support" ).install();', { raw: true, entryOnly: false } ) + new webpack.BannerPlugin( 'require( "source-map-support" ).install();', { raw: true, entryOnly: false } ), + new webpack.IgnorePlugin( /^public/ ), + new webpack.IgnorePlugin( /^\.\/locale$/, /moment$/ ), + new webpack.IgnorePlugin( /^assets/ ), + new webpack.NormalModuleReplacementPlugin( /^lib\/warn$/, 'lodash/utility/noop' ), + new webpack.NormalModuleReplacementPlugin( /^lib\/paths/, 'lodash/utility/noop' ), + new webpack.NormalModuleReplacementPlugin( /^lib\/user/, 'lodash/utility/noop' ), + new webpack.NormalModuleReplacementPlugin( /^analytics$/, 'lodash/utility/noop' ), + new webpack.NormalModuleReplacementPlugin( /^post-editor/, 'components/empty' ), + new webpack.NormalModuleReplacementPlugin( /^components\/count/, 'components/empty' ), + new webpack.NormalModuleReplacementPlugin( /^components\/sites-popover/, 'components/empty' ), + new webpack.NormalModuleReplacementPlugin( /^components\/gravatar/, 'components/empty' ), + new webpack.NormalModuleReplacementPlugin( /^components\/site-stats-sticky-link/, 'components/empty' ), + new webpack.NormalModuleReplacementPlugin( /^components\/sticky-panel/, 'components/empty' ), + new webpack.NormalModuleReplacementPlugin( /^notifications$/, 'lodash/utility/noop' ), + new webpack.NormalModuleReplacementPlugin( /^lib\/layout-focus$/, 'lodash/utility/noop' ), + new webpack.NormalModuleReplacementPlugin( /^components\/popover/, 'components/empty' ), + new webpack.NormalModuleReplacementPlugin( /^lib\/cart-values/, 'lodash/utility/noop' ), + new webpack.NormalModuleReplacementPlugin( /^lib\/upgrades/, 'lodash/utility/noop' ), + new webpack.NormalModuleReplacementPlugin( /^lib\/wp/, 'lodash/utility/noop' ), + new webpack.NormalModuleReplacementPlugin( /^lib\/scroll-to/, 'lodash/utility/noop' ), + new webpack.NormalModuleReplacementPlugin( /detect-history-navigation/, 'lodash/utility/noop' ), + new webpack.NormalModuleReplacementPlugin( /section-nav/, 'components/empty' ), ], externals: getExternals() };