Coder Social home page Coder Social logo

lombiq / combinator Goto Github PK

View Code? Open in Web Editor NEW
8.0 8.0 4.0 1.53 MB

An Orchard CMS module that combines and minifies external stylesheets and javascript files to cut down on load times.

License: Other

C# 94.93% HTML 5.07%
orchard orchard-cms orchard-module performance

combinator's People

Contributors

benedekfarkas avatar dragonnhun avatar i3undy avatar piedone avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

combinator's Issues

Clear cache for a fresh deployment (COLI-1199)

I'm looking for the simplest way to get the Combinator cache cleared when the application is deployed and then starts for the first time.

The best I came up with so far that is reliable and simple enough is that the deployment package includes a specific marker file that Combinator would detect when the tenant starts. If the file is present, Combinator clears its cache and then deletes the file so that subsequent shell starts wouldn't trigger the cache clear process.

For the deployment process to pick the file up automatically (without changing Orchard.proj and ideally Piedone.Combinator.csproj either) it should be in the App_Data folder, e.g. /App_Data/Sites/<tenantname>/_PiedoneModules/Combinator/, so that it can also be tenant-specific, but the file needs to be checked into the repository.

Keep in mind that the context here is a single-tenant application or one that has a low number of tenants, thus I didn't want to overengineer this for proper scalability unless it's actually needed.

Invalid URI: The hostname could not be parsed exception

I have noticed there are quite a few errors like below in the log file.

System.UriFormatException: Invalid URI: The hostname could not be parsed.
   at System.Uri.CreateThis(String uri, Boolean dontEscape, UriKind uriKind)
   at System.Uri..ctor(String uriString)
   at Orchard.DisplayManagement.Descriptors.ResourceBindingStrategy.StaticFileBindingStrategy.GetAlternateShapeNameFromFileName(String fileName) in D:\Proj\Src\Orchard\DisplayManagement\Descriptors\ResourceBindingStrategy\StylesheetBindingStrategy.cs:line 46

