renaming to owl-blogs
This commit is contained in:
parent
c0b4c01aba
commit
e657b69f50
|
@ -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 <repo> - Creates a new repository")
|
||||
println("<repo> new-user <name> - 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)
|
|
@ -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 <repo> - Specify the repository to use. Defaults to '.'")
|
||||
println("-port <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)
|
|
@ -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())),
|
|
@ -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
|
||||
}
|
||||
|
|
@ -1,4 +1,4 @@
|
|||
package kiss
|
||||
package owl
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
|
|
@ -0,0 +1,5 @@
|
|||
<ul>
|
||||
{{ range .UserLinks }}
|
||||
<li><a href="{{.Href}}">{{.Text}}</a></li>
|
||||
{{ end }}
|
||||
</ul>
|
12
kiss_test.go
12
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
|
||||
}
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package kiss_test
|
||||
package owl_test
|
||||
|
||||
import (
|
||||
"path"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package kiss
|
||||
package owl
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
|
|
|
@ -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)
|
||||
}
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
package kiss
|
||||
package owl
|
||||
|
||||
import (
|
||||
"embed"
|
||||
|
|
|
@ -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 {
|
||||
|
|
14
user_test.go
14
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")
|
||||
|
|
Loading…
Reference in New Issue