def test_content_url_encoding_safe(self): s = Site(self.SITE_PATH, config=self.config) s.load() path = '".jpg/abc' print((s.content_url(path, ""))) print(("/" + quote(path, ""))) assert s.content_url(path, "") == "/" + quote(path, "")
def test_content_url_encoding_safe(self): s = Site(self.SITE_PATH, config=self.config) s.load() path = '".jpg/abc' print(s.content_url(path, "")) print("/" + quote(path, "")) assert s.content_url(path, "") == "/" + quote(path, "")
def test_node_full_url_quoted(): s = Site(TEST_SITE_ROOT) s.config.base_url = 'http://localhost' r = RootNode(TEST_SITE_ROOT.child_folder('content'), s) assert not r.module n = r.add_node(TEST_SITE_ROOT.child_folder('content/blo~g')) assert n.full_url == 'http://localhost/' + quote('blo~g') c = r.add_node(TEST_SITE_ROOT.child_folder('content/blo~g/2010/december')) assert c.full_url == 'http://localhost/' + quote('blo~g/2010/december')
def test_textlinks(self): d = { 'objects': 'template/variables', 'plugins': 'plugins/metadata', 'sorter': 'plugins/sorter' } text = """ {%% markdown %%} [[!!img/hyde-logo.png]] * [Rich object model][hyde objects] and [overridable hierarchical metadata]([[ %(plugins)s ]]) thats available for use in templates. * Configurable [sorting][], filtering and grouping support. [hyde objects]: [[ %(objects)s ]] [sorting]: [[%(sorter)s]] {%% endmarkdown %%} """ site = Site(TEST_SITE) site.config.plugins = ['hyde.ext.plugins.text.TextlinksPlugin'] site.config.base_url = 'http://example.com/' site.config.media_url = '/media' tlink = File(site.content.source_folder.child('tlink.html')) tlink.write(text % d) print((tlink.read_all())) gen = Generator(site) gen.generate_all() f = File(site.config.deploy_root_path.child(tlink.name)) assert f.exists html = f.read_all() assert html for name, path in list(d.items()): assert site.config.base_url + quote(path) in html assert '/media/img/hyde-logo.png' in html
def test_content_url_encoding(self): s = Site(self.SITE_PATH, config=self.config) s.load() path = '".jpg' assert s.content_url(path) == "/" + quote(path)
def _encode_path(base, path, safe): base = base.strip().replace(os.sep, '/') path = path.strip().replace(os.sep, '/') path = quote(path, safe) if safe is not None else quote(path) full_path = base.rstrip('/') + '/' + path.lstrip('/') return full_path
def urlencode(ctx, url, safe=None): if safe is not None: return quote(url.encode('utf8'), safe) else: return quote(url.encode('utf8'))