(Note. This demo project is still ongoing so documentation/code might not work.)
A demo project of digimaker CMF, including a minimal website, web app and editorial backend setup.
You can just clone this project and do some configuration and it can be your initialized project.
For full documentation and references, please visit https://digimaker.org/doc
//clone it.
git clone https://github.com/digimakergo/dmdemo.git
cd dmdemo
//Import database
//Remember to change configs/dm.yaml's database connection.
//Replace {host}, {username} {database} with your real host, username and database
mysql -h {host} -u {username} -p {database} < data/dmdemo.sql
//run this under mysql root
SET GLOBAL sql_mode=(SELECT REPLACE(@@sql_mode,'ONLY_FULL_GROUP_BY',''));
//install dmcli, optional
go install github.com/digimakergo/digimaker/dmcli@latest
//change database connection information on configs/dm.yaml/database
//start server
go run cmd/main.go
View frontend: http://localhost:9200
The admin client is under web/admin
cd web/admin
# you may use npm install --legacy-peer-deps if npm version is > 7
npm install
npm start
View admin: http://localhost:3000
Login: admin user admin/Digimaker
or editor user: editor/Digimaker
cd web/app
npm install
npm start
(if 3000 is used, choose Yes when prompt up to change port, to use port 3001)
View frontend web app: http://localhost:3001 (or 3000 if admin app is not running)
Login: member member/digimaker
or admin/Digimaker
First you need to define a template override rule under configs/template_override.yaml (and template_override-dmdemo.yaml), then you can do the templating in that template file.
Example:
In pkg/controller/statistics.go, it provides an example of registering rest api and output how many article it has.
See web/app for examples.
create a new project folder eg. project-a
cd ..
mkdir project-a
cp -a dmdemo/configs project-a/
cp -a dmdemo/cmd project-a
cp -a dmdemo/entity project-a
cp -a dmdemo/go.* project-a/
If you have changes on config/contenttype.json, you can run below to update entity
cd project-a
dmcli entity
dmdemo
in cmd/main.go
to project-a
dmdemo
in go.mod to project-a
go mod tidy
to update go modulesgo run cmd/main.go
Deploy to linux:
#build for linux
env GOOS=linux GOARCH=amd64 go build ./cmd/main.go
#run on production, see dmdemo.service to deploy as a linux service
#need to deploy all(except .go files) into production.
./main
See dmdemo.service file to deploy as service in production.
Note: in production, you will still need folder configs
, web/templates
(configurable), var
(configurable) under running folder.
A project structure example which follows some recommendation from Go standard project layout: https://github.com/golang-standards/project-layout
Project A
│───cmd
│ └─main.go
│──configs
│ │─dm.yaml
│ │─contenttype.yaml
│ │-policies.yaml
│ └ template_override.yaml
│──entity
│──handlers
│──api
│──web
│ └templates
│
└───var
Note: all the .go related folders can be in any structure as long as they can be imported. The only required structure for Digimaker is the config files structure.