diff --git a/grails-app/controllers/org/codehaus/groovy/grails/plugins/qrcode/QrcodeController.groovy b/grails-app/controllers/org/codehaus/groovy/grails/plugins/qrcode/QrcodeController.groovy index 6ab2a24..c5f0fa9 100644 --- a/grails-app/controllers/org/codehaus/groovy/grails/plugins/qrcode/QrcodeController.groovy +++ b/grails-app/controllers/org/codehaus/groovy/grails/plugins/qrcode/QrcodeController.groovy @@ -24,7 +24,7 @@ class QrcodeController { def referer = request.getHeader("REFERER") String size = getSize(params) String backupText = "This qrcode was rendered by http://grails.org/plugin/qrcode" - qrcodeRenderer.renderPng(response,params.url?:params.text?:referer?:backupText, size?.toInteger()) + qrcodeRenderer.renderPng(response,params.url?:params.text?:referer?:backupText, size?.toInteger(), params.e, params.c) } /** @@ -33,10 +33,10 @@ class QrcodeController { def url = { String uri = params.u?:params.id?:request.getHeader("REFERER") String size = getSize(params) - qrcodeRenderer.renderPng(response, uri, size.toInteger().intValue()) + qrcodeRenderer.renderPng(response, uri, size.toInteger().intValue(), params.e, params.c) } - private String getSize(Map params) { + private static String getSize(Map params) { String size = params.s?:params.size?:params.w?:params.width if (!size || size.matches(/\D/)) { size = "300"} return size @@ -49,7 +49,7 @@ class QrcodeController { def text = { String content = params.t?:params.id String size = getSize(params) - qrcodeRenderer.renderPng(response, content, size.toInteger().intValue()) + qrcodeRenderer.renderPng(response, content, size.toInteger().intValue(), params.e, params.c) } diff --git a/grails-app/taglib/org/codehaus/groovy/grails/plugins/qrcode/QrcodeTagLib.groovy b/grails-app/taglib/org/codehaus/groovy/grails/plugins/qrcode/QrcodeTagLib.groovy index b4bfa68..6195a6a 100644 --- a/grails-app/taglib/org/codehaus/groovy/grails/plugins/qrcode/QrcodeTagLib.groovy +++ b/grails-app/taglib/org/codehaus/groovy/grails/plugins/qrcode/QrcodeTagLib.groovy @@ -24,7 +24,9 @@ class QrcodeTagLib { def url = { attrs -> def size = attrs.height?:attrs.width String target = request.getRequestURL() - String src = createLink(controller:'qrcode',action:'url',params:[u:target,s:size]) + String encoding = attrs.encoding ?: 'UTF-8' + String correction = attrs.correction ?: 'L' + String src = createLink(controller:'qrcode',action:'url',params:[u:target,s:size,e:encoding,c:correction]).replaceAll('&', '&') def mkp = new groovy.xml.MarkupBuilder(out) mkp { img(alt:url,src:src) @@ -38,7 +40,9 @@ class QrcodeTagLib { def image = { attrs -> def size = attrs.height?:attrs.width String text = attrs.text - String src = createLink(controller:'qrcode',action:'text',params:[t:text,s:size]) + String encoding = attrs.encoding ?: 'UTF-8' + String correction = attrs.correction ?: 'L' + String src = createLink(controller:'qrcode',action:'text',params:[t:text,s:size,e:encoding,c:correction]).replaceAll('&', '&') def mkp = new groovy.xml.MarkupBuilder(out) mkp { img(alt:url,src:src) @@ -52,7 +56,9 @@ class QrcodeTagLib { def label = attrs.label?:"qrlink" def size = attrs.height?:attrs.width String target = request.getRequestURL() - String src = createLink(controller:'qrcode',action:'url',params:[u:target,s:size]) + String encoding = attrs.encoding ?: 'UTF-8' + String correction = attrs.correction ?: 'L' + String src = createLink(controller:'qrcode',action:'url',params:[u:target,s:size,e:encoding,c:correction]).replaceAll('&', '&') out << '''