forked from openrs2/openrs2
This has the convenient side effect of us no longer needing to exclude the byteunits dependency from minimisation. Signed-off-by: Graham <gpe@openrs2.org>
parent
9be1a54b76
commit
193af138fe
@ -0,0 +1,9 @@ |
|||||||
|
package org.openrs2.archive.web |
||||||
|
|
||||||
|
import com.jakewharton.byteunits.BinaryByteUnit |
||||||
|
|
||||||
|
public object ByteUnits { |
||||||
|
public fun format(value: Long): String { |
||||||
|
return BinaryByteUnit.format(value).replace(" ", "\u00A0") |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,11 @@ |
|||||||
|
package org.openrs2.archive.web |
||||||
|
|
||||||
|
import org.thymeleaf.dialect.AbstractDialect |
||||||
|
import org.thymeleaf.dialect.IExpressionObjectDialect |
||||||
|
import org.thymeleaf.expression.IExpressionObjectFactory |
||||||
|
|
||||||
|
public object ByteUnitsDialect : AbstractDialect("byteunits"), IExpressionObjectDialect { |
||||||
|
override fun getExpressionObjectFactory(): IExpressionObjectFactory { |
||||||
|
return ByteUnitsExpressionFactory |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,25 @@ |
|||||||
|
package org.openrs2.archive.web |
||||||
|
|
||||||
|
import org.thymeleaf.context.IExpressionContext |
||||||
|
import org.thymeleaf.expression.IExpressionObjectFactory |
||||||
|
|
||||||
|
public object ByteUnitsExpressionFactory : IExpressionObjectFactory { |
||||||
|
private const val NAME = "byteunits" |
||||||
|
private val ALL_NAMES = setOf(NAME) |
||||||
|
|
||||||
|
override fun getAllExpressionObjectNames(): Set<String> { |
||||||
|
return ALL_NAMES |
||||||
|
} |
||||||
|
|
||||||
|
override fun buildObject(context: IExpressionContext, expressionObjectName: String): Any? { |
||||||
|
return if (expressionObjectName == NAME) { |
||||||
|
ByteUnits |
||||||
|
} else { |
||||||
|
null |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
override fun isCacheable(expressionObjectName: String): Boolean { |
||||||
|
return expressionObjectName == NAME |
||||||
|
} |
||||||
|
} |
Loading…
Reference in new issue