Ejemplo n.º 1
0
    /// <summary>
    /// Wraps a piece of text in a data container.
    /// </summary>
    /// <param name="resource">Text to wrap</param>
    /// <param name="name">Identifier for the file</param>
    /// <param name="etag">Etag to use for versioning</param>
    /// <param name="lastModified">Timestamp of the last modification of data</param>
    /// <param name="minifier">Minifier to use when creating minified version of the data</param>
    /// <param name="minificationEnabled">True, if the data should be minified, otherwise false</param>
    /// <returns>Data container containing the piece of text</returns>
    private static CMSOutputResource WrapObject(string resource, string name, string etag, DateTime lastModified, IResourceMinifier minifier, bool minificationEnabled)
    {
        if (resource == null)
        {
            return(null);
        }

        // Prepare new output resource object
        CMSOutputResource wrapper = new CMSOutputResource()
        {
            Name         = name,
            Etag         = etag,
            LastModified = lastModified,
            Data         = resource,
        };

        // Set up the settings
        if (minificationEnabled)
        {
            wrapper.MinifiedData = minifier.Minify(wrapper.Data);
        }
        if (RequestHelper.AllowResourceCompression)
        {
            wrapper.CompressedData = Compress(resource);
        }
        if (minificationEnabled && RequestHelper.AllowResourceCompression)
        {
            wrapper.MinifiedCompressedData = Compress(wrapper.MinifiedData);
        }

        return(wrapper);
    }
Ejemplo n.º 2
0
    /// <summary>
    /// Minify supplied source according to settings.
    /// </summary>
    /// <param name="resource">Resource to minifz</param>
    /// <param name="minifier">Minifier to use when creating minified version of the data</param>
    /// <param name="minificationEnabled">True, if the data should be minified, otherwise false</param>
    /// <param name="compressionEnabled">True, if data should be compressed, otherwise false</param>
    private static void MinifyResource(CMSOutputResource resource, IResourceMinifier minifier, bool minificationEnabled, bool compressionEnabled)
    {
        if (resource == null)
        {
            return;
        }

        // Set up the settings
        if (minificationEnabled && (minifier != null))
        {
            resource.MinifiedData = minifier.Minify(resource.Data);
        }

        // Compress
        if (RequestHelper.AllowResourceCompression && compressionEnabled)
        {
            resource.CompressedData = Compress(resource.Data);
        }

        // Compress and minify
        if (minificationEnabled && RequestHelper.AllowResourceCompression && compressionEnabled)
        {
            resource.MinifiedCompressedData = Compress(resource.MinifiedData);
        }
    }
    /// <summary>
    /// Minify supplied source according to settings.
    /// </summary>
    /// <param name="resource">Resource to minifz</param>
    /// <param name="minifier">Minifier to use when creating minified version of the data</param>
    /// <param name="minificationEnabled">True, if the data should be minified, otherwise false</param>
    /// <param name="compressionEnabled">True, if data should be compressed, otherwise false</param>
    private static void MinifyResource(CMSOutputResource resource, IResourceMinifier minifier, bool minificationEnabled, bool compressionEnabled)
    {
        if (resource == null)
        {
            return;
        }

        // Set up the settings
        if (minificationEnabled && (minifier != null))
        {
            resource.MinifiedData = minifier.Minify(resource.Data);
        }

        // Check whether the compression is enabled
        if (compressionEnabled && CMSAppBase.ConnectionAvailable)
        {
            compressionEnabled &= RequestHelper.AllowResourceCompression;
        }

        // Compress
        if (compressionEnabled)
        {
            resource.CompressedData = Compress(resource.Data);
        }

        // Compress and minify
        if (minificationEnabled && compressionEnabled)
        {
            resource.MinifiedCompressedData = Compress(resource.MinifiedData);
        }
    }
Ejemplo n.º 4
0
    /// <summary>
    /// Wraps a piece of text in a data container.
    /// </summary>
    /// <param name="resource">Text to wrap</param>
    /// <param name="name">Identifier for the file</param>
    /// <param name="etag">Etag to use for versioning</param>
    /// <param name="lastModified">Timestamp of the last modification of data</param>
    /// <param name="minifier">Minifier to use when creating minified version of the data</param>
    /// <param name="minificationEnabled">True, if the data should be minified, otherwise false</param>
    /// <returns>Data container containing the piece of text</returns>
    private static CMSOutputResource WrapObject(string resource, string name, string etag, DateTime lastModified, IResourceMinifier minifier, bool minificationEnabled)
    {
        if (resource == null)
        {
            return null;
        }

        // Prepare new output resource object
        CMSOutputResource wrapper = new CMSOutputResource()
        {
            Name = name,
            Etag = etag,
            LastModified = lastModified,
            Data = resource,
        };

        // Set up the settings
        if (minificationEnabled)
        {
            wrapper.MinifiedData = minifier.Minify(wrapper.Data);
        }
        if (RequestHelper.AllowResourceCompression)
        {
            wrapper.CompressedData = Compress(resource);
        }
        if (minificationEnabled && RequestHelper.AllowResourceCompression)
        {
            wrapper.MinifiedCompressedData = Compress(wrapper.MinifiedData);
        }

        return wrapper;
    }
Ejemplo n.º 5
0
    /// <summary>
    /// Minify supplied source according to settings.
    /// </summary>
    /// <param name="resource">Resource to minifz</param>
    /// <param name="minifier">Minifier to use when creating minified version of the data</param>
    /// <param name="minificationEnabled">True, if the data should be minified, otherwise false</param>
    /// <param name="compressionEnabled">True, if data should be compressed, otherwise false</param>
    private static void MinifyResource(CMSOutputResource resource, IResourceMinifier minifier, bool minificationEnabled, bool compressionEnabled)
    {
        if (resource == null)
        {
            return;
        }

        // Set up the settings
        if (minificationEnabled && (minifier != null))
        {
            resource.MinifiedData = minifier.Minify(resource.Data);
        }

        // Compress
        if (RequestHelper.AllowResourceCompression && compressionEnabled)
        {
            resource.CompressedData = Compress(resource.Data);
        }

        // Compress and minify
        if (minificationEnabled && RequestHelper.AllowResourceCompression && compressionEnabled)
        {
            resource.MinifiedCompressedData = Compress(resource.MinifiedData);
        }
    }