diff --git a/src/main/kotlin/net/thauvin/erik/readingtime/Config.kt b/src/main/kotlin/net/thauvin/erik/readingtime/Config.kt index d994592..6cf5900 100644 --- a/src/main/kotlin/net/thauvin/erik/readingtime/Config.kt +++ b/src/main/kotlin/net/thauvin/erik/readingtime/Config.kt @@ -35,17 +35,16 @@ import java.math.RoundingMode /** * Provides a configuration builder. */ -class Config private constructor(builder: Builder) { - val text: String - val wpm: Int - val postfix: String - val plural: String - val excludeImages: Boolean - val extra: Int - val roundingMode: RoundingMode - - init { - text = builder.text +class Config @JvmOverloads constructor( + val text: String, + var wpm: Int = 275, + var postfix: String = "min read", + var plural: String = "min read", + var excludeImages: Boolean = false, + var extra: Int = 0, + var roundingMode: RoundingMode = RoundingMode.HALF_EVEN +) { + constructor(builder: Builder) : this(builder.text) { wpm = builder.wpm postfix = builder.postfix plural = builder.plural @@ -105,6 +104,6 @@ class Config private constructor(builder: Builder) { /** * Builds the configuration. */ - fun build() = Config(this) + fun build(): Config = Config(this) } } diff --git a/src/main/resources/META-INF/tags/readingtime.tag b/src/main/resources/META-INF/tags/readingtime.tag index d0c0980..a8bd99f 100644 --- a/src/main/resources/META-INF/tags/readingtime.tag +++ b/src/main/resources/META-INF/tags/readingtime.tag @@ -4,20 +4,20 @@ See: https://erik.thauvin.net/licenses/bsd.shtml --%> -<%@tag body-content="scriptless" import="net.thauvin.erik.readingtime.ReadingTime" trimDirectiveWhitespaces="true"%> -<%@attribute name="debug" type="java.lang.Boolean"%> -<%@attribute name="excludeImages" type="java.lang.Boolean"%> -<%@attribute name="extra" type="java.lang.Integer"%> -<%@attribute name="plural"%> -<%@attribute name="postfix"%> -<%@attribute name="wpm" type="java.lang.Integer"%> +<%@tag body-content="scriptless" import="net.thauvin.erik.readingtime.ReadingTime" trimDirectiveWhitespaces="true" %> +<%@attribute name="debug" type="java.lang.Boolean" %> +<%@attribute name="excludeImages" type="java.lang.Boolean" %> +<%@attribute name="extra" type="java.lang.Integer" %> +<%@attribute name="plural" %> +<%@attribute name="postfix" %> +<%@attribute name="wpm" type="java.lang.Integer" %> <% final Boolean debug = (Boolean) getJspContext().getAttribute("debug"); final Boolean excludeImages = (Boolean) getJspContext().getAttribute("excludeImages"); final Integer extra = (Integer) getJspContext().getAttribute("extra"); final Integer wpm = (Integer) getJspContext().getAttribute("wpm"); - final String body = (String) getJspContext().getAttribute("body");; + final String body = (String) getJspContext().getAttribute("body"); final String plural = (String) getJspContext().getAttribute("plural"); final String postfix = (String) getJspContext().getAttribute("postfix");