diff --git a/cmd/kiss-cli/main.go b/cmd/owl-cli/main.go similarity index 91% rename from cmd/kiss-cli/main.go rename to cmd/owl-cli/main.go index b0bac68..eb6081c 100644 --- a/cmd/kiss-cli/main.go +++ b/cmd/owl-cli/main.go @@ -1,12 +1,12 @@ package main import ( - "h4kor/kiss-social" + "h4kor/owl-blogs" "os" ) func main() { - println("KISS Social") + println("owl blogs") println("Commands") println("init - Creates a new repository") println(" new-user - Creates a new user") @@ -19,7 +19,7 @@ func main() { if os.Args[1] == "init" { repoName := os.Args[2] - _, err := kiss.CreateRepository(repoName) + _, err := owl.CreateRepository(repoName) if err != nil { println("Error creating repository: ", err.Error()) } @@ -28,7 +28,7 @@ func main() { } repoName := os.Args[1] - repo, err := kiss.OpenRepository(repoName) + repo, err := owl.OpenRepository(repoName) if err != nil { println("Error opening repository: ", err.Error()) os.Exit(1) diff --git a/cmd/kiss-web/main.go b/cmd/owl-web/main.go similarity index 86% rename from cmd/kiss-web/main.go rename to cmd/owl-web/main.go index 4fa4738..28e1f47 100644 --- a/cmd/kiss-web/main.go +++ b/cmd/owl-web/main.go @@ -1,7 +1,7 @@ package main import ( - "h4kor/kiss-social" + "h4kor/owl-blogs" "net/http" "os" "strconv" @@ -9,7 +9,7 @@ import ( "github.com/julienschmidt/httprouter" ) -// func handler(repo kiss.Repository) func(http.ResponseWriter, *http.Request) { +// func handler(repo owl.Repository) func(http.ResponseWriter, *http.Request) { // return func(w http.ResponseWriter, r *http.Request) { // // normalize the path // path := r.URL.Path @@ -48,9 +48,9 @@ import ( // } // } -func indexHandler(repo kiss.Repository) func(http.ResponseWriter, *http.Request, httprouter.Params) { +func indexHandler(repo owl.Repository) func(http.ResponseWriter, *http.Request, httprouter.Params) { return func(w http.ResponseWriter, r *http.Request, _ httprouter.Params) { - html, err := kiss.RenderUserList(repo) + html, err := owl.RenderUserList(repo) if err != nil { println("Error rendering index: ", err.Error()) @@ -63,7 +63,7 @@ func indexHandler(repo kiss.Repository) func(http.ResponseWriter, *http.Request, } } -func userHandler(repo kiss.Repository) func(http.ResponseWriter, *http.Request, httprouter.Params) { +func userHandler(repo owl.Repository) func(http.ResponseWriter, *http.Request, httprouter.Params) { return func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) { userName := ps.ByName("user") user, err := repo.GetUser(userName) @@ -73,7 +73,7 @@ func userHandler(repo kiss.Repository) func(http.ResponseWriter, *http.Request, w.Write([]byte("User not found")) return } - html, err := kiss.RenderIndexPage(user) + html, err := owl.RenderIndexPage(user) if err != nil { println("Error rendering index page: ", err.Error()) w.WriteHeader(http.StatusInternalServerError) @@ -85,7 +85,7 @@ func userHandler(repo kiss.Repository) func(http.ResponseWriter, *http.Request, } } -func postHandler(repo kiss.Repository) func(http.ResponseWriter, *http.Request, httprouter.Params) { +func postHandler(repo owl.Repository) func(http.ResponseWriter, *http.Request, httprouter.Params) { return func(w http.ResponseWriter, r *http.Request, ps httprouter.Params) { userName := ps.ByName("user") postId := ps.ByName("post") @@ -103,7 +103,7 @@ func postHandler(repo kiss.Repository) func(http.ResponseWriter, *http.Request, w.Write([]byte("Post not found")) return } - html, err := kiss.RenderPost(post) + html, err := owl.RenderPost(post) if err != nil { println("Error rendering post: ", err.Error()) w.WriteHeader(http.StatusInternalServerError) @@ -117,7 +117,7 @@ func postHandler(repo kiss.Repository) func(http.ResponseWriter, *http.Request, } func main() { - println("KISS Web Server") + println("owl web server") println("Parameters") println("-repo - Specify the repository to use. Defaults to '.'") println("-port - Specify the port to use, Default is '8080'") @@ -138,7 +138,7 @@ func main() { port = 8080 } - repo, err := kiss.OpenRepository(repoName) + repo, err := owl.OpenRepository(repoName) if err != nil { println("Error opening repository: ", err.Error()) os.Exit(1) diff --git a/cmd/kiss-web/static/handler.go b/cmd/owl-web/static/handler.go similarity index 63% rename from cmd/kiss-web/static/handler.go rename to cmd/owl-web/static/handler.go index dccbbcb..c52fa8d 100644 --- a/cmd/kiss-web/static/handler.go +++ b/cmd/owl-web/static/handler.go @@ -1,11 +1,11 @@ package static import ( - "h4kor/kiss-social" + "h4kor/owl-blogs" "net/http" ) -func StaticHandler(repo kiss.Repository) http.Handler { +func StaticHandler(repo owl.Repository) http.Handler { return http.StripPrefix( "/static/", http.FileServer(http.Dir(repo.StaticDir())), diff --git a/cmd/kiss-web/static/handler_test.go b/cmd/owl-web/static/handler_test.go similarity index 89% rename from cmd/kiss-web/static/handler_test.go rename to cmd/owl-web/static/handler_test.go index c929ea5..74a499b 100644 --- a/cmd/kiss-web/static/handler_test.go +++ b/cmd/owl-web/static/handler_test.go @@ -1,8 +1,8 @@ package static_test import ( - "h4kor/kiss-social" - "h4kor/kiss-social/cmd/kiss-web/static" + "h4kor/owl-blogs" + "h4kor/owl-blogs/cmd/owl-web/static" "math/rand" "net/http" "net/http/httptest" @@ -26,8 +26,8 @@ func testRepoName() string { return "/tmp/" + randomName() } -func getTestRepo() kiss.Repository { - repo, _ := kiss.CreateRepository(testRepoName()) +func getTestRepo() owl.Repository { + repo, _ := owl.CreateRepository(testRepoName()) return repo } diff --git a/cmd/owl-web/user/handler.go b/cmd/owl-web/user/handler.go new file mode 100644 index 0000000..e69de29 diff --git a/cmd/owl-web/user/handler_test.go b/cmd/owl-web/user/handler_test.go new file mode 100644 index 0000000..e69de29 diff --git a/directories.go b/directories.go index 9d2c48f..4a88a1c 100644 --- a/directories.go +++ b/directories.go @@ -1,4 +1,4 @@ -package kiss +package owl import ( "os" diff --git a/embed/initial/header.html b/embed/initial/header.html new file mode 100644 index 0000000..dc71910 --- /dev/null +++ b/embed/initial/header.html @@ -0,0 +1,5 @@ +
    + {{ range .UserLinks }} +
  • {{.Text}}
  • + {{ end }} +
\ No newline at end of file diff --git a/go.mod b/go.mod index a3c7cba..706569f 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module h4kor/kiss-social +module h4kor/owl-blogs go 1.18 diff --git a/kiss_test.go b/kiss_test.go index 9818169..68a478f 100644 --- a/kiss_test.go +++ b/kiss_test.go @@ -1,7 +1,7 @@ -package kiss_test +package owl_test import ( - "h4kor/kiss-social" + "h4kor/owl-blogs" "math/rand" "time" ) @@ -24,14 +24,14 @@ func randomUserName() string { return randomName() } -func getTestUser() kiss.User { - repo, _ := kiss.CreateRepository(testRepoName()) +func getTestUser() owl.User { + repo, _ := owl.CreateRepository(testRepoName()) user, _ := repo.CreateUser(randomUserName()) return user } -func getTestRepo() kiss.Repository { - repo, _ := kiss.CreateRepository(testRepoName()) +func getTestRepo() owl.Repository { + repo, _ := owl.CreateRepository(testRepoName()) return repo } diff --git a/post.go b/post.go index 2dc8a9b..a7e8775 100644 --- a/post.go +++ b/post.go @@ -1,4 +1,4 @@ -package kiss +package owl import ( "bytes" diff --git a/post_test.go b/post_test.go index 8465582..8c3aa38 100644 --- a/post_test.go +++ b/post_test.go @@ -1,4 +1,4 @@ -package kiss_test +package owl_test import ( "path" diff --git a/renderer.go b/renderer.go index 4220a75..ea73b29 100644 --- a/renderer.go +++ b/renderer.go @@ -1,4 +1,4 @@ -package kiss +package owl import ( "bytes" diff --git a/renderer_test.go b/renderer_test.go index 12c8441..407989f 100644 --- a/renderer_test.go +++ b/renderer_test.go @@ -1,7 +1,7 @@ -package kiss_test +package owl_test import ( - "h4kor/kiss-social" + "h4kor/owl-blogs" "os" "path" "strings" @@ -11,7 +11,7 @@ import ( func TestCanRenderPost(t *testing.T) { user := getTestUser() post, _ := user.CreateNewPost("testpost") - result, err := kiss.RenderPost(post) + result, err := owl.RenderPost(post) if err != nil { t.Error("Error rendering post: " + err.Error()) @@ -27,7 +27,7 @@ func TestCanRenderPost(t *testing.T) { func TestRendererUsesBaseTemplate(t *testing.T) { user := getTestUser() post, _ := user.CreateNewPost("testpost") - result, err := kiss.RenderPost(post) + result, err := owl.RenderPost(post) if err != nil { t.Error("Error rendering post: " + err.Error()) @@ -43,7 +43,7 @@ func TestCanRenderIndexPage(t *testing.T) { user := getTestUser() user.CreateNewPost("testpost1") user.CreateNewPost("testpost2") - result, _ := kiss.RenderIndexPage(user) + result, _ := owl.RenderIndexPage(user) if !strings.Contains(result, "testpost1") { t.Error("Post title not rendered. Got: " + result) } @@ -59,7 +59,7 @@ func TestRenderIndexPageWithBrokenBaseTemplate(t *testing.T) { os.WriteFile(path.Join(user.Dir(), "meta/base.html"), []byte("{{content}}"), 0644) - _, err := kiss.RenderIndexPage(user) + _, err := owl.RenderIndexPage(user) if err == nil { t.Error("Expected error rendering index page, got nil") } @@ -70,7 +70,7 @@ func TestRenderUserList(t *testing.T) { repo.CreateUser("user1") repo.CreateUser("user2") - result, err := kiss.RenderUserList(repo) + result, err := owl.RenderUserList(repo) if err != nil { t.Error("Error rendering user list: " + err.Error()) } @@ -85,14 +85,14 @@ func TestRenderUserList(t *testing.T) { func TestRendersHeaderTitle(t *testing.T) { user := getTestUser() - user.SetConfig(kiss.UserConfig{ + user.SetConfig(owl.UserConfig{ Title: "Test Title", SubTitle: "Test SubTitle", HeaderColor: "#ff1337", }) post, _ := user.CreateNewPost("testpost") - result, _ := kiss.RenderPost(post) + result, _ := owl.RenderPost(post) if !strings.Contains(result, "Test Title") { t.Error("Header title not rendered. Got: " + result) } diff --git a/repository.go b/repository.go index f8815d4..bbbf0bb 100644 --- a/repository.go +++ b/repository.go @@ -1,4 +1,4 @@ -package kiss +package owl import ( "embed" diff --git a/repository_test.go b/repository_test.go index a8466b9..1249ae1 100644 --- a/repository_test.go +++ b/repository_test.go @@ -1,7 +1,7 @@ -package kiss_test +package owl_test import ( - "h4kor/kiss-social" + "h4kor/owl-blogs" "os" "path" "testing" @@ -9,7 +9,7 @@ import ( func TestCanCreateRepository(t *testing.T) { repoName := testRepoName() - _, err := kiss.CreateRepository(repoName) + _, err := owl.CreateRepository(repoName) if err != nil { t.Error("Error creating repository: ", err.Error()) } @@ -18,8 +18,8 @@ func TestCanCreateRepository(t *testing.T) { func TestCannotCreateExistingRepository(t *testing.T) { repoName := testRepoName() - kiss.CreateRepository(repoName) - _, err := kiss.CreateRepository(repoName) + owl.CreateRepository(repoName) + _, err := owl.CreateRepository(repoName) if err == nil { t.Error("No error returned when creating existing repository") } @@ -27,7 +27,7 @@ func TestCannotCreateExistingRepository(t *testing.T) { func TestCanCreateANewUser(t *testing.T) { // Create a new user - repo, _ := kiss.CreateRepository(testRepoName()) + repo, _ := owl.CreateRepository(testRepoName()) user, _ := repo.CreateUser(randomUserName()) if _, err := os.Stat(path.Join(user.Dir(), "")); err != nil { t.Error("User directory not created") @@ -36,7 +36,7 @@ func TestCanCreateANewUser(t *testing.T) { func TestCannotRecreateExisitingUser(t *testing.T) { // Create a new user - repo, _ := kiss.CreateRepository(testRepoName()) + repo, _ := owl.CreateRepository(testRepoName()) userName := randomUserName() repo.CreateUser(userName) _, err := repo.CreateUser(userName) @@ -47,7 +47,7 @@ func TestCannotRecreateExisitingUser(t *testing.T) { func TestCreateUserAddsVersionFile(t *testing.T) { // Create a new user - repo, _ := kiss.CreateRepository(testRepoName()) + repo, _ := owl.CreateRepository(testRepoName()) user, _ := repo.CreateUser(randomUserName()) if _, err := os.Stat(path.Join(user.Dir(), "/meta/VERSION")); err != nil { t.Error("Version file not created") @@ -56,7 +56,7 @@ func TestCreateUserAddsVersionFile(t *testing.T) { func TestCreateUserAddsBaseHtmlFile(t *testing.T) { // Create a new user - repo, _ := kiss.CreateRepository(testRepoName()) + repo, _ := owl.CreateRepository(testRepoName()) user, _ := repo.CreateUser(randomUserName()) if _, err := os.Stat(path.Join(user.Dir(), "/meta/base.html")); err != nil { t.Error("Base html file not created") @@ -65,7 +65,7 @@ func TestCreateUserAddsBaseHtmlFile(t *testing.T) { func TestCreateUserAddConfigYml(t *testing.T) { // Create a new user - repo, _ := kiss.CreateRepository(testRepoName()) + repo, _ := owl.CreateRepository(testRepoName()) user, _ := repo.CreateUser(randomUserName()) if _, err := os.Stat(path.Join(user.Dir(), "/meta/config.yml")); err != nil { t.Error("Config file not created") @@ -74,7 +74,7 @@ func TestCreateUserAddConfigYml(t *testing.T) { func TestCreateUserAddsPublicFolder(t *testing.T) { // Create a new user - repo, _ := kiss.CreateRepository(testRepoName()) + repo, _ := owl.CreateRepository(testRepoName()) user, _ := repo.CreateUser(randomUserName()) if _, err := os.Stat(path.Join(user.Dir(), "/public")); err != nil { t.Error("Public folder not created") @@ -83,7 +83,7 @@ func TestCreateUserAddsPublicFolder(t *testing.T) { func TestCanListRepoUsers(t *testing.T) { // Create a new user - repo, _ := kiss.CreateRepository(testRepoName()) + repo, _ := owl.CreateRepository(testRepoName()) user1, _ := repo.CreateUser(randomUserName()) user2, _ := repo.CreateUser(randomUserName()) // Create a new post @@ -101,9 +101,9 @@ func TestCanListRepoUsers(t *testing.T) { func TestCanOpenRepository(t *testing.T) { // Create a new user repoName := testRepoName() - repo, _ := kiss.CreateRepository(repoName) + repo, _ := owl.CreateRepository(repoName) // Open the repository - repo2, err := kiss.OpenRepository(repoName) + repo2, err := owl.OpenRepository(repoName) if err != nil { t.Error("Error opening repository: ", err.Error()) } @@ -113,7 +113,7 @@ func TestCanOpenRepository(t *testing.T) { } func TestCannotOpenNonExisitingRepo(t *testing.T) { - _, err := kiss.OpenRepository(testRepoName()) + _, err := owl.OpenRepository(testRepoName()) if err == nil { t.Error("No error returned when opening non-existing repository") } @@ -121,7 +121,7 @@ func TestCannotOpenNonExisitingRepo(t *testing.T) { func TestGetUser(t *testing.T) { // Create a new user - repo, _ := kiss.CreateRepository(testRepoName()) + repo, _ := owl.CreateRepository(testRepoName()) user, _ := repo.CreateUser(randomUserName()) // Get the user user2, err := repo.GetUser(user.Name()) @@ -135,7 +135,7 @@ func TestGetUser(t *testing.T) { func TestCannotGetNonexistingUser(t *testing.T) { // Create a new user - repo, _ := kiss.CreateRepository(testRepoName()) + repo, _ := owl.CreateRepository(testRepoName()) _, err := repo.GetUser(randomUserName()) if err == nil { t.Error("No error returned when getting non-existing user") @@ -144,7 +144,7 @@ func TestCannotGetNonexistingUser(t *testing.T) { func TestGetStaticDirOfRepo(t *testing.T) { // Create a new user - repo, _ := kiss.CreateRepository(testRepoName()) + repo, _ := owl.CreateRepository(testRepoName()) // Get the user staticDir := repo.StaticDir() if staticDir == "" { @@ -154,7 +154,7 @@ func TestGetStaticDirOfRepo(t *testing.T) { func TestNewRepoGetsStaticFiles(t *testing.T) { // Create a new user - repo, _ := kiss.CreateRepository(testRepoName()) + repo, _ := owl.CreateRepository(testRepoName()) if _, err := os.Stat(repo.StaticDir()); err != nil { t.Error("Static directory not found") } @@ -169,7 +169,7 @@ func TestNewRepoGetsStaticFiles(t *testing.T) { func TestNewRepoGetsBaseHtml(t *testing.T) { // Create a new user - repo, _ := kiss.CreateRepository(testRepoName()) + repo, _ := owl.CreateRepository(testRepoName()) if _, err := os.Stat(path.Join(repo.Dir(), "/base.html")); err != nil { t.Error("Base html file not found") } @@ -177,7 +177,7 @@ func TestNewRepoGetsBaseHtml(t *testing.T) { func TestCanGetRepoTemplate(t *testing.T) { // Create a new user - repo, _ := kiss.CreateRepository(testRepoName()) + repo, _ := owl.CreateRepository(testRepoName()) // Get the user template, err := repo.Template() if err != nil { diff --git a/user.go b/user.go index b72a6e7..7d39e5f 100644 --- a/user.go +++ b/user.go @@ -1,4 +1,4 @@ -package kiss +package owl import ( "fmt" diff --git a/user_test.go b/user_test.go index a60527e..bb8bbaf 100644 --- a/user_test.go +++ b/user_test.go @@ -1,8 +1,8 @@ -package kiss_test +package owl_test import ( "fmt" - "h4kor/kiss-social" + "h4kor/owl-blogs" "io/ioutil" "os" "path" @@ -11,7 +11,7 @@ import ( func TestCreateNewPostCreatesEntryInPublic(t *testing.T) { // Create a new user - repo, _ := kiss.CreateRepository(testRepoName()) + repo, _ := owl.CreateRepository(testRepoName()) user, _ := repo.CreateUser(randomUserName()) // Create a new post user.CreateNewPost("testpost") @@ -26,7 +26,7 @@ func TestCreateNewPostCreatesEntryInPublic(t *testing.T) { func TestCreateNewPostCreatesMediaDir(t *testing.T) { // Create a new user - repo, _ := kiss.CreateRepository(testRepoName()) + repo, _ := owl.CreateRepository(testRepoName()) user, _ := repo.CreateUser(randomUserName()) // Create a new post post, _ := user.CreateNewPost("testpost") @@ -37,7 +37,7 @@ func TestCreateNewPostCreatesMediaDir(t *testing.T) { func TestCreateNewPostMultipleCalls(t *testing.T) { // Create a new user - repo, _ := kiss.CreateRepository(testRepoName()) + repo, _ := owl.CreateRepository(testRepoName()) user, _ := repo.CreateUser(randomUserName()) // Create a new post user.CreateNewPost("testpost") @@ -54,7 +54,7 @@ func TestCreateNewPostMultipleCalls(t *testing.T) { func TestCanListUserPosts(t *testing.T) { // Create a new user - repo, _ := kiss.CreateRepository(testRepoName()) + repo, _ := owl.CreateRepository(testRepoName()) user, _ := repo.CreateUser(randomUserName()) // Create a new post user.CreateNewPost("testpost") @@ -71,7 +71,7 @@ func TestCanListUserPosts(t *testing.T) { func TestCanListUserPostsWithSubdirectories(t *testing.T) { // Create a new user - repo, _ := kiss.CreateRepository(testRepoName()) + repo, _ := owl.CreateRepository(testRepoName()) user, _ := repo.CreateUser(randomUserName()) // Create a new post user.CreateNewPost("testpost")