Cleaned up config.

This commit is contained in:
Erik C. Thauvin 2024-05-25 22:15:39 -07:00
parent bfb7ebcc09
commit 414fbc07cb
Signed by: erik
GPG key ID: 776702A6A2DA330E
2 changed files with 19 additions and 20 deletions

View file

@ -35,17 +35,16 @@ import java.math.RoundingMode
/** /**
* Provides a configuration builder. * Provides a configuration builder.
*/ */
class Config private constructor(builder: Builder) { class Config @JvmOverloads constructor(
val text: String val text: String,
val wpm: Int var wpm: Int = 275,
val postfix: String var postfix: String = "min read",
val plural: String var plural: String = "min read",
val excludeImages: Boolean var excludeImages: Boolean = false,
val extra: Int var extra: Int = 0,
val roundingMode: RoundingMode var roundingMode: RoundingMode = RoundingMode.HALF_EVEN
) {
init { constructor(builder: Builder) : this(builder.text) {
text = builder.text
wpm = builder.wpm wpm = builder.wpm
postfix = builder.postfix postfix = builder.postfix
plural = builder.plural plural = builder.plural
@ -105,6 +104,6 @@ class Config private constructor(builder: Builder) {
/** /**
* Builds the configuration. * Builds the configuration.
*/ */
fun build() = Config(this) fun build(): Config = Config(this)
} }
} }

View file

@ -4,20 +4,20 @@
See: https://erik.thauvin.net/licenses/bsd.shtml See: https://erik.thauvin.net/licenses/bsd.shtml
--%> --%>
<%@tag body-content="scriptless" import="net.thauvin.erik.readingtime.ReadingTime" trimDirectiveWhitespaces="true"%> <%@tag body-content="scriptless" import="net.thauvin.erik.readingtime.ReadingTime" trimDirectiveWhitespaces="true" %>
<%@attribute name="debug" type="java.lang.Boolean"%> <%@attribute name="debug" type="java.lang.Boolean" %>
<%@attribute name="excludeImages" type="java.lang.Boolean"%> <%@attribute name="excludeImages" type="java.lang.Boolean" %>
<%@attribute name="extra" type="java.lang.Integer"%> <%@attribute name="extra" type="java.lang.Integer" %>
<%@attribute name="plural"%> <%@attribute name="plural" %>
<%@attribute name="postfix"%> <%@attribute name="postfix" %>
<%@attribute name="wpm" type="java.lang.Integer"%> <%@attribute name="wpm" type="java.lang.Integer" %>
<jsp:doBody var="body" scope="page"/> <jsp:doBody var="body" scope="page"/>
<% <%
final Boolean debug = (Boolean) getJspContext().getAttribute("debug"); final Boolean debug = (Boolean) getJspContext().getAttribute("debug");
final Boolean excludeImages = (Boolean) getJspContext().getAttribute("excludeImages"); final Boolean excludeImages = (Boolean) getJspContext().getAttribute("excludeImages");
final Integer extra = (Integer) getJspContext().getAttribute("extra"); final Integer extra = (Integer) getJspContext().getAttribute("extra");
final Integer wpm = (Integer) getJspContext().getAttribute("wpm"); 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 plural = (String) getJspContext().getAttribute("plural");
final String postfix = (String) getJspContext().getAttribute("postfix"); final String postfix = (String) getJspContext().getAttribute("postfix");