Example #1
0
        /**
         * Render markup
         */
        private void RenderMarkup(StringBuilder builder)
        {
            //string thisVirtualFolder = Composite.Core.IO.Path.GetDirectoryName(this.AppRelativeVirtualPath);
            //string parentVirtualFolder = thisVirtualFolder.Substring(0, thisVirtualFolder.LastIndexOf(Composite.Core.IO.Path.DirectorySeparatorChar));
            //string fullPathWindowsStyle = parentVirtualFolder.Replace( "~", HttpContext.Current.Request.ApplicationPath );

            string root = UrlUtils.AdminRootPath;

            string scriptMarkup = GetScriptMarkup();


            foreach (string ss in _defaultscripts)
            {
                string relativeLink = ss.Replace("${root}", root);

                string filePath = PathUtil.Resolve(ss.Replace("${root}", "~/Composite"));
                if (C1File.Exists(filePath))
                {
                    DateTime lastModified = C1File.GetLastWriteTimeUtc(filePath);
                    relativeLink += "?timestamp=" + lastModified.GetHashCode();
                }

                builder.AppendLine(
                    scriptMarkup.Replace("${scriptsource}", relativeLink)
                    );
            }

            if (_type == "top")
            {
                // We emit a version number - which we want the client to remember
                _ctx.Response.Cache.SetExpires(DateTime.Now.AddYears(-10));
                _ctx.Response.Cache.SetCacheability(HttpCacheability.Private);

                var  url         = _ctx.Request.Url;
                bool isLocalHost = url.Host.ToLowerInvariant() == "localhost";

                _hasServerToServerConnection = HasServerToServerConnection();

                builder.AppendLine(@"<script type=""text/javascript"">");

                Func <bool, string> toJson = b => b.ToString().ToLowerInvariant();

                builder.AppendFormat(@"Application.hasExternalConnection = {0};", toJson(_hasServerToServerConnection));
                builder.AppendFormat(@"Application.isDeveloperMode = {0};", toJson(_mode == CompositeScriptMode.DEVELOP));
                builder.AppendFormat(@"Application.isLocalHost = {0};", toJson(isLocalHost));
                builder.AppendFormat(@"Application.isOnPublicNet = {0};", toJson(UrlIsOnPublicNet(url)));

                builder.AppendLine(@"</script>");
            }
            else
            {
                if (!_updateManagerDisabled)
                {
                    builder.AppendLine(@"<script type=""text/javascript"">");
                    builder.AppendLine(@"UpdateManager.xhtml = null;");
                    builder.AppendLine(@"</script>");
                }
            }
        }
Example #2
0
        private static DateTime GetLastModifiedUtc(IEnumerable <string> relatedFiles)
        {
            DateTime maxLastModifiedUtc = DateTime.MinValue;

            foreach (var filePath in relatedFiles)
            {
                if (!string.IsNullOrWhiteSpace(filePath) && C1File.Exists(filePath))
                {
                    DateTime lastModifiedUtc = C1File.GetLastWriteTimeUtc(filePath);
                    if (lastModifiedUtc > maxLastModifiedUtc)
                    {
                        maxLastModifiedUtc = lastModifiedUtc;
                    }
                }
            }

            return(maxLastModifiedUtc);
        }
        /// <exclude />
        public static string Render(string directive = null)
        {
            string root = UrlUtils.AdminRootPath;

            bool isInDevelopMode = CookieHandler.Get("mode") == "develop";

            string styleFile = isInDevelopMode
                ? "/styles/styles.css"
                : "/styles/styles.min.css";

            string cssLink = root + styleFile;

            string filePath = PathUtil.Resolve("~/Composite" + styleFile);

            if (C1File.Exists(filePath))
            {
                cssLink += "?timestamp=" + C1File.GetLastWriteTimeUtc(filePath).GetHashCode();
            }

            return(stylesheet(cssLink));
        }
Example #4
0
 private static DateTime GetLastModifiedUtc(string filePath)
 {
     return(C1File.GetLastWriteTimeUtc(filePath));
 }