Example #1
0
        public HttpResponseMessage Load()
        {
            // Get style less url
            var pageId = int.Parse(HttpContext.Current.Request["pageId"]);

            // Get all parameters
            string paramBlock = CanvasDesignerUtility.GetLessParameters(pageId);

            // Prepare string parameter result
            string[]       paramLines = paramBlock.Trim().Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);
            IList <string> parameters = new List <string>();

            foreach (var line in paramLines)
            {
                if (!line.Contains("@import"))
                {
                    parameters.Add("\"" + line.Replace(":", "\":\"").Replace(";", "\"").Replace("@", "").Replace(";", ""));
                }
            }

            // Response
            var resp = Request.CreateResponse();

            resp.Content = new StringContent("{" + String.Join(",", parameters) + "}");
            resp.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
            return(resp);
        }
Example #2
0
        public string Init()
        {
            // Get parameters
            var config = HttpContext.Current.Request["config"];
            var pageId = int.Parse(HttpContext.Current.Request["pageId"]);

            return(CanvasDesignerUtility.CreateOrUpdateLessFile(pageId, config));
        }
Example #3
0
        public HttpResponseMessage Delete()
        {
            var pageId = HttpContext.Current.Request["pageId"];

            CanvasDesignerUtility.DeleteStyle(int.Parse(pageId));

            var resp = Request.CreateResponse();

            resp.Content = new StringContent("ok");
            resp.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
            return(resp);
        }
Example #4
0
        public HttpResponseMessage Save()
        {
            // Get parameters
            var parameters = HttpContext.Current.Request["parameters"];
            var pageId     = int.Parse(HttpContext.Current.Request["pageId"]);
            var inherited  = Boolean.Parse(HttpContext.Current.Request["inherited"]);

            // Save and compile styles
            CanvasDesignerUtility.SaveAndPublishStyle(parameters, pageId, inherited);

            var resp = Request.CreateResponse();

            resp.Content = new StringContent("ok");
            resp.Content.Headers.ContentType = new MediaTypeHeaderValue("application/json");
            return(resp);
        }