Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2711)

Unified Diff: chrome/common/extensions/docs/server2/render_servlet.py

Issue 15087006: Docserver: there is only one. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: better redirects Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/common/extensions/docs/server2/render_servlet.py
diff --git a/chrome/common/extensions/docs/server2/render_servlet.py b/chrome/common/extensions/docs/server2/render_servlet.py
index eee9f7e0f6d2843b230924c9feba792ca03d4fbd..136f8aa727a21163a267c92708c621eb5740e8d1 100644
--- a/chrome/common/extensions/docs/server2/render_servlet.py
+++ b/chrome/common/extensions/docs/server2/render_servlet.py
@@ -9,7 +9,6 @@ import os
import traceback
from appengine_wrappers import IsDevServer
-from branch_utility import BranchUtility
from file_system import FileNotFoundError
from server_instance import ServerInstance
from servlet import Servlet, Response
@@ -23,40 +22,25 @@ class RenderServlet(Servlet):
'''Servlet which renders templates.
'''
class Delegate(object):
- def CreateServerInstanceForChannel(self, channel):
- raise NotImplementedError()
+ def CreateServerInstance(self):
+ raise NotImplementedError(self.__class__)
- def __init__(self, request, delegate, default_channel='stable'):
+ def __init__(self, request, delegate):
Servlet.__init__(self, request)
self._delegate = delegate
- self._default_channel = default_channel
def Get(self):
- path_with_channel, headers = (self._request.path, self._request.headers)
-
- # Redirect "extensions" and "extensions/" to "extensions/index.html", etc.
- if (os.path.splitext(path_with_channel)[1] == '' and
- path_with_channel.find('/') == -1):
- path_with_channel += '/'
- if path_with_channel.endswith('/'):
- return Response.Redirect('/%sindex.html' % path_with_channel)
-
- channel, path = BranchUtility.SplitChannelNameFromPath(path_with_channel)
-
- if channel == self._default_channel:
- return Response.Redirect('/%s' % path)
-
- if channel is None:
- channel = self._default_channel
-
- server_instance = self._delegate.CreateServerInstanceForChannel(channel)
-
- canonical_path = (
- server_instance.path_canonicalizer.Canonicalize(path).lstrip('/'))
+ server_instance = self._delegate.CreateServerInstance()
+
+ path = self._request.path
+ canonical_result = server_instance.path_canonicalizer.Canonicalize(path)
cduvall 2013/05/15 00:50:50 does the path passed in here have a leading '/'? I
not at google - send to devlin 2013/05/15 01:26:50 yeah, the servlet strips off the leading '/' for t
+ canonical_path = canonical_result.path.lstrip('/')
+ # TODO(kalman): do this generically by detecting index.html.
+ if canonical_path in ('apps/', 'extensions/'):
+ canonical_path += 'index.html'
if path != canonical_path:
- redirect_path = (canonical_path if channel is None else
- '%s/%s' % (channel, canonical_path))
- return Response.Redirect('/%s' % redirect_path)
+ return Response.Redirect('/%s' % canonical_path,
+ permanent=canonical_result.permanent)
templates = server_instance.template_data_source_factory.Create(
self._request, path)

Powered by Google App Engine
This is Rietveld 408576698