Browse Source

Merge pull request #88 from gfuchedzhy/hyde

---

added support for encoded urls to hyde server. Now it can handle urls encoded like this: "some%20url" or "%D0%9F%D1%80%D0%BE%D0%B3%D1%80%D0%B0%D0%BC%D0%BC%D0%B8%D1%80%D0%BE%D0%B2%D0%B0%D0%BD%D0%B8%D0%B5"
main
Lakshmi Vyasarajan 13 years ago
parent
commit
bf432cda87
2 changed files with 4 additions and 4 deletions
  1. +1
    -2
      hyde/server.py
  2. +3
    -2
      hyde/site.py

+ 1
- 2
hyde/server.py View File

@@ -56,9 +56,8 @@ class HydeRequestHandler(SimpleHTTPRequestHandler):
Finds the absolute path of the requested file by
referring to the `site` variable in the server.
"""
path = SimpleHTTPRequestHandler.translate_path(self, path)
site = self.server.site
result = urlparse.urlparse(self.path)
result = urlparse.urlparse(urllib.unquote(self.path).decode('utf-8'))
logger.debug("Trying to load file based on request: [%s]" % result.path)
path = result.path.lstrip('/')
res = None


+ 3
- 2
hyde/site.py View File

@@ -7,6 +7,7 @@ import fnmatch
import sys
import urlparse
from functools import wraps
from urllib import quote

from hyde.exceptions import HydeException
from hyde.fs import FS, File, Folder
@@ -408,14 +409,14 @@ class Site(object):
Returns the content url by appending the base url from the config
with the given path.
"""
return Folder(self.config.base_url).child(path).replace(os.sep, '/')
return quote(Folder(self.config.base_url).child(path).replace(os.sep, '/').encode("utf-8"))

def media_url(self, path):
"""
Returns the media url by appending the media base url from the config
with the given path.
"""
return Folder(self.config.media_url).child(path).replace(os.sep, '/')
return quote(Folder(self.config.media_url).child(path).replace(os.sep, '/').encode("utf-8"))

def full_url(self, path):
"""


Loading…
Cancel
Save