Example #1
0
		private void Deny_Unrestricted (Html32TextWriter htw)
		{
			htw.ShouldPerformDivTableSubstitution = true;
			Assert.IsTrue (htw.ShouldPerformDivTableSubstitution, "ShouldPerformDivTableSubstitution");
			htw.SupportsBold = true;
			Assert.IsTrue (htw.SupportsBold, "SupportsBold");
			htw.SupportsItalic = true;
			Assert.IsTrue (htw.SupportsItalic, "SupportsItalic");
			htw.RenderBeginTag (HtmlTextWriterTag.Table);
			htw.RenderBeginTag ("<tr>");
			htw.RenderEndTag ();
		}
Example #2
0
 /// <summary>
 /// Writes the navigation bar to the given <see cref="Html32TextWriter"/>.
 /// </summary>
 /// <param name='htw'>
 /// The <see cref="Html32TextWriter"/> to write the content to.
 /// </param>
 /// <param name='webpage'>
 /// The webpage that is currently displayed. This is needed to denote the current page.
 /// </param>
 private void WriteMasthead(Html32TextWriter htw, IWebPage webpage)
 {
     INavbar navbar = this.device.Navigationbar;
     htw.AddAttribute (HtmlTextWriterAttribute.Class, "navbar navbar-default navbar-fixed-top");
     htw.AddAttribute ("role", "navigation");
     htw.RenderBeginTag (HtmlTextWriterTag.Div);
     {
         htw.AddAttribute (HtmlTextWriterAttribute.Class, "container-fluid");
         htw.RenderBeginTag (HtmlTextWriterTag.Div);
         {
             htw.AddAttribute (HtmlTextWriterAttribute.Class, "navbar-header");
             htw.RenderBeginTag (HtmlTextWriterTag.Div);
             {
                 htw.AddAttribute (HtmlTextWriterAttribute.Class, "navbar-brand");
                 htw.AddAttribute (HtmlTextWriterAttribute.Href, "#");
                 htw.RenderBeginTag (HtmlTextWriterTag.A);
                 {
                     htw.Write (navbar.Name);
                 }
                 htw.RenderEndTag ();
             }
             htw.RenderEndTag ();
             htw.AddAttribute (HtmlTextWriterAttribute.Class, "navbar-collapse collapse");
             htw.RenderBeginTag (HtmlTextWriterTag.Div);
             {
                 htw.AddAttribute (HtmlTextWriterAttribute.Class, "nav navbar-nav");
                 htw.RenderBeginTag (HtmlTextWriterTag.Ul);
                 {
                     foreach (IWebPage wp in navbar.Pages) {
                         if (wp == webpage) {
                             htw.AddAttribute (HtmlTextWriterAttribute.Class, "active");
                         }
                         htw.RenderBeginTag (HtmlTextWriterTag.Li);
                         htw.AddAttribute (HtmlTextWriterAttribute.Href, wp.Href);
                         htw.RenderBeginTag (HtmlTextWriterTag.A);
                         htw.Write (wp.Name);
                         htw.RenderEndTag ();
                         htw.RenderEndTag ();
                     }
                 }
                 htw.RenderEndTag ();
             }
             htw.RenderEndTag ();
         }
         htw.RenderEndTag ();
     }
     htw.RenderEndTag ();
 }
Example #3
0
 /// <summary>
 /// Writes references of some javascript libraries to the given <see cref="Html32TextWriter"/> to let the bootstrap work.
 /// </summary>
 /// <param name='htw'>
 /// The <see cref="Html32TextWriter"/> to write the content to.
 /// </param>
 private void WriteJavascript(Html32TextWriter htw)
 {
     htw.AddAttribute (HtmlTextWriterAttribute.Src, "http://netdna.bootstrapcdn.com/bootstrap/3.1.1/js/bootstrap.min.js");
     htw.RenderBeginTag (HtmlTextWriterTag.Script);
     htw.RenderEndTag ();
     htw.WriteLine ();
     htw.AddAttribute (HtmlTextWriterAttribute.Src, "http://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js");
     htw.RenderBeginTag (HtmlTextWriterTag.Script);
     {}
     htw.RenderEndTag ();
 }
