Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Don't add reloading stub for adhoc resources in dev mode #52

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion ResourcesGrailsPlugin.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class ResourcesGrailsPlugin {
static DEFAULT_URI_PREFIX = 'static'
static DEFAULT_ADHOC_PATTERNS = ["/images/*", "*.css", "*.js"].asImmutable()

def version = "1.2"
def version = "1.2-FAST"
def grailsVersion = "1.3 > *"

def loadAfter = ['logging'] // retained to ensure correct loading under Grails < 2.0
Expand Down
14 changes: 11 additions & 3 deletions src/groovy/org/grails/plugin/resource/DevModeSanityFilter.groovy
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package org.grails.plugin.resource

import javax.servlet.*
import org.springframework.web.context.support.WebApplicationContextUtils
import grails.util.Environment

import javax.servlet.*
/**
* This just traps any obvious mistakes the user has made and warns them in dev mode
*
Expand Down Expand Up @@ -37,7 +35,17 @@ class DevModeSanityFilter implements Filter {
void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {

boolean processReloading = false

if (grailsResourceProcessor.reloading) {
if (grailsResourceProcessor.isDebugMode(request) && request.getAttribute('resources.adhoc')) {
processReloading = false //don't add reloading stub for adhoc resources in dev mode
} else {
processReloading = true
}
}

if (processReloading) {
response.contentType = "text/html"
response.writer << RELOADING_DOC
} else {
Expand Down
5 changes: 2 additions & 3 deletions src/groovy/org/grails/plugin/resource/ProcessingFilter.groovy
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
package org.grails.plugin.resource

import javax.servlet.*
import org.springframework.web.context.support.WebApplicationContextUtils
import grails.util.Environment

import javax.servlet.*
/**
* This is the servlet filter that handles all static resource requests and delegates to the service
* to return them.
Expand Down Expand Up @@ -31,6 +29,7 @@ class ProcessingFilter implements Filter {
def debugging = grailsResourceProcessor.isDebugMode(request)
if (debugging) {
request.setAttribute('resources.debug', debugging)
if (adhoc) request.setAttribute('resources.adhoc', true)
}
if (!debugging) {
if (adhoc) {
Expand Down