示例#1
0
        private static IEnumerable <string> generateDirectoryXml(string localPath, IHttpUrl url, string urlPath)
        {
            List <DirectoryInfo> dirs    = new List <DirectoryInfo>();
            List <FileInfo>      files   = new List <FileInfo>();
            DirectoryInfo        dirInfo = new DirectoryInfo(localPath);

            foreach (var d in dirInfo.GetDirectories())
            {
                dirs.Add(d);
            }
            foreach (var f in dirInfo.GetFiles())
            {
                files.Add(f);
            }
            dirs.Sort((a, b) => a.Name.CompareTo(b.Name));
            files.Sort((a, b) => a.Name.CompareTo(b.Name));

            yield return("<?xml version=\"1.0\" encoding=\"utf-8\"?>\n");

            yield return("<?xml-stylesheet href=\"{0}\" type=\"text/xsl\" ?>\n".Fmt(url.WithPathOnly("/$/directory-listing/xsl").ToHref().HtmlEscape()));

            yield return("<directory url=\"{0}\" unescapedurl=\"{1}\" img=\"{2}\" numdirs=\"{3}\" numfiles=\"{4}\">\n"
                         .Fmt(url.ToHref().HtmlEscape(), url.ToHref().UrlUnescape().HtmlEscape(), url.WithPathOnly("/$/directory-listing/icons/folderbig").ToHref().HtmlEscape(), dirs.Count, files.Count));

            foreach (var d in dirs)
            {
                yield return("  <dir link=\"{0}/\" img=\"{2}\">{1}</dir>\n".Fmt(d.Name.UrlEscape(), d.Name.HtmlEscape(), url.WithPathOnly("/$/directory-listing/icons/folder").ToHref().HtmlEscape()));
            }
            foreach (var f in files)
            {
                string extension = f.Name.Contains('.') ? f.Name.Substring(f.Name.LastIndexOf('.') + 1) : "";
                yield return("  <file link=\"{0}\" size=\"{1}\" nicesize=\"{2}\" img=\"{3}\">{4}</file>\n"
                             .Fmt(f.Name.UrlEscape(), f.Length, Ut.SizeToString(f.Length), url.WithPathOnly("/$/directory-listing/icons/" + GetDirectoryListingIconStr(extension)).ToHref().HtmlEscape(), f.Name.HtmlEscape()));
            }

            yield return("</directory>\n");
        }
示例#2
0
 private HttpResponse changePasswordForm(string loggedInUser, string returnTo, bool loginFailed, bool passwordsDiffer, string oldpassword, string newpassword1, string newpassword2, IHttpUrl formSubmitUrl)
 {
     return(HttpResponse.Html(
                new HTML(
                    new HEAD(
                        new TITLE("Change Password"),
                        new STYLELiteral(_formCss),
                        new META {
         name = "viewport", content = "width=device-width,initial-scale=1.0"
     }
                        ),
                    new BODY(
                        new FORM {
         method = method.post, action = formSubmitUrl.ToHref()
     }._(
                            new DIV(
                                returnTo == null ? null : new INPUT {
         type = itype.hidden, name = "returnto", value = returnTo
     },
                                new P("To change your password, type your old password, and then the new password twice."),
                                loginFailed ? new P("The specified old password is wrong.")
     {
         class_ = "error"
     } : null,
                                passwordsDiffer ? new P("The specified new passwords do not match. You have to type the same new password twice.")
     {
         class_ = "error"
     } : null,
                                HtmlTag.HtmlTable(null,
                                                  new object[] { "Username:"******"Old password:"******"password", type = itype.password, size = 60, value = oldpassword
                                                                 } },
                                                  new object[] { "New password (1):", new INPUT {
                                                                     name = "newpassword1", type = itype.password, size = 60, value = newpassword1
                                                                 } },
                                                  new object[] { "New password (2):", new INPUT {
                                                                     name = "newpassword2", type = itype.password, size = 60, value = newpassword2
                                                                 } },
                                                  new[] { null, new INPUT {
                                                              value = "Change password", type = itype.submit
                                                          } }
                                                  )
                                )
                            )
                        )
                    )
                ));
 }
