Update initial data
fenbox opened this issue · comments
Current
All data is empty and requires further configuration by the administrator to use.
Expected
Have initial data such as tags, sample Q&A, etc., so users can start using it right away.
After the user fills in the admin account during installation and clicks the Next button, the following initial data will be generated automatically.
![image](https://private-user-images.githubusercontent.com/360618/324302428-3f8c9049-9504-4032-a1e4-00e21d0933f7.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTkyNDgxNzksIm5iZiI6MTcxOTI0Nzg3OSwicGF0aCI6Ii8zNjA2MTgvMzI0MzAyNDI4LTNmOGM5MDQ5LTk1MDQtNDAzMi1hMWU0LTAwZTIxZDA5MzNmNy5wbmc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjQwNjI0JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI0MDYyNFQxNjUxMTlaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT00Yjc3ODE5M2Y3MmE1MmZjYmRmMTExMjUzMGRlZDIzYTNjYTUxY2NlOWM4MzFmZWE5ODg1MTAzZjFlN2E5NzlhJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZhY3Rvcl9pZD0wJmtleV9pZD0wJnJlcG9faWQ9MCJ9.MMfznVs5OZsgbDH0BnqqV-v4W7m-OPpc3o620Bl2m0E)
Initial tag:
- name: support
description: For general support questions.
Initial post:
- title: What is a tag?
body: When asking a question, we need to choose tags. What are tags and why should I use them?
tags:
- support
answer: Tags help to organize content and make searching easier. It helps your question get more attention from people interested in that tag. Tags also send notifications. If you are interested in some topic, follow that tag to get updates.
- title: What is reputation and how do I earn them?
body: I see that each user has reputation points, What is it and how do I earn them?
tags:
- support
answer: Your reputation points show how much the community values your knowledge. You earn points when someone find your question or answer helpful. You also get points when the person who asked the question thinks you did a good job and accepts your answer.
The author is the initial administrator.
i'll do it
is it a good idea to add it in the internal/migrations/init.go
file? in the InitDB
method?
that would require importing the tag_service
, question_service
, etc... or atleast the tag_repo
, question_repo
, etc...
because i need to generate unique ID and can't just do m.engine.Context(m.ctx).Insert(...)
@fenbox Maybe we can clarify the requirements a bit more.
- Option 1: Do we need an input field in the installation page, where the initial administrator can enter the contents of the initial tag and post, and initialize them along with the initial data?
- Option 2: The administrator can enter these details in the admin page after installation.
- Option 3: During installation, it is possible to add a command-line option to specify the location of the initial data configuration file.
I would perfer option 1. Or do you have any other ideas.
@zahash If it is option 1, then you are correct.
Like other platforms such as WordPress. There is no need an input field in the installation page.
i'm sorry i've never used wordpress, how does this feature work?
so which of the three options is it?
@zahash I have updated the description.
After users install the program, they will now see two Q&A post and one tag. No other functions.
is it a good idea to add it in the
internal/migrations/init.go
file? in theInitDB
method?
@zahash Your understanding is correct. This initialization content is fixed, which means that after installation, there is a default tag and Q&A content. Therefore, you can create these contents directly in the InitDB
method. BTW, you can put the initial content in init_data.go
.
why is there no AddTag
function in tag_repo.go
?
why is there no
AddTag
function intag_repo.go
?
@zahash In tag_common_repo.go
@LinkinStars hmmm.. whats the difference? why is it split into two files?
@LinkinStars hmmm.. whats the difference? why is it split into two files?
@zahash It was supposed to fix the golang circular references at the time.
i made a pr with a "work in progess" commit. It doesn't compile right now but is this the direction you want to go?
#918
how do i initialize the UniqueIDRepo
in internal/install/install_controller.go
InitBaseInfo
function?
because migrations.NewMentor( ... )
needs it
how do i initialize the
UniqueIDRepo
ininternal/install/install_controller.go
InitBaseInfo
function? becausemigrations.NewMentor( ... )
needs it
Maybe you can use unique.NewUniqueIDRepo(&data.Data{DB: engine})
. If you think this way is too troublesome, you also can use the engine *xorm.Engine
to Insert
directly.