Пример #1
0
 public IActionResult AbsoluteContent()
 {
     return(new ContentResult()
     {
         Content = Url.AbsoluteContent("UrlHelper/AbsoluteContent")
     });
 }
Пример #2
0
        public async Task <ActionResult> Upload()
        {
            var returnList = new List <MosaicoFileInfo>();

            for (int i = 0; i < Request.Files.Count; i++)
            {
                var file = Request.Files[i];

                if (file.ContentLength > 0)
                {
                    string fileName  = file.FileName;
                    string filePath  = Server.MapPath(Path.Combine("~/Media/Uploads", fileName));
                    string thumbPath = Server.MapPath(Path.Combine("~/Media/Thumbs", fileName));
                    file.SaveAs(filePath);

                    var image     = System.Drawing.Image.FromFile(filePath);
                    var thumbnail = ImageHelper.Resize(image, 120, 90);
                    thumbnail.Save(thumbPath);

                    returnList.Add(new MosaicoFileInfo
                    {
                        name         = fileName,
                        size         = file.ContentLength,
                        type         = MimeMapping.GetMimeMapping(fileName),
                        url          = Url.AbsoluteContent(string.Concat("/Media/Uploads/", fileName)),
                        thumbnailUrl = Url.AbsoluteContent(string.Concat("/Media/Thumbs/", fileName)),
                        deleteUrl    = string.Concat("/mosaico/img-delete/", fileName),
                        deleteType   = "DELETE"
                    });
                }
            }

            return(Json(new { files = returnList }));
        }
Пример #3
0
        public IActionResult Get()
        {
            var appRoot           = Url.AbsoluteContent("~/");
            var remoteServiceRoot = Url.AbsoluteContent("~/");

            var startUpData = new StartUpData(
                appName: _appConfigHelper.AppName,
                appRoot: appRoot,
                inDebug: false,
                remoteServiceRoot: remoteServiceRoot,
                version: _appConfigHelper.Version);

            return(Ok(startUpData));
        }
        private Uri ConvertToAbsoluteUri(string returnUrl)
        {
            NullGuard.NotNullOrWhiteSpace(returnUrl, nameof(returnUrl));

            if (Uri.TryCreate(returnUrl, UriKind.RelativeOrAbsolute, out Uri returnUri) == false)
            {
                return(null);
            }

            if (returnUri.IsAbsoluteUri)
            {
                return(returnUri);
            }

            return(ConvertToAbsoluteUri(Url.AbsoluteContent(returnUri.OriginalString)));
        }
Пример #5
0
        public ActionResult GetUploads()
        {
            string path = Server.MapPath("~/Media/Uploads");

            var files = (new DirectoryInfo(path)).GetFiles().Select(x => new MosaicoFileInfo
            {
                name         = x.Name,
                size         = x.Length,
                type         = MimeMapping.GetMimeMapping(x.Name),
                url          = Url.AbsoluteContent(string.Concat("/Media/Uploads/", x.Name)),
                thumbnailUrl = Url.AbsoluteContent(string.Concat("/Media/Thumbs/", x.Name)),
                deleteUrl    = string.Concat("/mosaico/img-delete/", x.Name),
                deleteType   = "DELETE"
            });

            return(Json(new { files = files }, JsonRequestBehavior.AllowGet));
        }
Пример #6
0
        public IActionResult GetUploads()
        {
            string path = Path.Combine(hostingEnvironment.WebRootPath, "Media/Uploads");

            var files = (new DirectoryInfo(path)).GetFiles().Select(x => new MosaicoFileInfo
            {
                Name         = x.Name,
                Size         = x.Length,
                Type         = MimeMapping.GetMimeMapping(x.Name),
                Url          = Url.AbsoluteContent(string.Concat("/Media/Uploads/", x.Name)),
                ThumbnailUrl = Url.AbsoluteContent(string.Concat("/Media/Thumbs/", x.Name)),
                DeleteUrl    = string.Concat("/mosaico/img-delete/", x.Name),
                DeleteType   = "DELETE"
            });

            return(Ok(new { files = files }));
        }
Пример #7
0
        public ActionResult SitemapXml()
        {
            var urls = new List <SitemapUrl>();

            foreach (var provider in providers)
            {
                urls.AddRange(provider.GetSitemapUrls(Url).ToList());
            }

            // Home page
            urls.Insert(0, new SitemapUrl("Home", Url.AbsoluteContent("~/"))
            {
                Priority = 1
            });

            return(new XmlSitemapResult(urls));
        }
Пример #8
0
        public ActionResult SitemapHtml()
        {
            var urls = new List <SitemapUrl>();

            foreach (var provider in providers)
            {
                urls.AddRange(provider.GetSitemapUrls(Url).ToList());
            }

            // Home page
            urls.Insert(0, new SitemapUrl("Home", Url.AbsoluteContent("~/"))
            {
                Priority = 1
            });

            var sb = new StringBuilder();

            using (var textWriter = new StringWriter(sb))
            {
                using (var writer = new HtmlTextWriter(textWriter))
                {
                    writer.AddAttribute(HtmlTextWriterAttribute.Class, "sitemap");
                    writer.RenderBeginTag(HtmlTextWriterTag.Div);

                    writer.AddAttribute(HtmlTextWriterAttribute.Id, "primaryNav");
                    writer.RenderBeginTag(HtmlTextWriterTag.Ul);

                    foreach (var url in urls)
                    {
                        RenderSitemapUrl(writer, url);
                    }

                    writer.RenderEndTag(); // ul
                    writer.RenderEndTag(); // div

                    writer.Flush();
                    textWriter.Flush();

                    ViewBag.Title = "Sitemap";
                    return(new ControlContentResult(sb.ToString()));
                }
            }
        }
Пример #9
0
        public async Task <IActionResult> Upload()
        {
            var files      = Request.Form.Files;
            var returnList = new List <MosaicoFileInfo>();

            foreach (var file in files)
            {
                if (file.Length > 0)
                {
                    string filePath  = Path.Combine(hostingEnvironment.WebRootPath, "Media/Uploads", file.FileName);
                    string thumbPath = Path.Combine(hostingEnvironment.WebRootPath, "Media/Thumbs", file.FileName);

                    using (var stream = new FileStream(filePath, FileMode.Create))
                    {
                        await file.CopyToAsync(stream);
                    }

                    using (var stream = new MemoryStream())
                    {
                        await file.CopyToAsync(stream);

                        var image     = System.Drawing.Image.FromStream(stream);
                        var thumbnail = ImageHelper.Resize(image, 120, 90);
                        thumbnail.Save(thumbPath);
                    }

                    returnList.Add(new MosaicoFileInfo
                    {
                        Name         = file.FileName,
                        Size         = file.Length,
                        Type         = MimeMapping.GetMimeMapping(file.FileName),
                        Url          = Url.AbsoluteContent(string.Concat("/Media/Uploads/", file.FileName)),
                        ThumbnailUrl = Url.AbsoluteContent(string.Concat("/Media/Thumbs/", file.FileName)),
                        DeleteUrl    = string.Concat("/mosaico/img-delete/", file.FileName),
                        DeleteType   = "DELETE"
                    });
                }
            }

            return(Ok(new { files = returnList }));
        }