Example #4
0
 /// <summary>
 /// Writes the header of the webpage. The header contains references to bootstrap, a favoicon and some stylefile.
 /// </summary>
 /// <param name='htw'>
 /// A <see cref="Html32TextWriter"/> to write the content to.
 /// </param>
 private void WriteHeader(Html32TextWriter htw)
 {
     htw.RenderBeginTag (HtmlTextWriterTag.Title);
     {
         htw.Write (this.device.Navigationbar.Name);
     }
     htw.RenderEndTag ();
     htw.AddAttribute (HtmlTextWriterAttribute.Name, "generator");
     htw.AddAttribute (HtmlTextWriterAttribute.Content, ProgramManager.ProgramNameVersion);
     htw.RenderBeginTag (HtmlTextWriterTag.Meta);
     {}
     htw.RenderEndTag ();
     htw.WriteLine ();
     htw.AddAttribute (HtmlTextWriterAttribute.Name, "viewport");
     htw.AddAttribute (HtmlTextWriterAttribute.Content, "width=device-width, initial-scale=1.0");
     htw.RenderBeginTag (HtmlTextWriterTag.Meta);
     {}
     htw.RenderEndTag ();
     htw.WriteLine ();
     htw.AddAttribute (HtmlTextWriterAttribute.Href, "http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css");
     htw.AddAttribute (HtmlTextWriterAttribute.Rel, "stylesheet");
     htw.RenderBeginTag (HtmlTextWriterTag.Link);
     {}
     htw.RenderEndTag ();
     htw.WriteLine ();
     htw.AddAttribute (HtmlTextWriterAttribute.Href, IconName);
     htw.AddAttribute (HtmlTextWriterAttribute.Rel, "icon");
     htw.AddAttribute (HtmlTextWriterAttribute.Type, "image/x-icon");
     htw.RenderBeginTag (HtmlTextWriterTag.Link);
     {}
     htw.RenderEndTag ();
     htw.WriteLine ();
     htw.RenderBeginTag (HtmlTextWriterTag.Style);
     {
         htw.Write ("body {min-height: 2000px;padding-top: 70px;}");
     }
     htw.RenderEndTag ();
     htw.AddAttribute ("language", "javascript");
     htw.RenderBeginTag (HtmlTextWriterTag.Script);
     {
         htw.WriteLine ("function genericAjax (source, target) {");
         htw.WriteLine ("    var xmlhttp;");
         htw.WriteLine ("    if (window.XMLHttpRequest) {");
         htw.WriteLine ("        xmlhttp=new XMLHttpRequest();");
         htw.WriteLine ("    } else {");
         htw.WriteLine ("        xmlhttp=new ActiveXObject(\"Microsoft.XMLHTTP\");");
         htw.WriteLine ("    }");
         htw.WriteLine ("    xmlhttp.onreadystatechange=function() {");
         htw.WriteLine ("        if (xmlhttp.readyState==4) {");
         htw.WriteLine ("            if(xmlhttp.status==200) {");
         htw.WriteLine ("                document.getElementById(target).innerHTML=xmlhttp.responseText;");
         htw.WriteLine ("            } else {");
         htw.WriteLine ("                document.getElementById(target).innerHTML=\"<div class='alert alert-warning'><strong>Warning:</strong> something went wrong during an AJAX call. Error code: \"+xmlhttp.status+\", Source: \"+source+\".</div>\";");
         htw.WriteLine ("            }");
         htw.WriteLine ("        }");
         htw.WriteLine ("    }");
         htw.WriteLine ("    xmlhttp.open(\"GET\",source,true);");
         htw.WriteLine ("    xmlhttp.send();");
         htw.WriteLine ("}");
     }
     htw.RenderEndTag ();
     htw.WriteLine ();
 }
Example #5
0
 /// <summary>
 /// Writes a footer of every webpage to the given <see cref="Html32TextWriter"/> instance.
 /// </summary>
 /// <param name='htw'>
 /// The <see cref="Html32TextWriter"/> to write the webpage to.
 /// </param>
 private void WriteFooter(Html32TextWriter htw)
 {
     htw.RenderBeginTag (HtmlTextWriterTag.Hr);
     htw.RenderEndTag ();
     htw.AddAttribute (HtmlTextWriterAttribute.Class, "footer");
     htw.RenderBeginTag (HtmlTextWriterTag.Div);
     htw.RenderBeginTag (HtmlTextWriterTag.P);
     htw.Write ("This page is created with {0}", ProgramManager.ProgramNameVersion);
     htw.RenderEndTag ();
     htw.RenderEndTag ();
 }
