Exemplo n.º 1
0
        public void SubmitLink(IManosContext ctx, Shorty app, string link)
        {
            string id = GenerateHash (link, 5);

            Cache [id] = new LinkData (link);
            ctx.Response.Redirect ("/r/" + id + "~");
        }
Exemplo n.º 2
0
        public void Redirector(IManosContext ctx, Shorty app, string id)
        {
            if (ctx.Request.Cookies.Get("show_info") != null)
            {
                LinkInfo(ctx, app, id);
                return;
            }

            Cache.Get(id, (name, item) => {
                LinkData info = item as LinkData;
                if (info == null)
                {
                    ctx.Response.StatusCode = 404;
                    return;
                }

                ++info.Clicks;
                ctx.Response.Redirect(info.Link);
            });
        }
Exemplo n.º 3
0
        public void LinkInfo(IManosContext ctx, Shorty app, string id)
        {
            Cache.Get(id, (name, item) => {
                LinkData info = item as LinkData;

                if (info == null)
                {
                    ctx.Response.StatusCode = 404;
                    ctx.Response.End();
                    return;
                }

                ctx.Response.End(@"<html>
                                        <head><title>Welcome to Shorty</title></head>
                                        <body>
                                         <a href='{0}'>{0}</a> was clicked {1} times.
                                         </body>
				     </html>"                    , info.Link, info.Clicks);
            });
        }
Exemplo n.º 4
0
        public void SubmitLink(IManosContext ctx, Shorty app, string link, bool show_info)
        {
            string id = GenerateHash (link, 5);

            if (show_info)
                ctx.Response.SetCookie ("show_info", "true");

            Cache [id] = new LinkData (link);
            ctx.Response.Redirect ("/r/" + id + "~");
        }