示例#3
0
 private HttpResponse createUserForm(string returnTo, bool userAlreadyExists, bool passwordsDiffer, string username, string newpassword1, string newpassword2, IHttpUrl formSubmitUrl)
 {
     return(HttpResponse.Html(
                new HTML(
                    new HEAD(
                        new TITLE("Create user"),
                        new STYLELiteral(_formCss),
                        new META {
         name = "viewport", content = "width=device-width,initial-scale=1.0"
     }
                        ),
                    new BODY(
                        new FORM {
         method = method.post, action = formSubmitUrl.ToHref()
     }._(
                            new DIV(
                                returnTo == null ? null : new INPUT {
         type = itype.hidden, name = "returnto", value = returnTo
     },
                                new P("To create a new user, type the desired username and the new password twice."),
                                userAlreadyExists ? new P("The specified username is already in use.")
     {
         class_ = "error"
     } : null,
                                passwordsDiffer ? new P("The specified new passwords do not match. You have to type the same new password twice.")
     {
         class_ = "error"
     } : null,
                                HtmlTag.HtmlTable(null,
                                                  new object[] { "Username:"******"username", type = itype.text, size = 60, value = username
                                                                 } },
                                                  new object[] { "New password (1):", new INPUT {
                                                                     name = "newpassword1", type = itype.password, size = 60, value = newpassword1
                                                                 } },
                                                  new object[] { "New password (2):", new INPUT {
                                                                     name = "newpassword2", type = itype.password, size = 60, value = newpassword2
                                                                 } },
                                                  new[] { null, new INPUT {
                                                              value = "Create user", type = itype.submit
                                                          } }
                                                  )
                                )
                            )
                        )
                    )
                ));
 }
示例#4
0
 private HttpResponse loginForm(string returnto, bool failed, string username, string password, IHttpUrl formSubmitUrl)
 {
     return(HttpResponse.Html(
                new HTML(
                    new HEAD(
                        new TITLE("Log in"),
                        new STYLELiteral(_formCss),
                        new META {
         name = "viewport", content = "width=device-width,initial-scale=1.0"
     }
                        ),
                    new BODY(
                        new FORM {
         method = method.post, action = formSubmitUrl.ToHref()
     }._(
                            new DIV(
                                returnto == null ? null : new INPUT {
         type = itype.hidden, name = "returnto", value = returnto
     },
                                new P("Please log in to access ", _appName, "."),
                                failed ? new P("The specified username and/or password has not been recognised.")
     {
         class_ = "error"
     } : null,
                                HtmlTag.HtmlTable(null,
                                                  new object[] { "Username:"******"username", type = itype.text, size = 60, value = username
                                                                 } },
                                                  new object[] { "Password:"******"password", type = itype.password, size = 60, value = password
                                                                 } },
                                                  new[] { null, new INPUT {
                                                              value = "Log in", type = itype.submit
                                                          } }
                                                  )
                                )
                            )
                        )
                    )
                ));
 }
        private static IEnumerable<string> generateDirectoryXml(string localPath, IHttpUrl url, string urlPath)
        {
            List<DirectoryInfo> dirs = new List<DirectoryInfo>();
            List<FileInfo> files = new List<FileInfo>();
            DirectoryInfo dirInfo = new DirectoryInfo(localPath);
            foreach (var d in dirInfo.GetDirectories())
                dirs.Add(d);
            foreach (var f in dirInfo.GetFiles())
                files.Add(f);
            dirs.Sort((a, b) => a.Name.CompareTo(b.Name));
            files.Sort((a, b) => a.Name.CompareTo(b.Name));

            yield return "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n";
            yield return "<?xml-stylesheet href=\"{0}\" type=\"text/xsl\" ?>\n".Fmt(url.WithPathOnly("/$/directory-listing/xsl").ToHref().HtmlEscape());
            yield return "<directory url=\"{0}\" unescapedurl=\"{1}\" img=\"{2}\" numdirs=\"{3}\" numfiles=\"{4}\">\n"
                .Fmt(url.ToHref().HtmlEscape(), url.ToHref().UrlUnescape().HtmlEscape(), url.WithPathOnly("/$/directory-listing/icons/folderbig").ToHref().HtmlEscape(), dirs.Count, files.Count);
            foreach (var d in dirs)
                yield return "  <dir link=\"{0}/\" img=\"{2}\">{1}</dir>\n".Fmt(d.Name.UrlEscape(), d.Name.HtmlEscape(), url.WithPathOnly("/$/directory-listing/icons/folder").ToHref().HtmlEscape());
            foreach (var f in files)
            {
                string extension = f.Name.Contains('.') ? f.Name.Substring(f.Name.LastIndexOf('.') + 1) : "";
                yield return "  <file link=\"{0}\" size=\"{1}\" nicesize=\"{2}\" img=\"{3}\">{4}</file>\n"
                    .Fmt(f.Name.UrlEscape(), f.Length, Ut.SizeToString(f.Length), url.WithPathOnly("/$/directory-listing/icons/" + GetDirectoryListingIconStr(extension)).ToHref().HtmlEscape(), f.Name.HtmlEscape());
            }

            yield return "</directory>\n";
        }
