2023-06-25 18:04:06 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2023-07-08 12:28:15 +00:00
|
|
|
"fmt"
|
|
|
|
"os"
|
2023-06-25 19:32:36 +00:00
|
|
|
"owl-blogs/app"
|
2023-07-16 19:48:39 +00:00
|
|
|
entrytypes "owl-blogs/entry_types"
|
2023-06-25 19:32:36 +00:00
|
|
|
"owl-blogs/infra"
|
2023-08-08 18:17:04 +00:00
|
|
|
"owl-blogs/interactions"
|
2023-08-09 19:56:56 +00:00
|
|
|
"owl-blogs/plugings"
|
2024-02-25 13:01:55 +00:00
|
|
|
"owl-blogs/render"
|
2023-06-25 19:32:36 +00:00
|
|
|
"owl-blogs/web"
|
2023-07-08 12:28:15 +00:00
|
|
|
|
|
|
|
"github.com/spf13/cobra"
|
2023-06-25 18:04:06 +00:00
|
|
|
)
|
|
|
|
|
2023-07-07 19:04:25 +00:00
|
|
|
const DbPath = "owlblogs.db"
|
|
|
|
|
2023-07-08 12:28:15 +00:00
|
|
|
var rootCmd = &cobra.Command{
|
|
|
|
Use: "owl",
|
|
|
|
Short: "Owl Blogs is a not so static blog generator",
|
|
|
|
}
|
|
|
|
|
|
|
|
func Execute() {
|
|
|
|
if err := rootCmd.Execute(); err != nil {
|
|
|
|
fmt.Fprintln(os.Stderr, err)
|
|
|
|
os.Exit(1)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-07-07 19:04:25 +00:00
|
|
|
func App(db infra.Database) *web.WebApp {
|
2023-08-08 18:17:04 +00:00
|
|
|
// Register Types
|
|
|
|
entryRegister := app.NewEntryTypeRegistry()
|
|
|
|
entryRegister.Register(&entrytypes.Image{})
|
|
|
|
entryRegister.Register(&entrytypes.Article{})
|
|
|
|
entryRegister.Register(&entrytypes.Page{})
|
|
|
|
entryRegister.Register(&entrytypes.Recipe{})
|
|
|
|
entryRegister.Register(&entrytypes.Note{})
|
|
|
|
entryRegister.Register(&entrytypes.Bookmark{})
|
|
|
|
entryRegister.Register(&entrytypes.Reply{})
|
|
|
|
|
|
|
|
interactionRegister := app.NewInteractionTypeRegistry()
|
|
|
|
interactionRegister.Register(&interactions.Webmention{})
|
2024-05-17 20:37:18 +00:00
|
|
|
interactionRegister.Register(&interactions.Like{})
|
2024-05-18 10:42:49 +00:00
|
|
|
interactionRegister.Register(&interactions.Repost{})
|
2023-08-08 18:17:04 +00:00
|
|
|
|
|
|
|
configRegister := app.NewConfigRegister()
|
|
|
|
|
|
|
|
// Create Repositories
|
|
|
|
entryRepo := infra.NewEntryRepository(db, entryRegister)
|
2023-07-08 09:08:55 +00:00
|
|
|
binRepo := infra.NewBinaryFileRepo(db)
|
2023-07-08 11:28:06 +00:00
|
|
|
authorRepo := infra.NewDefaultAuthorRepo(db)
|
2023-08-11 14:11:59 +00:00
|
|
|
configRepo := infra.NewConfigRepo(db)
|
2023-08-08 18:17:04 +00:00
|
|
|
interactionRepo := infra.NewInteractionRepo(db, interactionRegister)
|
2024-05-13 17:03:21 +00:00
|
|
|
followersRepo := infra.NewFollowerRepository(db)
|
2023-07-08 09:08:55 +00:00
|
|
|
|
2023-08-08 19:32:24 +00:00
|
|
|
// Create External Services
|
|
|
|
httpClient := &infra.OwlHttpClient{}
|
|
|
|
|
2023-08-09 19:56:56 +00:00
|
|
|
// busses
|
2023-08-11 13:52:14 +00:00
|
|
|
eventBus := app.NewEventBus()
|
2023-08-09 19:56:56 +00:00
|
|
|
|
2023-08-08 18:17:04 +00:00
|
|
|
// Create Services
|
2024-02-25 13:01:55 +00:00
|
|
|
siteConfigService := app.NewSiteConfigService(configRepo)
|
2024-05-17 20:37:18 +00:00
|
|
|
entryService := app.NewEntryService(entryRepo, siteConfigService, eventBus)
|
2023-07-08 09:08:55 +00:00
|
|
|
binaryService := app.NewBinaryFileService(binRepo)
|
2024-02-25 13:01:55 +00:00
|
|
|
authorService := app.NewAuthorService(authorRepo, siteConfigService)
|
2023-08-08 18:17:04 +00:00
|
|
|
webmentionService := app.NewWebmentionService(
|
2024-02-25 13:01:55 +00:00
|
|
|
siteConfigService, interactionRepo, entryRepo, httpClient, eventBus,
|
2023-08-08 18:17:04 +00:00
|
|
|
)
|
2024-05-17 20:37:18 +00:00
|
|
|
apService := app.NewActivityPubService(
|
|
|
|
followersRepo, configRepo, interactionRepo,
|
|
|
|
entryService, siteConfigService,
|
|
|
|
eventBus,
|
|
|
|
)
|
2023-07-08 11:28:06 +00:00
|
|
|
|
2024-02-25 13:01:55 +00:00
|
|
|
// setup render functions
|
|
|
|
render.SiteConfigService = siteConfigService
|
|
|
|
|
2023-08-10 19:56:06 +00:00
|
|
|
// plugins
|
2023-08-11 13:52:14 +00:00
|
|
|
plugings.NewEcho(eventBus)
|
2023-08-10 19:56:06 +00:00
|
|
|
plugings.RegisterInstagram(
|
2023-08-11 14:11:59 +00:00
|
|
|
configRepo, configRegister, binaryService, eventBus,
|
2023-08-10 19:56:06 +00:00
|
|
|
)
|
|
|
|
|
2023-08-08 18:17:04 +00:00
|
|
|
// Create WebApp
|
2023-07-22 19:12:53 +00:00
|
|
|
return web.NewWebApp(
|
2023-08-08 18:17:04 +00:00
|
|
|
entryService, entryRegister, binaryService,
|
2023-08-11 14:11:59 +00:00
|
|
|
authorService, configRepo, configRegister,
|
2024-02-25 13:01:55 +00:00
|
|
|
siteConfigService, webmentionService, interactionRepo,
|
2024-05-13 17:03:21 +00:00
|
|
|
apService,
|
2023-07-22 19:12:53 +00:00
|
|
|
)
|
2023-07-06 20:16:52 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func main() {
|
2023-07-08 12:28:15 +00:00
|
|
|
Execute()
|
2023-06-25 18:04:06 +00:00
|
|
|
}
|