def title_for(cls, tags=[], entities=[], actions=[], objects=None, use_env=True): import os from geebaby.tags import geebaby_split_host sub, domain = geebaby_split_host(os.environ["SERVER_NAME"]) if entities and objects: obj = objects.fetch(1) if obj: return u' | '.join(( getattr(obj[0], 'title', None) or getattr(obj[0], 'name', 'another-baby'), obj[0].tags and obj[0].tags[0] or '', domain.capitalize(), )) return u' | '.join(( ','.join(tags), domain.capitalize(), ))
def url_for(cls, tags=[], entities=[], actions=[], use_env=True): import os env_tags = [] if use_env: env_tags, _, _ = uri2tea("http://%s/" % os.environ["SERVER_NAME"]) host_tags = [] path_tags = [] for tag in tags: if tag in env_tags: host_tags.append(tag) else: path_tags.append(tag) path = '' if path_tags: path += '/'.join(path_tags) path += '/' if entities: path += entities[0] if actions: path += "." path += ".".join(actions) from geebaby.tags import geebaby_split_host sub, domain = geebaby_split_host(os.environ["SERVER_NAME"]) port = '' if os.environ["SERVER_PORT"] != '80': port = ':%s' % os.environ["SERVER_PORT"] #url = "http://%s/%s" % ('.'.join(host_tags + domain) + port, path) url = "http://%s.%s/%s%s%s" % ( tags and tags[0] or 'all', domain + port, '/'.join(tags[1:]) + (tags[1:] and '/' or ''), entities and entities[0] or '', actions and '.' + '.'.join(actions) or '', ) return url