-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #832 from Automattic/update/pretty-reader-urls
Reader: Pretty URLs for some feeds
- Loading branch information
Showing
10 changed files
with
124 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
REPORTER ?= spec | ||
NODE_BIN := $(shell npm bin) | ||
MOCHA ?= $(NODE_BIN)/mocha | ||
BASE_DIR := $(NODE_BIN)/../.. | ||
NODE_PATH := test:$(BASE_DIR)/client:$(BASE_DIR)/shared | ||
|
||
test: | ||
@NODE_ENV=test NODE_PATH=$(NODE_PATH) $(MOCHA) --compilers js:babel/register --reporter $(REPORTER) | ||
|
||
.PHONY: test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
const FEED_URL_BASE = '/read/blog/feed/'; | ||
const SITE_URL_BASE = '/read/blog/id/'; | ||
|
||
const PRETTY_FEED_URLS = { | ||
12733228: '/discover' | ||
}; | ||
|
||
const PRETTY_SITE_URLS = { | ||
53424024: '/discover' | ||
} | ||
|
||
export function getPrettySiteUrl( siteID ) { | ||
return PRETTY_SITE_URLS[ siteID ]; | ||
} | ||
|
||
export function getPrettyFeedUrl( feedID ) { | ||
return PRETTY_FEED_URLS[ feedID ]; | ||
} | ||
|
||
export function getSiteUrl( siteID ) { | ||
return getPrettySiteUrl( siteID ) || SITE_URL_BASE + siteID; | ||
} | ||
|
||
export function getFeedUrl( feedID ) { | ||
return getPrettyFeedUrl( feedID ) || FEED_URL_BASE + feedID; | ||
} | ||
|
||
export function getStreamUrlFromPost( post ) { | ||
if ( post.feed_ID ) { | ||
return getFeedUrl( post.feed_ID ); | ||
} | ||
|
||
return getSiteUrl( post.site_ID ); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/** | ||
* External dependencies | ||
*/ | ||
var expect = require( 'chai' ).expect; | ||
|
||
/** | ||
* Internal dependencies | ||
*/ | ||
var route = require( '../' ); | ||
|
||
describe( 'reader/route', function() { | ||
describe( 'getStreamUrlFromPost', function() { | ||
it( 'should return url for post from feed', function() { | ||
expect( route.getStreamUrlFromPost( { feed_ID: 1234 } ) ).to.equal( '/read/blog/feed/1234' ); | ||
} ); | ||
|
||
it( 'should return url for post from site', function() { | ||
expect( route.getStreamUrlFromPost( { site_ID: 1234 } ) ).to.equal( '/read/blog/id/1234' ); | ||
} ); | ||
} ); | ||
|
||
describe( 'getSiteUrl', function() { | ||
it( 'should return site URL', function() { | ||
expect( route.getSiteUrl( 1234 ) ).to.equal( '/read/blog/id/1234' ); | ||
} ); | ||
|
||
it( 'should return pretty URL for discover', function() { | ||
expect( route.getSiteUrl( 53424024 ) ).to.equal( '/discover' ); | ||
} ); | ||
} ); | ||
|
||
describe( 'getFeedUrl', function() { | ||
it( 'should return site URL', function() { | ||
expect( route.getFeedUrl( 1234 ) ).to.equal( '/read/blog/feed/1234' ); | ||
} ); | ||
|
||
it( 'should return pretty URL for discover', function() { | ||
expect( route.getFeedUrl( 12733228 ) ).to.equal( '/discover' ); | ||
} ); | ||
} ); | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters