class Shortener module Server module ShortServerHelpers def bad! message halt 412, {}, message end def nope!(message = 'No luck.') halt 404, {}, message end def base_url @base_url ||= "#{request.env['rack.url_scheme']}://#{request.env['HTTP_HOST']}" end def clippy(text, bgcolor='#FFFFFF') html = <<-EOF EOF end def ttl_display(ttl) if ttl == -1 ret = 'expired' elsif ttl == nil ret = '∞' else ret = ttl end ret end def boxify_class(int, boxify_classes = '', nonbox_classes = '', other_classes = '') str = if @boxify "#{other_classes} #{boxify_classes}" else "#{other_classes} #{nonbox_classes}" end str = str + " offset#{int}" unless !int.nil? && @boxify str end def logged_in? return true unless $conf.authenticate? env['warden'].authenticated? end def available?(thing) return true unless $conf.authenticate? return true unless $conf.auth_route?(thing) return logged_in? end def authorize!(redir_url = '/u/login') return true unless $conf.authenticate? redirect redir_url unless env['warden'].authenticated? end end end end