Skip to content

Commit

Permalink
Docs: Remove unnecessary redirects from directories to 'index' files …
Browse files Browse the repository at this point in the history
…since we

now do that automatically. Fix a bug preventing the root directory from
redirecting to 'index'.

R=jyasskin@chromium.org
NOTRY=true

Review URL: https://codereview.chromium.org/240303006

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@264337 0039d316-1c4b-4281-b951-d872f2087c98
  • Loading branch information
kalman@chromium.org committed Apr 16, 2014
1 parent 2a2c854 commit 52c7ac4
Show file tree
Hide file tree
Showing 10 changed files with 17 additions and 26 deletions.
2 changes: 1 addition & 1 deletion chrome/common/extensions/docs/server2/app.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
application: chrome-apps-doc
version: 3-17-8
version: 3-18-0
runtime: python27
api_version: 1
threadsafe: false
Expand Down
10 changes: 7 additions & 3 deletions chrome/common/extensions/docs/server2/content_provider.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from file_system import FileNotFoundError
from future import Future
from path_canonicalizer import PathCanonicalizer
from path_util import AssertIsValid, Join, ToDirectory
from path_util import AssertIsValid, IsDirectory, Join, ToDirectory
from special_paths import SITE_VERIFICATION_FILE
from third_party.handlebar import Handlebar
from third_party.markdown import markdown
Expand Down Expand Up @@ -148,8 +148,12 @@ def GetContentAndType(self, path):
new_path = self._AddExt(path)
# Add a trailing / to check if it is a directory and not a file with
# no extension.
if new_path is None and self.file_system.Exists(path + '/').Get():
new_path = self._AddExt(path + '/index')
if new_path is None and self.file_system.Exists(ToDirectory(path)).Get():
new_path = self._AddExt(Join(path, 'index'))
# If an index file wasn't found in this directly then we're never going
# to find a file.
if new_path is None:
return FileNotFoundError.RaiseInFuture('"%s" is a directory' % path)
if new_path is not None:
path = new_path

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
'dir.txt': 'dir.txt content',
'dir5.html': 'dir5.html content',
'img.png': 'img.png content',
'index.html': 'index.html content',
'read.txt': 'read.txt content',
'redirects.json': _REDIRECTS_JSON,
'noextension': 'noextension content',
Expand Down Expand Up @@ -183,6 +184,7 @@ def testNotFound(self):
self._content_provider.GetContentAndType('oops').Get)

def testIndexRedirect(self):
self._assertTemplateContent(u'index.html content', '')
self._assertTemplateContent(u'index.html content 1', 'dir4')
self._assertTemplateContent(u'dir5.html content', 'dir5')
self._assertMarkdownContent(
Expand Down
2 changes: 1 addition & 1 deletion chrome/common/extensions/docs/server2/cron.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,4 @@ cron:
- description: Repopulates all cached data.
url: /_cron
schedule: every 5 minutes
target: 3-17-8
target: 3-18-0
4 changes: 0 additions & 4 deletions chrome/common/extensions/docs/server2/render_servlet.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,10 +106,6 @@ def _GetSuccessResponse(self, request_path, server_instance):
return Response.Redirect('/' + request_path.rstrip('/'),
permanent=False)

if not path:
# Empty-path request hasn't been redirected by now. It doesn't exist.
raise FileNotFoundError('Empty path')

content_and_type = content_provider.GetContentAndType(path).Get()
if not content_and_type.content:
logging.error('%s had empty content' % path)
Expand Down
7 changes: 4 additions & 3 deletions chrome/common/extensions/docs/server2/render_servlet_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,11 @@ def testHtmlTemplate(self):
self.assertTrue(len(response.content) >
len(ReadFile('%s%s.html' % (PUBLIC_TEMPLATES, html_file))))

def testIndexRedirect(self):
def testIndexRender(self):
response = self._Render('extensions')
self.assertEqual(('/extensions/index', False),
response.GetRedirect())
self.assertEqual(200, response.status)
self.assertEqual(self._Render('extensions/index').content.ToString(),
response.content.ToString())

def testOtherRedirectsJsonRedirect(self):
response = self._Render('apps/webview_tag')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{
"": "index",
"experimental.debugger": "debugger",
"experimental_debugger": "debugger",
"experimental.infobars": "infobars",
Expand Down
9 changes: 2 additions & 7 deletions chrome/common/extensions/docs/templates/public/redirects.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
{
"": "/home/index",
"apps": "/apps/about_apps",
"devtools": "/devtools/index",
"extensions": "/extensions/index",
"multidevice": "/multidevice/index",
"native-client": "/native-client/overview",
"webstore": "/webstore/index"
"": "/home",
"apps": "/apps/about_apps"
}
3 changes: 0 additions & 3 deletions chrome/docs/redirects.json

This file was deleted.

3 changes: 0 additions & 3 deletions native_client_sdk/doc_generated/redirects.json

This file was deleted.

0 comments on commit 52c7ac4

Please sign in to comment.