Cleaned up config.
This commit is contained in:
parent
bfb7ebcc09
commit
414fbc07cb
2 changed files with 19 additions and 20 deletions
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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" %>
|
||||
<jsp:doBody var="body" scope="page"/>
|
||||
<%
|
||||
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");
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue