Esempio n. 1
0
        public async Task<ActionResult> RenderBlob(Errorable<TreeBlobPath> epath, DateTimeOffset? viewDate)
        {
            Debug.Assert(epath != null);
            if (epath.HasErrors) return ErrorJson(epath);
            var path = epath.Value;

            // Get the stream for the blob by its path:
            var eblob = await cms.tpsbrepo.GetBlobByTreePath(epath.Value);
            if (eblob.HasErrors) return ErrorJson(eblob);

            TreePathStreamedBlob blob = eblob.Value;
            if (blob == null) return new HttpNotFoundResult(String.Format("A blob could not be found off tree {0} by path '{0}'", path.RootTreeID.ToString(), path.Path.ToString()));

            // Render the blob:
            var renderer = new RenderingSystemContext(cms, viewDate);
            var ehtml = await renderer.Engine.RenderBlob(blob);
            if (ehtml.HasErrors) return ErrorJson(ehtml);

            var html = ehtml.Value;

            // HTML5 output:
            return Content((string)html, "application/xhtml+xml", Encoding.UTF8);
        }
Esempio n. 2
0
        public ActionResult ValidateBlob()
        {
            // Validate the blob's contents:
            var renderer = new RenderingSystemContext(cms);
            var vr = renderer.Engine.ValidateBlob(Request.InputStream);

            // Return the validation results:
            return Json(new
            {
                successful = (vr == null),
                error = (vr == null) ? (object)null : new { message = vr.Message, lineNumber = vr.LineNumber, linePosition = vr.LinePosition }
            });
        }