Exemplo n.º 1
0
    static int Main(string [] args)
    {
        HTML   html;
        Window win;

        Application.Init();
        html = new HTML();
        win  = new Window("Test");
        ScrolledWindow sw = new ScrolledWindow();

        win.Add(sw);
        sw.Add(html);
        HTMLStream s = html.Begin("text/html");

        if (args.Length > 0)
        {
            using (StreamReader r = File.OpenText(args [0]))
                s.Write(r.ReadToEnd());
        }
        else
        {
            s.Write("<html><body>");
            s.Write("Hello world!");
        }

        html.End(s, HTMLStreamStatus.Ok);
        win.ShowAll();
        Application.Run();
        return(0);
    }
Exemplo n.º 2
0
Arquivo: GMan.cs Projeto: pombreda/enh
    private void ShowHtml(string htmlText)
    {
        Console.WriteLine(htmlText);
        HTMLStream htmlStream = html.Begin();

        htmlStream.Write(htmlText);
        html.End(htmlStream, HTMLStreamStatus.Ok);
    }
Exemplo n.º 3
0
        override protected void OnUrlRequested(string url, HTMLStream handle)
        {
            // gobble up UrlRequested event by not calling base
            UrlDownloader ud = new UrlDownloader(url, handle);
            Thread        t  = new Thread(new ThreadStart(ud.Go));

            threads.Add(t);
            t.Start();
        }
Exemplo n.º 4
0
Arquivo: GMan.cs Projeto: pombreda/enh
    private void LoadHtml(string URL)
    {
        HttpWebRequest  web_request  = (HttpWebRequest)WebRequest.Create(URL);
        HttpWebResponse web_response = (HttpWebResponse)web_request.GetResponse();
        Stream          stream       = web_response.GetResponseStream();

        byte [] buffer = new byte [8192];

        HTMLStream html_stream = html.Begin();
        int        count;

        while ((count = stream.Read(buffer, 0, 8192)) != 0)
        {
            html_stream.Write(buffer, count);
        }
        html.End(html_stream, HTMLStreamStatus.Ok);
    }
        void RenderChanges()
        {
            notebook.Page = 0;
            HTMLStream s = html.Begin("text/html");

            if (changes != null)
            {
                s.Write("<h1>Pending Changes</h1>");
                int i = 0;
                foreach (PendingChange ch in changes)
                {
                    s.Write(String.Format("{3}: <a href=\"review:{0}${1}\">{2}</a><br>", ch.ID, ch.Serial, ch.Login, i++));
                }
            }
            else
            {
                s.Write("<h1>No pending changes on the server</h1>");
            }
            html.End(s, HTMLStreamStatus.Ok);
        }
Exemplo n.º 6
0
 public UrlDownloader(string url, HTMLStream handle)
 {
     this.url    = url;
     this.handle = handle;
 }
        //
        // Renders the id/serial representation for review by the administrator.
        //
        void RenderReview(int id, int serial)
        {
            current_id     = id;
            current_serial = serial;

            notebook.Page = 1;

            GlobalChangeset globalset;

            globalset = LoadReview(id, serial);

            HTMLStream s = html_review.Begin("text/html");

            s.Write("<html><body>");
            if (globalset == null)
            {
                s.Write("No data found");
                html_review.End(s, HTMLStreamStatus.Ok);
                return;
            }

            int key = 0;

            action_map = new Hashtable();

            //
            // First make sure we dont have sources that we dont know about,
            // so a contribution can not be flagged as done by accident
            //
            bool allow_flag_as_done = true;

            foreach (DocSetChangeset docset in globalset.DocSetChangesets)
            {
                if (!providers.Contains(docset.DocSet))
                {
                    s.Write(String.Format("<font color='red'>Warning: Skipping {0}</font>", docset.DocSet));
                    allow_flag_as_done = false;
                    continue;
                }
            }

            if (allow_flag_as_done)
            {
                s.Write(String.Format("<h1>Changes: <a href=\"flag-done:{0}${1}\">[Flag as Done]</a></h1>", id, serial));
            }

            foreach (DocSetChangeset docset in globalset.DocSetChangesets)
            {
                if (!providers.Contains(docset.DocSet))
                {
                    continue;
                }

                if (docset == null)
                {
                    s.Write("Null?");
                    continue;
                }
                string ds;

                ds = String.Format("<table width='100%' bgcolor='#aabbaa'><tr><td>Docset: {0}</td></tr></table>", docset.DocSet);
                foreach (FileChangeset fileset in docset.FileChangesets)
                {
                    string fs, es = null;

                    fs = String.Format("<h3><a href=\"apply-file:{0}\">[Apply]</a> File: {1} <br><blockquote>",
                                       key, fileset.RealFile);

                    action_map [key++] = new FileAction(globalset, docset, fileset);

                    if (fileset.RealFile == null)
                    {
                        s.Write(String.Format("Warning: invalid contribution, its missing filename"));
                        continue;
                    }
                    XmlDocument d = LoadDocument(docset, fileset.RealFile);

                    foreach (Change c in fileset.Changes)
                    {
                        XmlNode orig = d.SelectSingleNode(c.XPath);
                        XmlNode newn = c.NewNode;

                        if (orig == null)
                        {
                            s.Write(String.Format("Warning, node {0} does not exist", c.XPath));
                            continue;
                        }

                        if (ds != null)
                        {
                            s.Write(ds);
                            ds = null;
                        }
                        if (fs != null)
                        {
                            s.Write(fs);
                            fs = null;
                            es = "</blockquote>";
                        }

                        string original_text = orig.InnerXml;
                        string new_text      = c.NewNode.InnerXml;

                        if (original_text == new_text)
                        {
                            //s.Write ("<b>Applied</b><br>");
                            continue;
                        }

                        int p = c.XPath.LastIndexOf("/");
                        s.Write(String.Format("<a href=\"diff-change:{0}\">[Diff]</a>", key));
                        s.Write(String.Format("<a href=\"apply-change:{0}\">[Apply]</a>: {1} ", key, c.XPath));
                        if (c.FromVersion != RootTree.MonodocVersion)
                        {
                            s.Write("<b>FROM OLD VERSION</b>");
                        }
                        action_map [key++] = new ItemAction(globalset, docset, fileset, c);
                        s.Write("<table border=1 width=100%><tr bgcolor=grey><td width=50%>Current</td><td width=50%>New</td>");

                        s.Write("<tr>");
                        s.Write(String.Format("<td>{0}</td>", Htmlize(original_text)));

                        s.Write("<td>");
                        s.Write(Htmlize(new_text));
                        s.Write("</td></tr>");
                        s.Write("</table>");
                    }
                    if (es != null)
                    {
                        s.Write(es);
                    }
                }
            }
            s.Write("</body></html>");
            html_review.End(s, HTMLStreamStatus.Ok);
        }