Пример #1
0
        private void handleBlogs(HttpContext ctx, IAuthenticator authInterface)
        {
            StringBuilder sb = new StringBuilder();

            StringBuilder postToolboxResponse = new StringBuilder();

            this.authorizationCode = ctx.Session["CODE"].ToString();

            String userId = DAL.RetrieveUserIdByAuthCode(this.authorizationCode);

            BlogList blogList = Blogger.getBlogs(Blogger.BuildService(authInterface), userId);

            BlogLink blogLink = DAL.GetActiveBlogLinkByUserId(userId);

            //<--- this code is used to handle the add-on's tab -->
            PostToolbox postToolbox = DAL.GetPostToolbox(userId);

            postToolboxResponse.Append("<table class='table'>");
            postToolboxResponse.Append("<thead>");
            postToolboxResponse.Append("<th>Feature</th>");
            postToolboxResponse.Append("<th>Preview</th>");
            postToolboxResponse.Append("<th>Description</th>");
            postToolboxResponse.Append("<th>Action</th>");
            postToolboxResponse.Append("</thead>");
            postToolboxResponse.Append("<tbody>");
            postToolboxResponse.Append("<tr>");
            postToolboxResponse.Append("<td>Toolcard</td>");
            postToolboxResponse.Append("<td><a href='img/toolcard.png' target='_blank'><img src='img/toolcard.png' class='img-polaroid' style='height:150px;width:300px;'/></a></td>");
            postToolboxResponse.Append("<td style='width:50%'><p>The toolcard is a pinnable item that allows the glass user to extend the functionalilty of the glassware service. Additional options include blog-by-voice and comment retrieval.</p></td>");

            if (postToolbox.isActive)
            {
                postToolboxResponse.Append("<td>");
                postToolboxResponse.Append("<input type='hidden' name='operation' value='disableToolboxCard' />");
                postToolboxResponse.Append("<button type='submit' class='btn btn-danger'><i class='icon-remove-sign'></i> Disable</button>");
                postToolboxResponse.Append("</td>");
            }
            else
            {
                postToolboxResponse.Append("<td>");
                postToolboxResponse.Append("<input type='hidden' name='operation' value='enableToolboxCard' />");
                postToolboxResponse.Append("<button type='submit' class='btn btn-success'><i class='icon-ok-sign'></i> Enable</button>");
                postToolboxResponse.Append("</td>");
            }

            postToolboxResponse.Append("</tr>");
            postToolboxResponse.Append("</tbody>");
            postToolboxResponse.Append("</table>");
            //<--- end add-on tab -->


            if (blogList.Items.Count > 0)
            {
                sb.Append("<table class='table table-striped'>");
                sb.Append("<thead>");
                sb.Append("<th>Blog</th>");
                sb.Append("<th>Default</th>");
                sb.Append("</thead>");
                sb.Append("<tbody>");
                foreach (Blog blog in blogList.Items)
                {
                    String isHighlight = (blogLink.blogId == blog.Id) ? "success" : "";

                    sb.Append("<tr class='" + isHighlight + "'>");
                    sb.Append("<td>" + blog.Name + "</td>");
                    if (blogLink.blogId == blog.Id)
                    {
                        sb.Append("<td><input value='" + blog.Id + "|" + blog.Name + "' type='radio' name='blog_selection' checked='checked' /></td>");
                    }
                    else
                    {
                        sb.Append("<td><input value='" + blog.Id + "|" + blog.Name + "' type='radio' name='blog_selection' /></td>");
                    }
                    sb.Append("</tr>");
                }
                sb.Append("<tr>");
                sb.Append("<td></td>");
                sb.Append("<td><button type='submit' class='btn btn-block'><i class='icon-retweet'></i> Synchronize Glass</button></td>");
                sb.Append("</tr>");
                sb.Append("</tbody>");
                sb.Append("</table>");
            }
            else
            {
                sb.Append("<h3>No Blogger Blogs found for this account!</h3>");
            }

            vm.Arguments = new Dictionary <String, String>()
            {
                { "BLOGS", sb.ToString() },
                { "BUTTON_OPERATION", postToolboxResponse.ToString() }
            };

            // wright file
            ctx.Response.Write(vm.RenderView("main"));
        }