Example #6
0
        /// <summary>
        /// Writes the body of the given <see cref="IWebPage"/> to the <see cref="Html32TextWriter"/>.
        /// </summary>
        /// <param name='htw'>
        /// The <see cref="Html32TextWriter"/> to write the content to.
        /// </param>
        /// <param name='webpage'>
        /// The <see cref="IWebPage"/> to write to the <see cref="Html32TextWriter"/>.
        /// </param>
        private void WriteBody(Html32TextWriter htw, IWebPage webpage)
        {
            this.WriteMasthead (htw, webpage);
            htw.AddAttribute (HtmlTextWriterAttribute.Class, "container");
            htw.RenderBeginTag (HtmlTextWriterTag.Div);
            htw.RenderBeginTag (HtmlTextWriterTag.Hr);
            htw.RenderEndTag ();

            webpage.Render (this.device.Manager.ServerFolder, this, htw);

            this.WriteFooter (htw);
            htw.RenderEndTag ();
        }
Example #7
0
        /// <summary>
        /// Converts the set of <see cref="IdpGie.Shapes.IShape"/> by converting it into a readable format.
        /// </summary>
        public override void Process()
        {
            using (StreamReader inputStream = new StreamReader (client.GetStream ())) {
                String request = inputStream.ReadLine (), line;
                string[] tokens = request.Split (' ');
                if (tokens.Length != 3) {
                    throw new Exception ("invalid http request line");
                }
                StringBuilder rest = new StringBuilder ();
                do {
                    line = inputStream.ReadLine ();
                    rest.AppendLine (line);
                } while(line != string.Empty && line != null);
                //string http_url = tokens [1];
                string http_filename = tokens [1];
                Console.WriteLine ("\"{0}\"", http_filename);

                if (http_filename == "/" + IconName) {
                    this.device.Navigationbar.FavIcon.RenderIcon (this.device.Manager.ServerFolder, this, client.GetStream ());
                } else {
                    bool border;
                    IWebPage wp = this.device.Navigationbar.GetPage (http_filename.Substring (0x01), out border);
                    using (StreamWriter sw = new StreamWriter (client.GetStream ())) {
                        using (Html32TextWriter tw = new Html32TextWriter (sw)) {
                            if (border) {
                                tw.WriteLine ("<!DOCTYPE html>");
                                tw.RenderBeginTag (HtmlTextWriterTag.Html);
                                tw.RenderBeginTag (HtmlTextWriterTag.Head);
                                this.WriteHeader (tw);
                                tw.RenderEndTag ();
                                tw.RenderBeginTag (HtmlTextWriterTag.Body);
                                this.WriteBody (tw, wp);
                                this.WriteJavascript (tw);
                                tw.RenderEndTag ();
                                tw.RenderEndTag ();
                            } else {
                                wp.Render (this.device.Manager.ServerFolder, this, tw);
                            }
                        }
                    }
                }
            }
        }
 /// <summary>
 /// Render the webpage onto the give specified engine.
 /// </summary>
 /// <param name="serverFolder">The root of the folder of the web server.</param>
 /// <param name="engine">The given specified engine.</param>
 /// <param name="writer">The html writer to write content to.</param>
 public override void Render(string serverFolder, HttpEngine engine, Html32TextWriter writer)
 {
     string landingName = this.LandingName;
     writer.AddAttribute (HtmlTextWriterAttribute.Id, landingName);
     writer.RenderBeginTag (HtmlTextWriterTag.Div);
     writer.RenderEndTag ();
     if (this.QueryPage != null) {
         writer.RenderBeginTag (HtmlTextWriterTag.Script);
         writer.WriteLine ("genericAjax (\"{0}\", \"{1}\");", this.QueryPage.Href, landingName);
         writer.RenderEndTag ();
     }
 }
