diff --git a/src/main/kotlin/com/vandenbreemen/ktt/api/SystemAccess.kt b/src/main/kotlin/com/vandenbreemen/ktt/api/SystemAccess.kt new file mode 100644 index 0000000..e291075 --- /dev/null +++ b/src/main/kotlin/com/vandenbreemen/ktt/api/SystemAccess.kt @@ -0,0 +1,13 @@ +package com.vandenbreemen.ktt.api + +/** + * Store and retrieve values from the underlying wiki system + */ +interface SystemAccess { + + fun storeValue(key: String, value: String) + + fun retrieveValue(key: String): String? + + +} \ No newline at end of file diff --git a/src/main/kotlin/com/vandenbreemen/ktt/interactor/ConfigurationInteractor.kt b/src/main/kotlin/com/vandenbreemen/ktt/interactor/ConfigurationInteractor.kt index 730978f..80e909e 100644 --- a/src/main/kotlin/com/vandenbreemen/ktt/interactor/ConfigurationInteractor.kt +++ b/src/main/kotlin/com/vandenbreemen/ktt/interactor/ConfigurationInteractor.kt @@ -6,7 +6,7 @@ import com.vandenbreemen.ktt.view.UIConfiguration /** * Handle anything relating to configuration of the system, including some UI shortcuts etc. */ -class ConfigurationInteractor(private val wikiRepository: SQLiteWikiRepository) { +internal class ConfigurationInteractor(private val wikiRepository: SQLiteWikiRepository) { fun getPort(): Int { return wikiRepository.getUIConfiguration().runPort diff --git a/src/main/kotlin/com/vandenbreemen/ktt/interactor/CustomCssInteractor.kt b/src/main/kotlin/com/vandenbreemen/ktt/interactor/CustomCssInteractor.kt index a4d68b3..f203840 100644 --- a/src/main/kotlin/com/vandenbreemen/ktt/interactor/CustomCssInteractor.kt +++ b/src/main/kotlin/com/vandenbreemen/ktt/interactor/CustomCssInteractor.kt @@ -4,7 +4,7 @@ import com.vandenbreemen.ktt.model.StylesheetType import com.vandenbreemen.ktt.persistence.SQLiteWikiRepository import com.vandenbreemen.ktt.web.css -class CustomCssInteractor(private val repository: SQLiteWikiRepository) { +internal class CustomCssInteractor(private val repository: SQLiteWikiRepository) { /** * Creates/updates stylesheet for the given type of content diff --git a/src/main/kotlin/com/vandenbreemen/ktt/interactor/SystemAccessInteractor.kt b/src/main/kotlin/com/vandenbreemen/ktt/interactor/SystemAccessInteractor.kt index 413d9e8..5017250 100644 --- a/src/main/kotlin/com/vandenbreemen/ktt/interactor/SystemAccessInteractor.kt +++ b/src/main/kotlin/com/vandenbreemen/ktt/interactor/SystemAccessInteractor.kt @@ -1,17 +1,18 @@ package com.vandenbreemen.ktt.interactor +import com.vandenbreemen.ktt.api.SystemAccess import com.vandenbreemen.ktt.persistence.SQLiteWikiRepository /** * Interactor that provides access to a limited set of features on the KTT system. Use this * for allowing plugins/macros to store and retrieve their own types of data */ -class SystemAccessInteractor(private val repository: SQLiteWikiRepository) { - fun storeValue(key: String, value: String) { +internal class SystemAccessInteractor(private val repository: SQLiteWikiRepository): SystemAccess { + override fun storeValue(key: String, value: String) { repository.storeValue(key, value) } - fun retrieveValue(key: String): String? { + override fun retrieveValue(key: String): String? { return repository.retrieveValue(key) } diff --git a/src/main/kotlin/com/vandenbreemen/ktt/interactor/WikiInteractor.kt b/src/main/kotlin/com/vandenbreemen/ktt/interactor/WikiInteractor.kt index d54dcf3..cb6ce5e 100644 --- a/src/main/kotlin/com/vandenbreemen/ktt/interactor/WikiInteractor.kt +++ b/src/main/kotlin/com/vandenbreemen/ktt/interactor/WikiInteractor.kt @@ -5,7 +5,7 @@ import com.vandenbreemen.ktt.model.Page import com.vandenbreemen.ktt.model.PageSearchResult import com.vandenbreemen.ktt.persistence.SQLiteWikiRepository -class WikiInteractor(private val testWikiInteractor: TestWikiInteractor, private val repository: SQLiteWikiRepository) { +internal class WikiInteractor(private val testWikiInteractor: TestWikiInteractor, private val repository: SQLiteWikiRepository) { /** * fetch the page with the given ID diff --git a/src/main/kotlin/com/vandenbreemen/ktt/interactor/WikiPageTagsInteractor.kt b/src/main/kotlin/com/vandenbreemen/ktt/interactor/WikiPageTagsInteractor.kt index 78db43c..9ebff9b 100644 --- a/src/main/kotlin/com/vandenbreemen/ktt/interactor/WikiPageTagsInteractor.kt +++ b/src/main/kotlin/com/vandenbreemen/ktt/interactor/WikiPageTagsInteractor.kt @@ -2,7 +2,7 @@ package com.vandenbreemen.ktt.interactor import com.vandenbreemen.ktt.persistence.SQLiteWikiRepository -class WikiPageTagsInteractor(private val repository: SQLiteWikiRepository) { +internal class WikiPageTagsInteractor(private val repository: SQLiteWikiRepository) { fun addUpdatePageTags(pageId: String, tagsString: String) { val tags = tagsString.split("[\\s]*[,][\\s]*".toRegex()) diff --git a/src/main/kotlin/com/vandenbreemen/ktt/macro/AboutMacro.kt b/src/main/kotlin/com/vandenbreemen/ktt/macro/AboutMacro.kt index 1b2930c..786443b 100644 --- a/src/main/kotlin/com/vandenbreemen/ktt/macro/AboutMacro.kt +++ b/src/main/kotlin/com/vandenbreemen/ktt/macro/AboutMacro.kt @@ -1,15 +1,15 @@ package com.vandenbreemen.ktt.macro -import com.vandenbreemen.ktt.interactor.SystemAccessInteractor +import com.vandenbreemen.ktt.api.SystemAccess -class AboutMacro(): Macro { +internal class AboutMacro(): Macro { override val name: String get() = "kttAbout" override val description: String? get() = "Displays the standard about and ascii art for the wiki" - override fun execute(args: Map, systemAccessInteractor: SystemAccessInteractor): String { + override fun execute(args: Map, systemAccessInteractor: SystemAccess): String { val about = javaClass.getResource("/about.dat").readText() diff --git a/src/main/kotlin/com/vandenbreemen/ktt/macro/Macro.kt b/src/main/kotlin/com/vandenbreemen/ktt/macro/Macro.kt index 1f58271..7739fd8 100644 --- a/src/main/kotlin/com/vandenbreemen/ktt/macro/Macro.kt +++ b/src/main/kotlin/com/vandenbreemen/ktt/macro/Macro.kt @@ -1,6 +1,6 @@ package com.vandenbreemen.ktt.macro -import com.vandenbreemen.ktt.interactor.SystemAccessInteractor +import com.vandenbreemen.ktt.api.SystemAccess /** * Description of a macro along with logic for processing it etc @@ -17,5 +17,5 @@ interface Macro { /** * Execute with the parameters, returning content as a string. Content should be in markdown */ - fun execute(args: Map, systemAccessInteractor: SystemAccessInteractor): String + fun execute(args: Map, systemAccessInteractor: SystemAccess): String } \ No newline at end of file diff --git a/src/main/kotlin/com/vandenbreemen/ktt/macro/MacroRegistryMacro.kt b/src/main/kotlin/com/vandenbreemen/ktt/macro/MacroRegistryMacro.kt index f20cbfd..e622c35 100644 --- a/src/main/kotlin/com/vandenbreemen/ktt/macro/MacroRegistryMacro.kt +++ b/src/main/kotlin/com/vandenbreemen/ktt/macro/MacroRegistryMacro.kt @@ -1,8 +1,8 @@ package com.vandenbreemen.ktt.macro -import com.vandenbreemen.ktt.interactor.SystemAccessInteractor +import com.vandenbreemen.ktt.api.SystemAccess -class MacroRegistryMacro(private val macroRegistry: MacroRegistry): Macro { +internal class MacroRegistryMacro(private val macroRegistry: MacroRegistry): Macro { override val name: String get() = "macros" @@ -10,7 +10,7 @@ class MacroRegistryMacro(private val macroRegistry: MacroRegistry): Macro { override val description: String? get() = "Lists all macros currently available in this wiki" - override fun execute(args: Map, systemAccessInteractor: SystemAccessInteractor): String { + override fun execute(args: Map, systemAccessInteractor: SystemAccess): String { return """ --------------------------------- diff --git a/src/main/kotlin/com/vandenbreemen/ktt/main/WikiApplication.kt b/src/main/kotlin/com/vandenbreemen/ktt/main/WikiApplication.kt index cd0e1ff..98f074e 100644 --- a/src/main/kotlin/com/vandenbreemen/ktt/main/WikiApplication.kt +++ b/src/main/kotlin/com/vandenbreemen/ktt/main/WikiApplication.kt @@ -1,5 +1,6 @@ package com.vandenbreemen.ktt.main +import com.vandenbreemen.ktt.api.SystemAccess import com.vandenbreemen.ktt.interactor.* import com.vandenbreemen.ktt.macro.AboutMacro import com.vandenbreemen.ktt.macro.MacroRegistry @@ -19,7 +20,7 @@ import com.vandenbreemen.ktt.web.startServer object WikiApplication { private val repository = SQLiteWikiRepository(("main.db")) - val systemAccessInteractor = SystemAccessInteractor(repository) + val systemAccessInteractor: SystemAccess = SystemAccessInteractor(repository) private val pageRenderingPluginRegistry: PageRenderingPluginRegistry by lazy { PageRenderingPluginRegistry() diff --git a/src/main/kotlin/com/vandenbreemen/ktt/persistence/SQLiteWikiRepository.kt b/src/main/kotlin/com/vandenbreemen/ktt/persistence/SQLiteWikiRepository.kt index 7c0354e..575dec2 100644 --- a/src/main/kotlin/com/vandenbreemen/ktt/persistence/SQLiteWikiRepository.kt +++ b/src/main/kotlin/com/vandenbreemen/ktt/persistence/SQLiteWikiRepository.kt @@ -10,7 +10,7 @@ import com.vandenbreemen.ktt.view.UIConfiguration import java.util.concurrent.ConcurrentHashMap import java.util.concurrent.TimeUnit -class SQLiteWikiRepository(private val databasePath: String) { +internal class SQLiteWikiRepository(private val databasePath: String) { private val dao = SQLiteDAO(databasePath) diff --git a/src/main/kotlin/com/vandenbreemen/ktt/presenter/WikiPresenter.kt b/src/main/kotlin/com/vandenbreemen/ktt/presenter/WikiPresenter.kt index 2135fe8..12dc6dc 100644 --- a/src/main/kotlin/com/vandenbreemen/ktt/presenter/WikiPresenter.kt +++ b/src/main/kotlin/com/vandenbreemen/ktt/presenter/WikiPresenter.kt @@ -12,7 +12,7 @@ import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.Dispatchers import kotlinx.coroutines.launch -class WikiPresenter(private val wikiInteractor: WikiInteractor, private val pageTagsInteractor: WikiPageTagsInteractor, +internal class WikiPresenter(private val wikiInteractor: WikiInteractor, private val pageTagsInteractor: WikiPageTagsInteractor, private val breadcrumbsInteractor: BreadcrumbsInteractor = BreadcrumbsInteractor(), private val customCssInteractor: CustomCssInteractor, ) { diff --git a/src/main/kotlin/com/vandenbreemen/ktt/view/plugins/MacrosPlugin.kt b/src/main/kotlin/com/vandenbreemen/ktt/view/plugins/MacrosPlugin.kt index cfe24e0..3482dfe 100644 --- a/src/main/kotlin/com/vandenbreemen/ktt/view/plugins/MacrosPlugin.kt +++ b/src/main/kotlin/com/vandenbreemen/ktt/view/plugins/MacrosPlugin.kt @@ -1,10 +1,10 @@ package com.vandenbreemen.ktt.view.plugins -import com.vandenbreemen.ktt.interactor.SystemAccessInteractor +import com.vandenbreemen.ktt.api.SystemAccess import com.vandenbreemen.ktt.macro.MacroRegistry import com.vandenbreemen.ktt.view.PageRenderingPlugin -class MacrosPlugin(private val macroRegistry: MacroRegistry, private val systemAccessInteractor: SystemAccessInteractor): PageRenderingPlugin { +internal class MacrosPlugin(private val macroRegistry: MacroRegistry, private val systemAccessInteractor: SystemAccess): PageRenderingPlugin { override fun process(markdown: String): String { val allMacros = "[{]@macro:([a-zA-Z0-9]+)[\\s]*([^}]*)[}]".toRegex().findAll(markdown) diff --git a/src/main/kotlin/com/vandenbreemen/ktt/view/plugins/PageLinkPlugin.kt b/src/main/kotlin/com/vandenbreemen/ktt/view/plugins/PageLinkPlugin.kt index e6e8d2b..4dab369 100644 --- a/src/main/kotlin/com/vandenbreemen/ktt/view/plugins/PageLinkPlugin.kt +++ b/src/main/kotlin/com/vandenbreemen/ktt/view/plugins/PageLinkPlugin.kt @@ -3,7 +3,7 @@ package com.vandenbreemen.ktt.view.plugins import com.vandenbreemen.ktt.persistence.SQLiteWikiRepository import com.vandenbreemen.ktt.view.PageRenderingPlugin -class PageLinkPlugin(private val repository: SQLiteWikiRepository): PageRenderingPlugin { +internal class PageLinkPlugin(private val repository: SQLiteWikiRepository): PageRenderingPlugin { override fun process(markdown: String): String { return markdown.replace("(\\s|^)[\\[]([A-Za-z0-9 .()-]+)[\\]]".toRegex(setOf(RegexOption.MULTILINE))) { diff --git a/src/main/kotlin/com/vandenbreemen/ktt/web/MainServer.kt b/src/main/kotlin/com/vandenbreemen/ktt/web/MainServer.kt index a89e81e..cd3a045 100644 --- a/src/main/kotlin/com/vandenbreemen/ktt/web/MainServer.kt +++ b/src/main/kotlin/com/vandenbreemen/ktt/web/MainServer.kt @@ -23,7 +23,7 @@ import java.io.File val logger = LoggerFactory.getLogger("MainServer") -fun startServer(staticContentInteractor: StaticContentInteractor, configInteractor: ConfigurationInteractor, +internal fun startServer(staticContentInteractor: StaticContentInteractor, configInteractor: ConfigurationInteractor, renderingInteractor: PageRenderingInteractor, presenter: WikiPresenter ) { diff --git a/src/test/kotlin/com/vandenbreemen/ktt/interactor/ConfigurationInteractorTest.kt b/src/test/kotlin/com/vandenbreemen/ktt/interactor/ConfigurationInteractorTest.kt index 0405aa9..bf10d1a 100644 --- a/src/test/kotlin/com/vandenbreemen/ktt/interactor/ConfigurationInteractorTest.kt +++ b/src/test/kotlin/com/vandenbreemen/ktt/interactor/ConfigurationInteractorTest.kt @@ -6,7 +6,7 @@ import org.junit.jupiter.api.AfterEach import org.junit.jupiter.api.Test import java.io.File -class ConfigurationInteractorTest { +internal class ConfigurationInteractorTest { val path = "config_tst.dat" val configurationInteractor = ConfigurationInteractor(SQLiteWikiRepository(path)) diff --git a/src/test/kotlin/com/vandenbreemen/ktt/interactor/CustomCssInteractorTest.kt b/src/test/kotlin/com/vandenbreemen/ktt/interactor/CustomCssInteractorTest.kt index 66b7e61..fa6aa7e 100644 --- a/src/test/kotlin/com/vandenbreemen/ktt/interactor/CustomCssInteractorTest.kt +++ b/src/test/kotlin/com/vandenbreemen/ktt/interactor/CustomCssInteractorTest.kt @@ -7,7 +7,7 @@ import org.junit.jupiter.api.AfterEach import org.junit.jupiter.api.Test import java.io.File -class CustomCssInteractorTest { +internal class CustomCssInteractorTest { val path = "cust_css.dat" val customCssInteractor = CustomCssInteractor(SQLiteWikiRepository(path)) diff --git a/src/test/kotlin/com/vandenbreemen/ktt/interactor/MarkdownInteractorTest.kt b/src/test/kotlin/com/vandenbreemen/ktt/interactor/MarkdownInteractorTest.kt index 3a45630..9089e02 100644 --- a/src/test/kotlin/com/vandenbreemen/ktt/interactor/MarkdownInteractorTest.kt +++ b/src/test/kotlin/com/vandenbreemen/ktt/interactor/MarkdownInteractorTest.kt @@ -7,7 +7,7 @@ import org.junit.jupiter.api.AfterEach import org.junit.jupiter.api.Test import java.io.File -class MarkdownInteractorTest { +internal class MarkdownInteractorTest { private val file = "mkInteractorTest.dat" val repo = SQLiteWikiRepository(file) diff --git a/src/test/kotlin/com/vandenbreemen/ktt/interactor/SystemAccessInteractorTest.kt b/src/test/kotlin/com/vandenbreemen/ktt/interactor/SystemAccessInteractorTest.kt index 9bb7955..d1733a2 100644 --- a/src/test/kotlin/com/vandenbreemen/ktt/interactor/SystemAccessInteractorTest.kt +++ b/src/test/kotlin/com/vandenbreemen/ktt/interactor/SystemAccessInteractorTest.kt @@ -6,7 +6,7 @@ import org.junit.jupiter.api.AfterEach import org.junit.jupiter.api.Test import java.io.File -class SystemAccessInteractorTest { +internal class SystemAccessInteractorTest { val filename = "sysaccess.dat" val interactor = SystemAccessInteractor(SQLiteWikiRepository(filename)) diff --git a/src/test/kotlin/com/vandenbreemen/ktt/interactor/WikiInteractorTest.kt b/src/test/kotlin/com/vandenbreemen/ktt/interactor/WikiInteractorTest.kt index d6fb436..380413f 100644 --- a/src/test/kotlin/com/vandenbreemen/ktt/interactor/WikiInteractorTest.kt +++ b/src/test/kotlin/com/vandenbreemen/ktt/interactor/WikiInteractorTest.kt @@ -12,7 +12,7 @@ import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import java.io.File -class WikiInteractorTest { +internal class WikiInteractorTest { val testWikiInteractor = TestWikiInteractor() val filePath = "interactor_test.db" diff --git a/src/test/kotlin/com/vandenbreemen/ktt/interactor/WikiPageTagsInteractorTest.kt b/src/test/kotlin/com/vandenbreemen/ktt/interactor/WikiPageTagsInteractorTest.kt index 185fe73..5142ad7 100644 --- a/src/test/kotlin/com/vandenbreemen/ktt/interactor/WikiPageTagsInteractorTest.kt +++ b/src/test/kotlin/com/vandenbreemen/ktt/interactor/WikiPageTagsInteractorTest.kt @@ -7,7 +7,7 @@ import org.junit.jupiter.api.AfterEach import org.junit.jupiter.api.Test import java.io.File -class WikiPageTagsInteractorTest { +internal class WikiPageTagsInteractorTest { val testWikiInteractor = TestWikiInteractor() val filePath = "interactor_test.db" val repository = SQLiteWikiRepository(filePath) diff --git a/src/test/kotlin/com/vandenbreemen/ktt/view/PageRenderingInteractorTest.kt b/src/test/kotlin/com/vandenbreemen/ktt/view/PageRenderingInteractorTest.kt index 8d77238..0bba1e5 100644 --- a/src/test/kotlin/com/vandenbreemen/ktt/view/PageRenderingInteractorTest.kt +++ b/src/test/kotlin/com/vandenbreemen/ktt/view/PageRenderingInteractorTest.kt @@ -11,7 +11,7 @@ import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import java.io.File -class PageRenderingInteractorTest() { +internal class PageRenderingInteractorTest() { val registry = PageRenderingPluginRegistry() val repository = SQLiteWikiRepository("page_plugin_tests.dat") diff --git a/src/test/kotlin/com/vandenbreemen/ktt/view/plugins/MacrosPluginTest.kt b/src/test/kotlin/com/vandenbreemen/ktt/view/plugins/MacrosPluginTest.kt index be2be3b..a5347b9 100644 --- a/src/test/kotlin/com/vandenbreemen/ktt/view/plugins/MacrosPluginTest.kt +++ b/src/test/kotlin/com/vandenbreemen/ktt/view/plugins/MacrosPluginTest.kt @@ -1,5 +1,6 @@ package com.vandenbreemen.ktt.view.plugins +import com.vandenbreemen.ktt.api.SystemAccess import com.vandenbreemen.ktt.interactor.SystemAccessInteractor import com.vandenbreemen.ktt.macro.Macro import com.vandenbreemen.ktt.macro.MacroRegistry @@ -10,16 +11,16 @@ import org.junit.jupiter.api.BeforeEach import org.junit.jupiter.api.Test import java.io.File -class MacrosPluginTest { +internal class MacrosPluginTest { - class HelloWorldTestMacro(): Macro { + internal class HelloWorldTestMacro(): Macro { override val name: String get() = "HelloWorld" override val description: String? get() = "Unit testing macro" - override fun execute(args: Map, systemAccessInteractor: SystemAccessInteractor): String { + override fun execute(args: Map, systemAccessInteractor: SystemAccess): String { val message = args["message"] ?: "(missing message)" val additional = args["additional"] if(additional != null) {