def change_public_url_processor(f, i): RESERVED = ['www', 'internal', 'new'] url = i.public_url.strip().lower() if url and url != jt.site.public_url: exists = db.get_site(public_url=url) if exists or url in RESERVED or len(url) < 3: f.public_url.error('error') if url and not re.match(r'^[a-zA-Z0-9-]+$', url): f.public_url.error('error')
def create_dummy_user(username, password, displayname=None, email=''): username = web.lstrips(username, 'user/') displayname = displayname or username from infogami.core.db import new_user # hack user = new_user(db.get_site(), username, displayname, email, password) user.displayname = username user.save() return user
def create_dummy_user(username, password, displayname=None, email=''): username = web.lstrips(username, 'user/') displayname = displayname or username from infogami.core.db import new_user # hack user = new_user(db.get_site(), username, displayname, email, password) user.displayname = username user.save() return user
def dispatch_public(url, path): jt.access = 'public' # modes res = re.match(r'^('+'|'.join(modes.keys())+')/([^/]*)$', path) if res: mode, method = res.groups() jt.site = db.get_site(public_url=url) if not jt.site or jt.site.deleted: return no_site(url) return dispatch_mode(mode, method) # pages jt.site = db.get_site(public_url=url) if not jt.site or jt.site.deleted: return no_site(url) page = path if page != page.replace(' ', '_'): return web.seeother(utils.page_url(page)+web.ctx.query) return dispatch_page(page)
def dispatch_public(url, path): jt.access = 'public' # modes res = re.match(r'^(' + '|'.join(modes.keys()) + ')/([^/]*)$', path) if res: mode, method = res.groups() jt.site = db.get_site(public_url=url) if not jt.site or jt.site.deleted: return no_site(url) return dispatch_mode(mode, method) # pages jt.site = db.get_site(public_url=url) if not jt.site or jt.site.deleted: return no_site(url) page = path if page != page.replace(' ', '_'): return web.seeother(utils.page_url(page) + web.ctx.query) return dispatch_page(page)
def dispatch_secret(path): jt.access = 'secret' # modes res = re.match(r'^([^/]+)/('+'|'.join(modes.keys())+')/([^/]*)$', path) if res: url, mode, method = res.groups() jt.site = db.get_site(secret_url=url) if not jt.site or jt.site.deleted: return no_site(url) if jt.site.public_url: return web.seeother(utils.site_url()+mode+'/'+method) return dispatch_mode(mode, method) # pages res = re.match(r'^([^/]+)/(.*)', path) if res: url, page = res.groups() # make all secret urls lowercase if not url.islower(): return web.seeother('/%s/%s' % (url.lower(), page)) jt.site = db.get_site(secret_url=url) if not jt.site or jt.site.deleted: return no_site(url) if page != page.replace(' ', '_'): return web.seeother(utils.page_url(page)+web.ctx.query) if jt.site.public_url: return web.seeother(utils.site_url()+page) return dispatch_page(page) return web.notfound()
def dispatch_secret(path): jt.access = 'secret' # modes res = re.match(r'^([^/]+)/(' + '|'.join(modes.keys()) + ')/([^/]*)$', path) if res: url, mode, method = res.groups() jt.site = db.get_site(secret_url=url) if not jt.site or jt.site.deleted: return no_site(url) if jt.site.public_url: return web.seeother(utils.site_url() + mode + '/' + method) return dispatch_mode(mode, method) # pages res = re.match(r'^([^/]+)/(.*)', path) if res: url, page = res.groups() # make all secret urls lowercase if not url.islower(): return web.seeother('/%s/%s' % (url.lower(), page)) jt.site = db.get_site(secret_url=url) if not jt.site or jt.site.deleted: return no_site(url) if page != page.replace(' ', '_'): return web.seeother(utils.page_url(page) + web.ctx.query) if jt.site.public_url: return web.seeother(utils.site_url() + page) return dispatch_page(page) return web.notfound()
def cleanup(): sites = db.get_site() for s in sites: site_id = s.id updated = s.updated print site_id, updated
def POST_url_available(self): RESERVED = ['www', 'internal', 'new', 'signin'] i = web.input('url') exists = (i.url in RESERVED) or db.get_site(public_url=i.url) serialize_json(available=(exists is None))