My observation was, the below line from method CombinedResourceManager.TraverseResouceShapes supplies a fullpath value(like //127.0.0.1:10000/devstoreaccount1/media/Default/_PiedoneModules/Combinator/Styles/-2140532205-6.css?timestamp=131261368560000000) that's already been combined by the combinator.

var shapeName = StaticFileBindingStrategy.GetAlternateShapeNameFromFileName(fullPath);

My combinator settings are not right?

Combinator after clear cache freeze the server

I have a multitenant configuration of orchard 1.9.3 and every time I clear combinator cache the server gets unresponsive for several minutes, at least 10, what could be the reason of it ? is there any way of avoiding it?

Correctly handle font face sources

@Piedone created on Sep 5, 2014:
https://combinator.codeplex.com/workitem/68

Font-face declarations can't be in combined resources if a remote resource storage or different resource base URL domain is used since their srcs should point to URLs under the website's domain.

This means that any CSS with a font-face declaration that has an src pointing to an URL needs either to point back to the site (but this defeats resource sharing) or allow-origin should be configured, see: http://stackoverflow.com/questions/11616306/css-font-face-absolute-url-from-external-domain-fonts-not-loading-in-firefox

To go with the first one and point srcs to the site domain we'd need to detect if we're dealing with the src declaration of a font-face block. This needs ExCSS: #7

Clustered sites behind load balancer

Hi,
We have one DB for all 4 sites that we have which are behind a load balancer, and its causing us some issues because each time we are doing some changes (js, css) we need to copy the minified combinator files from one environment to other 3.
The problem with this method is that we can have situations when during testing we didn’t access some page or state of the page, and combinator didn’t generate the minified files for it, in this case after copying the files to other 3 environments we will not have all the minified files from combinator that we need.

Is there a solution for this?

Combinator fails in Redis setup

CacheServiceMonitor class internally uses ConcurrentDictionary to track cachekeys. This ConcurrentDictionary does not reflect the previous entries added when the redis caching is enabled.
I guess, the modified ConcurrentDictionary must be persisted every time it goes through a change since the persistence is not automatic.

Russian characters becomes "????" after compression

Hello.
Few our javascript files may contain some Russian characters for the notification messages for example. In the compressed js files these messages becomes like this:
var a=$("<div><p>Hello world!</p><p>?????? ???!</p><p>?? ? ?? ???????????!</p></div>");$("#layout-main").append(a);

We solved this issue by setting encoding property of the compressor in the MinificationService class:

public string MinifyJavaScript(string javaScript)
{
    if (string.IsNullOrEmpty(javaScript)) return string.Empty;

    var compressor = new JavaScriptCompressor();

    compressor.Encoding = Encoding.UTF8;

    return compressor.Compress(javaScript);
}

Convert relative URLs to absolute ones pointing to the site domain when processing font URLs

@Piedone created on Jul 30, 2014:
https://orchardwatcher.codeplex.com/workitem/2

Premises: processed resources should be stored in a remote storage AND using a resource base URL.

There's an issue when there are local source URLs for fonts, e.g.:

@font-face {
  font-family: 'FontAwesome';
  src: url('../Content/fonts/fontawesome-webfont.eot?v=4.0.3');
  src: url('../Content/fonts/fontawesome-webfont.eot?#iefix&v=4.0.3') format('embedded-opentype'), url('../Content/fonts/fontawesome-webfont.woff?v=4.0.3') format('woff'), url('../Content/fonts/fontawesome-webfont.ttf?v=4.0.3') format('truetype'), url('../Content/fonts/fontawesome-webfont.svg?v=4.0.3#fontawesomeregular') format('svg');
  font-weight: normal;
  font-style: normal;
}

These URLs, when the processed resource is saved to the remote storage, will be converted to unified relative, then protocoll-less absolute paths (see ResourceProcessingService.ConvertRelativeUrlsToAbsolute()). This causes a cross-origin error though: such fonts should rather be fetched from the site directly (i.e. their URL re-written as absolute ones, but pointing to the calling site).

The check needed for this could be made whether the current property is under font-face, but this can only be made from ExCSS, when that will be used in Combinator.

Alternatively you could enable CORS on the remote storage. This is a way to do it on Azure Blob storage: http://blog.codingoutloud.com/2014/02/21/stupid-azure-trick-6-a-cors-toggler-command-line-tool-for-windows-azure-blobs/ (on DotNest we'd indeed need to allow * because of the arbitrary site URLs, what is bad...).

The current workaround is to exclude the whole stylesheet containing the font face.

Exclusion filters won't take effect with resource sharing if resource is already processed

@Piedone created on Jul 3, 2014:
https://combinator.codeplex.com/workitem/60

With resource sharing enabled if you set up exclusion filters to exclude a set of resources then if that set was already processed and is saved to the resource share than exclusion filters won't take effect and the saved resource will be used.

E.g. set exclusion filter to ".*". If jQuery (let's assume there's a set of resources that solely consists of jQuery) was already processed and is saved to the resource share than it will be taken, despite the exclusion filter.

File is being used by another process (COLI-1216)

I have some entries in the log files:

2023-09-27 13:23:12,833 [101] Piedone.Combinator.CombinedResourceManager - Default - Error when combining Style files [https://mysite/controller?somethingId=6865]
System.IO.IOException: The process cannot access the file 'D:\Sites\mysite\Media\Default_PiedoneModules\Combinator\Styles\662943427-1.css' because it is being used by another process.
at System.IO.__Error.WinIOError(Int32 errorCode, String maybeFullPath)
at System.IO.FileInfo.Delete()
at Piedone.Combinator.Services.CacheFileService.Save(String fingerprint, CombinatorResource resource, ICombinatorSettings settings)
at Piedone.Combinator.Services.CombinatorService.<>c__DisplayClass15_0.b__0(CombinatorResource combinedResource, List1 containedResources) at Piedone.Combinator.Services.CombinatorService.Combine(IList1 resources, String fingerprint, ResourceType resourceType, ICombinatorSettings settings, Boolean saveOnlySharedResources)
at Piedone.Combinator.Services.CombinatorService.CombineStylesheets(IList`1 resources, ICombinatorSettings settings)
at Piedone.Combinator.CombinedResourceManager.BuildRequiredResources(String stringResourceType)

As you can see it's a CSS file but the same applies to JS files too. I'm not sure what's the root cause of this issue and I haven't found any correlation with clearing the combinator cache so far. This needs further investigation but this log entry happens from time to time.

RegexAdjustRelativePaths does not take account of cache file being stored on different url (i.e. blob storage)

rdobson created on Sep 3, 2014:
https://combinator.codeplex.com/workitem/66

I have changed to the following:

private static void RegexAdjustRelativePaths(CombinatorResource resource, Uri cacheFileUri)
{
    RegexProcessUrls(resource,
        (match) =>
        {
            var url = match.Groups[1].ToString();

            var uri = RegexMakeInlineUri(resource, url);

            // Remote paths are preserved as full urls, local paths become uniformed relative ones.
            var uriString = "";
            if (resource.IsCdnResource || resource.AbsoluteUrl.Host != uri.Host || resource.AbsoluteUrl.Port != uri.Port)
                uriString = uri.ToProtocolRelative();
            else if (cacheFileUri != null && (cacheFileUri.Host != uri.Host || cacheFileUri.Port != uri.Port))
                uriString = uri.ToProtocolRelative();
            else
                uriString = uri.PathAndQuery;

            return "url(\"" + uriString + "\")";
        });
}

I am passing in a uri of a fake file in storage to check against using the following method in CacheFileService:

public Uri GetUri() {
        try {
            var publicUrl = _storageProvider.GetPublicUrl("test.txt");
            return new Uri(publicUrl);
        }
// ReSharper disable once EmptyGeneralCatchClause
        catch {
        }
        return null;
    }

Does not use the ToRootUrlString to ensure port numbers are correct

rdobson created on Sep 3, 2014:
https://combinator.codeplex.com/workitem/65

I have created my own extension method that calls the built in Orchard method but instead returns a Uri of the following in UriExtensions.cs:

public static Uri ToBaseUri(this HttpRequestBase request) {
        return new Uri(request.ToRootUrlString());
    }

Then used this instead of Request.Url in:

  • Models/CombinatorResource.cs AbsoluteUrl
  • Services/CacheFileService.cs GetCombinedResources

[1.9.1] A tenant could not be started & null exception

Xeevis created on Jul 10, 2015:
https://combinator.codeplex.com/workitem/76

On Orchard 1.9.1 with latest commits of both Combinator (f9afb20278e8) & Helpful Libraries (1d415cb8fb4b), when Combinator is enabled I get constantly "A tenant could not be started" error.

Very simple steps

  1. Fresh install of Orchard 1.9.1

  2. Enable Combinator

  3. Same error logged on every app start (every time app is restarted and frontend page refreshed)

    2015-07-10 17:37:52,953 [6] Orchard.Environment.DefaultOrchardHost - (null) - A tenant could not be started: Default
    (null)
    Autofac.Core.DependencyResolutionException: An exception was thrown while executing a resolve operation. See the InnerException for details. ---> Object reference not set to an instance of an object. (See inner exception for details.) ---> System.NullReferenceException: Object reference not set to an instance of an object.
    at Orchard.Environment.WorkContextAccessor.HttpContextScopeImplementation..ctor(IEnumerable1 events, ILifetimeScope lifetimeScope, HttpContextBase httpContext, Object workContextKey) in z:\Builds\work\9f6cd39ff0f68f41\src\Orchard\Environment\WorkContextAccessor.cs:line 88 at Orchard.Environment.WorkContextAccessor.CreateWorkContextScope(HttpContextBase httpContext) in z:\Builds\work\9f6cd39ff0f68f41\src\Orchard\Environment\WorkContextAccessor.cs:line 49 at Orchard.Mvc.MvcModule.HttpContextBaseFactory(IComponentContext context) in z:\Builds\work\9f6cd39ff0f68f41\src\Orchard\Mvc\MvcModule.cs:line 54 at Orchard.Mvc.MvcModule.RequestContextFactory(IComponentContext context) in z:\Builds\work\9f6cd39ff0f68f41\src\Orchard\Mvc\MvcModule.cs:line 80 at Autofac.RegistrationExtensions.<>c__DisplayClass101.b__f(IComponentContext c, IEnumerable`1 p)

If combinator is disabled, error is no longer produced. I'm not observing any disruption in service, only the log entry.

Table "Piedone_Combinator_CombinedFileRecord" is locked in sql server

We are permanently getting a table locked after the first request. Every next request receives a timeout error and nothing is minified.

To resolve this issue we did next changes in CacheFileService.cs in the Save() method:

            ...
                LastUpdatedUtc = resource.LastUpdatedUtc,
                Settings = _combinatorResourceManager.SerializeResourceSettings(resource)
            };

           _transactionManager.GetSession().Transaction.Begin();
           _fileRepository.Create(fileRecord);
           _fileRepository.Flush();
           _transactionManager.GetSession().Transaction.Commit();

Project logo

hey there, do you need a logo for this project? I am a graphic designer, just tell me if you need one. cheers

CDN configuration from the site general settings is ignored

There is a configuration "Use CDN" under site general settings is ignored when combinator is enabled. It always picks the local version and falls back to cdn only when local resource url is not set.
I see the below method from ResourceDefinitionExtensions.cs is used to get the full path which has no access to the site settings.

 public static string GetFullPath(this ResourceDefinition resource)
        {
            if (string.IsNullOrEmpty(resource.Url)) return resource.UrlCdn;

            if (resource.Url.Contains("~")) return resource.Url;

            return Path.Combine(resource.BasePath, resource.Url);
        }

LESS compiler does not resolve imports with relative paths

Dunross created on Sep 15, 2013:
https://combinator.codeplex.com/workitem/53

Sample scenario: Download Bootstrap as LESS files and try to load it using Combinator LESS file support. It reports "You are importing a file ending in .less that cannot be found."

The reason is that all imports in Bootstrap have relative paths (otherwise it would not be usable in all installations), but the LESS compiler isn't configured to set the "current directory" to the compiled file location.

It needs to be configured.

Extra phantom module listed in admin page

Orchard 1.9.2.0
Combinator download from master branch as zip, extracted to folder with the -master removed from end
Helpful Lib same as above

image

Shows the two libraries at the top so I thought they were the correct ones but then I saw no dependency listed.

If I filter the view it shows the proper one in its proper place:

image

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.