search: function( context ) { var SearchStream = require( 'reader/search-stream' ), basePath = '/read/search', fullAnalyticsPageTitle = analyticsPageTitle + ' > Search', searchSlug = context.query.q, mcKey = 'search'; let store; if ( searchSlug ) { store = feedStreamFactory( 'search:' + searchSlug ); ensureStoreLoading( store, context ); } else { store = feedStreamFactory( 'custom_recs_posts_with_images' ); ensureStoreLoading( store, context ); } trackPageLoad( basePath, fullAnalyticsPageTitle, mcKey ); if ( searchSlug ) { recordTrack( 'calypso_reader_search_performed', { query: searchSlug } ); } else { recordTrack( 'calypso_reader_search_loaded' ); } renderWithReduxStore( React.createElement( SearchStream, { key: 'search', store: store, query: searchSlug, trackScrollPage: trackScrollPage.bind( null, basePath, fullAnalyticsPageTitle, analyticsPageTitle, mcKey ), onUpdatesShown: trackUpdatesLoaded.bind( null, mcKey ), showBack: false, showPrimaryFollowButtonOnCards: true, onQueryChange: function( newValue ) { let searchUrl = '/read/search'; if ( newValue ) { searchUrl += '?' + qs.stringify( { q: newValue } ); } page.replace( searchUrl ); } } ), document.getElementById( 'primary' ), context.store ); }
readA8C: function( context ) { var FollowingComponent = require( 'reader/following-stream' ), basePath = route.sectionify( context.path ), fullAnalyticsPageTitle = analyticsPageTitle + ' > A8C', feedStore = feedStreamFactory( 'a8c' ), mcKey = 'a8c'; ensureStoreLoading( feedStore, context ); trackPageLoad( basePath, fullAnalyticsPageTitle, mcKey ); setPageTitle( 'Automattic' ); ReactDom.render( React.createElement( FollowingComponent, { key: 'read-a8c', className: 'is-a8c', listName: 'Automattic', store: feedStore, trackScrollPage: trackScrollPage.bind( null, basePath, fullAnalyticsPageTitle, analyticsPageTitle, mcKey ), onUpdatesShown: trackUpdatesLoaded.bind( null, mcKey ) } ), document.getElementById( 'primary' ) ); }
following: function( context ) { var FollowingComponent = require( 'reader/following-stream' ), basePath = route.sectionify( context.path ), fullAnalyticsPageTitle = analyticsPageTitle + ' > Following', followingStore = feedStreamFactory( 'following' ), mcKey = 'following'; ensureStoreLoading( followingStore, context ); trackPageLoad( basePath, fullAnalyticsPageTitle, mcKey ); recordTrack( 'calypso_reader_following_loaded' ); setPageTitle( i18n.translate( 'Following' ) ); ReactDom.render( React.createElement( FollowingComponent, { key: 'following', listName: i18n.translate( 'Followed Sites' ), store: followingStore, trackScrollPage: trackScrollPage.bind( null, basePath, fullAnalyticsPageTitle, analyticsPageTitle, mcKey ), onUpdatesShown: trackUpdatesLoaded.bind( null, mcKey ) } ), document.getElementById( 'primary' ) ); },
blogListing: function( context ) { var SiteStream = require( 'reader/site-stream' ), basePath = '/read/blogs/:blog_id', fullAnalyticsPageTitle = analyticsPageTitle + ' > Site > ' + context.params.blog_id, feedStore = feedStreamFactory( 'site:' + context.params.blog_id ), mcKey = 'blog'; ensureStoreLoading( feedStore, context ); trackPageLoad( basePath, fullAnalyticsPageTitle, mcKey ); recordTrack( 'calypso_reader_blog_preview', { blog_id: context.params.blog_id } ); ReactDom.render( React.createElement( SiteStream, { key: 'site-' + context.params.blog_id, store: feedStore, siteId: context.params.blog_id, setPageTitle: setPageTitle, trackScrollPage: trackScrollPage.bind( null, basePath, fullAnalyticsPageTitle, analyticsPageTitle, mcKey ), onUpdatesShown: trackUpdatesLoaded.bind( null, mcKey ), suppressSiteNameLink: true, showBack: userHasHistory( context ) } ), document.getElementById( 'primary' ) ); },
discover: function( context ) { var blogId = config( 'discover_blog_id' ), SiteStream = require( 'reader/site-stream' ), basePath = route.sectionify( context.path ), fullAnalyticsPageTitle = analyticsPageTitle + ' > Site > ' + blogId, feedStore = feedStreamFactory( 'site:' + blogId ), mcKey = 'discover'; titleActions.setTitle( 'Discover' ); ensureStoreLoading( feedStore, context ); trackPageLoad( basePath, fullAnalyticsPageTitle, mcKey ); stats.recordTrack( 'calypso_reader_discover_viewed' ); ReactDom.render( React.createElement( SiteStream, { key: 'site-' + blogId, store: feedStore, siteId: blogId, trackScrollPage: trackScrollPage.bind( null, basePath, fullAnalyticsPageTitle, analyticsPageTitle, mcKey ), onUpdatesShown: trackUpdatesLoaded.bind( null, mcKey ), suppressSiteNameLink: true, showBack: false } ), document.getElementById( 'primary' ) ); }
likes: function( context ) { var LikedPostsStream = require( 'reader/liked-stream' ), basePath = route.sectionify( context.path ), fullAnalyticsPageTitle = analyticsPageTitle + ' > My Likes', likedPostsStore = feedStreamFactory( 'likes' ), mcKey = 'postlike'; ensureStoreLoading( likedPostsStore, context ); trackPageLoad( basePath, fullAnalyticsPageTitle, mcKey ); ReactDom.render( React.createElement( LikedPostsStream, { key: 'liked', store: likedPostsStore, setPageTitle: setPageTitle, trackScrollPage: trackScrollPage.bind( null, basePath, fullAnalyticsPageTitle, analyticsPageTitle, mcKey ), onUpdatesShown: trackUpdatesLoaded.bind( null, mcKey ) } ), document.getElementById( 'primary' ) ); },
tagListing: function( context ) { var TagStream = require( 'reader/tag-stream' ), basePath = '/tag/:slug', fullAnalyticsPageTitle = analyticsPageTitle + ' > Tag > ' + context.params.tag, tagSlug = trim( context.params.tag ) .toLowerCase() .replace( /\s+/g, '-' ) .replace( /-{2,}/g, '-' ), encodedTag = encodeURIComponent( tagSlug ).toLowerCase(), tagStore = feedStreamFactory( 'tag:' + tagSlug ), mcKey = 'topic'; ensureStoreLoading( tagStore, context ); trackPageLoad( basePath, fullAnalyticsPageTitle, mcKey ); stats.recordTrack( 'calypso_reader_tag_loaded', { tag: tagSlug } ); ReactDom.render( React.createElement( TagStream, { key: 'tag-' + encodedTag, store: tagStore, tag: encodedTag, setPageTitle: setPageTitle, trackScrollPage: trackScrollPage.bind( null, basePath, fullAnalyticsPageTitle, analyticsPageTitle, mcKey ), onUpdatesShown: trackUpdatesLoaded.bind( null, mcKey ), showBack: userHasHistory( context ) } ), document.getElementById( 'primary' ) ); },
listListing: function( context ) { var ListStream = require( 'reader/list-stream' ), basePath = '/read/list/:owner/:slug', fullAnalyticsPageTitle = analyticsPageTitle + ' > List > ' + context.params.user + ' - ' + context.params.list, listStore = feedStreamFactory( 'list:' + context.params.user + '-' + context.params.list ), mcKey = 'list'; ensureStoreLoading( listStore, context ); trackPageLoad( basePath, fullAnalyticsPageTitle, mcKey ); stats.recordTrack( 'calypso_reader_list_loaded', { list_owner: context.params.user, list_slug: context.params.list } ); ReactDom.render( React.createElement( ListStream, { key: 'tag-' + context.params.user + '-' + context.params.list, store: listStore, list: { owner: context.params.user, slug: context.params.list }, setPageTitle: setPageTitle, trackScrollPage: trackScrollPage.bind( null, basePath, fullAnalyticsPageTitle, analyticsPageTitle, mcKey ), onUpdatesShown: trackUpdatesLoaded.bind( null, mcKey ) } ), document.getElementById( 'primary' ) ); },
/** * Internal dependencies */ import feedStreamFactory from 'lib/feed-stream-store'; import { recordTrack } from 'reader/stats'; import { ensureStoreLoading, trackPageLoad, trackUpdatesLoaded, trackScrollPage, setPageTitle } from 'reader/controller-helper'; const analyticsPageTitle = 'Reader'; export default { listListing( context ) { var ListStream = require( 'reader/list-stream' ), basePath = '/read/list/:owner/:slug', fullAnalyticsPageTitle = analyticsPageTitle + ' > List > ' + context.params.user + ' - ' + context.params.list, listStore = feedStreamFactory( 'list:' + context.params.user + '-' + context.params.list ), mcKey = 'list'; ensureStoreLoading( listStore, context ); trackPageLoad( basePath, fullAnalyticsPageTitle, mcKey ); recordTrack( 'calypso_reader_list_loaded', { list_owner: context.params.user, list_slug: context.params.list } ); ReactDom.render( React.createElement( ReduxProvider, { store: context.store }, React.createElement( ListStream, { key: 'tag-' + context.params.user + '-' + context.params.list, postStore: listStore,
import { ensureStoreLoading, trackPageLoad, trackUpdatesLoaded, trackScrollPage, setPageTitle } from 'reader/controller-helper'; import { renderWithReduxStore } from 'lib/react-helpers'; const analyticsPageTitle = 'Reader'; export default { tagListing( context ) { var TagStream = require( 'reader/tag-stream/main' ), basePath = '/tag/:slug', fullAnalyticsPageTitle = analyticsPageTitle + ' > Tag > ' + context.params.tag, tagSlug = trim( context.params.tag ) .toLowerCase() .replace( /\s+/g, '-' ) .replace( /-{2,}/g, '-' ), encodedTag = encodeURIComponent( tagSlug ).toLowerCase(), tagStore = feedStreamFactory( 'tag:' + tagSlug ), mcKey = 'topic'; ensureStoreLoading( tagStore, context ); trackPageLoad( basePath, fullAnalyticsPageTitle, mcKey ); recordTrack( 'calypso_reader_tag_loaded', { tag: tagSlug } ); renderWithReduxStore( React.createElement( TagStream, { key: 'tag-' + encodedTag, store: tagStore, tag: encodedTag, setPageTitle: setPageTitle,
context.store ); next(); }, unmountSidebar( context, next ) { ReactDom.unmountComponentAtNode( document.getElementById( 'secondary' ) ); next(); }, following( context ) { const StreamComponent = require( 'reader/following/main' ), basePath = route.sectionify( context.path ), fullAnalyticsPageTitle = analyticsPageTitle + ' > Following', followingStore = feedStreamFactory( 'following' ), mcKey = 'following'; const recommendationsStore = feedStreamFactory( 'custom_recs_posts_with_images' ); recommendationsStore.perPage = 4; ensureStoreLoading( followingStore, context ); trackPageLoad( basePath, fullAnalyticsPageTitle, mcKey ); recordTrack( 'calypso_reader_following_loaded' ); setPageTitle( context, i18n.translate( 'Following' ) ); ReactDom.render( React.createElement( ReduxProvider, { store: context.store }, React.createElement( StreamComponent, {
export function getLastStore() { if ( storeId ) { return feedStreamFactory( storeId ); } return null; }
trackPageLoad( basePath, fullAnalyticsPageTitle, mcKey ); // FIXME: Auto-converted from the Flux setTitle action. Please use <DocumentHead> instead. context.store.dispatch( setTitle( i18n.translate( 'Recommended Sites For You ‹ Reader' ) ) ); }, // Post Recommendations - Used by the Data team to test recommendation algorithms recommendedPosts( context ) { const RecommendedPostsStream = require( 'reader/recommendations/posts' ), basePath = route.sectionify( context.path ); const fullAnalyticsPageTitle = ( '/recommendations/posts' === basePath ) ? ANALYTICS_PAGE_TITLE + ' > Recommended Posts' : ANALYTICS_PAGE_TITLE + ' > Coldstart Posts'; const RecommendedPostsStore = ( '/recommendations/posts' === basePath ) ? feedStreamFactory( 'recommendations_posts' ) : feedStreamFactory( 'coldstart_posts' ); const mcKey = ( '/recommendations/posts' === basePath ) ? 'recommendations_posts' : 'coldstart_posts'; ensureStoreLoading( RecommendedPostsStore, context ); trackPageLoad( basePath, fullAnalyticsPageTitle, mcKey ); renderWithReduxStore( React.createElement( RecommendedPostsStream, { key: 'recommendations_posts', store: RecommendedPostsStore, trackScrollPage: trackScrollPage.bind(
import { renderWithReduxStore } from 'lib/react-helpers'; const ANALYTICS_PAGE_TITLE = 'Reader'; const exported = { // Post Recommendations - Used by the Data team to test recommendation algorithms recommendedPosts( context ) { const basePath = route.sectionify( context.path ); let fullAnalyticsPageTitle = ''; let RecommendedPostsStore = null; let mcKey = ''; switch ( basePath ) { case '/recommendations/cold': fullAnalyticsPageTitle = ANALYTICS_PAGE_TITLE + ' > Coldstart Posts'; RecommendedPostsStore = feedStreamFactory( 'cold_posts' ); mcKey = 'coldstart_posts'; break; case '/recommendations/cold1w': fullAnalyticsPageTitle = ANALYTICS_PAGE_TITLE + ' > Coldstart+1w Posts'; RecommendedPostsStore = feedStreamFactory( 'cold_posts_1w' ); mcKey = 'coldstart_posts_1w'; break; case '/recommendations/cold2w': fullAnalyticsPageTitle = ANALYTICS_PAGE_TITLE + ' > Coldstart+2w Posts'; RecommendedPostsStore = feedStreamFactory( 'cold_posts_2w' ); mcKey = 'coldstart_posts_2w'; break; case '/recommendations/cold4w': fullAnalyticsPageTitle = ANALYTICS_PAGE_TITLE + ' > Coldstart+4w Posts'; RecommendedPostsStore = feedStreamFactory( 'cold_posts_4w' );
/** * Internal dependencies */ import route from 'lib/route'; import feedStreamFactory from 'lib/feed-stream-store'; import { ensureStoreLoading, trackPageLoad, trackUpdatesLoaded, trackScrollPage, setPageTitle } from 'reader/controller-helper'; const analyticsPageTitle = 'Reader'; export default { likes( context ) { var LikedPostsStream = require( 'reader/liked-stream/main' ), basePath = route.sectionify( context.path ), fullAnalyticsPageTitle = analyticsPageTitle + ' > My Likes', likedPostsStore = feedStreamFactory( 'likes' ), mcKey = 'postlike'; ensureStoreLoading( likedPostsStore, context ); trackPageLoad( basePath, fullAnalyticsPageTitle, mcKey ); ReactDom.render( React.createElement( LikedPostsStream, { key: 'liked', store: likedPostsStore, setPageTitle: setPageTitle, trackScrollPage: trackScrollPage.bind( null, basePath, fullAnalyticsPageTitle,