Ejemplo n.º 1
0
        /// <summary>
        /// Returns the list of servable files
        /// in the same directory
        /// as the context web directory.
        /// </summary>
        /// <param name="context">Web site HttpContext object</param>
        public static List <string> MakeServableList(HttpContext context)
        {
            if (context == null)
            {
                return(new List <string>());
            }

            string directorypath = FileTools.GetDirectoryPath(context);

            List <string> filelist =
                SourceTools.MakeFileList(directorypath, FileTools.ALL);

            List <string> servablelist = new List <string>();

            foreach (string name in filelist)
            {
                if (IsServable(name))
                {
                    servablelist.Add(name);
                }
            }

            return(servablelist);
        }
Ejemplo n.º 2
0
        // ToHtml requires a knowledge of the page on which
        // the html will be installed in order to properly
        // compute relative links.
        public string ToHtml(Page page)
        {
            if (!_valid)
            {
                return("<p><code>" + _path + "</code>" + errormessage + "</p>\n");
            }

            StringBuilder builder = new StringBuilder();

            // Show tilde file path
            // Link to the file view utility if viewable

            int  category = FileTools.GetFileCategory(_path);
            bool viewable = category != FileTools.OTHER;

            builder.Append("<p>");

            if (viewable)
            {
                string FileViewTildePath = SourceTools.FileViewTildePath;
                string fileViewURL       = FileTools.GetRelativePath(page, FileViewTildePath);

                builder.Append("<a href ='");
                builder.Append(fileViewURL);
                builder.Append("?");
                builder.Append(_path);
                builder.Append("' target='_blank'>");
            }

            builder.Append("<code>");
            builder.Append(_path);
            builder.Append("</code>");

            if (viewable)
            {
                builder.Append("</a>");
            }

            builder.Append("</p>\n");

            // Add launch link if servable

            bool servable = HttpContextTools.IsServable(_path);

            if (servable)
            {
                string launchURL = FileTools.GetRelativePath(page, _path);

                builder.Append("<p>Launch ");
                builder.Append("<a href ='");
                builder.Append(launchURL);
                builder.Append("' target='_blank'>");
                builder.Append("<code>");
                builder.Append(_path);
                builder.Append("</code>");
                builder.Append("</a>");
                builder.Append("</p>\n");
            }

            builder.Append("<table class='filedata'>\n");

            // File size

            builder.Append("<tr>\n");

            builder.Append("<td>");
            builder.Append("Size");
            builder.Append("</td>\n");

            builder.Append("<td>");
            builder.Append(_size.ToString());
            builder.Append("</td>\n");

            builder.Append("</tr>\n");

            // File date

            builder.Append("<tr>\n");

            builder.Append("<td>");
            builder.Append("Date");
            builder.Append("</td>\n");

            builder.Append("<td>");
            builder.Append(_date.ToYMD());
            builder.Append("</td>\n");

            builder.Append("<td>");
            builder.Append(_date.ToHMS());
            builder.Append("</td>\n");

            builder.Append("</tr>\n");

            // Add image dimensions if applicable

            bool image = (_width > 0) && (_height > 0);

            if (image)
            {
                builder.Append("<tr>\n");

                builder.Append("<td>");
                builder.Append("Dims");
                builder.Append("</td>\n");

                builder.Append("<td>");
                builder.Append(_width.ToString());
                builder.Append(" ");
                builder.Append("&times;");
                builder.Append(" ");
                builder.Append(_height.ToString());
                builder.Append("</td>\n");

                builder.Append("</tr>\n");
            }

            builder.Append("</table>\n");

            return(builder.ToString());
        }