示例#6
0
 private HttpResponse changePasswordForm(string loggedInUser, string returnTo, bool loginFailed, bool passwordsDiffer, string oldpassword, string newpassword1, string newpassword2, IHttpUrl formSubmitUrl)
 {
     return HttpResponse.Html(
         new HTML(
             new HEAD(
                 new TITLE("Change Password"),
                 new STYLELiteral(_formCss)
             ),
             new BODY(
                 new FORM { method = method.post, action = formSubmitUrl.ToHref() }._(
                     new DIV(
                         returnTo == null ? null : new INPUT { type = itype.hidden, name = "returnto", value = returnTo },
                         new P("To change your password, type your old password, and then the new password twice."),
                         loginFailed ? new P("The specified old password is wrong.") { class_ = "error" } : null,
                         passwordsDiffer ? new P("The specified new passwords do not match. You have to type the same new password twice.") { class_ = "error" } : null,
                         HtmlTag.HtmlTable(null,
                             new object[] { "Username:"******"Old password:"******"password", type = itype.password, size = 60, value = oldpassword } },
                             new object[] { "New password (1):", new INPUT { name = "newpassword1", type = itype.password, size = 60, value = newpassword1 } },
                             new object[] { "New password (2):", new INPUT { name = "newpassword2", type = itype.password, size = 60, value = newpassword2 } },
                             new[] { null, new INPUT { value = "Change password", type = itype.submit } }
                         )
                     )
                 )
             )
         )
     );
 }
示例#7
0
 private HttpResponse createUserForm(string returnTo, bool userAlreadyExists, bool passwordsDiffer, string username, string newpassword1, string newpassword2, IHttpUrl formSubmitUrl)
 {
     return HttpResponse.Html(
         new HTML(
             new HEAD(
                 new TITLE("Create user"),
                 new STYLELiteral(_formCss)
             ),
             new BODY(
                 new FORM { method = method.post, action = formSubmitUrl.ToHref() }._(
                     new DIV(
                         returnTo == null ? null : new INPUT { type = itype.hidden, name = "returnto", value = returnTo },
                         new P("To create a new user, type the desired username and the new password twice."),
                         userAlreadyExists ? new P("The specified username is already in use.") { class_ = "error" } : null,
                         passwordsDiffer ? new P("The specified new passwords do not match. You have to type the same new password twice.") { class_ = "error" } : null,
                         HtmlTag.HtmlTable(null,
                             new object[] { "Username:"******"username", type = itype.text, size = 60, value = username } },
                             new object[] { "New password (1):", new INPUT { name = "newpassword1", type = itype.password, size = 60, value = newpassword1 } },
                             new object[] { "New password (2):", new INPUT { name = "newpassword2", type = itype.password, size = 60, value = newpassword2 } },
                             new[] { null, new INPUT { value = "Create user", type = itype.submit } }
                         )
                     )
                 )
             )
         )
     );
 }
示例#8
0
 private HttpResponse loginForm(string returnto, bool failed, string username, string password, IHttpUrl formSubmitUrl)
 {
     return HttpResponse.Html(
         new HTML(
             new HEAD(
                 new TITLE("Log in"),
                 new STYLELiteral(_formCss)
             ),
             new BODY(
                 new FORM { method = method.post, action = formSubmitUrl.ToHref() }._(
                     new DIV(
                         returnto == null ? null : new INPUT { type = itype.hidden, name = "returnto", value = returnto },
                         new P("Please log in to access ", _appName, "."),
                         failed ? new P("The specified username and/or password has not been recognised.") { class_ = "error" } : null,
                         HtmlTag.HtmlTable(null,
                             new object[] { "Username:"******"username", type = itype.text, size = 60, value = username } },
                             new object[] { "Password:"******"password", type = itype.password, size = 60, value = password } },
                             new[] { null, new INPUT { value = "Log in", type = itype.submit } }
                         )
                     )
                 )
             )
         )
     );
 }