changes in markup common system
This commit is contained in:
parent
47805b9e91
commit
e35d578490
@ -6,19 +6,19 @@ import com.insanusmokrassar.postssystem.core.post.PostId
|
|||||||
import com.insanusmokrassar.postssystem.core.post.RegisteredPost
|
import com.insanusmokrassar.postssystem.core.post.RegisteredPost
|
||||||
import com.insanusmokrassar.postssystem.core.post.repo.ReadPostsRepo
|
import com.insanusmokrassar.postssystem.core.post.repo.ReadPostsRepo
|
||||||
|
|
||||||
abstract class AbstractMarkupBuilderFactory<MarkupTarget>(
|
abstract class AbstractMarkupPlugin<MarkupTarget>(
|
||||||
@Suppress("MemberVisibilityCanBePrivate")
|
@Suppress("MemberVisibilityCanBePrivate")
|
||||||
protected val postsRepo: ReadPostsRepo,
|
protected val postsRepo: ReadPostsRepo,
|
||||||
@Suppress("MemberVisibilityCanBePrivate")
|
@Suppress("MemberVisibilityCanBePrivate")
|
||||||
protected val postsContentRepo: ReadContentRepo
|
protected val postsContentRepo: ReadContentRepo
|
||||||
) : MarkupBuilderFactory<MarkupTarget> {
|
) : MarkupPlugin<MarkupTarget> {
|
||||||
override suspend fun drawOn(target: MarkupTarget, forPost: PostId) {
|
override suspend fun drawMarkupBuilder(on: MarkupTarget, postId: PostId) {
|
||||||
val post = postsRepo.getPostById(forPost) ?: return
|
val post = postsRepo.getPostById(postId) ?: return
|
||||||
val contents = post.content.mapNotNull {
|
val contents = post.content.mapNotNull {
|
||||||
postsContentRepo.getContentById(it)
|
postsContentRepo.getContentById(it)
|
||||||
}
|
}
|
||||||
drawOn(target, post, contents)
|
drawMarkupBuilder(on, post, contents)
|
||||||
}
|
}
|
||||||
|
|
||||||
abstract suspend fun drawOn(target: MarkupTarget, forPost: RegisteredPost, content: List<RegisteredContent>)
|
abstract suspend fun drawMarkupBuilder(target: MarkupTarget, forPost: RegisteredPost, content: List<RegisteredContent>)
|
||||||
}
|
}
|
@ -1,21 +0,0 @@
|
|||||||
package com.insanusmokrassar.postssystem.markups.core
|
|
||||||
|
|
||||||
import com.insanusmokrassar.postssystem.core.post.PostId
|
|
||||||
|
|
||||||
/**
|
|
||||||
* System of markup for some target publishing system, which is drawing on [MarkupTarget].
|
|
||||||
*
|
|
||||||
* Some markup system which knows, how to create the markup system inside of some [MarkupTarget]. This interface
|
|
||||||
* will be implemented by creators like:
|
|
||||||
*
|
|
||||||
* * Telegram
|
|
||||||
* * Web
|
|
||||||
* * etc.
|
|
||||||
*
|
|
||||||
* [MarkupTarget] here is just a platform, which can be used by [MarkupBuilderFactory] to create markup inside.
|
|
||||||
*
|
|
||||||
* For example, it could be some creator like "TelegramForHTMLMarkupBuilder"
|
|
||||||
*/
|
|
||||||
interface MarkupBuilderFactory<MarkupTarget> {
|
|
||||||
suspend fun drawOn(target: MarkupTarget, forPost: PostId)
|
|
||||||
}
|
|
@ -0,0 +1,35 @@
|
|||||||
|
package com.insanusmokrassar.postssystem.markups.core
|
||||||
|
|
||||||
|
import com.insanusmokrassar.postssystem.core.post.PostId
|
||||||
|
|
||||||
|
/**
|
||||||
|
* That is the plugin for platform, which is able to be drawn on the [MarkupTarget].
|
||||||
|
*
|
||||||
|
* * Plugin could be some Telegram plugin
|
||||||
|
* * [MarkupTarget] could be web.
|
||||||
|
*/
|
||||||
|
interface MarkupPlugin<MarkupTarget> {
|
||||||
|
/**
|
||||||
|
* This name will be used in `select`-questions on site
|
||||||
|
*/
|
||||||
|
val name: String
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Link to icon which will be used for links onto this plugin
|
||||||
|
*/
|
||||||
|
val iconLink: String?
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Drawing on [MarkupTarget].
|
||||||
|
*
|
||||||
|
* As a result, plugin must use [MarkupTarget] as a canvas to create the builder of markup. This fun
|
||||||
|
* will be implemented by creators like:
|
||||||
|
*
|
||||||
|
* * Telegram
|
||||||
|
* * Web
|
||||||
|
* * etc.
|
||||||
|
*
|
||||||
|
* For example, it could be some creator like "TelegramForHTMLMarkupBuilder"
|
||||||
|
*/
|
||||||
|
suspend fun drawMarkupBuilder(on: MarkupTarget, postId: PostId)
|
||||||
|
}
|
@ -2,10 +2,10 @@ package com.insanusmokrassar.postssystem.markups.html
|
|||||||
|
|
||||||
import com.insanusmokrassar.postssystem.core.content.api.ReadContentRepo
|
import com.insanusmokrassar.postssystem.core.content.api.ReadContentRepo
|
||||||
import com.insanusmokrassar.postssystem.core.post.repo.ReadPostsRepo
|
import com.insanusmokrassar.postssystem.core.post.repo.ReadPostsRepo
|
||||||
import com.insanusmokrassar.postssystem.markups.core.AbstractMarkupBuilderFactory
|
import com.insanusmokrassar.postssystem.markups.core.AbstractMarkupPlugin
|
||||||
import kotlinx.html.FlowContent
|
import kotlinx.html.FlowContent
|
||||||
|
|
||||||
abstract class HtmlMarkupBuilderFactory(
|
abstract class HtmlMarkupPlugin(
|
||||||
postsRepo: ReadPostsRepo,
|
postsRepo: ReadPostsRepo,
|
||||||
postsContentRepo: ReadContentRepo
|
postsContentRepo: ReadContentRepo
|
||||||
) : AbstractMarkupBuilderFactory<FlowContent>(postsRepo, postsContentRepo)
|
) : AbstractMarkupPlugin<FlowContent>(postsRepo, postsContentRepo)
|
@ -2,10 +2,10 @@ package com.insanusmokrassar.postssystem.markups.html
|
|||||||
|
|
||||||
import com.insanusmokrassar.postssystem.core.content.api.ReadContentRepo
|
import com.insanusmokrassar.postssystem.core.content.api.ReadContentRepo
|
||||||
import com.insanusmokrassar.postssystem.core.post.repo.ReadPostsRepo
|
import com.insanusmokrassar.postssystem.core.post.repo.ReadPostsRepo
|
||||||
import com.insanusmokrassar.postssystem.markups.core.AbstractMarkupBuilderFactory
|
import com.insanusmokrassar.postssystem.markups.core.AbstractMarkupPlugin
|
||||||
import kotlinx.html.FlowContent
|
import kotlinx.html.FlowContent
|
||||||
|
|
||||||
abstract class HtmlMarkupBuilderFactory(
|
abstract class HtmlMarkupPlugin(
|
||||||
postsRepo: ReadPostsRepo,
|
postsRepo: ReadPostsRepo,
|
||||||
postsContentRepo: ReadContentRepo
|
postsContentRepo: ReadContentRepo
|
||||||
) : AbstractMarkupBuilderFactory<FlowContent>(postsRepo, postsContentRepo)
|
) : AbstractMarkupPlugin<FlowContent>(postsRepo, postsContentRepo)
|
Loading…
Reference in New Issue
Block a user