diff --git a/README.md b/README.md index 74745d62..060faacc 100644 --- a/README.md +++ b/README.md @@ -12,37 +12,3 @@ части клиентов (например, андроид) * Мультимодульный проект * Server - пока что JVM-only модуль, включающий все необходимые для сервера фичи - -____ -## Как создать контент? -К примеру требуется создать контент Binary. Для этого необходимо выполнить следующие действия -1. Скопировать папку template из core/features в core/features/content -2. Переименовать эту папку в binary -3. Внутри папки binary заменить все вхождения template на content.binary -4. В файле settings.gradle в массив includes добавить -```kt - ":features:content:binary:common", - ":features:content:binary:client", - ":features:content:binary:server", -``` -5. В папке core/features/content/binary/common/src создать серию вложенных ддруг в друга папок commonMain/kotlin/dev/inmo/postssystem/features/content/binary/common -6. В последней папке common создать по ниже приведенным примерам data class -```kt - @Serializable - data class BinaryContent( - val bytes: ByteArray - ) : Content -``` -и конфигуратор -```kt -object BinaryContentSerializerModuleConfigurator : ContentSerializersModuleConfigurator.Element { - override fun PolymorphicModuleBuilder.invoke() { - subclass(BinaryContent::class, BinaryContent.serializer()) - } -} -``` -7. В двух файлах Di, расположенных в core/client/src/commonMain/kotlin/dev/inmo/postsystem/client и core/server/src/main/java/dev/inmo/postsystem/client соответственно -```kt - singleWithRandomQualifier { BinaryContentSerializerModuleConfigurator } -``` -8. Наверное нужно написать что делать с этим теперь можно? \ No newline at end of file diff --git a/features/content/README.MD b/features/content/README.MD new file mode 100644 index 00000000..de7f58c5 --- /dev/null +++ b/features/content/README.MD @@ -0,0 +1,37 @@ +## How to create content? + +For example, you want to create content named "MyFormat". To do this, you must perform the following actions: +1. Copy "template" folder from "core/features" in "core/features/content" +2. Rename this folder in "myformat" +3. Inside the "myformat" folder rename all the "template" on "content.myformat" +4. In the "settings.gradle" file in the "includes" array add the following code: + +```kotlin + ":features:content:myformat:common", + ":features:content:myformat:client", + ":features:content:myformat:server", +``` + +5. In the "core/features/content/myformat/common/src" folder create folders with appropriate subfolders "commonMain/kotlin/dev/inmo/postssystem/features/content/myformat/common": +6. In the last folder "сommon", create a data class and the configurator as shown below: + +```kotlin + @Serializable + data class MyFormatContent( + // Your code + ) : Content +``` + +```kotlin +object MyFormatContentSerializerModuleConfigurator : ContentSerializersModuleConfigurator.Element { + override fun PolymorphicModuleBuilder.invoke() { + subclass(MyFormatContent::class, MyFormatContent.serializer()) + } +} +``` + +7. In two "di.kt" file located in "core/client/src/commonMain/kotlin/dev/inmo/postsystem/client" and "core/server/src/main/java/dev/inmo/postsystem/client" respectively add the following string: + +```kotlin + singleWithRandomQualifier { MyFormatContentSerializerModuleConfigurator } +``` \ No newline at end of file