Example #9
0
 /// <summary>
 /// Render the webpage onto the give specified engine.
 /// </summary>
 /// <param name="serverFolder">The root of the folder of the web server.</param>
 /// <param name="engine">The given specified engine.</param>
 /// <param name="writer">The html writer to write content to.</param>
 public override void Render(string serverFolder, HttpEngine engine, Html32TextWriter writer)
 {
     writer.AddAttribute (HtmlTextWriterAttribute.Class, "table table-hover table-condensed table-bordered");
     writer.RenderBeginTag (HtmlTextWriterTag.Table);
     {
         writer.RenderBeginTag (HtmlTextWriterTag.Thead);
         {
             writer.RenderBeginTag (HtmlTextWriterTag.Tr);
             {
                 foreach (WebPredicateTableColumn column in this.Columns) {
                     writer.RenderBeginTag (HtmlTextWriterTag.Th);
                     writer.Write (column.Name);
                     writer.RenderEndTag ();
                 }
                 writer.RenderBeginTag (HtmlTextWriterTag.Th);
                 writer.AddAttribute (HtmlTextWriterAttribute.Class, "btn-group");
                 writer.RenderBeginTag (HtmlTextWriterTag.Div);
                 {
                     writer.AddAttribute (HtmlTextWriterAttribute.Onclick, string.Format ("genericAjax (\"{0}\", \"landing{1}\");", this.Href, this.Id));
                     writer.AddAttribute (HtmlTextWriterAttribute.Class, "btn btn-info btn-xs");
                     writer.RenderBeginTag (HtmlTextWriterTag.Button);
                     writer.WriteLine ("<i class=\"glyphicon glyphicon-refresh\"></i>");
                     writer.RenderEndTag ();
                     writer.AddAttribute (HtmlTextWriterAttribute.Class, "btn btn-success btn-xs");
                     writer.RenderBeginTag (HtmlTextWriterTag.Button);
                     writer.WriteLine ("<i class=\"glyphicon glyphicon-plus\"></i>");
                     writer.RenderEndTag ();
                 }
                 writer.RenderEndTag ();
                 writer.RenderEndTag ();
             }
             writer.RenderEndTag ();
         }
         writer.RenderEndTag ();
         writer.RenderBeginTag (HtmlTextWriterTag.Tbody);
         {
             IEnumerable<int> indices = this.Columns.Select (x => x.Index).ToArray ();
             foreach (IEnumerable<object> row in this.Source) {
                 writer.WriteLine ();
                 writer.RenderBeginTag (HtmlTextWriterTag.Tr);
                 foreach (object item in row.IndicesOrdered (indices)) {
                     writer.RenderBeginTag (HtmlTextWriterTag.Td);
                     writer.Write (item);
                     writer.RenderEndTag ();
                 }
                 writer.RenderBeginTag (HtmlTextWriterTag.Td);
                 writer.AddAttribute (HtmlTextWriterAttribute.Class, "btn-group");
                 writer.RenderBeginTag (HtmlTextWriterTag.Div);
                 {
                     writer.AddAttribute (HtmlTextWriterAttribute.Onclick, string.Format ("genericAjax (\"{0}\", \"landing{1}\");", this.Href, this.Id));
                     writer.AddAttribute (HtmlTextWriterAttribute.Class, "btn btn-warning btn-xs");
                     writer.RenderBeginTag (HtmlTextWriterTag.Button);
                     writer.WriteLine ("<i class=\"glyphicon glyphicon-edit\"></i>");
                     writer.RenderEndTag ();
                     writer.AddAttribute (HtmlTextWriterAttribute.Class, "btn btn-danger btn-xs");
                     writer.RenderBeginTag (HtmlTextWriterTag.Button);
                     writer.WriteLine ("<i class=\"glyphicon glyphicon-remove\"></i>");
                     writer.RenderEndTag ();
                 }
                 writer.RenderEndTag ();
                 writer.RenderEndTag ();
                 writer.RenderEndTag ();
             }
         }
         writer.RenderEndTag ();
     }
     writer.RenderEndTag ();
 }
 /// <summary>
 ///  Render the webpage onto the give specified engine. 
 /// </summary>
 /// <param name='serverFolder'>
 ///  The root of the folder of the web server. 
 /// </param>
 /// <param name='engine'>
 ///  The given specified engine. 
 /// </param>
 /// <param name='writer'>
 ///  The html writer to write content to. 
 /// </param>
 public override void Render(string serverFolder, HttpEngine engine, Html32TextWriter writer)
 {
     this.Load (serverFolder);
     foreach (HtmlAttribute ha in this.node.Attributes) {
         writer.AddAttribute (ha.Name, ha.Value);
     }
     writer.RenderBeginTag (this.node.Name);
     if (this.pieces != null) {
         foreach (IWebPagePiece piece in this.pieces) {
             piece.Render (serverFolder, engine, writer);
         }
     }
     writer.RenderEndTag ();
 }